Skip to content

Commit

Permalink
GUI: Account for the scroll bar size in ScrollContainerWidget objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 authored and sev- committed May 14, 2023
1 parent 30bdbb6 commit 7ef8da5
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 38 deletions.
6 changes: 6 additions & 0 deletions gui/ThemeEval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ ThemeEval &ThemeEval::addWidget(const Common::String &name, const Common::String
typeH == -1 ? h : typeH,
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign,
getVar("Globals.TabWidget.Tab.Height", 0));
else if (type == "ScrollContainerWidget")
widget = new ThemeLayoutScrollContainerWidget(_curLayout.top(), name,
typeW == -1 ? w : typeW,
typeH == -1 ? h : typeH,
typeAlign == Graphics::kTextAlignInvalid ? align : typeAlign,
getVar("Globals.Scrollbar.Width", 0));
else
widget = new ThemeLayoutWidget(_curLayout.top(), name,
typeW == -1 ? w : typeW,
Expand Down
35 changes: 35 additions & 0 deletions gui/ThemeLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class ThemeLayout {
kLayoutHorizontal,
kLayoutWidget,
kLayoutTabWidget,
kLayoutScrollContainerWidget,
kLayoutSpace
};

Expand Down Expand Up @@ -285,6 +286,40 @@ class ThemeLayoutTabWidget : public ThemeLayoutWidget {
}
};

class ThemeLayoutScrollContainerWidget : public ThemeLayoutWidget {
int _scrollWidth;

public:
ThemeLayoutScrollContainerWidget(ThemeLayout *p, const Common::String &name, int16 w, int16 h, Graphics::TextAlign align, int scrollWidth):
ThemeLayoutWidget(p, name, w, h, align, p->getUseRTL()) {
_scrollWidth = scrollWidth;
}

void reflowLayout(Widget *widgetChain) override {
for (uint i = 0; i < _children.size(); ++i) {
_children[i]->reflowLayout(widgetChain);
}
}

bool getWidgetData(const Common::String &name, int16 &x, int16 &y, int16 &w, int16 &h, bool &useRTL) override {
if (ThemeLayoutWidget::getWidgetData(name, x, y, w, h, useRTL)) {
w -= _scrollWidth;
return true;
}

return false;
}

protected:
LayoutType getLayoutType() const override { return kLayoutScrollContainerWidget; }

ThemeLayout *makeClone(ThemeLayout *newParent) override {
ThemeLayoutScrollContainerWidget *n = new ThemeLayoutScrollContainerWidget(*this);
n->_parent = newParent;
return n;
}
};

