1/**************************************************************************/
2/* openxr_action_set_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_SET_EDITOR_H
32#define OPENXR_ACTION_SET_EDITOR_H
33
34#include "../action_map/openxr_action_map.h"
35#include "../action_map/openxr_action_set.h"
36#include "openxr_action_editor.h"
37
38#include "scene/gui/box_container.h"
39#include "scene/gui/button.h"
40#include "scene/gui/line_edit.h"
41#include "scene/gui/panel_container.h"
42#include "scene/gui/text_edit.h"
43
44class OpenXRActionSetEditor : public HBoxContainer {
45 GDCLASS(OpenXRActionSetEditor, HBoxContainer);
46
47private:
48 EditorUndoRedoManager *undo_redo;
49 Ref<OpenXRActionMap> action_map;
50 Ref<OpenXRActionSet> action_set;
51
52 bool is_expanded = true;
53
54 PanelContainer *panel = nullptr;
55 Button *fold_btn = nullptr;
56 VBoxContainer *main_vb = nullptr;
57 HBoxContainer *action_set_hb = nullptr;
58 LineEdit *action_set_name = nullptr;
59 LineEdit *action_set_localized_name = nullptr;
60 TextEdit *action_set_priority = nullptr;
61 Button *add_action = nullptr;
62 Button *rem_action_set = nullptr;
63 VBoxContainer *actions_vb = nullptr;
64
65 void _set_fold_icon();
66 void _theme_changed();
67 OpenXRActionEditor *_add_action_editor(Ref<OpenXRAction> p_action);
68
69 void _on_toggle_expand();
70 void _on_action_set_name_changed(const String p_new_text);
71 void _on_action_set_localized_name_changed(const String p_new_text);
72 void _on_action_set_priority_changed(const String p_new_text);
73 void _on_add_action();
74 void _on_remove_action_set();
75
76 void _on_remove_action(Object *p_action_editor);
77
78protected:
79 static void _bind_methods();
80 void _notification(int p_what);
81
82 // used for undo/redo
83 void _do_set_name(const String p_new_text);
84 void _do_set_localized_name(const String p_new_text);
85 void _do_set_priority(int64_t value);
86 void _do_add_action_editor(OpenXRActionEditor *p_action_editor);
87 void _do_remove_action_editor(OpenXRActionEditor *p_action_editor);
88
89public:
90 Ref<OpenXRActionSet> get_action_set() { return action_set; };
91 void set_focus_on_entry();
92
93 void remove_all_actions();
94
95 OpenXRActionSetEditor(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRActionSet> p_action_set);
96};
97
98#endif // OPENXR_ACTION_SET_EDITOR_H
99