Răsfoiți Sursa

Scaling menu as FL 2026's: Host (LYNX's default size, ticked by default) then 100 % ... 400 %; a chosen 125 % stays apart from Host (round 190he)

Ka1-S 2 săptămâni în urmă
părinte
comite
a50aa7889e

+ 8 - 9
src/core/EditorScale.h

@@ -6,27 +6,26 @@
 
 // Round 190he (issue #152: "plugin scaling fails, the FL-engine plugins can't be made smaller"): the size of the
 // windows LYNX draws for a plugin (a channel's settings window, a built-in effect's window). FL's plugin menu has
-// "Scaling" with fixed sizes (FLEngine_x64.dll, the wrapper's PluginMenu: PluginScalingMenu > Scaling100Menu …
-// Scaling400Menu, plus System / Host); FL's 100 % is the plugin's own design size. LYNX opens these windows at FL's
-// size × 1.25 (ChannelSettings' layoutScale), so its default is 125 % and FL's 100 % is the smaller size the reporter
-// asked for. Dragging the window's edge also sizes it, keeping its proportions, between `minPercent` and `maxPercent`.
+// "Scaling" (FLEngine_x64.dll PluginMenu: PluginScalingMenu; FL 2026 shot shots/FL-harmor-wrapper-menu-scaling.png):
+// System, Host (ticked by default), 100 % … 400 %; FL's 100 % is the plugin's own design size. LYNX opens these
+// windows at FL's size × 1.25, its "Host" size; FL's 100 % is the smaller size the reporter asked for. Dragging the
+// window's edge also sizes it, keeping its proportions, between `minPercent` and `maxPercent`.
 namespace lynx::editorscale
 {
-inline constexpr int defaultPercent = 125; // LYNX's size (FL × 1.25); a channel's `editorScale` 0 means this
+inline constexpr int defaultPercent = 125; // LYNX's size (FL × 1.25), FL's "Host"; a channel's `editorScale` 0 means this
 inline constexpr int minPercent = 40, maxPercent = 400;
 inline constexpr std::array<int, 9> menuPercents { 100, 125, 150, 175, 200, 250, 300, 350, 400 }; // FL's items
 
-// the stored value (0 = default) as a percentage of FL's size
+// the stored value (0 = Host, LYNX's default) as a percentage of FL's size
 constexpr int percentOf (int stored) noexcept
 {
     return stored <= 0 ? defaultPercent : std::clamp (stored, minPercent, maxPercent);
 }
 
-// what to store for a percentage (the default is stored as 0, so old projects and untouched windows write nothing)
+// what to store for a chosen percentage (Host is stored as 0, so old projects and untouched windows write nothing)
 constexpr int storedFor (int percent) noexcept
 {
-    const auto p = std::clamp (percent, minPercent, maxPercent);
-    return p == defaultPercent ? 0 : p;
+    return std::clamp (percent, minPercent, maxPercent);
 }
 
 // the factor the window's content is drawn at, against its default size

+ 2 - 1
src/engine/ProjectFile.cpp

@@ -2339,7 +2339,8 @@ ChannelDef channelFromVar (const juce::var& c, const Song& song)
         }
     }
     def.icon = juce::jlimit (0, 0xFFFF, (int) c.getProperty ("icon", 0));
-    def.editorScale = editorscale::storedFor (editorscale::percentOf ((int) c.getProperty ("editorScale", 0)));
+    if (const auto scale = (int) c.getProperty ("editorScale", 0); scale > 0) // (0 / missing = Host, LYNX's default size)
+        def.editorScale = editorscale::storedFor (scale);
     def.flWrapperFlags = (int) c.getProperty ("flWrapperFlags", -1);
     if (c.hasProperty ("flOrigin"))
         def.flOrigin = flOriginFromVar (c["flOrigin"]);

+ 11 - 6
src/ui/ChannelSettings.cpp

@@ -6518,7 +6518,7 @@ public:
 
     void setStoredScale (int newStored)
     {
-        stored = editorscale::storedFor (editorscale::percentOf (newStored));
+        stored = newStored <= 0 ? 0 : editorscale::storedFor (newStored);
         fitToPage();
     }
 
@@ -6675,20 +6675,25 @@ public:
     void showScalingMenu()
     {
         juce::PopupMenu sizes;
-        const auto now = editorscale::percentOf (scaled->storedScale());
+        const auto stored = scaled->storedScale();
+        const juce::Component::SafePointer<SettingsWindow> safe (this);
+        // FL's items (System is left out: LYNX's whole interface already follows the display's scale)
+        sizes.addItem (tr ("Host"), true, stored == 0, [safe] {
+            if (safe != nullptr)
+                safe->setStoredScale (0);
+        });
         for (const auto percent : editorscale::menuPercents)
-            sizes.addItem (juce::String (percent) + "%", true, percent == now, [safe = juce::Component::SafePointer<SettingsWindow> (this), percent] {
+            sizes.addItem (juce::String (percent) + "%", true, stored == percent, [safe, percent] {
                 if (safe != nullptr)
-                    safe->setScalePercent (percent);
+                    safe->setStoredScale (editorscale::storedFor (percent));
             });
         juce::PopupMenu menu;
         menu.addSubMenu (tr ("Scaling"), sizes);
         menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
     }
 
-    void setScalePercent (int percent)
+    void setStoredScale (int stored)
     {
-        const auto stored = editorscale::storedFor (percent);
         scaled->setStoredScale (stored);
         setContentComponentSize (scaled->getWidth(), scaled->getHeight());
         remember (stored);

+ 5 - 0
src/ui/PluginEditors.cpp

@@ -5767,6 +5767,11 @@ public:
             juce::PopupMenu sizes;
             const auto* content = getContentComponent();
             const auto now = content != nullptr ? editorscale::percentForWidth (content->getWidth(), (int) std::ceil (designWidth * 1.25)) : 0;
+            // FL's items (System left out: LYNX's interface already follows the display's scale); Host = LYNX's 125 %
+            sizes.addItem (tr ("Host"), true, false, [safe = juce::Component::SafePointer<NativeEffectWindow> (this)] {
+                if (safe != nullptr)
+                    safe->setScalePercent (editorscale::defaultPercent);
+            });
             for (const auto percent : editorscale::menuPercents)
                 sizes.addItem (juce::String (percent) + "%", true, percent == now, [safe = juce::Component::SafePointer<NativeEffectWindow> (this), percent] {
                     if (safe != nullptr)

+ 2 - 2
tests/U190heTests.inc

@@ -16,8 +16,8 @@ TEST (u190he_scaling_offers_fl_sizes_and_lynx_default_stays_125)
     using namespace lynx::editorscale;
     // FL's PluginScalingMenu: 100 % … 400 %; LYNX opens at FL's size × 1.25
     CHECK (menuPercents.front() == 100 && menuPercents.back() == 400);
-    CHECK (percentOf (0) == 125);
-    CHECK (storedFor (125) == 0); // (the default writes nothing in the project)
+    CHECK (percentOf (0) == 125); // FL's "Host" (stored 0: nothing written in the project)
+    CHECK (storedFor (125) == 125); // (125 % chosen by hand is not Host: FL ticks one or the other)
     CHECK (storedFor (100) == 100);
     CHECK (percentOf (100) == 100);
     // FL's 100 % is smaller than LYNX's default: the window can be made smaller (the reporter's request)