Button::Button(const Resources &r, const std::string &t):
Widget(r),
- text(style),
+ text(),
icon(0),
pressed(false)
{
void Button::set_text(const std::string &t)
{
- text=t;
+ text = t;
}
void Button::set_icon(const GL::Texture2D *i)
{
- icon=i;
+ icon = i;
}
void Button::button_press(int, int, unsigned btn)
{
if(btn==1)
{
- pressed=true;
- state|=ACTIVE;
+ pressed = true;
+ state |= ACTIVE;
}
}
{
if(pressed && btn==1)
{
- state&=~ACTIVE;
- pressed=false;
+ state &= ~ACTIVE;
+ pressed = false;
if(geom.is_inside_relative(x, y))
signal_clicked.emit();
if(pressed)
{
if(!geom.is_inside_relative(x, y))
- state&=~ACTIVE;
+ state &= ~ACTIVE;
else
- state|=ACTIVE;
+ state |= ACTIVE;
}
}
if(part.get_name()=="icon" && icon)
{
Geometry rgeom;
- rgeom.w=icon->get_width();
- rgeom.h=icon->get_height();
+ rgeom.w = icon->get_width();
+ rgeom.h = icon->get_height();
part.get_alignment().apply(rgeom, geom, part.get_margin());
icon->bind();
}
}
+void Button::on_style_change()
+{
+ text.set_style(style);
+}
+
Button::Loader::Loader(Button &btn):
Widget::Loader(btn)
void Button::Loader::text(const std::string &t)
{
- static_cast<Button &>(wdg).text=t;
+ static_cast<Button &>(wdg).text = t;
}
} // namespace GLtk