Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename raise() to move_to_front() #60108

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions doc/classes/CanvasItem.xml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,13 @@
Transformations issued by [param event]'s inputs are applied in local space instead of global space.
</description>
</method>
<method name="move_to_front">
<return type="void" />
<description>
Moves this node to display on top of its siblings. This has more use in [Control], as [Node2D] can be ordered with [member Node2D.z_index].
Internally, the node is moved to the bottom of parent's children list. The method has no effect on nodes without a parent.
</description>
</method>
<method name="queue_redraw">
<return type="void" />
<description>
Expand Down
6 changes: 0 additions & 6 deletions doc/classes/Node.xml
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,6 @@
Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to [method Object.free]. Use [method Object.is_queued_for_deletion] to check whether a node will be deleted at the end of the frame.
</description>
</method>
<method name="raise">
<return type="void" />
<description>
Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs ([Control] nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using [code]raise[/code], a Control will be drawn on top of its siblings.
</description>
</method>
<method name="remove_and_skip">
<return type="void" />
<description>
Expand Down
8 changes: 4 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,7 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor, bool p_config_changed
singleton->main_editor_button_vb->add_child(tb);
singleton->editor_table.push_back(p_editor);

singleton->distraction_free->raise();
singleton->distraction_free->move_to_front();
}
singleton->editor_data.add_editor_plugin(p_editor);
singleton->add_child(p_editor);
Expand Down Expand Up @@ -4965,7 +4965,7 @@ void EditorNode::_load_docks_from_config(Ref<ConfigFile> p_layout, const String
}

if (atidx == i) {
node->raise();
node->move_to_front();
continue;
}

Expand Down Expand Up @@ -5390,7 +5390,7 @@ Button *EditorNode::add_bottom_panel_item(String p_text, Control *p_item) {
tb->set_toggle_mode(true);
tb->set_focus_mode(Control::FOCUS_NONE);
bottom_panel_vb->add_child(p_item);
bottom_panel_hb->raise();
bottom_panel_hb->move_to_front();
bottom_panel_hb_editors->add_child(tb);
p_item->set_v_size_flags(Control::SIZE_EXPAND_FILL);
p_item->hide();
Expand Down Expand Up @@ -5424,7 +5424,7 @@ void EditorNode::make_bottom_panel_item_visible(Control *p_item) {
void EditorNode::raise_bottom_panel_item(Control *p_item) {
for (int i = 0; i < bottom_panel_items.size(); i++) {
if (bottom_panel_items[i].control == p_item) {
bottom_panel_items[i].button->raise();
bottom_panel_items[i].button->move_to_front();
SWAP(bottom_panel_items.write[i], bottom_panel_items.write[bottom_panel_items.size() - 1]);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/asset_library_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void EditorAssetLibrary::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_READY: {
add_theme_style_override("panel", get_theme_stylebox(SNAME("bg"), SNAME("AssetLib")));
error_label->raise();
error_label->move_to_front();
} break;

case NOTIFICATION_ENTER_TREE:
Expand Down
2 changes: 1 addition & 1 deletion editor/progress_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void ProgressDialog::add_task(const String &p_task, const String &p_label, int p
} else {
cancel_hb->hide();
}
cancel_hb->raise();
cancel_hb->move_to_front();
cancelled = false;
_popup();
if (p_can_cancel) {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/color_picker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ void ColorPicker::_screen_pick_pressed() {
} else {
screen->show();
}
screen->raise();
screen->move_to_front();
#ifndef _MSC_VER
#warning show modal no longer works, needs to be converted to a popup
#endif
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/graph_edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ void GraphEdit::_graph_node_raised(Node *p_gn) {
if (gn->is_comment()) {
move_child(gn, 0);
} else {
gn->raise();
gn->move_to_front();
}
}

Expand Down
8 changes: 8 additions & 0 deletions scene/main/canvas_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ void CanvasItem::queue_redraw() {
MessageQueue::get_singleton()->push_callable(callable_mp(this, &CanvasItem::_redraw_callback));
}

void CanvasItem::move_to_front() {
if (!get_parent()) {
return;
}
get_parent()->move_child(this, get_parent()->get_child_count() - 1);
}

void CanvasItem::set_modulate(const Color &p_modulate) {
if (modulate == p_modulate) {
return;
Expand Down Expand Up @@ -897,6 +904,7 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("hide"), &CanvasItem::hide);

ClassDB::bind_method(D_METHOD("queue_redraw"), &CanvasItem::queue_redraw);
ClassDB::bind_method(D_METHOD("move_to_front"), &CanvasItem::move_to_front);

ClassDB::bind_method(D_METHOD("set_as_top_level", "enable"), &CanvasItem::set_as_top_level);
ClassDB::bind_method(D_METHOD("is_set_as_top_level"), &CanvasItem::is_set_as_top_level);
Expand Down
1 change: 1 addition & 0 deletions scene/main/canvas_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class CanvasItem : public Node {
void hide();

void queue_redraw();
void move_to_front();

void set_clip_children(bool p_enabled);
bool is_clipping_children() const;
Expand Down
16 changes: 0 additions & 16 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,21 +389,6 @@ void Node::_move_child(Node *p_child, int p_pos, bool p_ignore_end) {
data.blocked--;
}

void Node::raise() {
if (!data.parent) {
return;
}

// Internal children move within a different index range.
if (_is_internal_front()) {
data.parent->move_child(this, data.parent->data.internal_children_front - 1);
} else if (_is_internal_back()) {
data.parent->move_child(this, data.parent->data.internal_children_back - 1);
} else {
data.parent->move_child(this, data.parent->get_child_count(false) - 1);
}
}

void Node::_propagate_groups_dirty() {
for (const KeyValue<StringName, GroupData> &E : data.grouped) {
if (E.value.group) {
Expand Down Expand Up @@ -2816,7 +2801,6 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_in_group", "group"), &Node::is_in_group);
ClassDB::bind_method(D_METHOD("move_child", "child_node", "to_position"), &Node::move_child);
ClassDB::bind_method(D_METHOD("get_groups"), &Node::_get_groups);
ClassDB::bind_method(D_METHOD("raise"), &Node::raise);
ClassDB::bind_method(D_METHOD("set_owner", "owner"), &Node::set_owner);
ClassDB::bind_method(D_METHOD("get_owner"), &Node::get_owner);
ClassDB::bind_method(D_METHOD("remove_and_skip"), &Node::remove_and_skip);
Expand Down
1 change: 0 additions & 1 deletion scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ class Node : public Object {

void move_child(Node *p_child, int p_pos);
void _move_child(Node *p_child, int p_pos, bool p_ignore_end = false);
void raise();

void set_owner(Node *p_owner);
Node *get_owner() const;
Expand Down
2 changes: 1 addition & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2103,7 +2103,7 @@ void Viewport::_gui_set_drag_preview(Control *p_base, Control *p_control) {
p_control->set_as_top_level(true);
p_control->set_position(gui.last_mouse_pos);
p_base->get_root_parent_control()->add_child(p_control); // Add as child of viewport.
p_control->raise();
p_control->move_to_front();

gui.drag_preview_id = p_control->get_instance_id();
}
Expand Down