class ThemeLayoutSpacing : public ThemeLayout {
public:
ThemeLayoutSpacing(ThemeLayout *p, int size) : ThemeLayout(p) {
Expand Down
25 changes: 19 additions & 6 deletions gui/themes/common/highres_layout.stx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,9 @@

<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GlobalOptions_Graphics_Container' overlays = 'GlobalOptions_Graphics.Container'>
Expand Down Expand Up @@ -913,7 +915,9 @@

<dialog name = 'GlobalOptions_GUI' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -1035,7 +1039,9 @@

<dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -1494,13 +1500,17 @@

<dialog name = 'GameOptions_Achievements' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

<dialog name = 'GameOptions_Graphics' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GameOptions_Graphics_Container' overlays = 'GameOptions_Graphics.Container'>
Expand Down Expand Up @@ -1788,7 +1798,9 @@

<dialog name = 'GlobalConfig_Achievements' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -2337,6 +2349,7 @@
<dialog name = 'UnknownGameDialog' overlays = 'Dialog.Launcher.GameList' shading = 'dim'>
<layout type = 'vertical' padding = '8, 8, 8, 0'>
<widget name = 'TextContainer'
type = 'ScrollContainerWidget'
/>
<layout type = 'horizontal' padding = '0, 0, 16, 16'>
<space/>
Expand Down
25 changes: 19 additions & 6 deletions gui/themes/common/lowres_layout.stx
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@

<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GlobalOptions_Graphics_Container' overlays = 'GlobalOptions_Graphics.Container'>
Expand Down Expand Up @@ -766,7 +768,9 @@

<dialog name = 'GlobalOptions_GUI' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -900,7 +904,9 @@

<dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -1341,13 +1347,17 @@

<dialog name = 'GameOptions_Achievements' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

<dialog name = 'GameOptions_Graphics' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GameOptions_Graphics_Container' overlays = 'GameOptions_Graphics.Container'>
Expand Down Expand Up @@ -1644,7 +1654,9 @@

<dialog name = 'GlobalConfig_Achievements' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -2172,6 +2184,7 @@
<dialog name = 'UnknownGameDialog' overlays = 'screen' inset = '8' shading = 'dim'>
<layout type = 'vertical' padding = '8, 8, 8, 0'>
<widget name = 'TextContainer'
type = 'ScrollContainerWidget'
/>
<layout type = 'horizontal' padding = '0, 0, 8, 8'>
<space/>
Expand Down
25 changes: 19 additions & 6 deletions gui/themes/scummclassic/classic_layout.stx
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@

<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GlobalOptions_Graphics_Container' overlays = 'GlobalOptions_Graphics.Container'>
Expand Down Expand Up @@ -681,7 +683,9 @@

<dialog name = 'GlobalOptions_GUI' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -803,7 +807,9 @@

<dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -1247,13 +1253,17 @@

<dialog name = 'GameOptions_Achievements' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

<dialog name = 'GameOptions_Graphics' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GameOptions_Graphics_Container' overlays = 'GameOptions_Graphics.Container'>
Expand Down Expand Up @@ -1541,7 +1551,9 @@

<dialog name = 'GlobalConfig_Achievements' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -2088,6 +2100,7 @@
<dialog name = 'UnknownGameDialog' overlays = 'Dialog.Launcher.GameList' shading = 'dim'>
<layout type = 'vertical' padding = '8, 8, 8, 0'>
<widget name = 'TextContainer'
type = 'ScrollContainerWidget'
/>
<layout type = 'horizontal' padding = '0, 0, 16, 16'>
<space/>
Expand Down
25 changes: 19 additions & 6 deletions gui/themes/scummclassic/classic_layout_lowres.stx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,9 @@

<dialog name = 'GlobalOptions_Graphics' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GlobalOptions_Graphics_Container' overlays = 'GlobalOptions_Graphics.Container'>
Expand Down Expand Up @@ -688,7 +690,9 @@

<dialog name = 'GlobalOptions_GUI' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -822,7 +826,9 @@

<dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -1263,13 +1269,17 @@

<dialog name = 'GameOptions_Achievements' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

<dialog name = 'GameOptions_Graphics' overlays = 'Dialog.GameOptions.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>
<dialog name = 'GameOptions_Graphics_Container' overlays = 'GameOptions_Graphics.Container'>
Expand Down Expand Up @@ -1565,7 +1575,9 @@

<dialog name = 'GlobalConfig_Achievements' overlays = 'Dialog.GlobalConfig.TabWidget'>
<layout type = 'vertical' padding = '0, 0, 0, 0'>
<widget name = 'Container'/>
<widget name = 'Container'
type = 'ScrollContainerWidget'
/>
</layout>
</dialog>

Expand Down Expand Up @@ -2072,6 +2084,7 @@
<dialog name = 'UnknownGameDialog' overlays = 'screen' inset = '8' shading = 'dim'>
<layout type = 'vertical' padding = '8, 8, 8, 0'>
<widget name = 'TextContainer'
type = 'ScrollContainerWidget'
/>
<layout type = 'horizontal' padding = '0, 0, 8, 8'>
<space/>
Expand Down
2 changes: 1 addition & 1 deletion gui/widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void Widget::draw() {
Widget *Widget::findWidgetInChain(Widget *w, int x, int y) {
while (w) {
// Stop as soon as we find a widget that contains the point (x,y)
if (x >= w->_x && x < w->_x + w->_w && y >= w->_y && y < w->_y + w->getHeight())
if (x >= w->_x && x < w->_x + w->getWidth() && y >= w->_y && y < w->_y + w->getHeight())
break;
w = w->_next;
}
Expand Down

0 comments on commit 7ef8da5

Please sign in to comment.