From 775d6f983a18457b82747ac6c53123f84629ede5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 20 Sep 2016 17:53:22 +0300 Subject: Add support for unselectable widgets. If move mouse over or try to select, this widget will be ignored. Set labels unselectable by default. Set unselectable tabs in debug window. --- src/gui/widgets/label.cpp | 1 + src/gui/widgets/tabbedarea.h | 6 ++++++ src/gui/widgets/tabs/debugwindowtabs.h | 2 +- src/gui/widgets/widget.cpp | 3 ++- src/gui/widgets/widget.h | 8 ++++++++ 5 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src/gui/widgets') diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index af6fa973d..6df442229 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -139,6 +139,7 @@ void Label::init() mPadding = mSkin->getPadding(); else mPadding = 0; + setSelectable(false); } void Label::draw(Graphics *const graphics) diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 3a34fc6a6..840dd84c6 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -237,6 +237,12 @@ class TabbedArea final : public ActionListener, void selectPrevTab(); + Widget *getTabContainer() const + { return mTabContainer; } + + Widget *getWidgetContainer() const + { return mWidgetContainer; } + private: typedef std::vector > TabContainer; diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h index 43292bcd5..044a2884c 100644 --- a/src/gui/widgets/tabs/debugwindowtabs.h +++ b/src/gui/widgets/tabs/debugwindowtabs.h @@ -44,7 +44,7 @@ class DebugTab notfinal : public Container protected: explicit DebugTab(const Widget2 *const widget) : Container(widget) - { } + { setSelectable(false); } }; class MapDebugTab final : public DebugTab diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index 986d97d99..4b4600dd6 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -105,7 +105,8 @@ Widget::Widget(const Widget2 *const widget) : mEnabled(true), mAllowLogic(true), mMouseConsume(true), - mRedraw(true) + mRedraw(true), + mSelectable(true) { mAllWidgets.push_back(this); mAllWidgetsSet.insert(this); diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 6556cc385..4cae7369e 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -1023,6 +1023,12 @@ class Widget notfinal : public Widget2 void setRedraw(const bool b) noexcept2 { mRedraw = b; } + bool isSelectable() const noexcept2 A_WARN_UNUSED + { return mSelectable; } + + void setSelectable(const bool selectable) + { mSelectable = selectable; } + static void distributeWindowResizeEvent(); void windowResized(); @@ -1246,6 +1252,8 @@ class Widget notfinal : public Widget2 bool mRedraw; + bool mSelectable; + /** * Holds the global font used by the widget. */ -- cgit v1.2.3-60-g2f50