+void Widget::update_style()
+{
+ Widget *top;
+ for(top=this; top->parent; top=top->parent) ;
+ Root *root = dynamic_cast<Root *>(top);
+ if(!root)
+ style = nullptr;
+ else
+ {
+ string sname = get_class();
+ if(!style_name.empty())
+ {
+ sname += '-';
+ sname += style_name;
+ }
+
+ style = &root->get_resources().get<Style>(sname);
+ }
+
+ on_style_change();
+ signal_autosize_changed.emit();
+ mark_rebuild();
+}
+
+void Widget::set_tooltip(const string &t)
+{
+ tooltip = t;
+}
+
+void Widget::set_visible(bool v)
+{
+ if(v==visible)
+ return;
+
+ visible = v;
+
+ signal_visibility_changed.emit(visible);
+}
+
+void Widget::set_focus()
+{
+ if(!parent)
+ throw hierarchy_error("no parent");
+ if(!visible)
+ throw logic_error("!visible");
+
+ signal_request_focus.emit();
+}
+
+void Widget::set_enabled(bool e)
+{
+ set_state(DISABLED, (e ? NORMAL : DISABLED));
+}
+
+void Widget::set_state(State mask, State bits)
+{
+ State old_state = state;
+ state = (state&~mask)|bits;
+ if(style && style->compare_states(old_state, state))
+ mark_rebuild();
+}
+
+void Widget::set_animation_interval(const Time::TimeDelta &iv)
+{
+ if(iv<Time::zero)
+ throw invalid_argument("Widget::set_animation_interval");
+
+ anim_interval = iv;
+ signal_request_animation.emit(anim_interval);
+}
+
+void Widget::stop_animation()
+{
+ set_animation_interval(Time::zero);
+}
+
+void Widget::mark_rebuild()
+{
+ if(rebuild_needed)
+ return;
+
+ rebuild_needed = true;
+ signal_rebuild_needed.emit();
+}
+
+void Widget::rebuild_hierarchy()
+{
+ if(rebuild_needed)
+ {
+ rebuild_needed = false;
+ rebuild();
+ }
+}
+
+void Widget::rebuild()