1/**************************************************************************/
2/* openxr_interaction_profile_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_INTERACTION_PROFILE_EDITOR_H
32#define OPENXR_INTERACTION_PROFILE_EDITOR_H
33
34#include "../action_map/openxr_action_map.h"
35#include "../action_map/openxr_interaction_profile.h"
36#include "../action_map/openxr_interaction_profile_metadata.h"
37#include "openxr_select_action_dialog.h"
38
39#include "editor/editor_undo_redo_manager.h"
40#include "scene/gui/scroll_container.h"
41
42class OpenXRInteractionProfileEditorBase : public ScrollContainer {
43 GDCLASS(OpenXRInteractionProfileEditorBase, ScrollContainer);
44
45protected:
46 EditorUndoRedoManager *undo_redo;
47 Ref<OpenXRInteractionProfile> interaction_profile;
48 Ref<OpenXRActionMap> action_map;
49
50 bool is_dirty = false;
51
52 static void _bind_methods();
53 void _notification(int p_what);
54
55 const OpenXRInteractionProfileMetadata::InteractionProfile *profile_def = nullptr;
56
57public:
58 Ref<OpenXRInteractionProfile> get_interaction_profile() { return interaction_profile; }
59
60 virtual void _update_interaction_profile() {}
61 virtual void _theme_changed() {}
62
63 void _do_update_interaction_profile();
64 void _add_binding(const String p_action, const String p_path);
65 void _remove_binding(const String p_action, const String p_path);
66
67 void remove_all_bindings_for_action(Ref<OpenXRAction> p_action);
68
69 OpenXRInteractionProfileEditorBase(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile);
70};
71
72class OpenXRInteractionProfileEditor : public OpenXRInteractionProfileEditorBase {
73 GDCLASS(OpenXRInteractionProfileEditor, OpenXRInteractionProfileEditorBase);
74
75private:
76 String selecting_for_io_path;
77 HBoxContainer *main_hb = nullptr;
78 OpenXRSelectActionDialog *select_action_dialog = nullptr;
79
80 void _add_io_path(VBoxContainer *p_container, const OpenXRInteractionProfileMetadata::IOPath *p_io_path);
81
82public:
83 void select_action_for(const String p_io_path);
84 void action_selected(const String p_action);
85 void _on_remove_pressed(const String p_action, const String p_for_io_path);
86
87 virtual void _update_interaction_profile() override;
88 virtual void _theme_changed() override;
89 OpenXRInteractionProfileEditor(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile);
90};
91
92#endif // OPENXR_INTERACTION_PROFILE_EDITOR_H
93