@@ -40,6 +40,8 @@ class AbstractPluginEditor
4040 float maxSizeMultiplier = 2 .0f ;
4141 float minAspectRatio = 0 .5f ;
4242 float maxAspectRatio = 2 .0f ;
43+ int dynamicStartWidth = -1 ;
44+ int dynamicStartHeight = -1 ;
4345 };
4446
4547 // Custom constrainer that enforces aspect ratio bounds (min/max aspect
@@ -178,8 +180,29 @@ class AbstractPluginEditor
178180 }
179181 setResizable (false , true );
180182
181- const auto startWidth = baseWidth * sizeFactor;
182- const auto startHeight = (baseHeight + headerHeight) * sizeFactor;
183+ // Resolve initial window size using priority order
184+ int initialWidth = baseWidth;
185+ int initialHeight = baseHeight + headerHeight;
186+
187+ // Priority 1: Check for saved window state
188+ int savedWidth = p.getSavedWindowWidth ();
189+ int savedHeight = p.getSavedWindowHeight ();
190+ if (savedWidth > 0 && savedHeight > 0 ) {
191+ initialWidth = savedWidth;
192+ initialHeight = savedHeight;
193+ isHeaderHidden = p.getSavedHeaderHiddenState ();
194+ }
195+ // Priority 2: Use dynamic start dimensions if in dynamic mode
196+ else if (windowMode == WindowMode::Dynamic &&
197+ _windowConfig.dynamicStartWidth > 0 &&
198+ _windowConfig.dynamicStartHeight > 0 ) {
199+ initialWidth = _windowConfig.dynamicStartWidth ;
200+ initialHeight = _windowConfig.dynamicStartHeight ;
201+ }
202+ // Priority 3: Use base dimensions (default, already set above)
203+
204+ const auto startWidth = initialWidth * sizeFactor;
205+ const auto startHeight = initialHeight * sizeFactor;
183206 setSize (startWidth, startHeight);
184207
185208 // Set the callback for header visibility changes
@@ -297,6 +320,7 @@ class AbstractPluginEditor
297320
298321 void handleHeaderVisibilityChange (bool isHeaderVisible)
299322 {
323+ isHeaderHidden = !isHeaderVisible;
300324 const int adjustedHeight =
301325 isHeaderVisible ? baseHeight + headerHeight : baseHeight;
302326
@@ -320,6 +344,9 @@ class AbstractPluginEditor
320344 setConstraints (baseWidth, adjustedHeight);
321345 setSize (baseWidth * sizeFactor, adjustedHeight * sizeFactor);
322346 }
347+
348+ // Save the header visibility state
349+ p.saveWindowState (getWidth (), getHeight (), isHeaderHidden);
323350 }
324351
325352 dmt::gui::window::Layout& getMainLayout () { return mainLayout; }
@@ -383,6 +410,9 @@ class AbstractPluginEditor
383410 compositor.setBounds (getLocalBounds ());
384411 compositorAttached = true ;
385412 repaint ();
413+
414+ // Save the current window state after size correction
415+ p.saveWindowState (getWidth (), getHeight (), isHeaderHidden);
386416 }
387417 }
388418
@@ -479,6 +509,7 @@ class AbstractPluginEditor
479509 float maxSizeMultiplier = 2 .0f ;
480510 float minAspectRatio = 0 .5f ;
481511 float maxAspectRatio = 2 .0f ;
512+ bool isHeaderHidden = false ;
482513 int lastWidth = baseWidth;
483514 int lastHeight = baseHeight;
484515 double ratio = baseWidth / baseHeight;
0 commit comments