From f54bd48a884e4e3c95818f042a4b2418a6e070a4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 7 Oct 2008 17:14:27 +0000 Subject: working button click --- src/ui/button.cc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/ui/button.cc') diff --git a/src/ui/button.cc b/src/ui/button.cc index 73a349e..0910995 100644 --- a/src/ui/button.cc +++ b/src/ui/button.cc @@ -4,9 +4,11 @@ the terms of the GNU General Public License version 2 */ -#include "ui/button.h" #include "auxiliary/functions.h" +#include "render/primitives.h" #include "sys/sys.h" +#include "ui/button.h" +#include "core/commandbuffer.h" namespace ui { @@ -44,6 +46,33 @@ void Button::draw() Label::draw(); } +void Button::draw_text() +{ + if (!text().size()) + return; + + if (palette()) { + if (has_focus()) + render::gl::color(palette()->highlight()); + else + render::gl::color(palette()->foreground()); + } + + render::primitives::text_centered(global_location(), size(), text()); +} + +void Button::event_keypress(unsigned int key, unsigned int modifier) +{ + +} + +void Button::event_keyrelease(unsigned int key, unsigned int modifier) +{ + if (key == 512 + SDL_BUTTON_LEFT) { + core::cmd() << button_command << std::endl; + } +} + } -- cgit v1.2.3