diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/widget.cpp | 13 | ||||
-rw-r--r-- | gui/widget.h | 4 | ||||
-rw-r--r-- | gui/widgets/list.cpp | 6 | ||||
-rw-r--r-- | gui/widgets/list.h | 1 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.cpp | 6 | ||||
-rw-r--r-- | gui/widgets/scrollcontainer.h | 2 | ||||
-rw-r--r-- | gui/widgets/tab.cpp | 7 | ||||
-rw-r--r-- | gui/widgets/tab.h | 2 |
8 files changed, 41 insertions, 0 deletions
diff --git a/gui/widget.cpp b/gui/widget.cpp index 850fad0e5f..4b84e19c09 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -175,6 +175,15 @@ Widget *Widget::findWidgetInChain(Widget *w, const char *name) { return 0; } +bool Widget::containsWidgetInChain(Widget *w, Widget *search) { + while (w) { + if (w == search || w->containsWidget(search)) + return true; + w = w->_next; + } + return false; +} + void Widget::setEnabled(bool e) { if ((_flags & WIDGET_ENABLED) != e) { if (e) @@ -837,6 +846,10 @@ ContainerWidget::~ContainerWidget() { } } +bool ContainerWidget::containsWidget(Widget *w) const { + return containsWidgetInChain(_firstWidget, w); +} + Widget *ContainerWidget::findWidget(int x, int y) { return findWidgetInChain(_firstWidget, x, y); } diff --git a/gui/widget.h b/gui/widget.h index e9343f264c..0da071e596 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -107,6 +107,7 @@ private: public: static Widget *findWidgetInChain(Widget *start, int x, int y); static Widget *findWidgetInChain(Widget *start, const char *name); + static bool containsWidgetInChain(Widget *start, Widget *search); public: Widget(GuiObject *boss, int x, int y, int w, int h, const char *tooltip = 0); @@ -158,6 +159,8 @@ public: const Common::String &getTooltip() const { return _tooltip; } void setTooltip(const Common::String &tooltip) { _tooltip = tooltip; } + virtual bool containsWidget(Widget *) const { return false; } + protected: void updateState(int oldFlags, int newFlags); @@ -388,6 +391,7 @@ public: ContainerWidget(GuiObject *boss, const Common::String &name); ~ContainerWidget(); + virtual bool containsWidget(Widget *) const; virtual Widget *findWidget(int x, int y); virtual void removeWidget(Widget *widget); protected: diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp index f6e5c67510..48d181e5ec 100644 --- a/gui/widgets/list.cpp +++ b/gui/widgets/list.cpp @@ -101,6 +101,12 @@ ListWidget::~ListWidget() { delete[] _textWidth; } +bool ListWidget::containsWidget(Widget *w) const { + if (w == _scrollBar || _scrollBar->containsWidget(w)) + return true; + return false; +} + Widget *ListWidget::findWidget(int x, int y) { if (x >= _w - _scrollBarWidth) return _scrollBar; diff --git a/gui/widgets/list.h b/gui/widgets/list.h index 1abb2b810e..44366be3e9 100644 --- a/gui/widgets/list.h +++ b/gui/widgets/list.h @@ -89,6 +89,7 @@ public: ListWidget(Dialog *boss, int x, int y, int w, int h, const char *tooltip = 0, uint32 cmd = 0); virtual ~ListWidget(); + virtual bool containsWidget(Widget *) const; virtual Widget *findWidget(int x, int y); void setList(const StringArray &list, const ColorList *colors = 0); diff --git a/gui/widgets/scrollcontainer.cpp b/gui/widgets/scrollcontainer.cpp index 9a7792730d..7c5ab6112c 100644 --- a/gui/widgets/scrollcontainer.cpp +++ b/gui/widgets/scrollcontainer.cpp @@ -144,6 +144,12 @@ void ScrollContainerWidget::drawWidget() { g_gui.theme()->drawDialogBackgroundClip(Common::Rect(_x, _y, _x + _w, _y + getHeight() - 1), getBossClipRect(), ThemeEngine::kDialogBackgroundDefault); } +bool ScrollContainerWidget::containsWidget(Widget *w) const { + if (w == _verticalScroll || _verticalScroll->containsWidget(w)) + return true; + return containsWidgetInChain(_firstWidget, w); +} + Widget *ScrollContainerWidget::findWidget(int x, int y) { if (_verticalScroll->isVisible() && x >= _w - _verticalScroll->getWidth()) return _verticalScroll; diff --git a/gui/widgets/scrollcontainer.h b/gui/widgets/scrollcontainer.h index c2d47370ee..9366a0b658 100644 --- a/gui/widgets/scrollcontainer.h +++ b/gui/widgets/scrollcontainer.h @@ -46,6 +46,8 @@ public: virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void reflowLayout(); + virtual bool containsWidget(Widget *) const; + protected: // We overload getChildY to make sure child widgets are positioned correctly. // Essentially this compensates for the space taken up by the tab title header. diff --git a/gui/widgets/tab.cpp b/gui/widgets/tab.cpp index 9bf9527c4f..e2e3e72db0 100644 --- a/gui/widgets/tab.cpp +++ b/gui/widgets/tab.cpp @@ -334,6 +334,13 @@ void TabWidget::draw() { } } +bool TabWidget::containsWidget(Widget *w) const { + if (w == _navLeft || w == _navRight || _navLeft->containsWidget(w) || _navRight->containsWidget(w)) + return true; + return containsWidgetInChain(_firstWidget, w); +} + + Widget *TabWidget::findWidget(int x, int y) { if (y < _tabHeight) { if (_navButtonsVisible) { diff --git a/gui/widgets/tab.h b/gui/widgets/tab.h index a1a5e06481..fe5e4d82bc 100644 --- a/gui/widgets/tab.h +++ b/gui/widgets/tab.h @@ -107,6 +107,8 @@ public: virtual int getFirstVisible() const; virtual void setFirstVisible(int tabID, bool adjustIfRoom = false); + virtual bool containsWidget(Widget *) const; + virtual void reflowLayout(); virtual void draw(); |