set_text(t);
}
-void Toggle::autosize()
+void Toggle::autosize_special(const Part &part, Geometry &ageom)
{
- if(!style)
- return;
-
- Widget::autosize();
-
- if(const Part *text_part = style->get_part("text"))
- {
- const Sides &margin = text_part->get_margin();
- geom.w = max(geom.w, text.get_width()+margin.left+margin.right);
- geom.h = max(geom.h, text.get_height()+margin.top+margin.bottom);
- }
-
- rebuild();
+ if(part.get_name()=="text")
+ text.autosize(part, ageom);
}
void Toggle::set_text(const string &t)
void Toggle::set_value(bool v)
{
+ bool old_value = value;
+
value = v;
if(value)
{
}
else
clear_state(ACTIVE);
+
+ if(value!=old_value)
+ signal_toggled.emit(value);
}
-void Toggle::rebuild_special(const Part &part, CachedPart &cache)
+void Toggle::rebuild_special(const Part &part)
{
if(part.get_name()=="text")
- text.build(part, geom, cache);
+ text.build(part, geom, part_cache);
}
void Toggle::button_press(int, int, unsigned btn)
if(pressed && btn==1)
{
if(geom.is_inside_relative(x, y) && (!value || !exclusive))
- {
set_value(!value);
- signal_toggled.emit(value);
- }
pressed = false;
}