From 90d23dc985c93066db4f82ccc748e2cfe92a5d3c Mon Sep 17 00:00:00 2001 From: tomara_x <86204514+tomara-x@users.noreply.github.com> Date: Tue, 26 Sep 2023 07:50:37 +0300 Subject: [PATCH] add default zoom setting --- Source/Canvas.cpp | 5 +++-- Source/Dialogs/AdvancedSettingsPanel.h | 10 ++++++++++ Source/Utility/SettingsFile.h | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) 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) },