From a38c924ff32081f5cd67c2b0e2d5ca61f0e99de2 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 23 Nov 2007 16:01:17 +0000 Subject: [PATCH] Support loading Buttons from datafiles Support repeated borders in Graphic Fix coordinate handling in Root Use the HOVER state in Button --- source/button.cpp | 28 ++++++++++++++- source/button.h | 9 +++++ source/graphic.cpp | 86 +++++++++++++++++++++++++++------------------- source/graphic.h | 5 +++ source/panel.cpp | 6 ++-- source/root.cpp | 9 +++++ source/root.h | 1 + source/state.cpp | 8 ++--- 8 files changed, 110 insertions(+), 42 deletions(-) diff --git a/source/button.cpp b/source/button.cpp index 2c8bedb..543782e 100644 --- a/source/button.cpp +++ b/source/button.cpp @@ -26,12 +26,26 @@ void Button::button_release(int x, int y, unsigned btn) { if(btn==1) { - state=NORMAL; if(geom.is_inside(x, y)) + { signal_clicked.emit(); + state=HOVER; + } + else + state=NORMAL; } } +void Button::pointer_enter() +{ + state=HOVER; +} + +void Button::pointer_leave() +{ + state=NORMAL; +} + void Button::render_part(const Part &part) const { if(part.get_name()=="text") @@ -40,5 +54,17 @@ void Button::render_part(const Part &part) const Widget::render_part(part); } + +Button::Loader::Loader(Button &btn): + Widget::Loader(btn) +{ + add("text", &Button::text); +} + +Button &Button::Loader::get_object() const +{ + return static_cast