aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_win.cpp
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-09-28 22:00:30 +0200
committerDavid Robillard <d@drobilla.net>2014-12-16 18:31:22 -0500
commit2e07e028c1080051846b1b200493e528a8f9a5e6 (patch)
tree61db9c5aba47555204d1b054662ac1954008d256 /pugl/pugl_win.cpp
parent3fa6c2c10f7d4ca06fd30e2442dcd25f492cc351 (diff)
downloadpugl-2e07e028c1080051846b1b200493e528a8f9a5e6.tar.gz
pugl-2e07e028c1080051846b1b200493e528a8f9a5e6.tar.bz2
pugl-2e07e028c1080051846b1b200493e528a8f9a5e6.zip
Support minimum window size.
Conflicts: pugl/pugl_win.cpp
Diffstat (limited to 'pugl/pugl_win.cpp')
-rw-r--r--pugl/pugl_win.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/pugl/pugl_win.cpp b/pugl/pugl_win.cpp
index ead0236..2040b98 100644
--- a/pugl/pugl_win.cpp
+++ b/pugl/pugl_win.cpp
@@ -128,9 +128,16 @@ puglCreateWindow(PuglView* view, const char* title)
int winFlags = WS_POPUPWINDOW | WS_CAPTION;
if (view->resizable) {
winFlags |= WS_SIZEBOX;
+ if (view->min_width || view->min_height) {
+ // Adjust the minimum window size to accomodate requested view size
+ RECT mr = { 0, 0, view->min_width, view->min_height };
+ AdjustWindowRectEx(&mr, winFlags, FALSE, WS_EX_TOPMOST);
+ view->min_width = mr.right - mr.left;
+ view->min_height = wr.bottom - mr.top;
+ }
}
- // Adjust the overall window size to accomodate our requested client size
+ // Adjust the window size to accomodate requested view size
RECT wr = { 0, 0, view->width, view->height };
AdjustWindowRectEx(&wr, winFlags, FALSE, WS_EX_TOPMOST);
@@ -305,18 +312,24 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
PuglKey key;
+ RECT rect;
+ MINMAXINFO* mmi;
setModifiers(view);
switch (message) {
case WM_CREATE:
case WM_SHOWWINDOW:
case WM_SIZE:
- RECT rect;
GetClientRect(view->impl->hwnd, &rect);
puglReshape(view, rect.right, rect.bottom);
view->width = rect.right;
view->height = rect.bottom;
break;
+ case WM_GETMINMAXINFO:
+ mmi = (MINMAXINFO*)lParam;
+ mmi->ptMinTrackSize.x = view->min_width;
+ mmi->ptMinTrackSize.y = view->min_height;
+ break;
case WM_PAINT:
BeginPaint(view->impl->hwnd, &ps);
puglDisplay(view);