]> git.tdb.fi Git - libs/gltk.git/commitdiff
Make the DISABLED state actually do something
authorMikko Rasa <tdb@tdb.fi>
Wed, 16 Oct 2013 12:09:25 +0000 (15:09 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 16 Oct 2013 15:55:16 +0000 (18:55 +0300)
source/container.cpp
source/widget.cpp
source/widget.h

index e8b666d67344e854cedf0d948fe6f38d2874eab8..a806ccd3ce6cd3cecb9cb02f0b8eb9d8051f81dd 100644 (file)
@@ -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()
index a9c233b5d8c370a0ece166c00bc81a8fb1b1f0ff..59105b949b3e09d027b6c9a78ed34e228f764aa2 100644 (file)
@@ -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;
index 7c601d2b5860668b426e3b8466ef316ab92fb2c3..6cb3d0654362f60142e4d083561291879713a7c8 100644 (file)
@@ -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); }