Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Windows 3.1 styling for CFGTOOL #5117

Merged
merged 28 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6129ee1
Fix 'list iterators incompatible'
aybe Jul 11, 2024
4529acd
Fix CONFIG.SYS window overflowing
aybe Jul 11, 2024
22d9dec
UX: keep 'show advanced options' flag for the session
aybe Jul 11, 2024
964e2b0
UX: always center window after changing output
aybe Jul 11, 2024
dff530a
Win31 button height is not 26 but 23
aybe Jul 11, 2024
9110575
Sort button LTRB stuff
aybe Jul 11, 2024
1b03686
Win31 pixel-perfect button borders
aybe Jul 11, 2024
ade05f0
Label focus height isn't from font but from button
aybe Jul 11, 2024
0ca7870
We don't need focus LTRB padding anymore
aybe Jul 11, 2024
ccf80bb
Fix focus horizontal padding
aybe Jul 11, 2024
442c41a
Drawing a rectangle by size does not involve -1
aybe Jul 11, 2024
01dedd6
Fix Drawable::draw*Rect off by one
aybe Jul 11, 2024
f22c654
Ensure focus width is odd for pixel-perfect dotted rect
aybe Jul 11, 2024
ef4cd9b
Ensure text is offset according previous commit
aybe Jul 11, 2024
f294999
Adjust comments regarding previous stuff
aybe Jul 11, 2024
3647771
Remove very confusing unused button constructor
aybe Jul 11, 2024
6cc9aca
Add Win31 like margins
aybe Jul 11, 2024
00b4220
Stop aligning save/close buttons manually
aybe Jul 11, 2024
288a6c8
DRY variables
aybe Jul 11, 2024
2d93a50
Fix/rename/simplify section title stuff
aybe Jul 11, 2024
22e2b96
Separate settings in menu by 16 instead of 15
aybe Jul 11, 2024
799e37b
Get mouse wheel to work without having to click first
aybe Jul 12, 2024
45d0ed6
Increase mouse wheel scrolling rate
aybe Jul 12, 2024
a77d30a
Scrolling target doesn't need to be top-most
aybe Jul 12, 2024
109a1db
Fix missing scrollbar borders (previous drawRect fix)
aybe Jul 12, 2024
f5f341a
Update CHANGELOG
aybe Jul 12, 2024
55cc619
Try fix Linux build issues...
aybe Jul 12, 2024
88c0444
Fix off by one
aybe Jul 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 23 additions & 14 deletions src/gui/sdl_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ void macosx_reload_touchbar(void);

std::list<std::string> 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::Char>, 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);
Expand Down Expand Up @@ -1662,7 +1666,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);
Expand Down Expand Up @@ -3166,14 +3170,16 @@ 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;
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<int,int>(const int) > gridfunc = [&/*access to locals here*/](const int i){
return std::pair<int,int>(gridbtnx+(i%btnperrow)*xSpace, gridbtny+(i/btnperrow)*ySpace);
Expand Down Expand Up @@ -3239,14 +3245,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++;
}

Expand All @@ -3255,13 +3259,17 @@ class ConfigurationWindow : public GUI::ToplevelWindow {

advopt = new GUI::Checkbox(this, gridbtnx, closerow_y, MSG_Get("SHOW_ADVOPT"));
Section_prop * section=static_cast<Section_prop *>(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);
(closeButton = new GUI::Button(this, 408, closerow_y, MSG_Get("CLOSE"), 130, gridbtnheight))->addActionHandler(this);

resize(gridbtnx + (xSpace * btnperrow) + 12 + border_left + border_right,
const auto xSave = gridbtnx + (gridbtnwidth + margin) * 2;
const auto xExit = gridbtnx + (gridbtnwidth + margin) * 3;

(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) + gridbtnx + border_left + border_right,
closerow_y + closeButton->getHeight() + 8 + border_top + border_bottom);

bar->resize(getWidth(),bar->getHeight());
Expand All @@ -3287,6 +3295,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;
Expand Down
110 changes: 69 additions & 41 deletions src/libs/gui_tk/gui_tk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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<Window *>::iterator i = children.begin(), e = children.end();
--e;
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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<Window *>::iterator i = children.begin(), e = children.end();
--e;
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -1024,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->hasFocus())
{
for(const auto& win2 : win1->children)
{
if(dynamic_cast<WindowInWindow*>(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)
aybe marked this conversation as resolved.
Show resolved Hide resolved
{
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)
Expand Down Expand Up @@ -2334,8 +2358,13 @@ bool ScreenSDL::event(SDL_Event &event) {
lastdown = 0;
return rc;
#if C_SDL2
#if WIN32
case SDL_MOUSEWHEEL:
return mouseWheel(event.wheel.y);
{
const auto wheel = event.wheel;
return mouseWheel(wheel.mouseX / scale, wheel.mouseY / scale, wheel.y);
}
#endif
#endif
}

Expand Down Expand Up @@ -2366,7 +2395,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);
Expand All @@ -2375,7 +2404,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);
Expand Down Expand Up @@ -2497,7 +2526,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)
Expand All @@ -2519,7 +2548,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)
Expand Down Expand Up @@ -2876,11 +2905,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);
scroll_pos_y = imin(imax(scroll_pos_y - wheel * 30, 0), scroll_pos_h);
return Window::mouseWheel(x, y, wheel);
}

void WindowInWindow::resize(int w, int h) {
Expand Down
Loading
Loading