diff options
| author | Juan Linietsky | 2016-07-18 16:41:28 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-07-18 16:41:59 -0300 |
| commit | f10bd217a26487f097bc4609c02302126d36ae41 (patch) | |
| tree | afc02337035501e3cdf1f073cec5bddc747d0362 /scene/gui/control.cpp | |
| parent | 4f9dea3aed8a0a15df6dfde65fc5f2bd5e8a0b06 (diff) | |
| download | godot-f10bd217a26487f097bc4609c02302126d36ae41.tar.gz godot-f10bd217a26487f097bc4609c02302126d36ae41.tar.zst godot-f10bd217a26487f097bc4609c02302126d36ae41.zip | |
properly fixed notificaitons for theme changed, closes #5774
Diffstat (limited to 'scene/gui/control.cpp')
| -rw-r--r-- | scene/gui/control.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index fc27c0d24..c176e50ce 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -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"))); |
