From 6129ee1289c28c1c88bbe44f2b60e9bf360ee8a1 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 18:46:19 +0200 Subject: [PATCH 01/28] Fix 'list iterators incompatible' --- src/libs/gui_tk/gui_tk.cpp | 30 ++++++++++++++++-------------- src/libs/gui_tk/gui_tk.h | 6 ++++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index c6f513ce7e..cb520a6056 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -761,13 +761,15 @@ bool Window::keyDown(const Key &key) if ((*i) != children.back()) children.back()->onTabbing(ONTABBING_REVTABFROMTHIS); (*i)->onTabbing(ONTABBING_REVTABTOTHIS); if ((*i)->raise()) - break; + { + toplevel = true; + break; + } } ++i; } - if (tab_quit) return false; - return (i != e) || toplevel/*prevent TAB escape to another window*/; + return handleTab(tab_quit, i, e); } else { std::list::iterator i = children.begin(), e = children.end(); --e; @@ -781,16 +783,15 @@ bool Window::keyDown(const Key &key) if ((*i) != children.back()) children.back()->onTabbing(ONTABBING_TABFROMTHIS); (*i)->onTabbing(ONTABBING_TABTOTHIS); if ((*i)->raise()) - break; + { + toplevel = true; + break; + } } ++i; } - if (tab_quit) return false; - // BUG/TODO swapped operands below to fix 'list iterators incompatible' - // occurs in VS debug build when pressing TAB after opening configuration tool - // currently this works but that just sweeps the problem under the rug - return toplevel /*prevent TAB escape to another window*/ || (i != e); + return handleTab(tab_quit, i, e); } } @@ -891,8 +892,7 @@ bool WindowInWindow::keyDown(const Key &key) ++i; } - if (tab_quit) return false; - return (i != e) || toplevel/*prevent TAB escape to another window*/; + return handleTab(tab_quit, i, e); } else { std::list::iterator i = children.begin(), e = children.end(); --e; @@ -907,13 +907,15 @@ bool WindowInWindow::keyDown(const Key &key) (*i)->onTabbing(ONTABBING_TABTOTHIS); if (!tab_quit) scrollToWindow(*i); if ((*i)->raise()) - break; + { + toplevel = true; + break; + } } ++i; } - if (tab_quit) return false; - return (i != e) || toplevel/*prevent TAB escape to another window*/; + return handleTab(tab_quit, i, e); } } diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 32cb7e4e56..b97a861efd 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -749,6 +749,12 @@ class Window : public Refcount { /// Key was released. Returns true if event was handled. virtual bool keyUp(const Key &key); + template + bool handleTab(const bool tab_quit, const Iterator& i, const Iterator& e) const + { + return tab_quit == false && (toplevel /*prevent TAB escape to another window*/ || i != e); + } + /// Put this window on top of all it's siblings. Preserves relative order. /** Returns true if the window accepts the raise request. */ virtual bool raise() { From 4529acdb4af9e8b1265c6eb9e117e5ae3b870ce9 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 18:56:34 +0200 Subject: [PATCH 02/28] Fix CONFIG.SYS window overflowing --- src/gui/sdl_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index eadbd7c054..24a77b30e8 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -1662,7 +1662,7 @@ class ConfigEditor : public GUI::ToplevelWindow { } } - int height=title=="Config"?100:210; + int height=title=="Config"?100:81; scroll_h += height + 2; /* border */ wiw = new GUI::WindowInWindow(this, 5, 5, width-border_left-border_right-10, scroll_h); From 22d9dec5c3af71939001ee1babe25ed88fa25d75 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 19:22:50 +0200 Subject: [PATCH 03/28] UX: keep 'show advanced options' flag for the session i.e. keep it same between N runs of CFGTOOL --- src/gui/sdl_gui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index 24a77b30e8..e30b571ec0 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -141,6 +141,10 @@ void macosx_reload_touchbar(void); std::list proplist = {}; GUI::Checkbox *advopt, *saveall, *imgfd360, *imgfd400, *imgfd720, *imgfd1200, *imgfd1440, *imgfd2880, *imghd250, *imghd520, *imghd1gig, *imghd2gig, *imghd4gig, *imghd8gig; + +// user pick of 'show advanced options' for the session +bool advOptUser = false; + std::string GetDOSBoxXPath(bool withexe); static std::map< std::vector, GUI::ToplevelWindow* > cfg_windows_active; void getlogtext(std::string &str), getcodetext(std::string &text), ApplySetting(std::string pvar, std::string inputline, bool quiet), GUI_Run(bool pressed); @@ -3255,7 +3259,7 @@ class ConfigurationWindow : public GUI::ToplevelWindow { advopt = new GUI::Checkbox(this, gridbtnx, closerow_y, MSG_Get("SHOW_ADVOPT")); Section_prop * section=static_cast(control->GetSection("dosbox")); - advopt->setChecked(section->Get_bool("show advanced options")); + advopt->setChecked(section->Get_bool("show advanced options") || advOptUser); strcpy(tmp1, (MSG_Get("SAVE")+std::string("...")).c_str()); (saveButton = new GUI::Button(this, 276, closerow_y, tmp1, 130, gridbtnheight))->addActionHandler(this); @@ -3287,6 +3291,7 @@ class ConfigurationWindow : public GUI::ToplevelWindow { } void actionExecuted(GUI::ActionEventSource *b, const GUI::String &arg) override { + advOptUser = advopt->isChecked(); GUI::String sname = RestoreName(arg); sname.at(0) = (unsigned int)std::tolower((int)sname.at(0)); Section *sec; From 964e2b0c9d5583518a6abcf575b69dbab4adee1c Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 19:47:19 +0200 Subject: [PATCH 04/28] UX: always center window after changing output Previously it was only for TTF. --- src/output/output_tools.cpp | 5 +++++ src/output/output_ttf.cpp | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/output/output_tools.cpp b/src/output/output_tools.cpp index e4c454bec0..ed6725c227 100644 --- a/src/output/output_tools.cpp +++ b/src/output/output_tools.cpp @@ -275,6 +275,11 @@ void change_output(int output) { GFX_LogSDLState(); UpdateWindowDimensions(); + +#ifdef C_SDL2 + // UX: always center window after changing output + SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); +#endif } void OutputSettingMenuUpdate(void) { diff --git a/src/output/output_ttf.cpp b/src/output/output_ttf.cpp index a3e6ca6e88..110efdcf3e 100644 --- a/src/output/output_ttf.cpp +++ b/src/output/output_ttf.cpp @@ -1455,7 +1455,6 @@ void ttf_switch_on(bool ss=true) { #ifdef C_SDL2 transparency = 0; SetWindowTransparency(static_cast(control->GetSection("sdl"))->Get_int("transparency")); - SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); #endif if (!IS_PC98_ARCH && vga.draw.address_add != ttf.cols * 2) checkcol = ss?2:1; } From dff530a2454a955fc3a2c0710977932edda073c4 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 22:33:33 +0200 Subject: [PATCH 05/28] Win31 button height is not 26 but 23 --- src/gui/sdl_gui.cpp | 2 +- src/libs/gui_tk/gui_tk.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index e30b571ec0..b333c34706 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -3170,7 +3170,7 @@ class ConfigurationWindow : public GUI::ToplevelWindow { bar->addActionHandler(this); int gridbtnwidth = 130; - int gridbtnheight = 26; + int gridbtnheight = GUI::CurrentTheme.ButtonHeight; int gridbtnx = 12; int gridbtny = 25; int btnperrow = 4; diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index b97a861efd..910643dbcb 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -229,6 +229,7 @@ struct Theme uint32_t ButtonFiller = 0xFF808080; uint32_t ButtonBevel1 = 0xFFFFFFFF; uint32_t ButtonBevel2 = 0xFFC0C0C0; + uint32_t ButtonHeight = 23; uint32_t FocusColor = 0xFF000000; int32_t FocusPadding = 2; int32_t FocusPaddingHorizontal = 1; From 9110575e8e8f3e5830776d8840b6a54c41122cb3 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 22:35:06 +0200 Subject: [PATCH 06/28] Sort button LTRB stuff --- src/libs/gui_tk/gui_tk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 910643dbcb..40b5227cf0 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -2368,7 +2368,7 @@ class Button : public BorderedWindow, public ActionEventSource { (void)y;//UNUSED if (button == Left) { - border_left = 7; border_right = 5; border_top = 6; border_bottom = 4; + border_left = 7; border_top = 6; border_right = 5; border_bottom = 4; pressed = true; } return true; @@ -2381,7 +2381,7 @@ class Button : public BorderedWindow, public ActionEventSource { (void)y;//UNUSED if (button == Left) { - border_left = 6; border_right = 6; border_top = 5; border_bottom = 5; + border_left = 6; border_top = 5; border_right = 6; border_bottom = 5; pressed = false; } return true; From 1b03686e456dd671bb2bf0e661bdae5e36fae247 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 22:50:48 +0200 Subject: [PATCH 07/28] Win31 pixel-perfect button borders --- src/libs/gui_tk/gui_tk.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 40b5227cf0..4a1beddbf7 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -2368,7 +2368,7 @@ class Button : public BorderedWindow, public ActionEventSource { (void)y;//UNUSED if (button == Left) { - border_left = 7; border_top = 6; border_right = 5; border_bottom = 4; + border_left = 7; border_top = 5; border_right = 5; border_bottom = 3; pressed = true; } return true; @@ -2381,7 +2381,7 @@ class Button : public BorderedWindow, public ActionEventSource { (void)y;//UNUSED if (button == Left) { - border_left = 6; border_top = 5; border_right = 6; border_bottom = 5; + border_left = 6; border_top = 4; border_right = 6; border_bottom = 4; pressed = false; } return true; @@ -2859,7 +2859,7 @@ template ToplevelWindow::ToplevelWindow(Screen *parent, int x, in } template Button::Button(Window *parent, int x, int y, const STR text, int w, int h) : - BorderedWindow(parent,x,y,w,h,6,5,6,5), ActionEventSource(text), pressed(0) + BorderedWindow(parent,x,y,w,h,6,4,6,4), ActionEventSource(text), pressed(0) { Label *l = new Label(this,0,0,text); From ade05f0055a19d3e0c22bd2b9d539b128ab47f60 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 23:02:51 +0200 Subject: [PATCH 08/28] Label focus height isn't from font but from button --- src/libs/gui_tk/gui_tk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 4a1beddbf7..31aece8f7a 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -230,6 +230,7 @@ struct Theme uint32_t ButtonBevel1 = 0xFFFFFFFF; uint32_t ButtonBevel2 = 0xFFC0C0C0; uint32_t ButtonHeight = 23; + uint32_t ButtonContentHeight = 15; uint32_t FocusColor = 0xFF000000; int32_t FocusPadding = 2; int32_t FocusPaddingHorizontal = 1; @@ -1676,8 +1677,7 @@ class Label : public Window { if (interpret == false) { const auto tw = font->getWidth(this->text); - const auto th = font->getHeight(); - Window::resize(tw + CurrentTheme.FocusPadding + CurrentTheme.FocusPaddingHorizontal, th + CurrentTheme.FocusPadding); + Window::resize(tw + CurrentTheme.FocusPadding + CurrentTheme.FocusPaddingHorizontal, static_cast(CurrentTheme.ButtonContentHeight) + CurrentTheme.FocusPadding); } } From 0ca7870d283a98013654b3ec3a8467bd5ff52cf0 Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 23:08:19 +0200 Subject: [PATCH 09/28] We don't need focus LTRB padding anymore --- src/libs/gui_tk/gui_tk.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 31aece8f7a..08823e394c 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -232,7 +232,6 @@ struct Theme uint32_t ButtonHeight = 23; uint32_t ButtonContentHeight = 15; uint32_t FocusColor = 0xFF000000; - int32_t FocusPadding = 2; int32_t FocusPaddingHorizontal = 1; uint32_t TextColor = 0xFF000000; uint32_t Light3D = 0xFFFCFCFC; @@ -1677,7 +1676,7 @@ class Label : public Window { if (interpret == false) { const auto tw = font->getWidth(this->text); - Window::resize(tw + CurrentTheme.FocusPadding + CurrentTheme.FocusPaddingHorizontal, static_cast(CurrentTheme.ButtonContentHeight) + CurrentTheme.FocusPadding); + Window::resize(tw + CurrentTheme.FocusPaddingHorizontal, static_cast(CurrentTheme.ButtonContentHeight)); } } @@ -1689,7 +1688,7 @@ class Label : public Window { { d.setColor(color); - d.drawText(CurrentTheme.FocusPadding, CurrentTheme.FocusPadding + font->getAscent(), text, interpret, 0); + d.drawText(CurrentTheme.FocusPaddingHorizontal, font->getAscent(), text, interpret, 0); if(hasFocus()) { From ccf80bbe0d34990eec35e433800784c16d27900e Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 23:12:45 +0200 Subject: [PATCH 10/28] Fix focus horizontal padding --- src/libs/gui_tk/gui_tk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 08823e394c..c4e1099c78 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -232,7 +232,7 @@ struct Theme uint32_t ButtonHeight = 23; uint32_t ButtonContentHeight = 15; uint32_t FocusColor = 0xFF000000; - int32_t FocusPaddingHorizontal = 1; + int32_t FocusPaddingHorizontal = 2; uint32_t TextColor = 0xFF000000; uint32_t Light3D = 0xFFFCFCFC; uint32_t Shadow3D = 0xFF808080; @@ -1676,7 +1676,7 @@ class Label : public Window { if (interpret == false) { const auto tw = font->getWidth(this->text); - Window::resize(tw + CurrentTheme.FocusPaddingHorizontal, static_cast(CurrentTheme.ButtonContentHeight)); + Window::resize(tw + CurrentTheme.FocusPaddingHorizontal * 2, static_cast(CurrentTheme.ButtonContentHeight)); } } From 442c41ac1d9e35d28b4d85576fd8384da23bf4ff Mon Sep 17 00:00:00 2001 From: aybe Date: Thu, 11 Jul 2024 23:32:45 +0200 Subject: [PATCH 11/28] Drawing a rectangle by size does not involve -1 --- src/libs/gui_tk/gui_tk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index c4e1099c78..0940c08abb 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -1693,7 +1693,7 @@ class Label : public Window { if(hasFocus()) { d.setColor(CurrentTheme.FocusColor); - d.drawDotRect(0, 0, width - 1, height - 1); + d.drawDotRect(0, 0, width, height); } } From 01dedd624e8db9ef1fe256e70df20c8088f81933 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 00:28:48 +0200 Subject: [PATCH 12/28] Fix Drawable::draw*Rect off by one --- src/libs/gui_tk/gui_tk.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index cb520a6056..dabb59366c 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -358,26 +358,26 @@ void Drawable::drawCircle(int d) { void Drawable::drawRect(int w, int h) { - gotoXY(x-lineWidth/2,y); - drawLine(x+w+lineWidth-1,y); - gotoXY(x-(lineWidth-1)/2,y); - drawLine(x,y+h); - gotoXY(x+(lineWidth-1)/2,y); - drawLine(x-w-lineWidth+1,y); - gotoXY(x+lineWidth/2,y); - drawLine(x,y-h); + gotoXY(x - lineWidth / 2, y); // tl + drawLine(x + (w - 1) + lineWidth - 1, y); // tr + gotoXY(x - (lineWidth - 1) / 2, y); // tl + drawLine(x, y + (h - 1)); // bl + gotoXY(x + (lineWidth - 1) / 2, y); // tl + drawLine(x - (w - 1) - lineWidth + 1, y); // tr + gotoXY(x + lineWidth / 2, y); // tl + drawLine(x, y - (h - 1)); // bl } void Drawable::drawDotRect(int w, int h) { - gotoXY(x-lineWidth/2,y); - drawDotLine(x+w+lineWidth-1,y); - gotoXY(x-(lineWidth-1)/2,y); - drawDotLine(x,y+h); - gotoXY(x+(lineWidth-1)/2,y); - drawDotLine(x-w-lineWidth+1,y); - gotoXY(x+lineWidth/2,y); - drawDotLine(x,y-h); + gotoXY(x - lineWidth / 2, y); // tl + drawDotLine(x + (w - 1) + lineWidth - 1, y); // tr + gotoXY(x - (lineWidth - 1) / 2, y); // tl + drawDotLine(x, y + (h - 1)); // bl + gotoXY(x + (lineWidth - 1) / 2, y); // tl + drawDotLine(x - (w - 1) - lineWidth + 1, y); // tr + gotoXY(x + lineWidth / 2, y); // tl + drawDotLine(x, y - (h - 1)); // bl } void Drawable::fill() From f22c654755eb97f81fba643fe06bd0f29467d9a4 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 00:44:45 +0200 Subject: [PATCH 13/28] Ensure focus width is odd for pixel-perfect dotted rect --- src/libs/gui_tk/gui_tk.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 0940c08abb..e068321507 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -1675,8 +1675,12 @@ class Label : public Window { // that said, it's pretty darn close to how it looks in Windows 3.11 if (interpret == false) { - const auto tw = font->getWidth(this->text); - Window::resize(tw + CurrentTheme.FocusPaddingHorizontal * 2, static_cast(CurrentTheme.ButtonContentHeight)); + auto tw = font->getWidth(this->text); + + tw = tw + CurrentTheme.FocusPaddingHorizontal * 2; + tw = tw & 1 ? tw : tw + 1; + + Window::resize(tw, static_cast(CurrentTheme.ButtonContentHeight)); } } From ef4cd9b5abe4eb78586f4233714ebb680ad4f57a Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 00:45:09 +0200 Subject: [PATCH 14/28] Ensure text is offset according previous commit --- src/libs/gui_tk/gui_tk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index e068321507..3388bd4ef3 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -1692,7 +1692,7 @@ class Label : public Window { { d.setColor(color); - d.drawText(CurrentTheme.FocusPaddingHorizontal, font->getAscent(), text, interpret, 0); + d.drawText(CurrentTheme.FocusPaddingHorizontal + (width & 1), font->getAscent(), text, interpret, 0); if(hasFocus()) { From f294999715e5c6865c64da07f08bbdef65a594e1 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 00:45:46 +0200 Subject: [PATCH 15/28] Adjust comments regarding previous stuff --- src/libs/gui_tk/gui_tk.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 3388bd4ef3..7f5eacdba4 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -229,8 +229,8 @@ struct Theme uint32_t ButtonFiller = 0xFF808080; uint32_t ButtonBevel1 = 0xFFFFFFFF; uint32_t ButtonBevel2 = 0xFFC0C0C0; - uint32_t ButtonHeight = 23; - uint32_t ButtonContentHeight = 15; + uint32_t ButtonHeight = 23; // must be odd + uint32_t ButtonContentHeight = 15; // must be odd uint32_t FocusColor = 0xFF000000; int32_t FocusPaddingHorizontal = 2; uint32_t TextColor = 0xFF000000; @@ -1672,7 +1672,7 @@ class Label : public Window { // override non-interpreted so as focus adapts itself better to text // one depends on the other, that's fundamentally wrong but well ... - // that said, it's pretty darn close to how it looks in Windows 3.11 + // this is good but not perfect -> we need accurate width (per char) if (interpret == false) { auto tw = font->getWidth(this->text); From 364777146280d83a14ae2c3dd02452693be62af1 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 00:46:13 +0200 Subject: [PATCH 16/28] Remove very confusing unused button constructor --- src/libs/gui_tk/gui_tk.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 7f5eacdba4..7189c4fb13 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -2354,9 +2354,6 @@ class Button : public BorderedWindow, public ActionEventSource { bool pressed; public: - /// Create a button with given position and size - Button(Window *parent, int x, int y, int w, int h) : BorderedWindow(parent,x,y,w,h,6,5,6,5), ActionEventSource("GUI::Button"), pressed(0) {} - /// Create a text button. /** If a size is specified, text is centered. Otherwise, button size is adjusted for the text. */ template Button(Window *parent, int x, int y, const T text, int w = -1, int h = -1); From 6cc9aca144c64c10500e88fce5412222ec5a4d7d Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 01:02:29 +0200 Subject: [PATCH 17/28] Add Win31 like margins --- src/gui/sdl_gui.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index b333c34706..9e852d0a6b 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -3176,8 +3176,10 @@ class ConfigurationWindow : public GUI::ToplevelWindow { int btnperrow = 4; int i = 0; - const auto xSpace = gridbtnwidth + 2; - const auto ySpace = gridbtnheight + 2; + constexpr auto margin = 3; + + const auto xSpace = gridbtnwidth + margin; + const auto ySpace = gridbtnheight + margin; std::function< std::pair(const int) > gridfunc = [&/*access to locals here*/](const int i){ return std::pair(gridbtnx+(i%btnperrow)*xSpace, gridbtny+(i/btnperrow)*ySpace); From 00b422013ee845f59afb8cb5d58438252547bf00 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 01:03:01 +0200 Subject: [PATCH 18/28] Stop aligning save/close buttons manually --- src/gui/sdl_gui.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index 9e852d0a6b..285df70e6e 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -3264,8 +3264,12 @@ class ConfigurationWindow : public GUI::ToplevelWindow { advopt->setChecked(section->Get_bool("show advanced options") || advOptUser); strcpy(tmp1, (MSG_Get("SAVE")+std::string("...")).c_str()); - (saveButton = new GUI::Button(this, 276, closerow_y, tmp1, 130, gridbtnheight))->addActionHandler(this); - (closeButton = new GUI::Button(this, 408, closerow_y, MSG_Get("CLOSE"), 130, gridbtnheight))->addActionHandler(this); + + const auto xSave = gridbtnx + (gridbtnwidth + margin) * 2; + const auto xExit = gridbtnx + (gridbtnwidth + margin) * 3; + + (saveButton = new GUI::Button(this, xSave, closerow_y, tmp1, 130, gridbtnheight))->addActionHandler(this); + (closeButton = new GUI::Button(this, xExit, closerow_y, MSG_Get("CLOSE"), 130, gridbtnheight))->addActionHandler(this); resize(gridbtnx + (xSpace * btnperrow) + 12 + border_left + border_right, closerow_y + closeButton->getHeight() + 8 + border_top + border_bottom); From 288a6c84357d337254beed59147a34cfd31548e7 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 01:04:41 +0200 Subject: [PATCH 19/28] DRY variables --- src/gui/sdl_gui.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index 285df70e6e..c96058e09d 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -3268,10 +3268,10 @@ class ConfigurationWindow : public GUI::ToplevelWindow { const auto xSave = gridbtnx + (gridbtnwidth + margin) * 2; const auto xExit = gridbtnx + (gridbtnwidth + margin) * 3; - (saveButton = new GUI::Button(this, xSave, closerow_y, tmp1, 130, gridbtnheight))->addActionHandler(this); - (closeButton = new GUI::Button(this, xExit, closerow_y, MSG_Get("CLOSE"), 130, gridbtnheight))->addActionHandler(this); + (saveButton = new GUI::Button(this, xSave, closerow_y, tmp1, gridbtnwidth, gridbtnheight))->addActionHandler(this); + (closeButton = new GUI::Button(this, xExit, closerow_y, MSG_Get("CLOSE"), gridbtnwidth, gridbtnheight))->addActionHandler(this); - resize(gridbtnx + (xSpace * btnperrow) + 12 + border_left + border_right, + resize(gridbtnx + (xSpace * btnperrow) + gridbtnx + border_left + border_right, closerow_y + closeButton->getHeight() + 8 + border_top + border_bottom); bar->resize(getWidth(),bar->getHeight()); From 2d93a506b115051640c841c9a1055ea79542cde9 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 01:43:44 +0200 Subject: [PATCH 20/28] Fix/rename/simplify section title stuff --- src/gui/sdl_gui.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index c96058e09d..bf4b2060b1 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -3246,13 +3246,12 @@ class ConfigurationWindow : public GUI::ToplevelWindow { for(const auto & sec : sections) { if (i != 0 && (i%15) == 0) bar->addItem(1, "|"); - std::string name = sec->GetName(); - std::string title = CapName(name); - name[0] = std::toupper(name[0]); + if (i != 0 && (i%16) == 0) bar->addItem(1, "|"); + std::string sectionTitle = CapName(std::string(sec->GetName())); const auto sz = gridfunc(i); - GUI::Button *b = new GUI::Button(this, sz.first, sz.second, title, gridbtnwidth, gridbtnheight); + GUI::Button *b = new GUI::Button(this, sz.first, sz.second, sectionTitle, gridbtnwidth, gridbtnheight); b->addActionHandler(this); - bar->addItem(1, title); + bar->addItem(1, sectionTitle); i++; } From 22e2b964d6ba89e7c4826adef38496adc7777315 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 01:44:01 +0200 Subject: [PATCH 21/28] Separate settings in menu by 16 instead of 15 --- src/gui/sdl_gui.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/sdl_gui.cpp b/src/gui/sdl_gui.cpp index bf4b2060b1..22d7c27fb4 100644 --- a/src/gui/sdl_gui.cpp +++ b/src/gui/sdl_gui.cpp @@ -3245,7 +3245,6 @@ class ConfigurationWindow : public GUI::ToplevelWindow { for(const auto & sec : sections) { - if (i != 0 && (i%15) == 0) bar->addItem(1, "|"); if (i != 0 && (i%16) == 0) bar->addItem(1, "|"); std::string sectionTitle = CapName(std::string(sec->GetName())); const auto sz = gridfunc(i); From 799e37bfbd0db6b1940dced3af3771ccc8b0815f Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 02:32:52 +0200 Subject: [PATCH 22/28] Get mouse wheel to work without having to click first --- src/libs/gui_tk/gui_tk.cpp | 36 ++++++++++++++++++++++++++++++------ src/libs/gui_tk/gui_tk.h | 4 ++-- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index dabb59366c..0694ffcc3f 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -1026,10 +1026,32 @@ bool Window::mouseDoubleClicked(int x, int y, MouseButton button) return mouseChild->mouseDoubleClicked(x-mouseChild->x, y-mouseChild->y, button); } -bool Window::mouseWheel(int wheel) +bool Window::mouseWheel(int x, int y, int wheel) { + for(const auto& win1 : children) + { + if(win1->toplevel && win1->hasFocus()) + { + for(const auto& win2 : win1->children) + { + if(dynamic_cast(win2)) + { + const auto xMin = win1->x + win2->x; + const auto yMin = win1->y + win2->y; + const auto xMax = xMin + win2->width - 1; + const auto yMax = yMin + win2->height - 1; + + if(x >= xMin && x <= xMax && y >= yMin && y < yMax) + { + return win2->mouseWheel(x, y, wheel); + } + } + } + } + } + if (mouseChild == NULL) return false; - return mouseChild->mouseWheel(wheel); + return mouseChild->mouseWheel(x, y, wheel); } bool BorderedWindow::mouseDown(int x, int y, MouseButton button) @@ -2337,7 +2359,10 @@ bool ScreenSDL::event(SDL_Event &event) { return rc; #if C_SDL2 case SDL_MOUSEWHEEL: - return mouseWheel(event.wheel.y); + { + const auto wheel = event.wheel; + return mouseWheel(wheel.mouseX / scale, wheel.mouseY / scale, wheel.y); + } #endif } @@ -2878,11 +2903,10 @@ bool WindowInWindow::mouseDoubleClicked(int x, int y, MouseButton button) { return Window::mouseDoubleClicked(x-xadj,y-xadj,button); } -bool WindowInWindow::mouseWheel(int wheel) +bool WindowInWindow::mouseWheel(int x, int y, int wheel) { - // BUG requires to click at least once in window for it to work scroll_pos_y = imin(imax(scroll_pos_y - wheel * 15, 0), scroll_pos_h); - return Window::mouseWheel(wheel); + return Window::mouseWheel(x, y, wheel); } void WindowInWindow::resize(int w, int h) { diff --git a/src/libs/gui_tk/gui_tk.h b/src/libs/gui_tk/gui_tk.h index 7189c4fb13..f986350fb8 100644 --- a/src/libs/gui_tk/gui_tk.h +++ b/src/libs/gui_tk/gui_tk.h @@ -744,7 +744,7 @@ class Window : public Refcount { /// Transient windows by default should disappear. virtual bool mouseDownOutside(MouseButton button); - virtual bool mouseWheel(int wheel); + virtual bool mouseWheel(int x, int y, int wheel); /// Key was pressed. Returns true if event was handled. virtual bool keyDown(const Key &key); /// Key was released. Returns true if event was handled. @@ -890,7 +890,7 @@ class WindowInWindow : public Window { /// Mouse was double-clicked. Returns true if event was handled. bool mouseDoubleClicked(int x, int y, MouseButton button) override; - bool mouseWheel(int wheel) override; + bool mouseWheel(int x, int y, int wheel) override; /// Key was pressed. Returns true if event was handled. bool keyDown(const Key &key) override; From 45d0ed6d6ba597ae6096b89c48ed1be09dcebf16 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 02:33:26 +0200 Subject: [PATCH 23/28] Increase mouse wheel scrolling rate --- src/libs/gui_tk/gui_tk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index 0694ffcc3f..9f3be6dd93 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -2905,7 +2905,7 @@ bool WindowInWindow::mouseDoubleClicked(int x, int y, MouseButton button) { bool WindowInWindow::mouseWheel(int x, int y, int wheel) { - scroll_pos_y = imin(imax(scroll_pos_y - wheel * 15, 0), scroll_pos_h); + scroll_pos_y = imin(imax(scroll_pos_y - wheel * 30, 0), scroll_pos_h); return Window::mouseWheel(x, y, wheel); } From a77d30a01156f08026e98c6595caf9714cf41afd Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 02:58:14 +0200 Subject: [PATCH 24/28] Scrolling target doesn't need to be top-most --- src/libs/gui_tk/gui_tk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index 9f3be6dd93..5e8b26cf68 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -1030,7 +1030,7 @@ bool Window::mouseWheel(int x, int y, int wheel) { for(const auto& win1 : children) { - if(win1->toplevel && win1->hasFocus()) + if(win1->hasFocus()) { for(const auto& win2 : win1->children) { From 109a1db20f1229755e18334dac83e656d10a4b1f Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 02:58:52 +0200 Subject: [PATCH 25/28] Fix missing scrollbar borders (previous drawRect fix) --- src/libs/gui_tk/gui_tk.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index 5e8b26cf68..83cec50631 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -2393,7 +2393,7 @@ void WindowInWindow::paintScrollBar3DOutset(Drawable &dscroll, int x, int y, int void WindowInWindow::paintScrollBarThumb(Drawable &dscroll, vscrollbarlayout &vsl) const { // black border dscroll.setColor(vsl.disabled ? CurrentTheme.Shadow3D : Color::Black); - dscroll.drawRect(vsl.xleft,vsl.ytop,vsl.thumbwidth-1,vsl.thumbheight-1); + dscroll.drawRect(vsl.xleft,vsl.ytop,vsl.thumbwidth,vsl.thumbheight); // 3D outset style, 1 pixel inward each side, inside the black rectangle we just drew paintScrollBar3DOutset(dscroll, vsl.xleft+1, vsl.ytop+1, vsl.thumbwidth-2, vsl.thumbheight-2); @@ -2402,7 +2402,7 @@ void WindowInWindow::paintScrollBarThumb(Drawable &dscroll, vscrollbarlayout &vs void WindowInWindow::paintScrollBarBackground(Drawable &dscroll,const vscrollbarlayout &vsl) const { /* scroll bar border, background */ dscroll.setColor(vsl.disabled ? CurrentTheme.Shadow3D : Color::Black); - dscroll.drawRect(vsl.scrollthumbRegion.x, vsl.scrollthumbRegion.y, vsl.scrollthumbRegion.w-1,vsl.scrollthumbRegion.h-1); + dscroll.drawRect(vsl.scrollthumbRegion.x, vsl.scrollthumbRegion.y, vsl.scrollthumbRegion.w,vsl.scrollthumbRegion.h); dscroll.setColor(CurrentTheme.Background); dscroll.fillRect(vsl.scrollthumbRegion.x+1,vsl.scrollthumbRegion.y+1,vsl.scrollthumbRegion.w-2,vsl.scrollthumbRegion.h-2); @@ -2524,7 +2524,7 @@ void WindowInWindow::paintAll(Drawable &d) const { // black border dscroll.setColor(vsl.disabled ? CurrentTheme.Shadow3D : Color::Black); - dscroll.drawRect(x,y,w-1,h-1); + dscroll.drawRect(x,y,w,h); // 3D outset style, 1 pixel inward each side, inside the black rectangle we just drew if (vscroll_uparrowhold && vscroll_uparrowdown) @@ -2546,7 +2546,7 @@ void WindowInWindow::paintAll(Drawable &d) const { // black border dscroll.setColor(vsl.disabled ? CurrentTheme.Shadow3D : Color::Black); - dscroll.drawRect(x,y,w-1,h-1); + dscroll.drawRect(x,y,w,h); // 3D outset style, 1 pixel inward each side, inside the black rectangle we just drew if (vscroll_downarrowhold && vscroll_downarrowdown) From f5f341ae9d6be63d3cf6d9f515b8208881467f2e Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 03:16:55 +0200 Subject: [PATCH 26/28] Update CHANGELOG --- CHANGELOG | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5298e2cdfd..a4a0a2e5c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -21,7 +21,14 @@ NEXT - Updated SDL2 library to 2.30.4 (maron2000) - Fixed TTF mode didn't change to graphic mode when machine = Hercules (maron2000) - - CFGTOOL: more Windows 3.1 styling, general UX/UI improvements (aybe). + - Configuration tool: (aybe) + - more Windows 3.1 styling: buttons, colors, focus, layout + - enhance main window layout, it is now visible in its entirety + - fix layout issues, off by one in rectangle drawing functions + - fix 'list iterators incompatible' when pressing the Tab key + - properties/help: sorted alphabetically, mouse wheel scrollable + - remove few rendundant labels, adjust names of some others + - retain 'show advanced options' state throughout session 2024.07.01 - Correct Hercules InColor memory emulation. Read and write planar From 55cc619d194aa4e45e608b58615f3a706a724d3f Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 03:42:07 +0200 Subject: [PATCH 27/28] Try fix Linux build issues... --- src/libs/gui_tk/gui_tk.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index 83cec50631..5f85250da8 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -2358,11 +2358,13 @@ bool ScreenSDL::event(SDL_Event &event) { lastdown = 0; return rc; #if C_SDL2 +#if WIN32 case SDL_MOUSEWHEEL: { const auto wheel = event.wheel; return mouseWheel(wheel.mouseX / scale, wheel.mouseY / scale, wheel.y); } +#endif #endif } From 88c0444cde54d4c29778abdfaa3c66431ca8dae9 Mon Sep 17 00:00:00 2001 From: aybe Date: Fri, 12 Jul 2024 15:55:51 +0200 Subject: [PATCH 28/28] Fix off by one --- src/libs/gui_tk/gui_tk.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/gui_tk/gui_tk.cpp b/src/libs/gui_tk/gui_tk.cpp index 5f85250da8..0f05b91c7d 100644 --- a/src/libs/gui_tk/gui_tk.cpp +++ b/src/libs/gui_tk/gui_tk.cpp @@ -1041,7 +1041,7 @@ bool Window::mouseWheel(int x, int y, int wheel) const auto xMax = xMin + win2->width - 1; const auto yMax = yMin + win2->height - 1; - if(x >= xMin && x <= xMax && y >= yMin && y < yMax) + if(x >= xMin && x <= xMax && y >= yMin && y <= yMax) { return win2->mouseWheel(x, y, wheel); }