diff options
author | Alexander Tkachev | 2016-07-11 14:17:27 +0600 |
---|---|---|
committer | Alexander Tkachev | 2016-08-24 16:07:55 +0600 |
commit | 9975307caf5452b25ad706ca2594239909f2354f (patch) | |
tree | 3764f264af07f3d469db6fa7358110eee15adb3a /gui | |
parent | ee3ce476068e487517022bdb9ee397ff2f070d86 (diff) | |
download | scummvm-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')
-rw-r--r-- | gui/options.cpp | 19 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.cpp | 15 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.h | 7 |
3 files changed, 26 insertions, 15 deletions
diff --git a/gui/options.cpp b/gui/options.cpp index a272b220ba..42d6a66053 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -100,7 +100,8 @@ enum { kConfigureStorageCmd = 'cfst', kRefreshStorageCmd = 'rfst', kDownloadStorageCmd = 'dlst', - kRunServerCmd = 'rnsv' + kRunServerCmd = 'rnsv', + kCloudTabContainerReflowCmd = 'ctcr' }; #endif @@ -1280,7 +1281,8 @@ GlobalOptionsDialog::GlobalOptionsDialog() else tab->addTab(_c("Cloud", "lowres")); - ScrollContainerWidget *container = new ScrollContainerWidget(tab, "GlobalOptions_Cloud.Container"); + ScrollContainerWidget *container = new ScrollContainerWidget(tab, "GlobalOptions_Cloud.Container", kCloudTabContainerReflowCmd); + container->setTarget(this); #ifdef USE_LIBCURL _selectedStorageIndex = CloudMan.getStorageIndex(); @@ -1600,19 +1602,24 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 } break; } +#ifdef USE_CLOUD + case kCloudTabContainerReflowCmd: + setupCloudTab(); + break; +#endif #ifdef USE_LIBCURL case kPopUpItemSelectedCmd: { - setupCloudTab(); - draw(); + //update container's scrollbar + reflowLayout(); break; } case kConfigureStorageCmd: { StorageWizardDialog dialog(_selectedStorageIndex); dialog.runModal(); - setupCloudTab(); - draw(); + //update container's scrollbar + reflowLayout(); break; } case kRefreshStorageCmd: 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(); |