mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-25 13:17:22 +01:00
Fix theme propagation for children of top level controls
This commit is contained in:
parent
3b84a64a36
commit
eed219ada1
@ -493,53 +493,45 @@ void Control::_notification(int p_notification) {
|
|||||||
case NOTIFICATION_ENTER_CANVAS: {
|
case NOTIFICATION_ENTER_CANVAS: {
|
||||||
data.parent = Object::cast_to<Control>(get_parent());
|
data.parent = Object::cast_to<Control>(get_parent());
|
||||||
|
|
||||||
|
if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
|
||||||
|
data.theme_owner = data.parent->data.theme_owner;
|
||||||
|
notification(NOTIFICATION_THEME_CHANGED);
|
||||||
|
}
|
||||||
|
|
||||||
if (is_set_as_toplevel()) {
|
if (is_set_as_toplevel()) {
|
||||||
data.SI = get_viewport()->_gui_add_subwindow_control(this);
|
data.SI = get_viewport()->_gui_add_subwindow_control(this);
|
||||||
|
|
||||||
if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) {
|
|
||||||
data.theme_owner = data.parent->data.theme_owner;
|
|
||||||
notification(NOTIFICATION_THEME_CHANGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Node *parent = this; //meh
|
Node *parent = get_parent();
|
||||||
Control *parent_control = nullptr;
|
bool is_subwindow = false;
|
||||||
bool subwindow = false;
|
bool has_parent_control = false;
|
||||||
|
|
||||||
while (parent) {
|
while (parent) {
|
||||||
parent = parent->get_parent();
|
|
||||||
|
|
||||||
if (!parent) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
|
CanvasItem *ci = Object::cast_to<CanvasItem>(parent);
|
||||||
if (ci && ci->is_set_as_toplevel()) {
|
if (ci && ci->is_set_as_toplevel()) {
|
||||||
subwindow = true;
|
is_subwindow = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent_control = Object::cast_to<Control>(parent);
|
Control *parent_control = Object::cast_to<Control>(parent);
|
||||||
|
|
||||||
if (parent_control) {
|
if (parent_control) {
|
||||||
|
has_parent_control = true;
|
||||||
break;
|
break;
|
||||||
} else if (ci) {
|
} else if (ci) {
|
||||||
|
// Continue.
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent = parent->get_parent();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent_control) {
|
if (has_parent_control) {
|
||||||
//do nothing, has a parent control
|
// Do nothing, has a parent control.
|
||||||
if (data.theme.is_null() && parent_control->data.theme_owner) {
|
} else if (is_subwindow) {
|
||||||
data.theme_owner = parent_control->data.theme_owner;
|
// Is a subwindow (process input before other controls for that canvas).
|
||||||
notification(NOTIFICATION_THEME_CHANGED);
|
|
||||||
}
|
|
||||||
} else if (subwindow) {
|
|
||||||
//is a subwindow (process input before other controls for that canvas)
|
|
||||||
data.SI = get_viewport()->_gui_add_subwindow_control(this);
|
data.SI = get_viewport()->_gui_add_subwindow_control(this);
|
||||||
} else {
|
} else {
|
||||||
//is a regular root control
|
// Is a regular root control.
|
||||||
Viewport *viewport = get_viewport();
|
Viewport *viewport = get_viewport();
|
||||||
ERR_FAIL_COND(!viewport);
|
ERR_FAIL_COND(!viewport);
|
||||||
data.RI = viewport->_gui_add_root_control(this);
|
data.RI = viewport->_gui_add_root_control(this);
|
||||||
@ -550,7 +542,7 @@ void Control::_notification(int p_notification) {
|
|||||||
if (data.parent_canvas_item) {
|
if (data.parent_canvas_item) {
|
||||||
data.parent_canvas_item->connect("item_rect_changed", this, "_size_changed");
|
data.parent_canvas_item->connect("item_rect_changed", this, "_size_changed");
|
||||||
} else {
|
} else {
|
||||||
//connect viewport
|
// Connect viewport.
|
||||||
Viewport *viewport = get_viewport();
|
Viewport *viewport = get_viewport();
|
||||||
ERR_FAIL_COND(!viewport);
|
ERR_FAIL_COND(!viewport);
|
||||||
viewport->connect("size_changed", this, "_size_changed");
|
viewport->connect("size_changed", this, "_size_changed");
|
||||||
|
Loading…
Reference in New Issue
Block a user