1/**************************************************************************/
2/* openxr_action_map_editor.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef OPENXR_ACTION_MAP_EDITOR_H
32#define OPENXR_ACTION_MAP_EDITOR_H
33
34#include "../action_map/openxr_action_map.h"
35#include "openxr_action_set_editor.h"
36#include "openxr_interaction_profile_editor.h"
37#include "openxr_select_interaction_profile_dialog.h"
38
39#include "editor/editor_plugin.h"
40#include "editor/editor_undo_redo_manager.h"
41#include "scene/gui/box_container.h"
42#include "scene/gui/button.h"
43#include "scene/gui/label.h"
44#include "scene/gui/scroll_container.h"
45#include "scene/gui/tab_container.h"
46
47class OpenXRActionMapEditor : public VBoxContainer {
48 GDCLASS(OpenXRActionMapEditor, VBoxContainer);
49
50private:
51 EditorUndoRedoManager *undo_redo;
52 String edited_path;
53 Ref<OpenXRActionMap> action_map;
54
55 HBoxContainer *top_hb = nullptr;
56 Label *header_label = nullptr;
57 Button *add_action_set = nullptr;
58 Button *add_interaction_profile = nullptr;
59 Button *load = nullptr;
60 Button *save_as = nullptr;
61 Button *_default = nullptr;
62 TabContainer *tabs = nullptr;
63 ScrollContainer *actionsets_scroll = nullptr;
64 VBoxContainer *actionsets_vb = nullptr;
65 OpenXRSelectInteractionProfileDialog *select_interaction_profile_dialog = nullptr;
66
67 OpenXRActionSetEditor *_add_action_set_editor(Ref<OpenXRActionSet> p_action_set);
68 void _create_action_sets();
69 OpenXRInteractionProfileEditorBase *_add_interaction_profile_editor(Ref<OpenXRInteractionProfile> p_interaction_profile);
70 void _create_interaction_profiles();
71
72 OpenXRActionSetEditor *_add_action_set(String p_name);
73 void _remove_action_set(String p_name);
74
75 void _on_add_action_set();
76 void _set_focus_on_action_set(OpenXRActionSetEditor *p_action_set_editor);
77 void _on_remove_action_set(Object *p_action_set_editor);
78 void _on_action_removed(Ref<OpenXRAction> p_action);
79
80 void _on_add_interaction_profile();
81 void _on_interaction_profile_selected(const String p_path);
82
83 void _load_action_map(const String p_path, bool p_create_new_if_missing = false);
84 void _on_save_action_map();
85 void _on_reset_to_default_layout();
86
87 void _on_tabs_tab_changed(int p_tab);
88 void _on_tab_button_pressed(int p_tab);
89
90protected:
91 static void _bind_methods();
92 void _notification(int p_what);
93
94 void _clear_action_map();
95
96 // used for undo/redo
97 void _do_add_action_set_editor(OpenXRActionSetEditor *p_action_set_editor);
98 void _do_remove_action_set_editor(OpenXRActionSetEditor *p_action_set_editor);
99 void _do_add_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor);
100 void _do_remove_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor);
101
102public:
103 void open_action_map(String p_path);
104
105 OpenXRActionMapEditor();
106 ~OpenXRActionMapEditor();
107};
108
109#endif // OPENXR_ACTION_MAP_EDITOR_H
110