Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default zoom setting #1196

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/Canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(defaultZoom)/100.0f);
zoomScale.addListener(this);

// Add lasso component
Expand Down
10 changes: 10 additions & 0 deletions Source/Dialogs/AdvancedSettingsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ class AdvancedSettingsPanel : public Component
scaleValue.addListener(this);
otherProperties.add(new PropertiesPanel::EditableComponent<float>("Global scale factor", scaleValue));

defaultZoom = settingsFile->getProperty<float>("default_zoom");
defaultZoom.addListener(this);
otherProperties.add(new PropertiesPanel::EditableComponent<float>("Default zoom %", defaultZoom));

propertiesPanel.addSection("Other", otherProperties);

addAndMakeVisible(propertiesPanel);
Expand All @@ -85,6 +89,11 @@ class AdvancedSettingsPanel : public Component
SettingsFile::getInstance()->setGlobalScale(scale);
scaleValue = scale;
}
if (v.refersToSameSourceAs(defaultZoom)) {
auto zoom = std::clamp(getValue<float>(defaultZoom), 20.0f, 300.0f);
SettingsFile::getInstance()->setProperty("default_zoom", zoom);
defaultZoom = zoom;
}
}
Component* editor;

Expand All @@ -94,6 +103,7 @@ class AdvancedSettingsPanel : public Component
Value macTitlebarButtons;
Value reloadPatch;
Value scaleValue;
Value defaultZoom;

Value showPalettesValue;
Value autoPatchingValue;
Expand Down
1 change: 1 addition & 0 deletions Source/Utility/SettingsFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down