]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/button.cpp
Add protected functions for manipulating widget state
[libs/gltk.git] / source / button.cpp
index 5095379364b5c7a883d1d4fe615ec4d90655444a..5f9b18bfdf3290a830d4bc392b126d0be3649a19 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007-2011  Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <msp/gl/immediate.h>
 #include "button.h"
 #include "part.h"
@@ -51,6 +44,7 @@ void Button::autosize()
 void Button::set_text(const std::string &t)
 {
        text = t;
+       signal_autosize_changed.emit();
 }
 
 void Button::set_icon(const GL::Texture2D *i)
@@ -91,7 +85,7 @@ void Button::button_press(int, int, unsigned btn)
        if(btn==1)
        {
                pressed = true;
-               state |= ACTIVE;
+               set_state(ACTIVE);
        }
 }
 
@@ -99,7 +93,7 @@ void Button::button_release(int x, int y, unsigned btn)
 {
        if(pressed && btn==1)
        {
-               state &= ~ACTIVE;
+               clear_state(ACTIVE);
                pressed = false;
 
                if(geom.is_inside_relative(x, y))
@@ -112,9 +106,9 @@ void Button::pointer_motion(int x, int y)
        if(pressed)
        {
                if(!geom.is_inside_relative(x, y))
-                       state &= ~ACTIVE;
+                       clear_state(ACTIVE);
                else
-                       state |= ACTIVE;
+                       set_state(ACTIVE);
        }
 }