mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 13:21:10 +01:00
Ported from godot 4: Remove NOTIFICATION_MOVED_IN_PARENT
* This notification makes node children management very inefficient.
* Replaced by a NOTIFICATION_CHILDREN_CHANGED (and children_changed signal).
* Changed Canvas code (and similar) to use the above signal, to perform more efficiently.
This PR breaks compatibility (although this notification was very rarely used, even within the engine), but provides an alternate way to do the same.
It is required for the changes in #75627 to be entirely effective.
- reduz
Note that I removed NOTIFICATION_MOVED_IN_PARENT, as keeping it, but making it just not work is worse in my opinion.
104392ef4e
This commit is contained in:
parent
7d2667830d
commit
32e9927ac8
@ -31,10 +31,10 @@
|
||||
#ifndef HASH_SET_H
|
||||
#define HASH_SET_H
|
||||
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/os/memory.h"
|
||||
#include "core/containers/hash_map.h"
|
||||
#include "core/containers/hashfuncs.h"
|
||||
#include "core/math/math_funcs.h"
|
||||
#include "core/os/memory.h"
|
||||
|
||||
/**
|
||||
* Implementation of Set using a bidi indexed hash map.
|
||||
@ -343,6 +343,36 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ const TKey &key() const {
|
||||
return keys[index];
|
||||
}
|
||||
_FORCE_INLINE_ const TKey *key_ptr() const {
|
||||
return &keys[index];
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ Iterator &next() {
|
||||
index++;
|
||||
if (index >= (int32_t)num_keys) {
|
||||
index = -1;
|
||||
keys = nullptr;
|
||||
num_keys = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_FORCE_INLINE_ Iterator &prev() {
|
||||
index--;
|
||||
if (index < 0) {
|
||||
index = -1;
|
||||
keys = nullptr;
|
||||
num_keys = 0;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool valid() const {
|
||||
return keys != nullptr;
|
||||
}
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const Iterator &b) const { return keys == b.keys && index == b.index; }
|
||||
_FORCE_INLINE_ bool operator!=(const Iterator &b) const { return keys != b.keys || index != b.index; }
|
||||
|
||||
|
@ -826,6 +826,11 @@
|
||||
When this signal is received, the child [code]node[/code] is still in the tree and valid. This signal is emitted [i]after[/i] the child node's own [signal tree_exiting] and [constant NOTIFICATION_EXIT_TREE].
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="child_order_changed">
|
||||
<description>
|
||||
Emitted when the list of children is changed. This happens when child nodes are added, moved or removed.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="ready">
|
||||
<description>
|
||||
Emitted when the node is ready.
|
||||
@ -863,8 +868,8 @@
|
||||
Notification received when the node is about to exit a [SceneTree].
|
||||
This notification is emitted [i]after[/i] the related [signal tree_exiting].
|
||||
</constant>
|
||||
<constant name="NOTIFICATION_MOVED_IN_PARENT" value="12">
|
||||
Notification received when the node is moved in the parent.
|
||||
<constant name="NOTIFICATION_CHILD_ORDER_CHANGED" value="12">
|
||||
Notification received when the list of children is changed. This happens when child nodes are added, moved or removed.
|
||||
</constant>
|
||||
<constant name="NOTIFICATION_READY" value="13">
|
||||
Notification received when the node is ready. See [method _ready].
|
||||
|
@ -33,11 +33,12 @@
|
||||
#include "../resources/skeleton_modification_2d.h"
|
||||
#include "../resources/skeleton_modification_stack_2d.h"
|
||||
#include "core/config/engine.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/editor_data.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/plugins/canvas_item_editor_plugin.h"
|
||||
#include "editor/editor_data.h"
|
||||
#endif //TOOLS_ENABLED
|
||||
|
||||
bool Bone2D::_set(const StringName &p_path, const Variant &p_value) {
|
||||
@ -118,6 +119,7 @@ void Bone2D::_notification(int p_what) {
|
||||
bone.bone = this;
|
||||
skeleton->bones.push_back(bone);
|
||||
skeleton->_make_bone_setup_dirty();
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, skeleton, "_make_bone_setup_dirty", varray(), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
|
||||
cache_transform = get_transform();
|
||||
@ -154,14 +156,6 @@ void Bone2D::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
} else if (p_what == NOTIFICATION_MOVED_IN_PARENT) {
|
||||
if (skeleton) {
|
||||
skeleton->_make_bone_setup_dirty();
|
||||
}
|
||||
|
||||
if (copy_transform_to_cache) {
|
||||
cache_transform = get_transform();
|
||||
}
|
||||
} else if (p_what == NOTIFICATION_EXIT_TREE) {
|
||||
if (skeleton) {
|
||||
for (int i = 0; i < skeleton->bones.size(); i++) {
|
||||
@ -171,6 +165,7 @@ void Bone2D::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
skeleton->_make_bone_setup_dirty();
|
||||
get_parent()->disconnect(SceneStringNames::get_singleton()->child_order_changed, skeleton, "_make_bone_setup_dirty");
|
||||
skeleton = nullptr;
|
||||
}
|
||||
parent_bone = nullptr;
|
||||
@ -801,6 +796,8 @@ void Skeleton2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_bone_local_pose_override", "bone_idx", "override_pose", "strength", "persistent"), &Skeleton2D::set_bone_local_pose_override);
|
||||
ClassDB::bind_method(D_METHOD("get_bone_local_pose_override", "bone_idx"), &Skeleton2D::get_bone_local_pose_override);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_make_bone_setup_dirty"), &Skeleton2D::_make_bone_setup_dirty);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("bone_setup_changed"));
|
||||
}
|
||||
|
||||
|
@ -29,17 +29,17 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "canvas_item.h"
|
||||
#include "core/input/input.h"
|
||||
#include "core/object/message_queue.h"
|
||||
#include "core/object/method_bind_ext.gen.inc"
|
||||
#include "core/input/input.h"
|
||||
#include "core/version.h"
|
||||
#include "scene/main/canvas_layer.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/resources/font.h"
|
||||
#include "scene/resources/style_box.h"
|
||||
#include "scene/resources/texture.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "scene/resources/world_2d.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "servers/rendering/rendering_server_raster.h"
|
||||
#include "servers/rendering_server.h"
|
||||
@ -509,6 +509,10 @@ void CanvasItem::_toplevel_raise_self() {
|
||||
}
|
||||
|
||||
void CanvasItem::_enter_canvas() {
|
||||
if (get_parent()) {
|
||||
get_viewport()->canvas_parent_mark_dirty(get_parent());
|
||||
}
|
||||
|
||||
if ((!Object::cast_to<CanvasItem>(get_parent())) || toplevel) {
|
||||
Node *n = this;
|
||||
|
||||
@ -543,13 +547,10 @@ void CanvasItem::_enter_canvas() {
|
||||
get_world()->gui_reset_canvas_sort_index();
|
||||
}
|
||||
|
||||
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, canvas_group, "_toplevel_raise_self");
|
||||
|
||||
} else {
|
||||
CanvasItem *parent = get_parent_item();
|
||||
canvas_layer = parent->canvas_layer;
|
||||
RenderingServer::get_singleton()->canvas_item_set_parent(canvas_item, parent->get_canvas_item());
|
||||
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
|
||||
}
|
||||
|
||||
pending_update = false;
|
||||
@ -585,20 +586,10 @@ void CanvasItem::_notification(int p_what) {
|
||||
if (!block_transform_notify && !xform_change.in_list()) {
|
||||
get_tree()->xform_change_list.add(&xform_change);
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_MOVED_IN_PARENT: {
|
||||
if (!is_inside_tree()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (canvas_group != "") {
|
||||
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, canvas_group, "_toplevel_raise_self");
|
||||
} else {
|
||||
CanvasItem *p = get_parent_item();
|
||||
ERR_FAIL_COND(!p);
|
||||
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
|
||||
if (get_viewport()) {
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->canvas_parent_mark_dirty, varray(get_parent()), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
if (xform_change.in_list()) {
|
||||
@ -610,6 +601,10 @@ void CanvasItem::_notification(int p_what) {
|
||||
C = nullptr;
|
||||
}
|
||||
global_invalid = true;
|
||||
|
||||
if (get_viewport()) {
|
||||
get_parent()->disconnect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->canvas_parent_mark_dirty);
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_DRAW:
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
@ -620,6 +615,20 @@ void CanvasItem::_notification(int p_what) {
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItem::update_draw_order() {
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canvas_group.empty()) {
|
||||
get_tree()->call_group_flags(SceneTree::GROUP_CALL_UNIQUE, canvas_group, "_toplevel_raise_self");
|
||||
} else {
|
||||
CanvasItem *p = get_parent_item();
|
||||
ERR_FAIL_COND(!p);
|
||||
RenderingServer::get_singleton()->canvas_item_set_draw_index(canvas_item, get_index());
|
||||
}
|
||||
}
|
||||
|
||||
void CanvasItem::update() {
|
||||
if (!is_inside_tree()) {
|
||||
return;
|
||||
|
@ -284,6 +284,8 @@ public:
|
||||
virtual Transform2D _edit_get_transform() const;
|
||||
#endif
|
||||
|
||||
void update_draw_order();
|
||||
|
||||
/* VISIBILITY */
|
||||
|
||||
void set_visible(bool p_visible);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "core/object/message_queue.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "servers/rendering_server.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
@ -379,9 +380,14 @@ Point2 Node2D::to_global(Point2 p_local) const {
|
||||
|
||||
void Node2D::_notification(int p_notification) {
|
||||
switch (p_notification) {
|
||||
case NOTIFICATION_MOVED_IN_PARENT: {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
if (get_viewport()) {
|
||||
get_viewport()->gui_set_root_order_dirty();
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->gui_set_root_order_dirty, varray(), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
if (get_viewport()) {
|
||||
get_parent()->disconnect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->gui_set_root_order_dirty);
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
@ -546,6 +546,8 @@ void Control::_notification(int p_notification) {
|
||||
Viewport *viewport = get_viewport();
|
||||
ERR_FAIL_COND(!viewport);
|
||||
data.RI = viewport->_gui_add_root_control(this);
|
||||
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->gui_set_root_order_dirty, varray(), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
|
||||
data.parent_canvas_item = get_parent_item();
|
||||
@ -584,6 +586,7 @@ void Control::_notification(int p_notification) {
|
||||
if (data.RI) {
|
||||
get_viewport()->_gui_remove_root_control(data.RI);
|
||||
data.RI = nullptr;
|
||||
get_parent()->disconnect(SceneStringNames::get_singleton()->child_order_changed, get_viewport(), SceneStringNames::get_singleton()->gui_set_root_order_dirty);
|
||||
}
|
||||
|
||||
data.parent = nullptr;
|
||||
@ -596,20 +599,14 @@ void Control::_notification(int p_notification) {
|
||||
*/
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_MOVED_IN_PARENT: {
|
||||
case NOTIFICATION_CHILD_ORDER_CHANGED: {
|
||||
// some parents need to know the order of the children to draw (like TabContainer)
|
||||
// update if necessary
|
||||
if (data.parent) {
|
||||
data.parent->update();
|
||||
}
|
||||
update();
|
||||
|
||||
if (data.SI) {
|
||||
if (data.SI && get_viewport()) {
|
||||
get_viewport()->_gui_set_subwindow_order_dirty();
|
||||
}
|
||||
if (data.RI) {
|
||||
get_viewport()->gui_set_root_order_dirty();
|
||||
}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_RESIZED: {
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "canvas_layer.h"
|
||||
#include "scene/2d/canvas_item.h"
|
||||
#include "scene/resources/world_2d.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "viewport.h"
|
||||
|
||||
void CanvasLayer::set_layer(int p_xform) {
|
||||
@ -184,26 +185,32 @@ void CanvasLayer::_notification(int p_what) {
|
||||
viewport = vp->get_viewport_rid();
|
||||
|
||||
RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
|
||||
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
|
||||
RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
|
||||
_update_follow_viewport();
|
||||
|
||||
if (vp) {
|
||||
get_parent()->connect(SceneStringNames::get_singleton()->child_order_changed, vp, SceneStringNames::get_singleton()->canvas_parent_mark_dirty, varray(get_parent()), CONNECT_REFERENCE_COUNTED);
|
||||
vp->canvas_parent_mark_dirty(get_parent());
|
||||
}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
ERR_FAIL_NULL_MSG(vp, "Viewport is not initialized.");
|
||||
|
||||
get_parent()->disconnect(SceneStringNames::get_singleton()->child_order_changed, vp, SceneStringNames::get_singleton()->canvas_parent_mark_dirty);
|
||||
|
||||
vp->_canvas_layer_remove(this);
|
||||
RenderingServer::get_singleton()->viewport_remove_canvas(viewport, canvas);
|
||||
viewport = RID();
|
||||
_update_follow_viewport(false);
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_MOVED_IN_PARENT: {
|
||||
if (is_inside_tree()) {
|
||||
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} break;
|
||||
void CanvasLayer::update_draw_order() {
|
||||
if (is_inside_tree()) {
|
||||
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,8 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void update_draw_order();
|
||||
|
||||
void set_layer(int p_xform);
|
||||
int get_layer() const;
|
||||
|
||||
|
@ -38,8 +38,8 @@
|
||||
#include "scene/animation/scene_tree_tween.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "scene/scene_string_names.h"
|
||||
#include "world.h"
|
||||
#include "viewport.h"
|
||||
#include "world.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/object/class_db.h"
|
||||
@ -450,9 +450,8 @@ void Node::move_child(Node *p_child, int p_pos) {
|
||||
}
|
||||
// notification second
|
||||
move_child_notify(p_child);
|
||||
for (int i = motion_from; i <= motion_to; i++) {
|
||||
data.children[i]->notification(NOTIFICATION_MOVED_IN_PARENT);
|
||||
}
|
||||
notification(NOTIFICATION_CHILD_ORDER_CHANGED);
|
||||
emit_signal(SceneStringNames::get_singleton()->child_order_changed);
|
||||
|
||||
p_child->_propagate_groups_dirty();
|
||||
|
||||
@ -1484,6 +1483,8 @@ void Node::_add_child_nocheck(Node *p_child, const StringName &p_name) {
|
||||
//recognize children created in this node constructor
|
||||
p_child->data.parent_owned = data.in_constructor;
|
||||
add_child_notify(p_child);
|
||||
notification(NOTIFICATION_CHILD_ORDER_CHANGED);
|
||||
emit_signal(SceneStringNames::get_singleton()->child_order_changed);
|
||||
|
||||
// Allow physics interpolated nodes to automatically reset when added to the tree
|
||||
// (this is to save the user doing this manually each time)
|
||||
@ -1562,9 +1563,11 @@ void Node::remove_child(Node *p_child) {
|
||||
|
||||
for (int i = idx; i < child_count; i++) {
|
||||
children[i]->data.pos = i;
|
||||
children[i]->notification(NOTIFICATION_MOVED_IN_PARENT);
|
||||
}
|
||||
|
||||
notification(NOTIFICATION_CHILD_ORDER_CHANGED);
|
||||
emit_signal(SceneStringNames::get_singleton()->child_order_changed);
|
||||
|
||||
p_child->data.parent = nullptr;
|
||||
p_child->data.pos = -1;
|
||||
|
||||
@ -3363,7 +3366,7 @@ void Node::_bind_methods() {
|
||||
|
||||
BIND_CONSTANT(NOTIFICATION_ENTER_TREE);
|
||||
BIND_CONSTANT(NOTIFICATION_EXIT_TREE);
|
||||
BIND_CONSTANT(NOTIFICATION_MOVED_IN_PARENT);
|
||||
BIND_CONSTANT(NOTIFICATION_CHILD_ORDER_CHANGED);
|
||||
BIND_CONSTANT(NOTIFICATION_READY);
|
||||
BIND_CONSTANT(NOTIFICATION_PAUSED);
|
||||
BIND_CONSTANT(NOTIFICATION_UNPAUSED);
|
||||
@ -3418,6 +3421,7 @@ void Node::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("tree_exited"));
|
||||
ADD_SIGNAL(MethodInfo("child_entered_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node")));
|
||||
ADD_SIGNAL(MethodInfo("child_exiting_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node")));
|
||||
ADD_SIGNAL(MethodInfo("child_order_changed"));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "pause_mode", PROPERTY_HINT_ENUM, "Inherit,Stop,Process"), "set_pause_mode", "get_pause_mode");
|
||||
|
||||
|
@ -279,7 +279,7 @@ public:
|
||||
// you can make your own, but don't use the same numbers as other notifications in other nodes
|
||||
NOTIFICATION_ENTER_TREE = 10,
|
||||
NOTIFICATION_EXIT_TREE = 11,
|
||||
NOTIFICATION_MOVED_IN_PARENT = 12,
|
||||
NOTIFICATION_CHILD_ORDER_CHANGED = 12,
|
||||
NOTIFICATION_READY = 13,
|
||||
NOTIFICATION_PAUSED = 14,
|
||||
NOTIFICATION_UNPAUSED = 15,
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "core/core_string_names.h"
|
||||
#include "core/input/input.h"
|
||||
#include "core/input/shortcut.h"
|
||||
#include "core/object/message_queue.h"
|
||||
#include "core/os/os.h"
|
||||
#include "scene/2d/camera_2d.h"
|
||||
#include "scene/2d/collision_object_2d.h"
|
||||
@ -735,6 +736,14 @@ Rect2 Viewport::get_visible_rect() const {
|
||||
return r;
|
||||
}
|
||||
|
||||
void Viewport::canvas_parent_mark_dirty(Node *p_node) {
|
||||
bool request_update = gui.canvas_parents_with_dirty_order.is_empty();
|
||||
gui.canvas_parents_with_dirty_order.insert(p_node->get_instance_id());
|
||||
if (request_update) {
|
||||
MessageQueue::get_singleton()->push_call(this, SceneStringNames::get_singleton()->_process_dirty_canvas_parent_orders);
|
||||
}
|
||||
}
|
||||
|
||||
Size2 Viewport::get_size() const {
|
||||
return size;
|
||||
}
|
||||
@ -3207,10 +3216,15 @@ void Viewport::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_handle_input_locally", "enable"), &Viewport::set_handle_input_locally);
|
||||
ClassDB::bind_method(D_METHOD("is_handling_input_locally"), &Viewport::is_handling_input_locally);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("gui_set_root_order_dirty"), &Viewport::gui_set_root_order_dirty);
|
||||
ClassDB::bind_method(D_METHOD("canvas_parent_mark_dirty", "node"), &Viewport::canvas_parent_mark_dirty);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_subwindow_visibility_changed"), &Viewport::_subwindow_visibility_changed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_process_picking", "ignore_paused"), &Viewport::_process_picking);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_process_dirty_canvas_parent_orders"), &Viewport::_process_dirty_canvas_parent_orders);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_override_stretch"), "set_size_override_stretch", "is_size_override_stretch_enabled");
|
||||
|
||||
@ -3301,6 +3315,33 @@ void Viewport::_subwindow_visibility_changed() {
|
||||
gui.subwindow_visibility_dirty = true;
|
||||
}
|
||||
|
||||
void Viewport::_process_dirty_canvas_parent_orders() {
|
||||
for (HashSet<ObjectID>::Iterator iter = gui.canvas_parents_with_dirty_order.begin(); iter.valid(); iter.next()) {
|
||||
const ObjectID &id = iter.key();
|
||||
|
||||
Object *obj = ObjectDB::get_instance(id);
|
||||
if (!obj) {
|
||||
continue; // May have been deleted.
|
||||
}
|
||||
|
||||
Node *n = Object::cast_to<Node>(obj);
|
||||
for (int i = 0; i < n->get_child_count(); i++) {
|
||||
Node *c = n->get_child(i);
|
||||
CanvasItem *ci = Object::cast_to<CanvasItem>(c);
|
||||
if (ci) {
|
||||
ci->update_draw_order();
|
||||
continue;
|
||||
}
|
||||
CanvasLayer *cl = Object::cast_to<CanvasLayer>(c);
|
||||
if (cl) {
|
||||
cl->update_draw_order();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui.canvas_parents_with_dirty_order.clear();
|
||||
}
|
||||
|
||||
Viewport::Viewport() {
|
||||
viewport = RID_PRIME(RenderingServer::get_singleton()->viewport_create());
|
||||
texture_rid = RenderingServer::get_singleton()->viewport_get_texture(viewport);
|
||||
|
@ -31,6 +31,7 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/containers/hash_set.h"
|
||||
#include "core/math/transform_2d.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/texture.h"
|
||||
@ -297,6 +298,8 @@ public:
|
||||
bool gui_is_dragging() const;
|
||||
bool gui_is_drag_successful() const;
|
||||
|
||||
void canvas_parent_mark_dirty(Node *p_node);
|
||||
|
||||
Viewport();
|
||||
~Viewport();
|
||||
|
||||
@ -477,6 +480,7 @@ private:
|
||||
List<Control *> all_known_subwindows;
|
||||
bool roots_order_dirty;
|
||||
List<Control *> roots;
|
||||
HashSet<ObjectID> canvas_parents_with_dirty_order;
|
||||
int canvas_sort_index; //for sorting items with canvas as root
|
||||
bool dragging;
|
||||
bool drag_successful;
|
||||
@ -568,6 +572,8 @@ private:
|
||||
void _drop_physics_mouseover(bool p_paused_only = false);
|
||||
|
||||
void _update_canvas_items(Node *p_node);
|
||||
|
||||
void _process_dirty_canvas_parent_orders();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(Viewport::UpdateMode);
|
||||
|
@ -94,6 +94,10 @@ SceneStringNames::SceneStringNames() {
|
||||
iteration = StaticCString::create("iteration");
|
||||
update = StaticCString::create("update");
|
||||
updated = StaticCString::create("updated");
|
||||
child_order_changed = StaticCString::create("child_order_changed");
|
||||
canvas_parent_mark_dirty = StaticCString::create("canvas_parent_mark_dirty");
|
||||
gui_set_root_order_dirty = StaticCString::create("gui_set_root_order_dirty");
|
||||
_process_dirty_canvas_parent_orders = StaticCString::create("_process_dirty_canvas_parent_orders");
|
||||
|
||||
_physics_process = StaticCString::create("_physics_process");
|
||||
_process = StaticCString::create("_process");
|
||||
|
@ -79,6 +79,10 @@ public:
|
||||
StringName iteration;
|
||||
StringName update;
|
||||
StringName updated;
|
||||
StringName child_order_changed;
|
||||
StringName canvas_parent_mark_dirty;
|
||||
StringName gui_set_root_order_dirty;
|
||||
StringName _process_dirty_canvas_parent_orders;
|
||||
|
||||
StringName line_separation;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user