diff options
author | David Robillard <d@drobilla.net> | 2020-11-29 18:42:04 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-29 18:42:04 +0100 |
commit | 272369a4a40cd46123d4741571b6fcc7c6d8c3a8 (patch) | |
tree | 08c83725ae5ca16970e000996f5c65edb6ac4e3a /src | |
parent | 98e2535b82ab601081a56c8a22d789d2da25cfd8 (diff) | |
download | patchage-272369a4a40cd46123d4741571b6fcc7c6d8c3a8.tar.gz patchage-272369a4a40cd46123d4741571b6fcc7c6d8c3a8.tar.bz2 patchage-272369a4a40cd46123d4741571b6fcc7c6d8c3a8.zip |
Fix unstable module positions
Diffstat (limited to 'src')
-rw-r--r-- | src/CanvasModule.cpp | 7 | ||||
-rw-r--r-- | src/Configuration.cpp | 5 |
2 files changed, 10 insertions, 2 deletions
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); } |