From 272369a4a40cd46123d4741571b6fcc7c6d8c3a8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 29 Nov 2020 18:42:04 +0100 Subject: Fix unstable module positions --- src/CanvasModule.cpp | 7 ++++++- src/Configuration.cpp | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CanvasModule.cpp b/src/CanvasModule.cpp index c049346..dc0af4e 100644 --- a/src/CanvasModule.cpp +++ b/src/CanvasModule.cpp @@ -115,7 +115,12 @@ CanvasModule::load_location() if (_app->conf().get_module_location(_name, _type, loc)) { move_to(loc.x, loc.y); } else { - move_to(20 + rand() % 640, 20 + rand() % 480); + const double x = 20 + rand() % 640; + const double y = 20 + rand() % 480; + + // Move, then store generated location so it is stable + move_to(x, y); + store_location(x, y); } } diff --git a/src/Configuration.cpp b/src/Configuration.cpp index 6158702..f667b1b 100644 --- a/src/Configuration.cpp +++ b/src/Configuration.cpp @@ -346,9 +346,12 @@ Configuration::save() const ModuleSettings& settings = s.second; if (settings.split) { - if (settings.input_location && settings.output_location) { + if (settings.input_location) { write_module_position( file, name, "input", *settings.input_location); + } + + if (settings.output_location) { write_module_position( file, name, "output", *settings.output_location); } -- cgit v1.2.1