[Scummvm-git-logs] scummvm master -> 7ef8da53d787479b5642b732a36af8c34acfb9d6
sev-
noreply at scummvm.org
Sun May 14 20:44:01 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
30bdbb6f76 Revert "GUI: Ensure that all keymap widgets fit within the scroll container"
7ef8da53d7 GUI: Account for the scroll bar size in ScrollContainerWidget objects
Commit: 30bdbb6f764649877b46ebdc39030edfea147e54
https://github.com/scummvm/scummvm/commit/30bdbb6f764649877b46ebdc39030edfea147e54
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-05-14T22:43:57+02:00
Commit Message:
Revert "GUI: Ensure that all keymap widgets fit within the scroll container"
This reverts commit d255fbe671f6d5f7effa99988131dd92845b8b5b.
Changed paths:
backends/keymapper/remap-widget.cpp
diff --git a/backends/keymapper/remap-widget.cpp b/backends/keymapper/remap-widget.cpp
index fe15a30231d..57fbf0b18ed 100644
--- a/backends/keymapper/remap-widget.cpp
+++ b/backends/keymapper/remap-widget.cpp
@@ -104,7 +104,7 @@ void RemapWidget::reflowActionWidgets() {
int spacing = g_gui.xmlEval()->getVar("Globals.KeyMapper.Spacing");
int keyButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth");
int resetButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ResetWidth");
- int labelWidth = widgetsBoss()->getWidth() - (spacing + keyButtonWidth + spacing);
+ int labelWidth = getWidth() - (spacing + keyButtonWidth + spacing);
labelWidth = MAX(0, labelWidth);
uint textYOff = (buttonHeight - kLineHeight) / 2;
@@ -121,7 +121,7 @@ void RemapWidget::reflowActionWidgets() {
// Insert a keymap separator
uint descriptionX = 2 * spacing + keyButtonWidth;
- uint resetX = widgetsBoss()->getWidth() - spacing - resetButtonWidth;
+ uint resetX = getWidth() - spacing - resetButtonWidth;
KeymapTitleRow keymapTitle = _keymapSeparators[row.keymap];
if (keymapTitle.descriptionText) {
Commit: 7ef8da53d787479b5642b732a36af8c34acfb9d6
https://github.com/scummvm/scummvm/commit/7ef8da53d787479b5642b732a36af8c34acfb9d6
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2023-05-14T22:43:57+02:00
Commit Message:
GUI: Account for the scroll bar size in ScrollContainerWidget objects
Changed paths:
gui/ThemeEval.cpp
gui/ThemeLayout.h
gui/themes/common/highres_layout.stx
gui/themes/common/lowres_layout.stx
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummclassic/classic_layout_lowres.stx
gui/widget.cpp
gui/widgets/scrollcontainer.cpp
gui/widgets/scrollcontainer.h
diff --git a/gui/ThemeEval.cpp b/gui/ThemeEval.cpp
index e834d0c5a34..71793cf7419 100644
--- a/gui/ThemeEval.cpp
+++ b/gui/ThemeEval.cpp
@@ -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,
diff --git a/gui/ThemeLayout.h b/gui/ThemeLayout.h
index 7911004a021..51f0aa30b4d 100644
--- a/gui/ThemeLayout.h
+++ b/gui/ThemeLayout.h
@@ -50,6 +50,7 @@ public:
kLayoutHorizontal,
kLayoutWidget,
kLayoutTabWidget,
+ kLayoutScrollContainerWidget,
kLayoutSpace
};
@@ -285,6 +286,40 @@ protected:
}
};
+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) {
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index 10b53ae11e9..2cb8ec2427d 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -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'>
@@ -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>
@@ -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>
@@ -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'>
@@ -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>
@@ -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/>
diff --git a/gui/themes/common/lowres_layout.stx b/gui/themes/common/lowres_layout.stx
index 8be4441b29f..b0bde12867a 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -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'>
@@ -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>
@@ -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>
@@ -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'>
@@ -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>
@@ -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/>
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index a3934aa47a2..afd2bf5377c 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -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'>
@@ -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>
@@ -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>
@@ -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'>
@@ -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>
@@ -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/>
diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx
index 0d47f07848a..87bca6bf287 100644
--- a/gui/themes/scummclassic/classic_layout_lowres.stx
+++ b/gui/themes/scummclassic/classic_layout_lowres.stx
@@ -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'>
@@ -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>
@@ -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>
@@ -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'>
@@ -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>
@@ -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/>
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 0ea97fb9a9e..407c72ff2e8 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -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;
}
diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp
index b8b8223930d..0baa42811fe 100644
--- a/gui/widgets/scrollcontainer.cpp
+++ b/gui/widgets/scrollcontainer.cpp
@@ -41,7 +41,7 @@ void ScrollContainerWidget::init() {
setFlags(WIDGET_ENABLED);
_type = kScrollContainerWidget;
_backgroundType = ThemeEngine::kWidgetBackgroundPlain;
- _verticalScroll = new ScrollBarWidget(this, _w-16, 0, 16, _h);
+ _verticalScroll = new ScrollBarWidget(this, _w, 0, 16, _h);
_verticalScroll->setTarget(this);
_scrolledX = 0;
_scrolledY = 0;
@@ -54,7 +54,7 @@ void ScrollContainerWidget::handleMouseWheel(int x, int y, int direction) {
}
void ScrollContainerWidget::recalc() {
- int scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
+ _scrollbarWidth = g_gui.xmlEval()->getVar("Globals.Scrollbar.Width", 0);
_limitH = _h;
//calculate virtual height
@@ -78,8 +78,8 @@ void ScrollContainerWidget::recalc() {
_verticalScroll->_currentPos = _scrolledY;
_verticalScroll->_entriesPerPage = _limitH;
_verticalScroll->_singleStep = kLineHeight;
- _verticalScroll->setPos(_w - scrollbarWidth, _scrolledY);
- _verticalScroll->setSize(scrollbarWidth, _limitH-1);
+ _verticalScroll->setPos(_w, _scrolledY);
+ _verticalScroll->setSize(_scrollbarWidth, _limitH-1);
}
@@ -94,7 +94,11 @@ int16 ScrollContainerWidget::getChildY() const {
}
uint16 ScrollContainerWidget::getWidth() const {
- return _w - (_verticalScroll->isVisible() ? _verticalScroll->getWidth() : 0);
+ // NOTE: if you change that, make sure to do the same
+ // changes in the ThemeLayoutScrollContainerWidget (gui/ThemeLayout.cpp)
+ // NOTE: this width is used for clipping, so it *includes*
+ // scrollbars, because it starts from getAbsX(), not getChildX()
+ return _w + _scrollbarWidth;
}
uint16 ScrollContainerWidget::getHeight() const {
@@ -142,6 +146,22 @@ void ScrollContainerWidget::drawWidget() {
g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + getHeight()), _backgroundType);
}
+void ScrollContainerWidget::draw() {
+ Widget::draw();
+
+ if (_verticalScroll->isVisible()) {
+ _verticalScroll->draw();
+ }
+}
+
+void ScrollContainerWidget::markAsDirty() {
+ Widget::markAsDirty();
+
+ if (_verticalScroll->isVisible()) {
+ _verticalScroll->markAsDirty();
+ }
+}
+
bool ScrollContainerWidget::containsWidget(Widget *w) const {
if (w == _verticalScroll || _verticalScroll->containsWidget(w))
return true;
@@ -149,7 +169,7 @@ bool ScrollContainerWidget::containsWidget(Widget *w) const {
}
Widget *ScrollContainerWidget::findWidget(int x, int y) {
- if (_verticalScroll->isVisible() && x >= _w - _verticalScroll->getWidth())
+ if (_verticalScroll->isVisible() && x >= _w)
return _verticalScroll;
Widget *w = Widget::findWidgetInChain(_firstWidget, x + _scrolledX, y + _scrolledY);
if (w)
@@ -157,11 +177,6 @@ Widget *ScrollContainerWidget::findWidget(int x, int y) {
return this;
}
-Common::Rect ScrollContainerWidget::getClipRect() const {
- // Make sure the clipping rect contains the scrollbar so it is properly redrawn
- return Common::Rect(getAbsX(), getAbsY(), getAbsX() + _w, getAbsY() + getHeight() - 1); // this -1 is because of container border, which might not be present actually
-}
-
void ScrollContainerWidget::setBackgroundType(ThemeEngine::WidgetBackground backgroundType) {
_backgroundType = backgroundType;
}
diff --git a/gui/widgets/scrollcontainer.h b/gui/widgets/scrollcontainer.h
index abaf88d1118..ea8587ec5f1 100644
--- a/gui/widgets/scrollcontainer.h
+++ b/gui/widgets/scrollcontainer.h
@@ -31,6 +31,7 @@ namespace GUI {
class ScrollContainerWidget: public Widget, public CommandSender {
ScrollBarWidget *_verticalScroll;
int16 _scrolledX, _scrolledY;
+ int _scrollbarWidth;
uint16 _limitH;
uint32 _reflowCmd;
ThemeEngine::WidgetBackground _backgroundType;
@@ -49,8 +50,6 @@ public:
bool containsWidget(Widget *) const override;
- Common::Rect getClipRect() const override;
-
void setBackgroundType(ThemeEngine::WidgetBackground backgroundType);
void handleMouseWheel(int x, int y, int direction) override;
@@ -62,6 +61,9 @@ public:
uint16 getWidth() const override;
uint16 getHeight() const override;
+ void draw() override;
+ void markAsDirty() override;
+
protected:
void drawWidget() override;
More information about the Scummvm-git-logs
mailing list