summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-09-20 17:53:22 +0300
committerAndrei Karas <akaras@inbox.ru>2016-09-20 18:49:07 +0300
commit775d6f983a18457b82747ac6c53123f84629ede5 (patch)
tree7a13a11156825d7186fa2305caf07854893adf0a /src/gui
parent0cc66ba20aa01f5319fcea108abdca5916c5c61b (diff)
downloadmv-775d6f983a18457b82747ac6c53123f84629ede5.tar.gz
mv-775d6f983a18457b82747ac6c53123f84629ede5.tar.bz2
mv-775d6f983a18457b82747ac6c53123f84629ede5.tar.xz
mv-775d6f983a18457b82747ac6c53123f84629ede5.zip
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.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp5
-rw-r--r--src/gui/widgets/label.cpp1
-rw-r--r--src/gui/widgets/tabbedarea.h6
-rw-r--r--src/gui/widgets/tabs/debugwindowtabs.h2
-rw-r--r--src/gui/widgets/widget.cpp3
-rw-r--r--src/gui/widgets/widget.h8
-rw-r--r--src/gui/windows/debugwindow.cpp3
7 files changed, 25 insertions, 3 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 8f643282b..17c3558ae 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -1230,6 +1230,7 @@ Widget* Gui::getWidgetAt(const int x, const int y) const
// If the widget's parent has no child then we have found the widget..
Widget* parent = mTop;
Widget* child = mTop;
+ Widget* selectable = mTop;
while (child)
{
@@ -1238,9 +1239,11 @@ Widget* Gui::getWidgetAt(const int x, const int y) const
parent->getAbsolutePosition(parentX, parentY);
child = parent->getWidgetAt(x - parentX, y - parentY);
parent = swap;
+ if (parent && parent->isSelectable())
+ selectable = parent;
}
- return parent;
+ return selectable;
}
Widget* Gui::getMouseEventSource(const int x, const int y) const
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 <std::pair<Tab*, Widget*> > 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.
*/
diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp
index 3c0c60b0f..2c9a5c3f6 100644
--- a/src/gui/windows/debugwindow.cpp
+++ b/src/gui/windows/debugwindow.cpp
@@ -57,6 +57,9 @@ DebugWindow::DebugWindow() :
setDefaultSize(400, 300, ImagePosition::CENTER);
+ mTabs->setSelectable(false);
+ mTabs->getWidgetContainer()->setSelectable(false);
+ mTabs->getTabContainer()->setSelectable(false);
// TRANSLATORS: debug window tab
mTabs->addTab(std::string(_("Map")), mMapWidget);
// TRANSLATORS: debug window tab