diff --git a/examples/example1/src/example1.d b/examples/example1/src/example1.d index 5d56e5c4..9a66d204 100644 --- a/examples/example1/src/example1.d +++ b/examples/example1/src/example1.d @@ -266,7 +266,9 @@ extern (C) int UIAppMain(string[] args) { //} // create window - Window window = Platform.instance.createWindow("DlangUI Example 1", null, WindowFlag.Resizable, 800, 700); + //Window window = Platform.instance.createWindow("DlangUI Example 1", null, WindowFlag.Resizable, 800, 700); + // Expand window size if content is bigger than 800, 700 (change to above version if you want scrollbars and 800, 700 size) + Window window = Platform.instance.createWindow("DlangUI Example 1", null, WindowFlag.Resizable | WindowFlag.ExpandSize, 800, 700); // here you can see window or content resize mode //Window window = Platform.instance.createWindow("DlangUI Example 1", null, WindowFlag.Resizable, 400, 400); //window.windowOrContentResizeMode = WindowOrContentResizeMode.resizeWindow; diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index 6162cd13..d27c66ca 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -56,6 +56,8 @@ enum WindowFlag : uint { MeasureSize = 8, /// window without decorations Borderless = 16, + /// expand window size if main widget minimal size is greater than size defined in window constructor + ExpandSize = 32, } /// Window states @@ -333,9 +335,9 @@ class Window : CustomEventTarget { @property bool caretReplace() { return _caretReplace; } // window content resize mode - protected WindowOrContentResizeMode _windowOrContentResizeMode = WindowOrContentResizeMode.resizeWindow; + //protected WindowOrContentResizeMode _windowOrContentResizeMode = WindowOrContentResizeMode.resizeWindow; //protected WindowOrContentResizeMode _windowOrContentResizeMode = WindowOrContentResizeMode.shrinkWidgets; - //protected WindowOrContentResizeMode _windowOrContentResizeMode = WindowOrContentResizeMode.scrollWindow; + protected WindowOrContentResizeMode _windowOrContentResizeMode = WindowOrContentResizeMode.scrollWindow; @property WindowOrContentResizeMode windowOrContentResizeMode() {return _windowOrContentResizeMode; } @property void windowOrContentResizeMode(WindowOrContentResizeMode newMode) { @@ -466,7 +468,7 @@ class Window : CustomEventTarget { void adjustWindowOrContentSize(int minContentWidth, int minContentHeight) { _minContentWidth = minContentWidth; _minContentHeight = minContentHeight; - if (_windowOrContentResizeMode == WindowOrContentResizeMode.resizeWindow) + if (_windowOrContentResizeMode == WindowOrContentResizeMode.resizeWindow || flags & WindowFlag.ExpandSize) resizeWindow(Point(max(_windowRect.right, minContentWidth), max(_windowRect.bottom, minContentHeight))); updateWindowOrContentSize(); }