Browse Source

Make OpenXRActionMapEditor into EditorDock

kobewi 2 weeks ago
parent
commit
0932e8d4b7

+ 1 - 0
editor/icons/OpenXRActionMap.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="16" height="16"><path fill="#e0e0e0" d="M4 12v1c0 .552285.4477153 1 1 1-.5522847 0-1 .447715-1 1v1h1v-1h1v1H7V15C7 14.447715 6.5522847 14 6 14 6.5522847 14 7 13.552285 7 13V12H6v1H5v-1zm5 0v4h1v-1h1v1h1v-1c-.000919-.175812-.04817-.348275-.137-.5.08883-.151725.136081-.324188.137-.5v-1c0-.552285-.447715-1-1-1zm1 1h1v1h-1zM4.55 0A.85.85 0 0 0 3.7.85V8.5a.85.85 0 0 0 .85.85h6.8A.85.85 0 0 0 12.2 8.5V.85A.85.85 0 0 0 11.35 0ZM8.5 1.2 8.782 2.329 9.127 2.469 10.121 1.872 10.828 2.579 10.23 3.576 10.373 3.918 11.5 4.2v1L10.371 5.482 10.231 5.826 10.828 6.821 10.121 7.528 9.124 6.93 8.781 7.073 8.501 8.2h-1L7.218 7.07 6.874 6.931 5.879 7.528 5.172 6.821 5.77 5.824 5.627 5.481 4.5 5.2v-1L5.63 3.918 5.769 3.574 5.172 2.579 5.879 1.872 6.876 2.47 7.219 2.327 7.5 1.2Z"/><circle cx="8" cy="4.675" r="1" fill="#e0e0e0"/><path fill="#e0e0e0" d="m 2,1.36 v 7.65 a 1.7,1.7 0 0 0 1.7,1.7 h 8.5 a 1.7,1.7 0 0 0 1.7,-1.7 V 1.36 H 13.05 V 9.01 A 0.85,0.85 0 0 1 12.2,9.86 H 3.7 A 0.85,0.85 0 0 1 2.85,9.01 V 1.36 Z"/></svg>

+ 14 - 5
modules/openxr/editor/openxr_action_map_editor.cpp

@@ -33,8 +33,8 @@
 #include "core/config/project_settings.h"
 #include "core/config/project_settings.h"
 #include "core/io/dir_access.h"
 #include "core/io/dir_access.h"
 #include "editor/editor_node.h"
 #include "editor/editor_node.h"
-#include "editor/gui/editor_bottom_panel.h"
 #include "editor/gui/editor_file_dialog.h"
 #include "editor/gui/editor_file_dialog.h"
+#include "editor/settings/editor_command_palette.h"
 #include "editor/themes/editor_scale.h"
 #include "editor/themes/editor_scale.h"
 
 
 HashMap<String, String> OpenXRActionMapEditor::interaction_profile_editors;
 HashMap<String, String> OpenXRActionMapEditor::interaction_profile_editors;
