33#include < juce_core/juce_core.h>
44#include < juce_gui_basics/juce_gui_basics.h>
55
6+ // ==============================================================================
7+ // Window configuration constants
8+ namespace WindowConfig
9+ {
10+ static constexpr int DEFAULT_WIDTH = 1000 ;
11+ static constexpr int DEFAULT_HEIGHT = 700 ;
12+ static constexpr int MIN_WIDTH = 900 ;
13+ static constexpr int MIN_HEIGHT = 650 ;
14+ static constexpr int MAX_WIDTH = 2000 ;
15+ static constexpr int MAX_HEIGHT = 1500 ;
16+ }
17+
618// ==============================================================================
719class AudioProcessorApplication : public juce ::JUCEApplication
820{
@@ -74,7 +86,7 @@ class AudioProcessorApplication : public juce::JUCEApplication
7486 setFullScreen (true );
7587 #else
7688 setResizable (true , true );
77- centreWithSize ( 800 , 600 );
89+ setupWindowBounds ( );
7890 #endif
7991
8092 setVisible (true );
@@ -88,6 +100,42 @@ class AudioProcessorApplication : public juce::JUCEApplication
88100 JUCEApplication::getInstance ()->systemRequestedQuit ();
89101 }
90102
103+ private:
104+ void setupWindowBounds ()
105+ {
106+ auto displays = juce::Desktop::getInstance ().getDisplays ();
107+ auto mainDisplay = displays.getMainDisplay ();
108+ auto workArea = mainDisplay.userArea ;
109+
110+ // Calculate dynamic limits based on screen size
111+ int maxWidth = juce::jmin (WindowConfig::MAX_WIDTH, workArea.getWidth () - 100 );
112+ int maxHeight = juce::jmin (WindowConfig::MAX_HEIGHT, workArea.getHeight () - 100 );
113+
114+ // Ensure minimum size fits on screen
115+ int minWidth = juce::jmin (WindowConfig::MIN_WIDTH, workArea.getWidth () - 200 );
116+ int minHeight = juce::jmin (WindowConfig::MIN_HEIGHT, workArea.getHeight () - 200 );
117+
118+ // Ensure minimum size is not too small for usability
119+ minWidth = juce::jmax (minWidth, 600 );
120+ minHeight = juce::jmax (minHeight, 400 );
121+
122+ // Set the resize limits with screen-aware bounds
123+ setResizeLimits (minWidth, minHeight, maxWidth, maxHeight);
124+
125+ // Use default size if it fits, otherwise scale down proportionally
126+ int defaultWidth = WindowConfig::DEFAULT_WIDTH;
127+ int defaultHeight = WindowConfig::DEFAULT_HEIGHT;
128+
129+ if (defaultWidth > maxWidth || defaultHeight > maxHeight)
130+ {
131+ float scale = juce::jmin (float (maxWidth) / defaultWidth, float (maxHeight) / defaultHeight);
132+ defaultWidth = int (defaultWidth * scale);
133+ defaultHeight = int (defaultHeight * scale);
134+ }
135+
136+ centreWithSize (defaultWidth, defaultHeight);
137+ }
138+
91139 /* Note: Be careful if you override any DocumentWindow methods - the base
92140 class uses a lot of them, so by overriding you might break its functionality.
93141 It's best to do all your work in your content component instead, but if
0 commit comments