]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/button.cpp
Rework how widget ownership works in Container
[libs/gltk.git] / source / button.cpp
index 86b73c9daa0c3f8ba9a689ebf628f102667c97f7..0dd20c7a6abb841cd4d2f9e98d1b75030d912d98 100644 (file)
@@ -8,11 +8,9 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-Button::Button(const std::string &t):
-       text(),
-       icon(0),
-       pressed(false)
+Button::Button(const std::string &t)
 {
+       input_type = INPUT_NAVIGATION;
        set_text(t);
 }
 
@@ -32,13 +30,13 @@ void Button::set_text(const std::string &t)
 {
        text = t;
        signal_autosize_changed.emit();
-       rebuild();
+       mark_rebuild();
 }
 
 void Button::set_icon(const GL::Texture2D *i)
 {
        icon = i;
-       rebuild();
+       mark_rebuild();
 }
 
 void Button::rebuild_special(const Part &part)
@@ -102,6 +100,16 @@ void Button::pointer_motion(int x, int y)
        }
 }
 
+bool Button::navigate(Navigation nav)
+{
+       if(nav==NAV_ACTIVATE)
+               signal_clicked.emit();
+       else
+               return false;
+
+       return true;
+}
+
 void Button::on_style_change()
 {
        text.set_style(style);