From 2e3bb9608ef4c74a8ba9c101ba24b68285405090 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 16 Oct 2013 15:09:25 +0300 Subject: [PATCH] Make the DISABLED state actually do something --- source/container.cpp | 8 +++++++- source/widget.cpp | 5 +++++ source/widget.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/source/container.cpp b/source/container.cpp index e8b666d..a806ccd 100644 --- a/source/container.cpp +++ b/source/container.cpp @@ -188,7 +188,13 @@ Widget *Container::get_pointer_target(int x, int y) else if(click_focus) return click_focus; else - return get_child_at(x, y); + { + Widget *child = get_child_at(x, y); + if(child && child->is_enabled()) + return child; + else + return 0; + } } void Container::pointer_leave() diff --git a/source/widget.cpp b/source/widget.cpp index a9c233b..59105b9 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -172,6 +172,11 @@ void Widget::set_focus() signal_request_focus.emit(); } +void Widget::set_enabled(bool e) +{ + set_state(DISABLED, (e ? NORMAL : DISABLED)); +} + void Widget::set_state(State mask, State bits) { state = (state&~mask)|bits; diff --git a/source/widget.h b/source/widget.h index 7c601d2..6cb3d06 100644 --- a/source/widget.h +++ b/source/widget.h @@ -107,6 +107,8 @@ public: void set_focusable(bool); bool is_focusable() const { return focusable; } void set_focus(); + void set_enabled(bool); + bool is_enabled() const { return !(state&DISABLED); } protected: void set_state(State s) { set_state(s, s); } -- 2.43.0