From df3ef2ab0e805b3500803607aa33e8152f11b048 Mon Sep 17 00:00:00 2001 From: ruevs Date: Thu, 4 Nov 2021 17:52:25 +0200 Subject: [PATCH] GUI: Flexible vertical space above the toolbar If the main window is not high enough allow the default 32 pixel padding between the menu bar and the toolbar to shrink down to zero. This allows the main window height to be a minimum of 688 pixels (on Windows 10) so it is possible to capture 720P video tutorials. Fixes #1130 --- src/graphicswin.cpp | 2 +- src/toolbar.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 17e04dce..cac542ae 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -430,7 +430,7 @@ void GraphicsWindow::Init() { using namespace std::placeholders; // Do this first, so that if it causes an onRender event we don't try to paint without // a canvas. - window->SetMinContentSize(720, 670); + window->SetMinContentSize(720, /*ToolbarDrawOrHitTest 636*/ 32 * 18 + 3 * 16 + 8 + 4); window->onClose = std::bind(&SolveSpaceUI::MenuFile, Command::EXIT); window->onRender = std::bind(&GraphicsWindow::Paint, this); window->onKeyboardEvent = std::bind(&GraphicsWindow::KeyboardEvent, this, _1); diff --git a/src/toolbar.cpp b/src/toolbar.cpp index bf6b59c5..74764883 100644 --- a/src/toolbar.cpp +++ b/src/toolbar.cpp @@ -153,11 +153,18 @@ bool GraphicsWindow::ToolbarDrawOrHitTest(int mx, int my, UiCanvas *canvas, double width, height; window->GetContentSize(&width, &height); - int x = 17, y = (int)(height - 52); + int x = 17, y = (int)(height - 21); // 20 is the menu bar height - // When changing these values, also change the asReference drawing code in drawentity.cpp. + // When changing these values, also change the asReference drawing code in drawentity.cpp + // as well as the "window->SetMinContentSize(720, 636);" in graphicswin.cpp int fudge = 8; - int h = 32*18 + 3*16 + fudge; + int h = 32*18 + 3*16 + fudge; // Toolbar height = 18 icons * 32 pixels + 3 dividers * 16 pixels + fudge + + if(h < y) { + // If there is enough vertical space leave up to 32 pixels between the menu bar and the toolbar. + y -= ((y - h) < 32) ? y - h : 32; + } + int aleft = 0, aright = 66, atop = y+16+fudge/2, abot = y+16-h; bool withinToolbar =