diff --git a/Source/Canvas.cpp b/Source/Canvas.cpp index a9229168a..0c8f6228d 100644 --- a/Source/Canvas.cpp +++ b/Source/Canvas.cpp @@ -108,8 +108,9 @@ Canvas::Canvas(PluginEditor* parent, pd::Patch::Ptr p, Component* parentGraph) setSize(infiniteCanvasSize, infiniteCanvasSize); - // initialize per canvas zoom to 100% when first creating canvas - zoomScale.setValue(1.0f); + // initialize to default zoom + auto defaultZoom = SettingsFile::getInstance()->getPropertyAsValue("default_zoom"); + zoomScale.setValue(getValue(defaultZoom)/100.0f); zoomScale.addListener(this); // Add lasso component diff --git a/Source/Dialogs/AdvancedSettingsPanel.h b/Source/Dialogs/AdvancedSettingsPanel.h index 2a54a20be..0cf7c9158 100644 --- a/Source/Dialogs/AdvancedSettingsPanel.h +++ b/Source/Dialogs/AdvancedSettingsPanel.h @@ -59,6 +59,10 @@ class AdvancedSettingsPanel : public Component scaleValue.addListener(this); otherProperties.add(new PropertiesPanel::EditableComponent("Global scale factor", scaleValue)); + defaultZoom = settingsFile->getProperty("default_zoom"); + defaultZoom.addListener(this); + otherProperties.add(new PropertiesPanel::EditableComponent("Default zoom %", defaultZoom)); + propertiesPanel.addSection("Other", otherProperties); addAndMakeVisible(propertiesPanel); @@ -85,6 +89,11 @@ class AdvancedSettingsPanel : public Component SettingsFile::getInstance()->setGlobalScale(scale); scaleValue = scale; } + if (v.refersToSameSourceAs(defaultZoom)) { + auto zoom = std::clamp(getValue(defaultZoom), 20.0f, 300.0f); + SettingsFile::getInstance()->setProperty("default_zoom", zoom); + defaultZoom = zoom; + } } Component* editor; @@ -94,6 +103,7 @@ class AdvancedSettingsPanel : public Component Value macTitlebarButtons; Value reloadPatch; Value scaleValue; + Value defaultZoom; Value showPalettesValue; Value autoPatchingValue; diff --git a/Source/Utility/SettingsFile.h b/Source/Utility/SettingsFile.h index bad3ce1f0..cc82a2245 100644 --- a/Source/Utility/SettingsFile.h +++ b/Source/Utility/SettingsFile.h @@ -109,6 +109,7 @@ class SettingsFile : public ValueTree::Listener { "order", var(0) }, { "direction", var(0) }, { "global_scale", var(1.0f) }, + { "default_zoom", var(100.0f) }, { "show_palettes", var(true) }, { "show_all_audio_device_rates", var(false) }, { "add_object_menu_pinned", var(false) },