properly fixed notificaitons for theme changed, closes #5774

This commit is contained in:
Juan Linietsky 2016-07-18 16:41:28 -03:00
parent 4f9dea3aed
commit f10bd217a2
3 changed files with 42 additions and 3 deletions

View file

@ -1865,7 +1865,7 @@ void Control::_modal_stack_remove() {
}
void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) {
void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner,bool p_assign) {
Control *c = p_at->cast_to<Control>();
@ -1884,15 +1884,30 @@ void Control::_propagate_theme_changed(CanvasItem *p_at,Control *p_owner) {
if (c) {
c->data.theme_owner=p_owner;
if (p_assign) {
c->data.theme_owner=p_owner;
}
c->_notification(NOTIFICATION_THEME_CHANGED);
c->update();
}
}
void Control::_theme_changed() {
_propagate_theme_changed(this,this,false);
}
void Control::set_theme(const Ref<Theme>& p_theme) {
if (data.theme==p_theme)
return;
if (data.theme.is_valid()) {
data.theme->disconnect("changed",this,"_theme_changed");
}
data.theme=p_theme;
if (!p_theme.is_null()) {
@ -1909,6 +1924,9 @@ void Control::set_theme(const Ref<Theme>& p_theme) {
}
if (data.theme.is_valid()) {
data.theme->connect("changed",this,"_theme_changed");
}
}
@ -2448,6 +2466,10 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("minimum_size_changed"), &Control::minimum_size_changed);
ObjectTypeDB::bind_method(_MD("_theme_changed"), &Control::_theme_changed);
ObjectTypeDB::bind_method(_MD("_font_changed"), &Control::_font_changed);
BIND_VMETHOD(MethodInfo("_input_event",PropertyInfo(Variant::INPUT_EVENT,"event")));

View file

@ -172,7 +172,9 @@ private:
float _get_range(int p_idx) const;
float _s2a(float p_val, AnchorType p_anchor,float p_range) const;
float _a2s(float p_val, AnchorType p_anchor,float p_range) const;
void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner);
void _propagate_theme_changed(CanvasItem *p_at, Control *p_owner, bool p_assign=true);
void _theme_changed();
void _change_notify_margins();
void _update_minimum_size();

View file

@ -219,7 +219,22 @@ Ref<Theme> Theme::get_default() {
void Theme::set_default_theme_font( const Ref<Font>& p_default_font ) {
if (default_theme_font==p_default_font)
return;
if (default_theme_font.is_valid()) {
_unref_font(default_theme_font);
}
default_theme_font=p_default_font;
if (default_theme_font.is_valid()) {
_ref_font(default_theme_font);
}
_change_notify();
emit_changed();;
}
Ref<Font> Theme::get_default_theme_font() const {