@@ -384,7 +384,7 @@ void OpenXRActionMapEditor::_do_remove_interaction_profile_editor(OpenXRInteract
 }
 }
 
 
 void OpenXRActionMapEditor::open_action_map(const String &p_path) {
 void OpenXRActionMapEditor::open_action_map(const String &p_path) {
-	EditorNode::get_bottom_panel()->make_item_visible(this);
+	make_visible();
 
 
 	// out with the old...
 	// out with the old...
 	_clear_action_map();
 	_clear_action_map();
@@ -430,11 +430,20 @@ String OpenXRActionMapEditor::get_binding_modifier_editor_class(const String &p_
 }
 }
 
 
 OpenXRActionMapEditor::OpenXRActionMapEditor() {
 OpenXRActionMapEditor::OpenXRActionMapEditor() {
-	undo_redo = EditorUndoRedoManager::get_singleton();
+	set_name(TTRC("OpenXR Action Map"));
+	set_icon_name("OpenXRActionMap");
+	set_dock_shortcut(ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_openxr_action_map_bottom_panel", TTRC("Toggle OpenXR Action Map Dock")));
+	set_default_slot(DockConstants::DOCK_SLOT_BOTTOM);
+	set_available_layouts(EditorDock::DOCK_LAYOUT_HORIZONTAL | EditorDock::DOCK_LAYOUT_FLOATING);
 	set_custom_minimum_size(Size2(0.0, 300.0 * EDSCALE));
 	set_custom_minimum_size(Size2(0.0, 300.0 * EDSCALE));
 
 
+	undo_redo = EditorUndoRedoManager::get_singleton();
+
+	VBoxContainer *main_vb = memnew(VBoxContainer);
+	add_child(main_vb);
+
 	top_hb = memnew(HBoxContainer);
 	top_hb = memnew(HBoxContainer);
-	add_child(top_hb);
+	main_vb->add_child(top_hb);
 
 
 	header_label = memnew(Label);
 	header_label = memnew(Label);
 	header_label->set_text(String(TTR("Action Map")));
 	header_label->set_text(String(TTR("Action Map")));
@@ -475,7 +484,7 @@ OpenXRActionMapEditor::OpenXRActionMapEditor() {
 	tabs->set_theme_type_variation("TabContainerOdd");
 	tabs->set_theme_type_variation("TabContainerOdd");
 	tabs->connect("tab_changed", callable_mp(this, &OpenXRActionMapEditor::_on_tabs_tab_changed));
 	tabs->connect("tab_changed", callable_mp(this, &OpenXRActionMapEditor::_on_tabs_tab_changed));
 	tabs->connect("tab_button_pressed", callable_mp(this, &OpenXRActionMapEditor::_on_tab_button_pressed));
 	tabs->connect("tab_button_pressed", callable_mp(this, &OpenXRActionMapEditor::_on_tab_button_pressed));
-	add_child(tabs);
+	main_vb->add_child(tabs);
 
 
 	actionsets_scroll = memnew(ScrollContainer);
 	actionsets_scroll = memnew(ScrollContainer);
 	actionsets_scroll->set_h_size_flags(SIZE_EXPAND_FILL);
 	actionsets_scroll->set_h_size_flags(SIZE_EXPAND_FILL);

+ 3 - 2
modules/openxr/editor/openxr_action_map_editor.h

@@ -36,6 +36,7 @@
 #include "openxr_select_interaction_profile_dialog.h"
 #include "openxr_select_interaction_profile_dialog.h"
 
 
 #include "core/templates/hash_map.h"
 #include "core/templates/hash_map.h"
+#include "editor/docks/editor_dock.h"
 #include "editor/editor_undo_redo_manager.h"
 #include "editor/editor_undo_redo_manager.h"
 #include "editor/plugins/editor_plugin.h"
 #include "editor/plugins/editor_plugin.h"
 #include "scene/gui/box_container.h"
 #include "scene/gui/box_container.h"
@@ -44,8 +45,8 @@
 #include "scene/gui/scroll_container.h"
 #include "scene/gui/scroll_container.h"
 #include "scene/gui/tab_container.h"
 #include "scene/gui/tab_container.h"
 
 
-class OpenXRActionMapEditor : public VBoxContainer {
-	GDCLASS(OpenXRActionMapEditor, VBoxContainer);
+class OpenXRActionMapEditor : public EditorDock {
+	GDCLASS(OpenXRActionMapEditor, EditorDock);
 
 
 private:
 private:
 	static HashMap<String, String> interaction_profile_editors; // interaction profile path, interaction profile editor
 	static HashMap<String, String> interaction_profile_editors; // interaction profile path, interaction profile editor

+ 2 - 3
modules/openxr/editor/openxr_editor_plugin.cpp

@@ -33,9 +33,8 @@
 #include "../action_map/openxr_action_map.h"
 #include "../action_map/openxr_action_map.h"
 #include "../openxr_api.h"
 #include "../openxr_api.h"
 
 
+#include "editor/docks/editor_dock_manager.h"
 #include "editor/editor_node.h"
 #include "editor/editor_node.h"
-#include "editor/gui/editor_bottom_panel.h"
-#include "editor/settings/editor_command_palette.h"
 #include "platform/android/export/export_plugin.h"
 #include "platform/android/export/export_plugin.h"
 
 
 #include <openxr/openxr.h>
 #include <openxr/openxr.h>
@@ -176,7 +175,7 @@ OpenXREditorPlugin::OpenXREditorPlugin() {
 	// Only add our OpenXR action map editor if OpenXR is enabled for the whole project.
 	// Only add our OpenXR action map editor if OpenXR is enabled for the whole project.
 	if (OpenXRAPI::openxr_is_enabled(false)) {
 	if (OpenXRAPI::openxr_is_enabled(false)) {
 		action_map_editor = memnew(OpenXRActionMapEditor);
 		action_map_editor = memnew(OpenXRActionMapEditor);
-		EditorNode::get_bottom_panel()->add_item(TTRC("OpenXR Action Map"), action_map_editor, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_openxr_action_map_bottom_panel", TTRC("Toggle OpenXR Action Map Bottom Panel")));
+		EditorDockManager::get_singleton()->add_dock(action_map_editor);
 
 
 		binding_modifier_inspector_plugin = Ref<EditorInspectorPluginBindingModifier>(memnew(EditorInspectorPluginBindingModifier));
 		binding_modifier_inspector_plugin = Ref<EditorInspectorPluginBindingModifier>(memnew(EditorInspectorPluginBindingModifier));
 		EditorInspector::add_inspector_plugin(binding_modifier_inspector_plugin);
 		EditorInspector::add_inspector_plugin(binding_modifier_inspector_plugin);