summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/Tree.xml30
-rw-r--r--doc/classes/TreeItem.xml4
-rw-r--r--editor/action_map_editor.cpp10
-rw-r--r--editor/action_map_editor.h2
-rw-r--r--editor/animation_track_editor.cpp2
-rw-r--r--editor/connections_dialog.cpp8
-rw-r--r--editor/connections_dialog.h2
-rw-r--r--editor/debugger/editor_debugger_tree.cpp8
-rw-r--r--editor/debugger/editor_debugger_tree.h2
-rw-r--r--editor/debugger/script_editor_debugger.cpp16
-rw-r--r--editor/debugger/script_editor_debugger.h4
-rw-r--r--editor/dependency_editor.cpp14
-rw-r--r--editor/dependency_editor.h4
-rw-r--r--editor/editor_audio_buses.cpp8
-rw-r--r--editor/editor_audio_buses.h2
-rw-r--r--editor/editor_autoload_settings.cpp7
-rw-r--r--editor/editor_autoload_settings.h2
-rw-r--r--editor/editor_plugin_settings.cpp7
-rw-r--r--editor/editor_plugin_settings.h2
-rw-r--r--editor/editor_settings_dialog.cpp7
-rw-r--r--editor/editor_settings_dialog.h2
-rw-r--r--editor/export_template_manager.cpp7
-rw-r--r--editor/export_template_manager.h2
-rw-r--r--editor/filesystem_dock.cpp14
-rw-r--r--editor/filesystem_dock.h4
-rw-r--r--editor/groups_editor.cpp16
-rw-r--r--editor/groups_editor.h4
-rw-r--r--editor/import/dynamic_font_import_settings.cpp32
-rw-r--r--editor/import/dynamic_font_import_settings.h8
-rw-r--r--editor/import/scene_import_settings.cpp8
-rw-r--r--editor/import/scene_import_settings.h2
-rw-r--r--editor/localization_editor.cpp32
-rw-r--r--editor/localization_editor.h8
-rw-r--r--editor/plugins/animation_library_editor.cpp16
-rw-r--r--editor/plugins/animation_player_editor_plugin.cpp169
-rw-r--r--editor/plugins/animation_player_editor_plugin.h1
-rw-r--r--editor/plugins/replication_editor_plugin.cpp8
-rw-r--r--editor/plugins/replication_editor_plugin.h2
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.cpp8
-rw-r--r--editor/plugins/resource_preloader_editor_plugin.h2
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.cpp4
-rw-r--r--editor/plugins/skeleton_3d_editor_plugin.h2
-rw-r--r--editor/plugins/theme_editor_plugin.cpp16
-rw-r--r--editor/plugins/theme_editor_plugin.h4
-rw-r--r--editor/scene_tree_editor.cpp24
-rw-r--r--editor/scene_tree_editor.h5
-rw-r--r--modules/visual_script/editor/visual_script_editor.cpp16
-rw-r--r--modules/visual_script/editor/visual_script_editor.h4
-rw-r--r--scene/animation/animation_player.cpp18
-rw-r--r--scene/gui/option_button.cpp2
-rw-r--r--scene/gui/tree.cpp196
-rw-r--r--scene/gui/tree.h10
-rw-r--r--scene/resources/animation_library.cpp6
53 files changed, 551 insertions, 242 deletions
diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml
index 1d4a5b922d..6ae85ad242 100644
--- a/doc/classes/Tree.xml
+++ b/doc/classes/Tree.xml
@@ -353,10 +353,11 @@
</member>
</members>
<signals>
- <signal name="button_pressed">
+ <signal name="button_clicked">
<argument index="0" name="item" type="TreeItem" />
<argument index="1" name="column" type="int" />
<argument index="2" name="id" type="int" />
+ <argument index="3" name="mouse_button_index" type="int" />
<description>
Emitted when a button on the tree was pressed (see [method TreeItem.add_button]).
</description>
@@ -379,22 +380,23 @@
Emitted when a column's title is pressed.
</description>
</signal>
- <signal name="custom_popup_edited">
- <argument index="0" name="arrow_clicked" type="bool" />
+ <signal name="custom_item_clicked">
+ <argument index="0" name="mouse_button_index" type="int" />
<description>
- Emitted when a cell with the [constant TreeItem.CELL_MODE_CUSTOM] is clicked to be edited.
+ Emitted when an item with [constant TreeItem.CELL_MODE_CUSTOM] is clicked with a mouse button.
</description>
</signal>
- <signal name="empty_rmb">
- <argument index="0" name="position" type="Vector2" />
+ <signal name="custom_popup_edited">
+ <argument index="0" name="arrow_clicked" type="bool" />
<description>
- Emitted when the right mouse button is pressed in the empty space of the tree.
+ Emitted when a cell with the [constant TreeItem.CELL_MODE_CUSTOM] is clicked to be edited.
</description>
</signal>
- <signal name="empty_tree_rmb_selected">
+ <signal name="empty_clicked">
<argument index="0" name="position" type="Vector2" />
+ <argument index="1" name="mouse_button_index" type="int" />
<description>
- Emitted when the right mouse button is pressed if right mouse button selection is active and the tree is empty.
+ Emitted when a mouse button is clicked in the empty space of the tree.
</description>
</signal>
<signal name="item_activated">
@@ -423,15 +425,11 @@
Emitted when an item is edited.
</description>
</signal>
- <signal name="item_rmb_edited">
- <description>
- Emitted when an item is edited using the right mouse button.
- </description>
- </signal>
- <signal name="item_rmb_selected">
+ <signal name="item_mouse_selected">
<argument index="0" name="position" type="Vector2" />
+ <argument index="1" name="mouse_button_index" type="int" />
<description>
- Emitted when an item is selected with the right mouse button.
+ Emitted when an item is selected with a mouse button.
</description>
</signal>
<signal name="item_selected">
diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml
index d2e29bf3b1..0a680b9627 100644
--- a/doc/classes/TreeItem.xml
+++ b/doc/classes/TreeItem.xml
@@ -687,6 +687,10 @@
<member name="disable_folding" type="bool" setter="set_disable_folding" getter="is_folding_disabled">
If [code]true[/code], folding is disabled for this TreeItem.
</member>
+ <member name="visible" type="bool" setter="set_visible" getter="is_visible">
+ If [code]true[/code], the [TreeItem] is visible (default).
+ Note that if a [TreeItem] is set to not be visible, none of its children will be visible either.
+ </member>
</members>
<constants>
<constant name="CELL_MODE_STRING" value="0" enum="TreeCellMode">
diff --git a/editor/action_map_editor.cpp b/editor/action_map_editor.cpp
index 99355de361..6333b402da 100644
--- a/editor/action_map_editor.cpp
+++ b/editor/action_map_editor.cpp
@@ -868,7 +868,11 @@ void ActionMapEditor::_action_edited() {
}
}
-void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_id) {
+void ActionMapEditor::_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
ItemButton option = (ItemButton)p_id;
TreeItem *item = Object::cast_to<TreeItem>(p_item);
@@ -926,7 +930,7 @@ void ActionMapEditor::_tree_item_activated() {
return;
}
- _tree_button_pressed(item, 2, BUTTON_EDIT_EVENT);
+ _tree_button_pressed(item, 2, BUTTON_EDIT_EVENT, MouseButton::LEFT);
}
void ActionMapEditor::set_show_builtin_actions(bool p_show) {
@@ -1249,7 +1253,7 @@ ActionMapEditor::ActionMapEditor() {
action_tree->set_column_custom_minimum_width(2, 50 * EDSCALE);
action_tree->connect("item_edited", callable_mp(this, &ActionMapEditor::_action_edited));
action_tree->connect("item_activated", callable_mp(this, &ActionMapEditor::_tree_item_activated));
- action_tree->connect("button_pressed", callable_mp(this, &ActionMapEditor::_tree_button_pressed));
+ action_tree->connect("button_clicked", callable_mp(this, &ActionMapEditor::_tree_button_pressed));
main_vbox->add_child(action_tree);
action_tree->set_drag_forwarding(this);
diff --git a/editor/action_map_editor.h b/editor/action_map_editor.h
index 15a1501a67..d8c40a97a7 100644
--- a/editor/action_map_editor.h
+++ b/editor/action_map_editor.h
@@ -182,7 +182,7 @@ private:
void _add_action(const String &p_name);
void _action_edited();
- void _tree_button_pressed(Object *p_item, int p_column, int p_id);
+ void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _tree_item_activated();
void _search_term_updated(const String &p_search_term);
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index fa4f32a351..e01e6e1811 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -2999,8 +2999,6 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
}
}
- print_line(hovering_key_idx);
-
if (hovering_key_idx != previous_hovering_key_idx) {
// Required to draw keyframe hover feedback on the correct keyframe.
update();
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 4cff0ffd3d..6ed723b891 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -864,7 +864,11 @@ void ConnectionsDock::_handle_slot_menu_option(int p_option) {
}
}
-void ConnectionsDock::_rmb_pressed(Vector2 p_position) {
+void ConnectionsDock::_rmb_pressed(Vector2 p_position, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+
TreeItem *item = tree->get_selected();
if (!item) {
@@ -1166,7 +1170,7 @@ ConnectionsDock::ConnectionsDock() {
connect_dialog->connect("connected", callable_mp(this, &ConnectionsDock::_make_or_edit_connection));
tree->connect("item_selected", callable_mp(this, &ConnectionsDock::_tree_item_selected));
tree->connect("item_activated", callable_mp(this, &ConnectionsDock::_tree_item_activated));
- tree->connect("item_rmb_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed));
+ tree->connect("item_mouse_selected", callable_mp(this, &ConnectionsDock::_rmb_pressed));
add_theme_constant_override("separation", 3 * EDSCALE);
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index 88d52c83f2..dcfde8800a 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -216,7 +216,7 @@ class ConnectionsDock : public VBoxContainer {
void _handle_signal_menu_option(int p_option);
void _handle_slot_menu_option(int p_option);
- void _rmb_pressed(Vector2 p_position);
+ void _rmb_pressed(Vector2 p_position, MouseButton p_button);
void _close();
protected:
diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp
index 3a65d015d5..023204b74a 100644
--- a/editor/debugger/editor_debugger_tree.cpp
+++ b/editor/debugger/editor_debugger_tree.cpp
@@ -57,7 +57,7 @@ void EditorDebuggerTree::_notification(int p_what) {
case NOTIFICATION_POSTINITIALIZE: {
connect("cell_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_selected));
connect("item_collapsed", callable_mp(this, &EditorDebuggerTree::_scene_tree_folded));
- connect("item_rmb_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
+ connect("item_mouse_selected", callable_mp(this, &EditorDebuggerTree::_scene_tree_rmb_selected));
} break;
}
}
@@ -100,7 +100,11 @@ void EditorDebuggerTree::_scene_tree_folded(Object *p_obj) {
}
}
-void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position) {
+void EditorDebuggerTree::_scene_tree_rmb_selected(const Vector2 &p_position, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+
TreeItem *item = get_item_at_position(p_position);
if (!item) {
return;
diff --git a/editor/debugger/editor_debugger_tree.h b/editor/debugger/editor_debugger_tree.h
index 4e38f00ffa..bba524039e 100644
--- a/editor/debugger/editor_debugger_tree.h
+++ b/editor/debugger/editor_debugger_tree.h
@@ -56,7 +56,7 @@ private:
String _get_path(TreeItem *p_item);
void _scene_tree_folded(Object *p_obj);
void _scene_tree_selected();
- void _scene_tree_rmb_selected(const Vector2 &p_position);
+ void _scene_tree_rmb_selected(const Vector2 &p_position, MouseButton p_button);
void _item_menu_id_pressed(int p_option);
void _file_selected(const String &p_file);
diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp
index 44a7aade09..60486b5286 100644
--- a/editor/debugger/script_editor_debugger.cpp
+++ b/editor/debugger/script_editor_debugger.cpp
@@ -1472,7 +1472,11 @@ void ScriptEditorDebugger::_clear_errors_list() {
clear_button->set_disabled(true);
}
-void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos) {
+void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+
breakpoints_menu->clear();
breakpoints_menu->set_size(Size2(1, 1));
@@ -1490,7 +1494,11 @@ void ScriptEditorDebugger::_breakpoints_item_rmb_selected(const Vector2 &p_pos)
}
// Right click on specific file(s) or folder(s).
-void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos) {
+void ScriptEditorDebugger::_error_tree_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+
item_menu->clear();
item_menu->reset_size();
@@ -1780,7 +1788,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
breakpoints_tree->set_allow_reselect(true);
breakpoints_tree->set_allow_rmb_select(true);
breakpoints_tree->set_hide_root(true);
- breakpoints_tree->connect("item_rmb_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected));
+ breakpoints_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_breakpoints_item_rmb_selected));
breakpoints_tree->create_item();
parent_sc->add_child(breakpoints_tree);
@@ -1835,7 +1843,7 @@ ScriptEditorDebugger::ScriptEditorDebugger() {
error_tree->set_hide_root(true);
error_tree->set_v_size_flags(SIZE_EXPAND_FILL);
error_tree->set_allow_rmb_select(true);
- error_tree->connect("item_rmb_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected));
+ error_tree->connect("item_mouse_selected", callable_mp(this, &ScriptEditorDebugger::_error_tree_item_rmb_selected));
errors_tab->add_child(error_tree);
item_menu = memnew(PopupMenu);
diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h
index d445fe48d1..aa0a50ff03 100644
--- a/editor/debugger/script_editor_debugger.h
+++ b/editor/debugger/script_editor_debugger.h
@@ -201,8 +201,8 @@ private:
void _clear_errors_list();
- void _breakpoints_item_rmb_selected(const Vector2 &p_pos);
- void _error_tree_item_rmb_selected(const Vector2 &p_pos);
+ void _breakpoints_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button);
+ void _error_tree_item_rmb_selected(const Vector2 &p_pos, MouseButton p_button);
void _item_menu_id_pressed(int p_option);
void _tab_changed(int p_tab);
diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp
index 5b5e0203a3..7b73a392b4 100644
--- a/editor/dependency_editor.cpp
+++ b/editor/dependency_editor.cpp
@@ -49,7 +49,10 @@ void DependencyEditor::_searched(const String &p_path) {
_update_file();
}
-void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button) {
+void DependencyEditor::_load_pressed(Object *p_item, int p_cell, int p_button, MouseButton p_mouse_button) {
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
replacing = ti->get_text(1);
@@ -242,7 +245,7 @@ DependencyEditor::DependencyEditor() {
tree->set_column_clip_content(1, true);
tree->set_column_expand_ratio(1, 1);
tree->set_hide_root(true);
- tree->connect("button_pressed", callable_mp(this, &DependencyEditor::_load_pressed));
+ tree->connect("button_clicked", callable_mp(this, &DependencyEditor::_load_pressed));
HBoxContainer *hbc = memnew(HBoxContainer);
Label *label = memnew(Label(TTR("Dependencies:")));
@@ -761,7 +764,10 @@ void OrphanResourcesDialog::_delete_confirm() {
refresh();
}
-void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id) {
+void OrphanResourcesDialog::_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String path = ti->get_metadata(0);
@@ -796,5 +802,5 @@ OrphanResourcesDialog::OrphanResourcesDialog() {
files->set_column_title(1, TTR("Owns"));
files->set_hide_root(true);
vbc->add_margin_child(TTR("Resources Without Explicit Ownership:"), files, true);
- files->connect("button_pressed", callable_mp(this, &OrphanResourcesDialog::_button_pressed));
+ files->connect("button_clicked", callable_mp(this, &OrphanResourcesDialog::_button_pressed));
}
diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h
index 585143fe0a..96d82d58eb 100644
--- a/editor/dependency_editor.h
+++ b/editor/dependency_editor.h
@@ -54,7 +54,7 @@ class DependencyEditor : public AcceptDialog {
void _fix_and_find(EditorFileSystemDirectory *efsd, HashMap<String, HashMap<String, String>> &candidates);
void _searched(const String &p_path);
- void _load_pressed(Object *p_item, int p_cell, int p_button);
+ void _load_pressed(Object *p_item, int p_cell, int p_button, MouseButton p_mouse_button);
void _fix_all();
void _update_list();
@@ -166,7 +166,7 @@ class OrphanResourcesDialog : public ConfirmationDialog {
List<String> paths;
void _find_to_delete(TreeItem *p_item, List<String> &paths);
void _delete_confirm();
- void _button_pressed(Object *p_item, int p_column, int p_id);
+ void _button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void refresh();
static void _bind_methods();
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index d34bc521f1..083f7cdc6c 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -739,7 +739,11 @@ void EditorAudioBus::_delete_effect_pressed(int p_option) {
ur->commit_action();
}
-void EditorAudioBus::_effect_rmb(const Vector2 &p_pos) {
+void EditorAudioBus::_effect_rmb(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+
TreeItem *item = effects->get_selected();
if (!item) {
return;
@@ -897,7 +901,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) {
effects->connect("cell_selected", callable_mp(this, &EditorAudioBus::_effect_selected));
effects->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true);
effects->set_drag_forwarding(this);
- effects->connect("item_rmb_selected", callable_mp(this, &EditorAudioBus::_effect_rmb));
+ effects->connect("item_mouse_selected", callable_mp(this, &EditorAudioBus::_effect_rmb));
effects->set_allow_rmb_select(true);
effects->set_focus_mode(FOCUS_CLICK);
effects->set_allow_reselect(true);
diff --git a/editor/editor_audio_buses.h b/editor/editor_audio_buses.h
index 70c0712b52..436b391ccd 100644
--- a/editor/editor_audio_buses.h
+++ b/editor/editor_audio_buses.h
@@ -108,7 +108,7 @@ class EditorAudioBus : public PanelContainer {
void _effect_add(int p_which);
void _effect_selected();
void _delete_effect_pressed(int p_option);
- void _effect_rmb(const Vector2 &p_pos);
+ void _effect_rmb(const Vector2 &p_pos, MouseButton p_button);
void _update_visible_channels();
virtual Variant get_drag_data(const Point2 &p_point) override;
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index 4c73e36269..ee4955d0a0 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -280,7 +280,10 @@ void EditorAutoloadSettings::_autoload_edited() {
updating_autoload = false;
}
-void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button) {
+void EditorAutoloadSettings::_autoload_button_pressed(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
String name = "autoload/" + ti->get_text(0);
@@ -950,7 +953,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
tree->connect("cell_selected", callable_mp(this, &EditorAutoloadSettings::_autoload_selected));
tree->connect("item_edited", callable_mp(this, &EditorAutoloadSettings::_autoload_edited));
- tree->connect("button_pressed", callable_mp(this, &EditorAutoloadSettings::_autoload_button_pressed));
+ tree->connect("button_clicked", callable_mp(this, &EditorAutoloadSettings::_autoload_button_pressed));
tree->connect("item_activated", callable_mp(this, &EditorAutoloadSettings::_autoload_activated));
tree->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/editor_autoload_settings.h b/editor/editor_autoload_settings.h
index 380cadbebb..e1e0bb0a64 100644
--- a/editor/editor_autoload_settings.h
+++ b/editor/editor_autoload_settings.h
@@ -81,7 +81,7 @@ class EditorAutoloadSettings : public VBoxContainer {
void _autoload_add();
void _autoload_selected();
void _autoload_edited();
- void _autoload_button_pressed(Object *p_item, int p_column, int p_button);
+ void _autoload_button_pressed(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _autoload_activated();
void _autoload_path_text_changed(const String p_path);
void _autoload_text_submitted(const String p_name);
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 85a906ef51..3a0b875b8c 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -46,7 +46,7 @@ void EditorPluginSettings::_notification(int p_what) {
case Node::NOTIFICATION_READY: {
plugin_config_dialog->connect("plugin_ready", Callable(EditorNode::get_singleton(), "_on_plugin_ready"));
- plugin_list->connect("button_pressed", callable_mp(this, &EditorPluginSettings::_cell_button_pressed));
+ plugin_list->connect("button_clicked", callable_mp(this, &EditorPluginSettings::_cell_button_pressed));
} break;
}
}
@@ -146,7 +146,10 @@ void EditorPluginSettings::_create_clicked() {
plugin_config_dialog->popup_centered();
}
-void EditorPluginSettings::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
+void EditorPluginSettings::_cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *item = Object::cast_to<TreeItem>(p_item);
if (!item) {
return;
diff --git a/editor/editor_plugin_settings.h b/editor/editor_plugin_settings.h
index 121534b613..4903a02c4d 100644
--- a/editor/editor_plugin_settings.h
+++ b/editor/editor_plugin_settings.h
@@ -50,7 +50,7 @@ class EditorPluginSettings : public VBoxContainer {
void _plugin_activity_changed();
void _create_clicked();
- void _cell_button_pressed(Object *p_item, int p_column, int p_id);
+ void _cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
static Vector<String> _get_plugins(const String &p_dir);
diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp
index fd578bd365..712a5b150f 100644
--- a/editor/editor_settings_dialog.cpp
+++ b/editor/editor_settings_dialog.cpp
@@ -475,7 +475,10 @@ void EditorSettingsDialog::_update_shortcuts() {
}
}
-void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx) {
+void EditorSettingsDialog::_shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND_MSG(!ti, "Object passed is not a TreeItem");
@@ -748,7 +751,7 @@ EditorSettingsDialog::EditorSettingsDialog() {
shortcuts->set_column_titles_visible(true);
shortcuts->set_column_title(0, TTR("Name"));
shortcuts->set_column_title(1, TTR("Binding"));
- shortcuts->connect("button_pressed", callable_mp(this, &EditorSettingsDialog::_shortcut_button_pressed));
+ shortcuts->connect("button_clicked", callable_mp(this, &EditorSettingsDialog::_shortcut_button_pressed));
shortcuts->connect("item_activated", callable_mp(this, &EditorSettingsDialog::_shortcut_cell_double_clicked));
tab_shortcuts->add_child(shortcuts);
diff --git a/editor/editor_settings_dialog.h b/editor/editor_settings_dialog.h
index 294186a509..a1ea54c6fb 100644
--- a/editor/editor_settings_dialog.h
+++ b/editor/editor_settings_dialog.h
@@ -103,7 +103,7 @@ class EditorSettingsDialog : public AcceptDialog {
void _filter_shortcuts(const String &p_filter);
void _update_shortcuts();
- void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx);
+ void _shortcut_button_pressed(Object *p_item, int p_column, int p_idx, MouseButton p_button = MouseButton::LEFT);
void _shortcut_cell_double_clicked();
void _builtin_action_popup_index_pressed(int p_index);
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index c6d3843b06..4ca2e1fdbf 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -593,7 +593,10 @@ void ExportTemplateManager::_mirror_options_button_cbk(int p_id) {
}
}
-void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_column, int p_id) {
+void ExportTemplateManager::_installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
if (!ti) {
return;
@@ -975,7 +978,7 @@ ExportTemplateManager::ExportTemplateManager() {
installed_table->set_custom_minimum_size(Size2(0, 100) * EDSCALE);
installed_table->set_v_size_flags(Control::SIZE_EXPAND_FILL);
main_vb->add_child(installed_table);
- installed_table->connect("button_pressed", callable_mp(this, &ExportTemplateManager::_installed_table_button_cbk));
+ installed_table->connect("button_clicked", callable_mp(this, &ExportTemplateManager::_installed_table_button_cbk));
// Dialogs.
uninstall_confirm = memnew(ConfirmationDialog);
diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h
index 61df212f1f..3494e11d5e 100644
--- a/editor/export_template_manager.h
+++ b/editor/export_template_manager.h
@@ -109,7 +109,7 @@ class ExportTemplateManager : public AcceptDialog {
String _get_selected_mirror() const;
void _mirror_options_button_cbk(int p_id);
- void _installed_table_button_cbk(Object *p_item, int p_column, int p_id);
+ void _installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _open_template_folder(const String &p_version);
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 8a995eaa8f..aaff892c2a 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -2592,7 +2592,10 @@ void FileSystemDock::_file_and_folders_fill_popup(PopupMenu *p_popup, Vector<Str
}
}
-void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) {
+void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
// Right click is pressed in the tree.
Vector<String> paths = _tree_get_selected(false);
@@ -2615,7 +2618,10 @@ void FileSystemDock::_tree_rmb_select(const Vector2 &p_pos) {
}
}
-void FileSystemDock::_tree_rmb_empty(const Vector2 &p_pos) {
+void FileSystemDock::_tree_empty_click(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
// Right click is pressed in the empty space of the tree.
path = "res://";
tree_popup->clear();
@@ -3106,8 +3112,8 @@ FileSystemDock::FileSystemDock() {
tree->connect("item_activated", callable_mp(this, &FileSystemDock::_tree_activate_file));
tree->connect("multi_selected", callable_mp(this, &FileSystemDock::_tree_multi_selected));
- tree->connect("item_rmb_selected", callable_mp(this, &FileSystemDock::_tree_rmb_select));
- tree->connect("empty_rmb", callable_mp(this, &FileSystemDock::_tree_rmb_empty));
+ tree->connect("item_mouse_selected", callable_mp(this, &FileSystemDock::_tree_rmb_select));
+ tree->connect("empty_clicked", callable_mp(this, &FileSystemDock::_tree_empty_click));
tree->connect("nothing_selected", callable_mp(this, &FileSystemDock::_tree_empty_selected));
tree->connect("gui_input", callable_mp(this, &FileSystemDock::_tree_gui_input));
tree->connect("mouse_exited", callable_mp(this, &FileSystemDock::_tree_mouse_exited));
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 40e8b1b7c8..f20c0b2f76 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -258,10 +258,10 @@ private:
void _file_sort_popup(int p_id);
void _file_and_folders_fill_popup(PopupMenu *p_popup, Vector<String> p_paths, bool p_display_path_dependent_options = true);
- void _tree_rmb_select(const Vector2 &p_pos);
- void _tree_rmb_empty(const Vector2 &p_pos);
+ void _tree_rmb_select(const Vector2 &p_pos, MouseButton p_button);
void _file_list_item_clicked(int p_item, const Vector2 &p_pos, MouseButton p_mouse_button_index);
void _file_list_empty_clicked(const Vector2 &p_pos, MouseButton p_mouse_button_index);
+ void _tree_empty_click(const Vector2 &p_pos, MouseButton p_button);
void _tree_empty_selected();
struct FileInfo {
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 37d535aed2..bbf9b11be3 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -303,7 +303,11 @@ void GroupDialog::_load_groups(Node *p_current) {
}
}
-void GroupDialog::_modify_group_pressed(Object *p_item, int p_column, int p_id) {
+void GroupDialog::_modify_group_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
if (!ti) {
return;
@@ -453,7 +457,7 @@ GroupDialog::GroupDialog() {
groups->set_v_size_flags(Control::SIZE_EXPAND_FILL);
groups->add_theme_constant_override("draw_guides", 1);
groups->connect("item_selected", callable_mp(this, &GroupDialog::_group_selected));
- groups->connect("button_pressed", callable_mp(this, &GroupDialog::_modify_group_pressed));
+ groups->connect("button_clicked", callable_mp(this, &GroupDialog::_modify_group_pressed));
groups->connect("item_edited", callable_mp(this, &GroupDialog::_group_renamed));
HBoxContainer *chbc = memnew(HBoxContainer);
@@ -600,7 +604,11 @@ void GroupsEditor::_add_group(const String &p_group) {
undo_redo->commit_action();
}
-void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id) {
+void GroupsEditor::_modify_group(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
if (!node) {
return;
}
@@ -735,7 +743,7 @@ GroupsEditor::GroupsEditor() {
tree->set_hide_root(true);
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
vbc->add_child(tree);
- tree->connect("button_pressed", callable_mp(this, &GroupsEditor::_modify_group));
+ tree->connect("button_clicked", callable_mp(this, &GroupsEditor::_modify_group));
tree->add_theme_constant_override("draw_guides", 1);
add_theme_constant_override("separation", 3 * EDSCALE);
diff --git a/editor/groups_editor.h b/editor/groups_editor.h
index b6a6204013..75cbfd01a4 100644
--- a/editor/groups_editor.h
+++ b/editor/groups_editor.h
@@ -84,7 +84,7 @@ class GroupDialog : public AcceptDialog {
void _rename_group_item(const String &p_old_name, const String &p_new_name);
void _add_group(String p_name);
- void _modify_group_pressed(Object *p_item, int p_column, int p_id);
+ void _modify_group_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _delete_group_item(const String &p_name);
bool _can_edit(Node *p_node, String p_group);
@@ -123,7 +123,7 @@ class GroupsEditor : public VBoxContainer {
void update_tree();
void _add_group(const String &p_group = "");
- void _modify_group(Object *p_item, int p_column, int p_id);
+ void _modify_group(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _group_name_changed(const String &p_new_text);
void _show_group_dialog();
diff --git a/editor/import/dynamic_font_import_settings.cpp b/editor/import/dynamic_font_import_settings.cpp
index 815366b279..e546f01205 100644
--- a/editor/import/dynamic_font_import_settings.cpp
+++ b/editor/import/dynamic_font_import_settings.cpp
@@ -547,7 +547,11 @@ void DynamicFontImportSettings::_variation_selected() {
}
}
-void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *vars_item = (TreeItem *)p_item;
ERR_FAIL_NULL(vars_item);
@@ -832,7 +836,11 @@ void DynamicFontImportSettings::_lang_add_item(const String &p_locale) {
lang_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
}
-void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_lang_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *lang_item = (TreeItem *)p_item;
ERR_FAIL_NULL(lang_item);
@@ -864,7 +872,11 @@ void DynamicFontImportSettings::_ot_add_item(int p_option) {
ot_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
}
-void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_ot_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ot_item = (TreeItem *)p_item;
ERR_FAIL_NULL(ot_item);
@@ -891,7 +903,11 @@ void DynamicFontImportSettings::_script_add_item(int p_option) {
script_item->set_button_color(2, 0, Color(1, 1, 1, 0.75));
}
-void DynamicFontImportSettings::_script_remove(Object *p_item, int p_column, int p_id) {
+void DynamicFontImportSettings::_script_remove(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *script_item = (TreeItem *)p_item;
ERR_FAIL_NULL(script_item);
@@ -1487,7 +1503,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
vars_list->set_column_expand(1, false);
vars_list->set_column_custom_minimum_width(1, 50 * EDSCALE);
vars_list->connect("item_selected", callable_mp(this, &DynamicFontImportSettings::_variation_selected));
- vars_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_variation_remove));
+ vars_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_variation_remove));
vars_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
inspector_vars = memnew(EditorInspector);
@@ -1639,7 +1655,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
lang_list->set_column_custom_minimum_width(1, 80 * EDSCALE);
lang_list->set_column_expand(2, false);
lang_list->set_column_custom_minimum_width(2, 50 * EDSCALE);
- lang_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_lang_remove));
+ lang_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_lang_remove));
lang_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *hb_script = memnew(HBoxContainer);
@@ -1667,7 +1683,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
script_list->set_column_custom_minimum_width(1, 80 * EDSCALE);
script_list->set_column_expand(2, false);
script_list->set_column_custom_minimum_width(2, 50 * EDSCALE);
- script_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_script_remove));
+ script_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_script_remove));
script_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
HBoxContainer *hb_ot = memnew(HBoxContainer);
@@ -1695,7 +1711,7 @@ DynamicFontImportSettings::DynamicFontImportSettings() {
ot_list->set_column_custom_minimum_width(1, 80 * EDSCALE);
ot_list->set_column_expand(2, false);
ot_list->set_column_custom_minimum_width(2, 50 * EDSCALE);
- ot_list->connect("button_pressed", callable_mp(this, &DynamicFontImportSettings::_ot_remove));
+ ot_list->connect("button_clicked", callable_mp(this, &DynamicFontImportSettings::_ot_remove));
ot_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
// Common
diff --git a/editor/import/dynamic_font_import_settings.h b/editor/import/dynamic_font_import_settings.h
index 154f347b77..ba75c98057 100644
--- a/editor/import/dynamic_font_import_settings.h
+++ b/editor/import/dynamic_font_import_settings.h
@@ -91,7 +91,7 @@ class DynamicFontImportSettings : public ConfirmationDialog {
void _variation_add();
void _variation_selected();
- void _variation_remove(Object *p_item, int p_column, int p_id);
+ void _variation_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _variation_changed(const String &p_edited_property);
void _variations_validate();
@@ -145,15 +145,15 @@ class DynamicFontImportSettings : public ConfirmationDialog {
void _lang_add();
void _lang_add_item(const String &p_locale);
- void _lang_remove(Object *p_item, int p_column, int p_id);
+ void _lang_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _script_add();
void _script_add_item(int p_option);
- void _script_remove(Object *p_item, int p_column, int p_id);
+ void _script_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _ot_add();
void _ot_add_item(int p_option);
- void _ot_remove(Object *p_item, int p_column, int p_id);
+ void _ot_remove(Object *p_item, int p_column, int p_id, MouseButton p_button);
// Common
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index 3c68477564..83dff30dfa 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -969,7 +969,11 @@ void SceneImportSettings::_save_path_changed(const String &p_path) {
}
}
-void SceneImportSettings::_browse_save_callback(Object *p_item, int p_column, int p_id) {
+void SceneImportSettings::_browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
String path = item->get_text(1);
@@ -1331,7 +1335,7 @@ SceneImportSettings::SceneImportSettings() {
add_child(external_paths);
external_path_tree = memnew(Tree);
external_paths->add_child(external_path_tree);
- external_path_tree->connect("button_pressed", callable_mp(this, &SceneImportSettings::_browse_save_callback));
+ external_path_tree->connect("button_clicked", callable_mp(this, &SceneImportSettings::_browse_save_callback));
external_paths->connect("confirmed", callable_mp(this, &SceneImportSettings::_save_dir_confirm));
external_path_tree->set_columns(3);
external_path_tree->set_column_titles_visible(true);
diff --git a/editor/import/scene_import_settings.h b/editor/import/scene_import_settings.h
index a4008582ce..81d13166ab 100644
--- a/editor/import/scene_import_settings.h
+++ b/editor/import/scene_import_settings.h
@@ -182,7 +182,7 @@ class SceneImportSettings : public ConfirmationDialog {
TreeItem *save_path_item = nullptr;
void _save_path_changed(const String &p_path);
- void _browse_save_callback(Object *p_item, int p_column, int p_id);
+ void _browse_save_callback(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _save_dir_confirm();
Dictionary base_subresource_settings;
diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp
index c31c3f4519..0325f4bd5c 100644
--- a/editor/localization_editor.cpp
+++ b/editor/localization_editor.cpp
@@ -42,8 +42,8 @@
void LocalizationEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
- translation_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_delete));
- translation_pot_list->connect("button_pressed", callable_mp(this, &LocalizationEditor::_pot_delete));
+ translation_list->connect("button_clicked", callable_mp(this, &LocalizationEditor::_translation_delete));
+ translation_pot_list->connect("button_clicked", callable_mp(this, &LocalizationEditor::_pot_delete));
List<String> tfn;
ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
@@ -93,7 +93,11 @@ void LocalizationEditor::_translation_file_open() {
translation_file_open->popup_file_dialog();
}
-void LocalizationEditor::_translation_delete(Object *p_item, int p_column, int p_button) {
+void LocalizationEditor::_translation_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
@@ -239,11 +243,15 @@ void LocalizationEditor::_translation_res_option_changed() {
updating_translations = false;
}
-void LocalizationEditor::_translation_res_delete(Object *p_item, int p_column, int p_button) {
+void LocalizationEditor::_translation_res_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
if (updating_translations) {
return;
}
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
+
if (!ProjectSettings::get_singleton()->has_setting("internationalization/locale/translation_remaps")) {
return;
}
@@ -267,11 +275,15 @@ void LocalizationEditor::_translation_res_delete(Object *p_item, int p_column, i
undo_redo->commit_action();
}
-void LocalizationEditor::_translation_res_option_delete(Object *p_item, int p_column, int p_button) {
+void LocalizationEditor::_translation_res_option_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
if (updating_translations) {
return;
}
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
+
if (!ProjectSettings::get_singleton()->has_setting("internationalization/locale/translation_remaps")) {
return;
}
@@ -320,7 +332,11 @@ void LocalizationEditor::_pot_add(const PackedStringArray &p_paths) {
undo_redo->commit_action();
}
-void LocalizationEditor::_pot_delete(Object *p_item, int p_column, int p_button) {
+void LocalizationEditor::_pot_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!ti);
@@ -536,7 +552,7 @@ LocalizationEditor::LocalizationEditor() {
translation_remap = memnew(Tree);
translation_remap->set_v_size_flags(Control::SIZE_EXPAND_FILL);
translation_remap->connect("cell_selected", callable_mp(this, &LocalizationEditor::_translation_res_select));
- translation_remap->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_res_delete));
+ translation_remap->connect("button_clicked", callable_mp(this, &LocalizationEditor::_translation_res_delete));
tmc->add_child(translation_remap);
translation_res_file_open_dialog = memnew(EditorFileDialog);
@@ -572,7 +588,7 @@ LocalizationEditor::LocalizationEditor() {
translation_remap_options->set_column_clip_content(1, false);
translation_remap_options->set_column_custom_minimum_width(1, 250);
translation_remap_options->connect("item_edited", callable_mp(this, &LocalizationEditor::_translation_res_option_changed));
- translation_remap_options->connect("button_pressed", callable_mp(this, &LocalizationEditor::_translation_res_option_delete));
+ translation_remap_options->connect("button_clicked", callable_mp(this, &LocalizationEditor::_translation_res_option_delete));
translation_remap_options->connect("custom_popup_edited", callable_mp(this, &LocalizationEditor::_translation_res_option_popup));
tmc->add_child(translation_remap_options);
diff --git a/editor/localization_editor.h b/editor/localization_editor.h
index 966ef0f36e..4b41a90cc2 100644
--- a/editor/localization_editor.h
+++ b/editor/localization_editor.h
@@ -61,21 +61,21 @@ class LocalizationEditor : public VBoxContainer {
void _translation_file_open();
void _translation_add(const PackedStringArray &p_paths);
- void _translation_delete(Object *p_item, int p_column, int p_button);
+ void _translation_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _translation_res_file_open();
void _translation_res_add(const PackedStringArray &p_paths);
- void _translation_res_delete(Object *p_item, int p_column, int p_button);
+ void _translation_res_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _translation_res_select();
void _translation_res_option_file_open();
void _translation_res_option_add(const PackedStringArray &p_paths);
void _translation_res_option_changed();
- void _translation_res_option_delete(Object *p_item, int p_column, int p_button);
+ void _translation_res_option_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _translation_res_option_popup(bool p_arrow_clicked);
void _translation_res_option_selected(const String &p_locale);
void _pot_add(const PackedStringArray &p_paths);
- void _pot_delete(Object *p_item, int p_column, int p_button);
+ void _pot_delete(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _pot_file_open();
void _pot_generate_open();
void _pot_generate(const String &p_file);
diff --git a/editor/plugins/animation_library_editor.cpp b/editor/plugins/animation_library_editor.cpp
index b43a4215b1..ed908e413c 100644
--- a/editor/plugins/animation_library_editor.cpp
+++ b/editor/plugins/animation_library_editor.cpp
@@ -75,12 +75,16 @@ void AnimationLibraryEditor::_add_library_validate(const String &p_name) {
add_library_validate->set_text(error);
add_library_dialog->get_ok_button()->set_disabled(true);
} else {
- add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
- if (p_name == "") {
- add_library_validate->set_text(TTR("Global library will be created."));
+ if (adding_animation) {
+ add_library_validate->set_text(TTR("Animation name is valid."));
} else {
- add_library_validate->set_text(TTR("Library name is valid."));
+ if (p_name == "") {
+ add_library_validate->set_text(TTR("Global library will be created."));
+ } else {
+ add_library_validate->set_text(TTR("Library name is valid."));
+ }
}
+ add_library_validate->add_theme_color_override("font_color", get_theme_color(SNAME("success_color"), SNAME("Editor")));
add_library_dialog->get_ok_button()->set_disabled(false);
}
}
@@ -469,7 +473,7 @@ void AnimationLibraryEditor::_button_pressed(TreeItem *p_item, int p_column, int
int attempt = 1;
while (al->has_animation(name)) {
attempt++;
- name = base_name + " " + itos(attempt);
+ name = base_name + " (" + itos(attempt) + ")";
}
UndoRedo *undo_redo = EditorNode::get_singleton()->get_undo_redo();
@@ -673,7 +677,7 @@ AnimationLibraryEditor::AnimationLibraryEditor() {
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
tree->connect("item_edited", callable_mp(this, &AnimationLibraryEditor::_item_renamed));
- tree->connect("button_pressed", callable_mp(this, &AnimationLibraryEditor::_button_pressed));
+ tree->connect("button_clicked", callable_mp(this, &AnimationLibraryEditor::_button_pressed));
file_popup = memnew(PopupMenu);
add_child(file_popup);
diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp
index 57cf13d298..e75cdba003 100644
--- a/editor/plugins/animation_player_editor_plugin.cpp
+++ b/editor/plugins/animation_player_editor_plugin.cpp
@@ -303,17 +303,23 @@ void AnimationPlayerEditor::_animation_selected(int p_which) {
}
void AnimationPlayerEditor::_animation_new() {
- name_dialog_op = TOOL_NEW_ANIM;
- name_title->set_text(TTR("New Animation Name:"));
-
int count = 1;
String base = TTR("New Anim");
+ String current_library_name = "";
+ if (animation->has_selectable_items()) {
+ String current_animation_name = animation->get_item_text(animation->get_selected());
+ Ref<Animation> current_animation = player->get_animation(current_animation_name);
+ if (current_animation.is_valid()) {
+ current_library_name = player->find_animation_library(current_animation);
+ }
+ }
+ String attempt_prefix = (current_library_name == "") ? "" : current_library_name + "/";
while (true) {
String attempt = base;
if (count > 1) {
attempt += " (" + itos(count) + ")";
}
- if (player->has_animation(attempt)) {
+ if (player->has_animation(attempt_prefix + attempt)) {
count++;
continue;
}
@@ -321,22 +327,13 @@ void AnimationPlayerEditor::_animation_new() {
break;
}
- List<StringName> libraries;
- player->get_animation_library_list(&libraries);
- library->clear();
- for (const StringName &K : libraries) {
- library->add_item((K == StringName()) ? String(TTR("[Global]")) : String(K));
- library->set_item_metadata(0, String(K));
- }
+ _update_name_dialog_library_dropdown();
- if (libraries.size() > 1) {
- library->show();
- } else {
- library->hide();
- }
-
- name->set_text(base);
+ name_dialog_op = TOOL_NEW_ANIM;
+ name_dialog->set_title(TTR("Create New Animation"));
name_dialog->popup_centered(Size2(300, 90));
+ name_title->set_text(TTR("New Animation Name:"));
+ name->set_text(base);
name->select_all();
name->grab_focus();
}
@@ -348,6 +345,12 @@ void AnimationPlayerEditor::_animation_rename() {
int selected = animation->get_selected();
String selected_name = animation->get_item_text(selected);
+ // Remove library prefix if present.
+ if (selected_name.contains("/")) {
+ selected_name = selected_name.get_slice("/", 1);
+ }
+
+ name_dialog->set_title(TTR("Rename Animation"));
name_title->set_text(TTR("Change Animation Name:"));
name->set_text(selected_name);
name_dialog_op = TOOL_RENAME_ANIM;
@@ -375,6 +378,10 @@ void AnimationPlayerEditor::_animation_remove_confirmed() {
Ref<AnimationLibrary> al = player->get_animation_library(player->find_animation_library(anim));
ERR_FAIL_COND(al.is_null());
+ // For names of form lib_name/anim_name, remove library name prefix.
+ if (current.contains("/")) {
+ current = current.get_slice("/", 1);
+ }
undo_redo->create_action(TTR("Remove Animation"));
if (player->get_autoplay() == current) {
undo_redo->add_do_method(player, "set_autoplay", "");
@@ -438,8 +445,14 @@ void AnimationPlayerEditor::_animation_name_edited() {
return;
}
- if (player->has_animation(new_name)) {
- error_dialog->set_text(TTR("Animation name already exists!"));
+ String test_name_prefix = "";
+ if (library->is_visible() && library->get_selected_id() != -1) {
+ test_name_prefix = library->get_item_metadata(library->get_selected_id());
+ test_name_prefix += (test_name_prefix != "") ? "/" : "";
+ }
+
+ if (player->has_animation(test_name_prefix + new_name)) {
+ error_dialog->set_text(vformat(TTR("Animation '%s' already exists!")));
error_dialog->popup_centered();
return;
}
@@ -452,6 +465,13 @@ void AnimationPlayerEditor::_animation_name_edited() {
Ref<AnimationLibrary> al = player->get_animation_library(player->find_animation_library(anim));
ERR_FAIL_COND(al.is_null());
+ // Extract library prefix if present.
+ String new_library_prefix = "";
+ if (current.contains("/")) {
+ new_library_prefix = current.get_slice("/", 0) + "/";
+ current = current.get_slice("/", 1);
+ }
+
undo_redo->create_action(TTR("Rename Animation"));
undo_redo->add_do_method(al.ptr(), "rename_animation", current, new_name);
undo_redo->add_do_method(anim.ptr(), "set_name", new_name);
@@ -461,19 +481,25 @@ void AnimationPlayerEditor::_animation_name_edited() {
undo_redo->add_undo_method(this, "_animation_player_changed", player);
undo_redo->commit_action();
- _select_anim_by_name(new_name);
+ _select_anim_by_name(new_library_prefix + new_name);
} break;
case TOOL_NEW_ANIM: {
Ref<Animation> new_anim = Ref<Animation>(memnew(Animation));
new_anim->set_name(new_name);
-
+ String library_name;
Ref<AnimationLibrary> al;
if (library->is_visible()) {
- al = player->get_animation_library(library->get_item_metadata(library->get_selected()));
+ library_name = library->get_item_metadata(library->get_selected());
+ // It's possible that [Global] was selected, but doesn't exist yet.
+ if (player->has_animation_library(library_name)) {
+ al = player->get_animation_library(library_name);
+ }
+
} else {
if (player->has_animation_library("")) {
al = player->get_animation_library("");
+ library_name = "";
}
}
@@ -484,6 +510,7 @@ void AnimationPlayerEditor::_animation_name_edited() {
al.instantiate();
lib_added = true;
undo_redo->add_do_method(player, "add_animation_library", "", al);
+ library_name = "";
}
undo_redo->add_do_method(al.ptr(), "add_animation", new_name, new_anim);
@@ -499,7 +526,11 @@ void AnimationPlayerEditor::_animation_name_edited() {
}
undo_redo->commit_action();
- _select_anim_by_name(new_name);
+ if (library_name != "") {
+ library_name = library_name + "/";
+ }
+ _select_anim_by_name(library_name + new_name);
+
} break;
case TOOL_DUPLICATE_ANIM: {
@@ -509,17 +540,44 @@ void AnimationPlayerEditor::_animation_name_edited() {
Ref<Animation> new_anim = _animation_clone(anim);
new_anim->set_name(new_name);
- Ref<AnimationLibrary> library = player->get_animation_library(player->find_animation_library(anim));
+ String library_name;
+ Ref<AnimationLibrary> al;
+ if (library->is_visible()) {
+ library_name = library->get_item_metadata(library->get_selected());
+ // It's possible that [Global] was selected, but doesn't exist yet.
+ if (player->has_animation_library(library_name)) {
+ al = player->get_animation_library(library_name);
+ }
+ } else {
+ if (player->has_animation_library("")) {
+ al = player->get_animation_library("");
+ library_name = "";
+ }
+ }
undo_redo->create_action(TTR("Duplicate Animation"));
- undo_redo->add_do_method(library.ptr(), "add_animation", new_name, new_anim);
- undo_redo->add_undo_method(library.ptr(), "remove_animation", new_name);
- undo_redo->add_do_method(player, "animation_set_next", new_name, player->animation_get_next(current));
+
+ bool lib_added = false;
+ if (al.is_null()) {
+ al.instantiate();
+ lib_added = true;
+ undo_redo->add_do_method(player, "add_animation_library", "", al);
+ library_name = "";
+ }
+
+ undo_redo->add_do_method(al.ptr(), "add_animation", new_name, new_anim);
+ undo_redo->add_undo_method(al.ptr(), "remove_animation", new_name);
undo_redo->add_do_method(this, "_animation_player_changed", player);
undo_redo->add_undo_method(this, "_animation_player_changed", player);
+ if (lib_added) {
+ undo_redo->add_undo_method(player, "remove_animation_library", "");
+ }
undo_redo->commit_action();
- _select_anim_by_name(new_name);
+ if (library_name != "") {
+ library_name = library_name + "/";
+ }
+ _select_anim_by_name(library_name + new_name);
} break;
}
@@ -851,6 +909,47 @@ void AnimationPlayerEditor::_update_animation_list_icons() {
}
}
+void AnimationPlayerEditor::_update_name_dialog_library_dropdown() {
+ StringName current_library_name = StringName();
+ if (animation->has_selectable_items()) {
+ String current_animation_name = animation->get_item_text(animation->get_selected());
+ Ref<Animation> current_animation = player->get_animation(current_animation_name);
+ if (current_animation.is_valid()) {
+ current_library_name = player->find_animation_library(current_animation);
+ }
+ }
+
+ List<StringName> libraries;
+ player->get_animation_library_list(&libraries);
+ library->clear();
+
+ // When [Global] isn't present, but other libraries are, add option of creating [Global].
+ int index_offset = 0;
+ if (!player->has_animation_library(StringName())) {
+ library->add_item(String(TTR("[Global] (create)")));
+ library->set_item_metadata(0, "");
+ index_offset = 1;
+ }
+
+ int current_lib_id = index_offset; // Don't default to [Global] if it doesn't exist yet.
+ for (int i = 0; i < libraries.size(); i++) {
+ StringName library_name = libraries[i];
+ library->add_item((library_name == StringName()) ? String(TTR("[Global]")) : String(library_name));
+ library->set_item_metadata(i + index_offset, String(library_name));
+ // Default to duplicating into same library.
+ if (library_name == current_library_name) {
+ current_lib_id = i + index_offset;
+ }
+ }
+
+ if (library->get_item_count() > 1) {
+ library->select(current_lib_id);
+ library->show();
+ } else {
+ library->hide();
+ }
+}
+
void AnimationPlayerEditor::edit(AnimationPlayer *p_player) {
if (player && pin->is_pressed()) {
return; // Ignore, pinned.
@@ -946,9 +1045,17 @@ void AnimationPlayerEditor::_animation_duplicate() {
new_name = new_name + " (copy)";
}
- name_title->set_text(TTR("New Animation Name:"));
- name->set_text(new_name);
+ if (new_name.contains("/")) {
+ // Discard library prefix.
+ new_name = new_name.get_slice("/", 1);
+ }
+
+ _update_name_dialog_library_dropdown();
+
name_dialog_op = TOOL_DUPLICATE_ANIM;
+ name_dialog->set_title("Duplicate Animation");
+ name_title->set_text(TTR("Duplicated Animation Name:"));
+ name->set_text(new_name);
name_dialog->popup_centered(Size2(300, 90));
name->select_all();
name->grab_focus();
diff --git a/editor/plugins/animation_player_editor_plugin.h b/editor/plugins/animation_player_editor_plugin.h
index 0cc04460ca..3b1de070fa 100644
--- a/editor/plugins/animation_player_editor_plugin.h
+++ b/editor/plugins/animation_player_editor_plugin.h
@@ -188,6 +188,7 @@ class AnimationPlayerEditor : public VBoxContainer {
void _update_animation();
void _update_player();
void _update_animation_list_icons();
+ void _update_name_dialog_library_dropdown();
void _blend_edited();
void _animation_player_changed(Object *p_pl);
diff --git a/editor/plugins/replication_editor_plugin.cpp b/editor/plugins/replication_editor_plugin.cpp
index 6992b5443b..72fe3c5f20 100644
--- a/editor/plugins/replication_editor_plugin.cpp
+++ b/editor/plugins/replication_editor_plugin.cpp
@@ -232,7 +232,7 @@ ReplicationEditor::ReplicationEditor() {
tree->set_column_expand(2, false);
tree->set_column_expand(3, false);
tree->create_item();
- tree->connect("button_pressed", callable_mp(this, &ReplicationEditor::_tree_button_pressed));
+ tree->connect("button_clicked", callable_mp(this, &ReplicationEditor::_tree_button_pressed));
tree->connect("item_edited", callable_mp(this, &ReplicationEditor::_tree_item_edited));
tree->set_v_size_flags(SIZE_EXPAND_FILL);
vb->add_child(tree);
@@ -387,7 +387,11 @@ void ReplicationEditor::_tree_item_edited() {
undo_redo->commit_action();
}
-void ReplicationEditor::_tree_button_pressed(Object *p_item, int p_column, int p_id) {
+void ReplicationEditor::_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
if (!ti) {
return;
diff --git a/editor/plugins/replication_editor_plugin.h b/editor/plugins/replication_editor_plugin.h
index b6de08a3a8..df3d97f884 100644
--- a/editor/plugins/replication_editor_plugin.h
+++ b/editor/plugins/replication_editor_plugin.h
@@ -71,7 +71,7 @@ private:
void _add_pressed();
void _tree_item_edited();
- void _tree_button_pressed(Object *p_item, int p_column, int p_id);
+ void _tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _update_checked(const NodePath &p_prop, int p_column, bool p_checked);
void _update_config();
void _dialog_closed(bool p_confirmed);
diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp
index 71d31aa1d7..16e874d7e2 100644
--- a/editor/plugins/resource_preloader_editor_plugin.cpp
+++ b/editor/plugins/resource_preloader_editor_plugin.cpp
@@ -213,7 +213,11 @@ void ResourcePreloaderEditor::_update_library() {
//player->add_resource("default",resource);
}
-void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
+void ResourcePreloaderEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
ERR_FAIL_COND(!item);
@@ -359,7 +363,7 @@ ResourcePreloaderEditor::ResourcePreloaderEditor() {
add_child(file);
tree = memnew(Tree);
- tree->connect("button_pressed", callable_mp(this, &ResourcePreloaderEditor::_cell_button_pressed));
+ tree->connect("button_clicked", callable_mp(this, &ResourcePreloaderEditor::_cell_button_pressed));
tree->set_columns(2);
tree->set_column_expand_ratio(0, 2);
tree->set_column_clip_content(0, true);
diff --git a/editor/plugins/resource_preloader_editor_plugin.h b/editor/plugins/resource_preloader_editor_plugin.h
index 0b799c13c6..96cef3de21 100644
--- a/editor/plugins/resource_preloader_editor_plugin.h
+++ b/editor/plugins/resource_preloader_editor_plugin.h
@@ -63,7 +63,7 @@ class ResourcePreloaderEditor : public PanelContainer {
void _paste_pressed();
void _remove_resource(const String &p_to_remove);
void _update_library();
- void _cell_button_pressed(Object *p_item, int p_column, int p_id);
+ void _cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _item_edited();
UndoRedo *undo_redo = nullptr;
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp
index 124c62ed67..8845fe9eca 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.cpp
+++ b/editor/plugins/skeleton_3d_editor_plugin.cpp
@@ -569,7 +569,7 @@ void Skeleton3DEditor::_joint_tree_selection_changed() {
}
// May be not used with single select mode.
-void Skeleton3DEditor::_joint_tree_rmb_select(const Vector2 &p_pos) {
+void Skeleton3DEditor::_joint_tree_rmb_select(const Vector2 &p_pos, MouseButton p_button) {
}
void Skeleton3DEditor::_update_properties() {
@@ -766,7 +766,7 @@ void Skeleton3DEditor::_notification(int p_what) {
update_joint_tree();
update_editors();
joint_tree->connect("item_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_selection_changed));
- joint_tree->connect("item_rmb_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_rmb_select));
+ joint_tree->connect("item_mouse_selected", callable_mp(this, &Skeleton3DEditor::_joint_tree_rmb_select));
#ifdef TOOLS_ENABLED
skeleton->connect("pose_updated", callable_mp(this, &Skeleton3DEditor::_draw_gizmo));
skeleton->connect("pose_updated", callable_mp(this, &Skeleton3DEditor::_update_properties));
diff --git a/editor/plugins/skeleton_3d_editor_plugin.h b/editor/plugins/skeleton_3d_editor_plugin.h
index f4a82225f2..8f03e7c8db 100644
--- a/editor/plugins/skeleton_3d_editor_plugin.h
+++ b/editor/plugins/skeleton_3d_editor_plugin.h
@@ -181,7 +181,7 @@ class Skeleton3DEditor : public VBoxContainer {
void _draw_handles();
void _joint_tree_selection_changed();
- void _joint_tree_rmb_select(const Vector2 &p_pos);
+ void _joint_tree_rmb_select(const Vector2 &p_pos, MouseButton p_button);
void _update_properties();
void _subgizmo_selection_change();
diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp
index 7b2c7d2a82..751751aaaa 100644
--- a/editor/plugins/theme_editor_plugin.cpp
+++ b/editor/plugins/theme_editor_plugin.cpp
@@ -1287,7 +1287,11 @@ void ThemeItemEditorDialog::_edited_type_selected() {
_update_edit_item_tree(selected_type);
}
-void ThemeItemEditorDialog::_edited_type_button_pressed(Object *p_item, int p_column, int p_id) {
+void ThemeItemEditorDialog::_edited_type_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
if (!item) {
return;
@@ -1461,7 +1465,11 @@ void ThemeItemEditorDialog::_update_edit_item_tree(String p_item_type) {
}
}
-void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_column, int p_id) {
+void ThemeItemEditorDialog::_item_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
if (!item) {
return;
@@ -1909,7 +1917,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito
edit_type_list->set_v_size_flags(Control::SIZE_EXPAND_FILL);
edit_dialog_side_vb->add_child(edit_type_list);
edit_type_list->connect("item_selected", callable_mp(this, &ThemeItemEditorDialog::_edited_type_selected));
- edit_type_list->connect("button_pressed", callable_mp(this, &ThemeItemEditorDialog::_edited_type_button_pressed));
+ edit_type_list->connect("button_clicked", callable_mp(this, &ThemeItemEditorDialog::_edited_type_button_pressed));
Label *edit_add_type_label = memnew(Label);
edit_add_type_label->set_text(TTR("Add Type:"));
@@ -2011,7 +2019,7 @@ ThemeItemEditorDialog::ThemeItemEditorDialog(ThemeTypeEditor *p_theme_type_edito
edit_items_tree->set_hide_root(true);
edit_items_tree->set_columns(1);
edit_items_vb->add_child(edit_items_tree);
- edit_items_tree->connect("button_pressed", callable_mp(this, &ThemeItemEditorDialog::_item_tree_button_pressed));
+ edit_items_tree->connect("button_clicked", callable_mp(this, &ThemeItemEditorDialog::_item_tree_button_pressed));
edit_items_message = memnew(Label);
edit_items_message->set_anchors_and_offsets_preset(Control::PRESET_WIDE);
diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h
index 323cfceb7e..543113a5eb 100644
--- a/editor/plugins/theme_editor_plugin.h
+++ b/editor/plugins/theme_editor_plugin.h
@@ -249,10 +249,10 @@ class ThemeItemEditorDialog : public AcceptDialog {
void _dialog_about_to_show();
void _update_edit_types();
void _edited_type_selected();
- void _edited_type_button_pressed(Object *p_item, int p_column, int p_id);
+ void _edited_type_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _update_edit_item_tree(String p_item_type);
- void _item_tree_button_pressed(Object *p_item, int p_column, int p_id);
+ void _item_tree_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _add_theme_type(const String &p_new_text);
void _add_theme_item(Theme::DataType p_data_type, String p_item_name, String p_item_type);
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index fbcf9739ca..eaec3bab02 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -49,7 +49,11 @@ Node *SceneTreeEditor::get_scene_node() {
return get_tree()->get_edited_scene_root();
}
-void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id) {
+void SceneTreeEditor::_cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button) {
+ if (p_button != MouseButton::LEFT) {
+ return;
+ }
+
if (connect_to_script_mode) {
return; //don't do anything in this mode
}
@@ -1166,7 +1170,17 @@ void SceneTreeEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data,
}
}
-void SceneTreeEditor::_rmb_select(const Vector2 &p_pos) {
+void SceneTreeEditor::_empty_clicked(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+ _rmb_select(p_pos);
+}
+
+void SceneTreeEditor::_rmb_select(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
emit_signal(SNAME("rmb_pressed"), tree->get_screen_position() + p_pos);
}
@@ -1251,14 +1265,14 @@ SceneTreeEditor::SceneTreeEditor(bool p_label, bool p_can_rename, bool p_can_ope
tree->set_drag_forwarding(this);
if (p_can_rename) {
tree->set_allow_rmb_select(true);
- tree->connect("item_rmb_selected", callable_mp(this, &SceneTreeEditor::_rmb_select));
- tree->connect("empty_tree_rmb_selected", callable_mp(this, &SceneTreeEditor::_rmb_select));
+ tree->connect("item_mouse_selected", callable_mp(this, &SceneTreeEditor::_rmb_select));
+ tree->connect("empty_clicked", callable_mp(this, &SceneTreeEditor::_empty_clicked));
}
tree->connect("cell_selected", callable_mp(this, &SceneTreeEditor::_selected_changed));
tree->connect("item_edited", callable_mp(this, &SceneTreeEditor::_renamed));
tree->connect("multi_selected", callable_mp(this, &SceneTreeEditor::_cell_multi_selected));
- tree->connect("button_pressed", callable_mp(this, &SceneTreeEditor::_cell_button_pressed));
+ tree->connect("button_clicked", callable_mp(this, &SceneTreeEditor::_cell_button_pressed));
tree->connect("nothing_selected", callable_mp(this, &SceneTreeEditor::_deselect_items));
error = memnew(AcceptDialog);
diff --git a/editor/scene_tree_editor.h b/editor/scene_tree_editor.h
index 1f79b48449..60387cea3e 100644
--- a/editor/scene_tree_editor.h
+++ b/editor/scene_tree_editor.h
@@ -107,7 +107,7 @@ class SceneTreeEditor : public Control {
bool pending_test_update = false;
static void _bind_methods();
- void _cell_button_pressed(Object *p_item, int p_column, int p_id);
+ void _cell_button_pressed(Object *p_item, int p_column, int p_id, MouseButton p_button);
void _toggle_visible(Node *p_node);
void _cell_multi_selected(Object *p_object, int p_cell, bool p_selected);
void _update_selection(TreeItem *item);
@@ -122,7 +122,8 @@ class SceneTreeEditor : public Control {
bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const;
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
- void _rmb_select(const Vector2 &p_pos);
+ void _empty_clicked(const Vector2 &p_pos, MouseButton p_button);
+ void _rmb_select(const Vector2 &p_pos, MouseButton p_button = MouseButton::RIGHT);
void _warning_changed(Node *p_for_node);
diff --git a/modules/visual_script/editor/visual_script_editor.cpp b/modules/visual_script/editor/visual_script_editor.cpp
index 642f15db86..7454c8076f 100644
--- a/modules/visual_script/editor/visual_script_editor.cpp
+++ b/modules/visual_script/editor/visual_script_editor.cpp
@@ -1440,7 +1440,11 @@ void VisualScriptEditor::_deselect_input_names() {
}
}
-void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button) {
+void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button) {
+ if (p_mouse_button != MouseButton::LEFT) {
+ return;
+ }
+
TreeItem *ti = Object::cast_to<TreeItem>(p_item);
TreeItem *root = members->get_root();
@@ -4343,7 +4347,11 @@ void VisualScriptEditor::_get_ends(int p_node, const List<VisualScript::Sequence
}
}
-void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos) {
+void VisualScriptEditor::_member_rmb_selected(const Vector2 &p_pos, MouseButton p_button) {
+ if (p_button != MouseButton::RIGHT) {
+ return;
+ }
+
TreeItem *ti = members->get_selected();
ERR_FAIL_COND(!ti);
@@ -4544,11 +4552,11 @@ VisualScriptEditor::VisualScriptEditor() {
members_section->add_margin_child(TTR("Members:"), members, true);
members->set_custom_minimum_size(Size2(0, 50 * EDSCALE));
members->set_hide_root(true);
- members->connect("button_pressed", callable_mp(this, &VisualScriptEditor::_member_button));
+ members->connect("button_clicked", callable_mp(this, &VisualScriptEditor::_member_button));
members->connect("item_edited", callable_mp(this, &VisualScriptEditor::_member_edited));
members->connect("cell_selected", callable_mp(this, &VisualScriptEditor::_member_selected), varray(), CONNECT_DEFERRED);
members->connect("gui_input", callable_mp(this, &VisualScriptEditor::_members_gui_input));
- members->connect("item_rmb_selected", callable_mp(this, &VisualScriptEditor::_member_rmb_selected));
+ members->connect("item_mouse_selected", callable_mp(this, &VisualScriptEditor::_member_rmb_selected));
members->set_allow_rmb_select(true);
members->set_allow_reselect(true);
members->set_hide_folding(true);
diff --git a/modules/visual_script/editor/visual_script_editor.h b/modules/visual_script/editor/visual_script_editor.h
index c7fd8c4a78..fd59d22cbe 100644
--- a/modules/visual_script/editor/visual_script_editor.h
+++ b/modules/visual_script/editor/visual_script_editor.h
@@ -226,7 +226,7 @@ class VisualScriptEditor : public ScriptEditorBase {
void _update_available_nodes();
- void _member_button(Object *p_item, int p_column, int p_button);
+ void _member_button(Object *p_item, int p_column, int p_button, MouseButton p_mouse_button);
void _expression_text_changed(const String &p_text, int p_id);
void _add_input_port(int p_id);
@@ -289,7 +289,7 @@ class VisualScriptEditor : public ScriptEditorBase {
VisualScriptNode::TypeGuess _guess_output_type(int p_port_action_node, int p_port_action_output, RBSet<int> &p_visited_nodes);
- void _member_rmb_selected(const Vector2 &p_pos);
+ void _member_rmb_selected(const Vector2 &p_pos, MouseButton p_button);
void _member_option(int p_option);
void _toggle_scripts_pressed();
diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp
index 921a06b73c..a400f9e4f5 100644
--- a/scene/animation/animation_player.cpp
+++ b/scene/animation/animation_player.cpp
@@ -1487,7 +1487,7 @@ bool AnimationPlayer::has_animation(const StringName &p_name) const {
}
Ref<Animation> AnimationPlayer::get_animation(const StringName &p_name) const {
- ERR_FAIL_COND_V(!animation_set.has(p_name), Ref<Animation>());
+ ERR_FAIL_COND_V_MSG(!animation_set.has(p_name), Ref<Animation>(), vformat("Animation not found: %s.", p_name));
const AnimationData &data = animation_set[p_name];
@@ -1509,8 +1509,8 @@ void AnimationPlayer::get_animation_list(List<StringName> *p_animations) const {
}
void AnimationPlayer::set_blend_time(const StringName &p_animation1, const StringName &p_animation2, float p_time) {
- ERR_FAIL_COND(!animation_set.has(p_animation1));
- ERR_FAIL_COND(!animation_set.has(p_animation2));
+ ERR_FAIL_COND_MSG(!animation_set.has(p_animation1), vformat("Animation not found: %s.", p_animation1));
+ ERR_FAIL_COND_MSG(!animation_set.has(p_animation2), vformat("Animation not found: %s.", p_animation2));
ERR_FAIL_COND_MSG(p_time < 0, "Blend time cannot be smaller than 0.");
BlendKey bk;
@@ -1567,7 +1567,7 @@ void AnimationPlayer::play(const StringName &p_name, float p_custom_blend, float
name = playback.assigned;
}
- ERR_FAIL_COND_MSG(!animation_set.has(name), "Animation not found: " + name + ".");
+ ERR_FAIL_COND_MSG(!animation_set.has(name), vformat("Animation not found: %s.", name));
Playback &c = playback;
@@ -1670,7 +1670,7 @@ void AnimationPlayer::set_assigned_animation(const String &p_anim) {
if (is_playing()) {
play(p_anim);
} else {
- ERR_FAIL_COND(!animation_set.has(p_anim));
+ ERR_FAIL_COND_MSG(!animation_set.has(p_anim), vformat("Animation not found: %s.", p_anim));
playback.current.pos = 0;
playback.current.from = &animation_set[p_anim];
playback.assigned = p_anim;
@@ -1713,7 +1713,7 @@ float AnimationPlayer::get_playing_speed() const {
void AnimationPlayer::seek(double p_time, bool p_update) {
if (!playback.current.from) {
if (playback.assigned) {
- ERR_FAIL_COND(!animation_set.has(playback.assigned));
+ ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned));
playback.current.from = &animation_set[playback.assigned];
}
ERR_FAIL_COND(!playback.current.from);
@@ -1729,7 +1729,7 @@ void AnimationPlayer::seek(double p_time, bool p_update) {
void AnimationPlayer::seek_delta(double p_time, float p_delta) {
if (!playback.current.from) {
if (playback.assigned) {
- ERR_FAIL_COND(!animation_set.has(playback.assigned));
+ ERR_FAIL_COND_MSG(!animation_set.has(playback.assigned), vformat("Animation not found: %s.", playback.assigned));
playback.current.from = &animation_set[playback.assigned];
}
ERR_FAIL_COND(!playback.current.from);
@@ -1899,7 +1899,7 @@ void AnimationPlayer::_set_process(bool p_process, bool p_force) {
}
void AnimationPlayer::animation_set_next(const StringName &p_animation, const StringName &p_next) {
- ERR_FAIL_COND(!animation_set.has(p_animation));
+ ERR_FAIL_COND_MSG(!animation_set.has(p_animation), vformat("Animation not found: %s.", p_animation));
animation_set[p_animation].next = p_next;
}
@@ -2012,7 +2012,7 @@ Ref<AnimatedValuesBackup> AnimationPlayer::apply_reset(bool p_user_initiated) {
al.instantiate();
al->add_animation(SceneStringNames::get_singleton()->RESET, reset_anim);
aux_player->add_animation_library("default", al);
- aux_player->set_assigned_animation(SceneStringNames::get_singleton()->RESET);
+ aux_player->set_assigned_animation("default/" + SceneStringNames::get_singleton()->RESET);
// Forcing the use of the original root because the scene where original player belongs may be not the active one
Node *root = get_node(get_root());
Ref<AnimatedValuesBackup> old_values = aux_player->backup_animated_values(root);
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index 4b79d79846..a86f2bdbc1 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -320,7 +320,7 @@ int OptionButton::get_selectable_item(bool p_from_last) const {
}
}
} else {
- for (int i = get_item_count() - 1; i >= 0; i++) {
+ for (int i = get_item_count() - 1; i >= 0; i--) {
if (!is_item_disabled(i) && !is_item_separator(i)) {
return i;
}
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 0ca9a66e08..4d18bc91c4 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -544,6 +544,21 @@ bool TreeItem::is_collapsed() {
return collapsed;
}
+void TreeItem::set_visible(bool p_visible) {
+ if (visible == p_visible) {
+ return;
+ }
+ visible = p_visible;
+ if (tree) {
+ tree->update();
+ _changed_notify();
+ }
+}
+
+bool TreeItem::is_visible() {
+ return visible;
+}
+
void TreeItem::uncollapse_tree() {
TreeItem *t = this;
while (t) {
@@ -646,7 +661,7 @@ TreeItem *TreeItem::get_first_child() const {
return first_child;
}
-TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
+TreeItem *TreeItem::_get_prev_visible(bool p_wrap) {
TreeItem *current = this;
TreeItem *prev = current->get_prev();
@@ -682,7 +697,21 @@ TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
return current;
}
-TreeItem *TreeItem::get_next_visible(bool p_wrap) {
+TreeItem *TreeItem::get_prev_visible(bool p_wrap) {
+ TreeItem *loop = this;
+ TreeItem *prev = this->_get_prev_visible(p_wrap);
+ while (prev && !prev->is_visible()) {
+ prev = prev->_get_prev_visible(p_wrap);
+ if (prev == loop) {
+ // Check that we haven't looped all the way around to the start.
+ prev = nullptr;
+ break;
+ }
+ }
+ return prev;
+}
+
+TreeItem *TreeItem::_get_next_visible(bool p_wrap) {
TreeItem *current = this;
if (!current->collapsed && current->first_child) {
@@ -709,12 +738,37 @@ TreeItem *TreeItem::get_next_visible(bool p_wrap) {
return current;
}
+TreeItem *TreeItem::get_next_visible(bool p_wrap) {
+ TreeItem *loop = this;
+ TreeItem *next = this->_get_next_visible(p_wrap);
+ while (next && !next->is_visible()) {
+ next = next->_get_next_visible(p_wrap);
+ if (next == loop) {
+ // Check that we haven't looped all the way around to the start.
+ next = nullptr;
+ break;
+ }
+ }
+ return next;
+}
+
TreeItem *TreeItem::get_child(int p_idx) {
_create_children_cache();
ERR_FAIL_INDEX_V(p_idx, children_cache.size(), nullptr);
return children_cache.get(p_idx);
}
+int TreeItem::get_visible_child_count() {
+ _create_children_cache();
+ int visible_count = 0;
+ for (int i = 0; i < children_cache.size(); i++) {
+ if (children_cache[i]->is_visible()) {
+ visible_count += 1;
+ }
+ }
+ return visible_count;
+}
+
int TreeItem::get_child_count() {
_create_children_cache();
return children_cache.size();
@@ -1256,6 +1310,9 @@ void TreeItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_collapsed", "enable"), &TreeItem::set_collapsed);
ClassDB::bind_method(D_METHOD("is_collapsed"), &TreeItem::is_collapsed);
+ ClassDB::bind_method(D_METHOD("set_visible", "enable"), &TreeItem::set_visible);
+ ClassDB::bind_method(D_METHOD("is_visible"), &TreeItem::is_visible);
+
ClassDB::bind_method(D_METHOD("uncollapse_tree"), &TreeItem::uncollapse_tree);
ClassDB::bind_method(D_METHOD("set_custom_minimum_height", "height"), &TreeItem::set_custom_minimum_height);
@@ -1340,6 +1397,7 @@ void TreeItem::_bind_methods() {
}
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collapsed"), "set_collapsed", "is_collapsed");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "is_visible");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_folding"), "set_disable_folding", "is_folding_disabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "custom_minimum_height", PROPERTY_HINT_RANGE, "0,1000,1"), "set_custom_minimum_height", "get_custom_minimum_height");
@@ -1445,7 +1503,7 @@ void Tree::update_cache() {
}
int Tree::compute_item_height(TreeItem *p_item) const {
- if (p_item == root && hide_root) {
+ if ((p_item == root && hide_root) || !p_item->is_visible()) {
return 0;
}
@@ -1506,6 +1564,9 @@ int Tree::compute_item_height(TreeItem *p_item) const {
}
int Tree::get_item_height(TreeItem *p_item) const {
+ if (!p_item->is_visible()) {
+ return 0;
+ }
int height = compute_item_height(p_item);
height += cache.vseparation;
@@ -1686,6 +1747,10 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
return -1; //draw no more!
}
+ if (!p_item->is_visible()) {
+ return 0;
+ }
+
RID ci = get_canvas_item();
int htotal = 0;
@@ -2056,7 +2121,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2
}
}
- if (!p_item->disable_folding && !hide_folding && p_item->first_child) { //has children, draw the guide box
+ if (!p_item->disable_folding && !hide_folding && p_item->first_child && p_item->get_visible_child_count() != 0) { //has visible children, draw the guide box
Ref<Texture2D> arrow;
@@ -2382,6 +2447,11 @@ void Tree::_range_click_timeout() {
}
int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int x_limit, bool p_double_click, TreeItem *p_item, MouseButton p_button, const Ref<InputEventWithModifiers> &p_mod) {
+ if (p_item && !p_item->is_visible()) {
+ // Skip any processing of invisible items.
+ return 0;
+ }
+
int item_h = compute_item_height(p_item) + cache.vseparation;
bool skip = (p_item == root && hide_root);
@@ -2491,7 +2561,6 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
cache.click_column = col;
cache.click_pos = click_pos;
update();
- //emit_signal(SNAME("button_pressed"));
return -1;
}
@@ -2513,9 +2582,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
if (!c.selected || p_button == MouseButton::RIGHT) {
p_item->select(col);
emit_signal(SNAME("multi_selected"), p_item, col, true);
- if (p_button == MouseButton::RIGHT) {
- emit_signal(SNAME("item_rmb_selected"), get_local_mouse_position());
- }
+ emit_signal(SNAME("item_mouse_selected"), get_local_mouse_position(), p_button);
//p_item->selected_signal.call(col);
} else {
@@ -2530,9 +2597,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
bool inrange = false;
select_single_item(p_item, root, col, selected_item, &inrange);
- if (p_button == MouseButton::RIGHT) {
- emit_signal(SNAME("item_rmb_selected"), get_local_mouse_position());
- }
+ emit_signal(SNAME("item_mouse_selected"), get_local_mouse_position(), p_button);
} else {
int icount = _count_selected_items(root);
@@ -2544,9 +2609,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
select_single_item(p_item, root, col);
}
- if (p_button == MouseButton::RIGHT) {
- emit_signal(SNAME("item_rmb_selected"), get_local_mouse_position());
- }
+ emit_signal(SNAME("item_mouse_selected"), get_local_mouse_position(), p_button);
}
}
@@ -2583,11 +2646,11 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
if (force_edit_checkbox_only_on_checkbox) {
if (x < cache.checked->get_width()) {
p_item->set_checked(col, !c.checked);
- item_edited(col, p_item);
+ item_edited(col, p_item, p_button);
}
} else {
p_item->set_checked(col, !c.checked);
- item_edited(col, p_item);
+ item_edited(col, p_item, p_button);
}
click_handled = true;
//p_item->edited_signal.call(col);
@@ -2629,17 +2692,17 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
p_item->set_range(col, c.val + (up ? 1.0 : -1.0) * c.step);
- item_edited(col, p_item);
+ item_edited(col, p_item, p_button);
} else if (p_button == MouseButton::RIGHT) {
p_item->set_range(col, (up ? c.max : c.min));
- item_edited(col, p_item);
+ item_edited(col, p_item, p_button);
} else if (p_button == MouseButton::WHEEL_UP) {
p_item->set_range(col, c.val + c.step);
- item_edited(col, p_item);
+ item_edited(col, p_item, p_button);
} else if (p_button == MouseButton::WHEEL_DOWN) {
p_item->set_range(col, c.val - c.step);
- item_edited(col, p_item);
+ item_edited(col, p_item, p_button);
}
//p_item->edited_signal.call(col);
@@ -2670,7 +2733,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
}
if (!p_item->cells[col].custom_button || !on_arrow) {
- item_edited(col, p_item, p_button == MouseButton::LEFT);
+ item_edited(col, p_item, p_button);
}
click_handled = true;
return -1;
@@ -2717,8 +2780,8 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, int
item_h += child_h;
}
}
- if (p_item == root && p_button == MouseButton::RIGHT) {
- emit_signal(SNAME("empty_rmb"), get_local_mouse_position());
+ if (p_item == root) {
+ emit_signal(SNAME("empty_clicked"), get_local_mouse_position(), p_button);
}
}
@@ -3126,7 +3189,6 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
}
Ref<InputEventMouseMotion> mm = p_event;
-
if (mm.is_valid()) {
if (cache.font.is_null()) { // avoid a strange case that may corrupt stuff
update_cache();
@@ -3256,18 +3318,17 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
}
}
- Ref<InputEventMouseButton> b = p_event;
-
- if (b.is_valid()) {
+ Ref<InputEventMouseButton> mb = p_event;
+ if (mb.is_valid()) {
if (cache.font.is_null()) { // avoid a strange case that may corrupt stuff
update_cache();
}
bool rtl = is_layout_rtl();
- if (!b->is_pressed()) {
- if (b->get_button_index() == MouseButton::LEFT) {
- Point2 pos = b->get_position();
+ if (!mb->is_pressed()) {
+ if (mb->get_button_index() == MouseButton::LEFT) {
+ Point2 pos = mb->get_position();
if (rtl) {
pos.x = get_size().width - pos.x;
}
@@ -3302,7 +3363,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
warp_mouse(range_drag_capture_pos);
} else {
Rect2 rect = get_selected()->get_meta("__focus_rect");
- Point2 mpos = b->get_position();
+ Point2 mpos = mb->get_position();
int icon_size_x = 0;
Ref<Texture2D> icon = get_selected()->get_icon(selected_col);
if (icon.is_valid()) {
@@ -3330,17 +3391,6 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
pressing_for_editor = false;
}
- if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) {
- // make sure in case of wrong reference after reconstructing whole TreeItems
- cache.click_item = get_item_at_position(cache.click_pos);
- emit_signal(SNAME("button_pressed"), cache.click_item, cache.click_column, cache.click_id);
- }
- cache.click_type = Cache::CLICK_NONE;
- cache.click_index = -1;
- cache.click_id = -1;
- cache.click_item = nullptr;
- cache.click_column = 0;
-
if (drag_touching) {
if (drag_speed == 0) {
drag_touching_deaccel = false;
@@ -3350,8 +3400,20 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
drag_touching_deaccel = true;
}
}
- update();
}
+
+ if (cache.click_type == Cache::CLICK_BUTTON && cache.click_item != nullptr) {
+ // make sure in case of wrong reference after reconstructing whole TreeItems
+ cache.click_item = get_item_at_position(cache.click_pos);
+ emit_signal("button_clicked", cache.click_item, cache.click_column, cache.click_id, mb->get_button_index());
+ }
+
+ cache.click_type = Cache::CLICK_NONE;
+ cache.click_index = -1;
+ cache.click_id = -1;
+ cache.click_item = nullptr;
+ cache.click_column = 0;
+ update();
return;
}
@@ -3359,12 +3421,12 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
return;
}
- switch (b->get_button_index()) {
+ switch (mb->get_button_index()) {
case MouseButton::RIGHT:
case MouseButton::LEFT: {
Ref<StyleBox> bg = cache.bg;
- Point2 pos = b->get_position();
+ Point2 pos = mb->get_position();
if (rtl) {
pos.x = get_size().width - pos.x;
}
@@ -3374,7 +3436,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
pos.y -= _get_title_button_height();
if (pos.y < 0) {
- if (b->get_button_index() == MouseButton::LEFT) {
+ if (mb->get_button_index() == MouseButton::LEFT) {
pos.x += cache.offset.x;
int len = 0;
for (int i = 0; i < columns.size(); i++) {
@@ -3391,10 +3453,8 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
break;
}
}
+
if (!root || (!root->get_first_child() && hide_root)) {
- if (b->get_button_index() == MouseButton::RIGHT && allow_rmb_select) {
- emit_signal(SNAME("empty_tree_rmb_selected"), get_local_mouse_position());
- }
break;
}
@@ -3409,17 +3469,17 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
cache.rtl = is_layout_rtl();
blocked++;
- propagate_mouse_event(pos + cache.offset, 0, 0, x_limit + cache.offset.width, b->is_double_click(), root, b->get_button_index(), b);
+ propagate_mouse_event(pos + cache.offset, 0, 0, x_limit + cache.offset.width, mb->is_double_click(), root, mb->get_button_index(), mb);
blocked--;
if (pressing_for_editor) {
- pressing_pos = b->get_position();
+ pressing_pos = mb->get_position();
if (rtl) {
pressing_pos.x = get_size().width - pressing_pos.x;
}
}
- if (b->get_button_index() == MouseButton::RIGHT) {
+ if (mb->get_button_index() == MouseButton::RIGHT) {
break;
}
@@ -3442,8 +3502,8 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
set_physics_process_internal(true);
}
- if (b->get_button_index() == MouseButton::LEFT) {
- if (get_item_at_position(b->get_position()) == nullptr && !b->is_shift_pressed() && !b->is_ctrl_pressed() && !b->is_command_pressed()) {
+ if (mb->get_button_index() == MouseButton::LEFT) {
+ if (get_item_at_position(mb->get_position()) == nullptr && !mb->is_shift_pressed() && !mb->is_ctrl_pressed() && !mb->is_command_pressed()) {
emit_signal(SNAME("nothing_selected"));
}
}
@@ -3457,7 +3517,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
} break;
case MouseButton::WHEEL_UP: {
double prev_value = v_scroll->get_value();
- v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * b->get_factor() / 8);
+ v_scroll->set_value(v_scroll->get_value() - v_scroll->get_page() * mb->get_factor() / 8);
if (v_scroll->get_value() != prev_value) {
accept_event();
}
@@ -3465,7 +3525,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
} break;
case MouseButton::WHEEL_DOWN: {
double prev_value = v_scroll->get_value();
- v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * b->get_factor() / 8);
+ v_scroll->set_value(v_scroll->get_value() + v_scroll->get_page() * mb->get_factor() / 8);
if (v_scroll->get_value() != prev_value) {
accept_event();
}
@@ -3911,16 +3971,16 @@ TreeItem *Tree::get_last_item() const {
return last;
}
-void Tree::item_edited(int p_column, TreeItem *p_item, bool p_lmb) {
+void Tree::item_edited(int p_column, TreeItem *p_item, MouseButton p_mouse_index) {
edited_item = p_item;
edited_col = p_column;
if (p_item != nullptr && p_column >= 0 && p_column < p_item->cells.size()) {
edited_item->cells.write[p_column].dirty = true;
}
- if (p_lmb) {
+ if (p_mouse_index == MouseButton::NONE) {
emit_signal(SNAME("item_edited"));
} else {
- emit_signal(SNAME("item_rmb_edited"));
+ emit_signal(SNAME("custom_item_clicked"), p_mouse_index);
}
}
@@ -4147,7 +4207,7 @@ int Tree::get_column_minimum_width(int p_column) const {
depth += 1;
} else {
TreeItem *common_parent = item->get_parent();
- while (common_parent != next->get_parent()) {
+ while (common_parent != next->get_parent() && common_parent) {
common_parent = common_parent->get_parent();
depth -= 1;
}
@@ -4464,7 +4524,7 @@ Point2 Tree::get_scroll() const {
}
void Tree::scroll_to_item(TreeItem *p_item, bool p_center_on_item) {
- if (!is_visible_in_tree()) {
+ if (!is_visible_in_tree() || !p_item->is_visible()) {
return; // Hack to work around crash in get_item_rect() if Tree is not in tree.
}
@@ -4588,7 +4648,7 @@ void Tree::_do_incr_search(const String &p_add) {
TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_column, int &h, int &section) const {
Point2 pos = p_pos;
- if (root != p_item || !hide_root) {
+ if ((root != p_item || !hide_root) && p_item->is_visible()) {
h = compute_item_height(p_item) + cache.vseparation;
if (pos.y < h) {
if (drop_mode_flags == DROP_MODE_ON_ITEM) {
@@ -4621,7 +4681,7 @@ TreeItem *Tree::_find_item_at_pos(TreeItem *p_item, const Point2 &p_pos, int &r_
h = 0;
}
- if (p_item->is_collapsed()) {
+ if (p_item->is_collapsed() || !p_item->is_visible()) {
return nullptr; // do not try children, it's collapsed
}
@@ -4965,17 +5025,15 @@ void Tree::_bind_methods() {
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
ADD_SIGNAL(MethodInfo("multi_selected", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::BOOL, "selected")));
- ADD_SIGNAL(MethodInfo("item_rmb_selected", PropertyInfo(Variant::VECTOR2, "position")));
- ADD_SIGNAL(MethodInfo("empty_rmb", PropertyInfo(Variant::VECTOR2, "position")));
- ADD_SIGNAL(MethodInfo("empty_tree_rmb_selected", PropertyInfo(Variant::VECTOR2, "position")));
+ ADD_SIGNAL(MethodInfo("item_mouse_selected", PropertyInfo(Variant::VECTOR2, "position"), PropertyInfo(Variant::INT, "mouse_button_index")));
+ ADD_SIGNAL(MethodInfo("empty_clicked", PropertyInfo(Variant::VECTOR2, "position"), PropertyInfo(Variant::INT, "mouse_button_index")));
ADD_SIGNAL(MethodInfo("item_edited"));
- ADD_SIGNAL(MethodInfo("item_rmb_edited"));
+ ADD_SIGNAL(MethodInfo("custom_item_clicked", PropertyInfo(Variant::INT, "mouse_button_index")));
ADD_SIGNAL(MethodInfo("item_custom_button_pressed"));
ADD_SIGNAL(MethodInfo("item_double_clicked"));
ADD_SIGNAL(MethodInfo("item_collapsed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem")));
ADD_SIGNAL(MethodInfo("check_propagated_to_item", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column")));
- //ADD_SIGNAL( MethodInfo("item_double_clicked" ) );
- ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id")));
+ ADD_SIGNAL(MethodInfo("button_clicked", PropertyInfo(Variant::OBJECT, "item", PROPERTY_HINT_RESOURCE_TYPE, "TreeItem"), PropertyInfo(Variant::INT, "column"), PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "mouse_button_index")));
ADD_SIGNAL(MethodInfo("custom_popup_edited", PropertyInfo(Variant::BOOL, "arrow_clicked")));
ADD_SIGNAL(MethodInfo("item_activated"));
ADD_SIGNAL(MethodInfo("column_title_pressed", PropertyInfo(Variant::INT, "column")));
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 8ee2a3c382..a70f24cb62 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -124,6 +124,7 @@ private:
Vector<Cell> cells;
bool collapsed = false; // won't show children
+ bool visible = true;
bool disable_folding = false;
int custom_min_height = 0;
@@ -209,6 +210,9 @@ private:
void _propagate_check_through_children(int p_column, bool p_checked, bool p_emit_signal);
void _propagate_check_through_parents(int p_column, bool p_emit_signal);
+ TreeItem *_get_prev_visible(bool p_wrap = false);
+ TreeItem *_get_next_visible(bool p_wrap = false);
+
public:
void set_text(int p_column, String p_text);
String get_text(int p_column) const;
@@ -273,6 +277,9 @@ public:
void set_collapsed(bool p_collapsed);
bool is_collapsed();
+ void set_visible(bool p_visible);
+ bool is_visible();
+
void uncollapse_tree();
void set_custom_minimum_height(int p_height);
@@ -335,6 +342,7 @@ public:
TreeItem *get_next_visible(bool p_wrap = false);
TreeItem *get_child(int p_idx);
+ int get_visible_child_count();
int get_child_count();
Array get_children();
int get_index();
@@ -466,7 +474,7 @@ private:
void _notification(int p_what);
- void item_edited(int p_column, TreeItem *p_item, bool p_lmb = true);
+ void item_edited(int p_column, TreeItem *p_item, MouseButton p_mouse_index = MouseButton::NONE);
void item_changed(int p_column, TreeItem *p_item);
void item_selected(int p_column, TreeItem *p_item);
void item_deselected(int p_column, TreeItem *p_item);
diff --git a/scene/resources/animation_library.cpp b/scene/resources/animation_library.cpp
index 2a581fb126..361bfd0cb3 100644
--- a/scene/resources/animation_library.cpp
+++ b/scene/resources/animation_library.cpp
@@ -63,7 +63,7 @@ Error AnimationLibrary::add_animation(const StringName &p_name, const Ref<Animat
}
void AnimationLibrary::remove_animation(const StringName &p_name) {
- ERR_FAIL_COND(!animations.has(p_name));
+ ERR_FAIL_COND_MSG(!animations.has(p_name), vformat("Animation not found: %s.", p_name));
animations.erase(p_name);
emit_signal(SNAME("animation_removed"), p_name);
@@ -71,9 +71,9 @@ void AnimationLibrary::remove_animation(const StringName &p_name) {
}
void AnimationLibrary::rename_animation(const StringName &p_name, const StringName &p_new_name) {
- ERR_FAIL_COND(!animations.has(p_name));
+ ERR_FAIL_COND_MSG(!animations.has(p_name), vformat("Animation not found: %s.", p_name));
ERR_FAIL_COND_MSG(!is_valid_animation_name(p_new_name), "Invalid animation name: '" + String(p_new_name) + "'.");
- ERR_FAIL_COND(animations.has(p_new_name));
+ ERR_FAIL_COND_MSG(animations.has(p_new_name), vformat("Animation name \"%s\" already exists in library.", p_new_name));
animations.insert(p_new_name, animations[p_name]);
animations.erase(p_name);