3 This file is part of libmspgltk
4 Copyright © 2007, 2009 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
8 #include <msp/gl/immediate.h>
15 Button::Button(const Resources &r, const std::string &t):
24 void Button::set_text(const std::string &t)
29 void Button::set_icon(const GL::Texture2D *i)
34 void Button::button_press(int, int, unsigned btn)
43 void Button::button_release(int x, int y, unsigned btn)
50 if(geom.is_inside_relative(x, y))
51 signal_clicked.emit();
55 void Button::pointer_motion(int x, int y)
59 if(!geom.is_inside_relative(x, y))
66 void Button::render_special(const Part &part) const
68 if(part.get_name()=="text")
69 render_text(part, text);
70 if(part.get_name()=="icon" && icon)
73 rgeom.w=icon->get_width();
74 rgeom.h=icon->get_height();
75 part.get_alignment().apply(rgeom, geom, part.get_margin());
78 GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2));
79 imm.color(1.0f, 1.0f, 1.0f);
82 imm.vertex(rgeom.x, rgeom.y);
84 imm.vertex(rgeom.x+rgeom.w, rgeom.y);
86 imm.vertex(rgeom.x+rgeom.w, rgeom.y+rgeom.h);
88 imm.vertex(rgeom.x, rgeom.y+rgeom.h);
90 GL::Texture::unbind();
95 Button::Loader::Loader(Button &btn):
98 add("text", &Button::text);
101 Button &Button::Loader::get_object() const
103 return static_cast<Button &>(wdg);