aboutsummaryrefslogtreecommitdiff
path: root/gui/widgets
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-11 14:17:27 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commit9975307caf5452b25ad706ca2594239909f2354f (patch)
tree3764f264af07f3d469db6fa7358110eee15adb3a /gui/widgets
parentee3ce476068e487517022bdb9ee397ff2f070d86 (diff)
downloadscummvm-rg350-9975307caf5452b25ad706ca2594239909f2354f.tar.gz
scummvm-rg350-9975307caf5452b25ad706ca2594239909f2354f.tar.bz2
scummvm-rg350-9975307caf5452b25ad706ca2594239909f2354f.zip
GUI: Fix Container's visibility issue
Now it respects outer code's decision to hide or move some widgets around. Outer code must be CommandReceiver which is set as ScrollContainer's target.
Diffstat (limited to 'gui/widgets')
-rw-r--r--gui/widgets/scrollcontainer.cpp15
-rw-r--r--gui/widgets/scrollcontainer.h7
2 files changed, 13 insertions, 9 deletions
diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp
index 1b38478c11..9251047185 100644
--- a/gui/widgets/scrollcontainer.cpp
+++ b/gui/widgets/scrollcontainer.cpp
@@ -28,13 +28,13 @@
namespace GUI {
-ScrollContainerWidget::ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h)
- : Widget(boss, x, y, w, h) {
+ScrollContainerWidget::ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h, uint32 reflowCmd)
+ : Widget(boss, x, y, w, h), CommandSender(nullptr), _reflowCmd(reflowCmd) {
init();
}
-ScrollContainerWidget::ScrollContainerWidget(GuiObject *boss, const Common::String &name)
- : Widget(boss, name) {
+ScrollContainerWidget::ScrollContainerWidget(GuiObject *boss, const Common::String &name, uint32 reflowCmd)
+ : Widget(boss, name), CommandSender(nullptr), _reflowCmd(reflowCmd) {
init();
}
@@ -59,7 +59,7 @@ void ScrollContainerWidget::recalc() {
int min = spacing, max = 0;
Widget *ptr = _firstWidget;
while (ptr) {
- if (ptr != _verticalScroll) {
+ if (ptr != _verticalScroll && ptr->isVisible()) {
int y = ptr->getAbsY() - getChildY();
min = MIN(min, y - spacing);
max = MAX(max, y + ptr->getHeight() + spacing);
@@ -115,6 +115,9 @@ void ScrollContainerWidget::reflowLayout() {
ptr->reflowLayout();
ptr = ptr->next();
}
+
+ //hide and move widgets, if needed
+ sendCommand(_reflowCmd, 0);
//recalculate height
recalc();
@@ -124,7 +127,7 @@ void ScrollContainerWidget::reflowLayout() {
while (ptr) {
int y = ptr->getAbsY() - getChildY();
int h = ptr->getHeight();
- bool visible = true;
+ bool visible = ptr->isVisible();
if (y + h - _scrolledY < 0) visible = false;
if (y - _scrolledY > _limitH) visible = false;
ptr->setVisible(visible);
diff --git a/gui/widgets/scrollcontainer.h b/gui/widgets/scrollcontainer.h
index 692c7e3507..c2d47370ee 100644
--- a/gui/widgets/scrollcontainer.h
+++ b/gui/widgets/scrollcontainer.h
@@ -29,16 +29,17 @@
namespace GUI {
-class ScrollContainerWidget: public Widget {
+class ScrollContainerWidget: public Widget, public CommandSender {
ScrollBarWidget *_verticalScroll;
int16 _scrolledX, _scrolledY;
uint16 _limitH;
+ uint32 _reflowCmd;
void recalc();
public:
- ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h);
- ScrollContainerWidget(GuiObject *boss, const Common::String &name);
+ ScrollContainerWidget(GuiObject *boss, int x, int y, int w, int h, uint32 reflowCmd = 0);
+ ScrollContainerWidget(GuiObject *boss, const Common::String &name, uint32 reflowCmd = 0);
~ScrollContainerWidget();
void init();