Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/modules/openxr/editor/openxr_interaction_profile_editor.h
10278 views
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
#pragma once
32
33
#include "../action_map/openxr_action_map.h"
34
#include "../action_map/openxr_interaction_profile.h"
35
#include "../action_map/openxr_interaction_profile_metadata.h"
36
#include "../editor/openxr_binding_modifiers_dialog.h"
37
#include "editor/editor_undo_redo_manager.h"
38
#include "openxr_select_action_dialog.h"
39
#include "scene/gui/box_container.h"
40
#include "scene/gui/button.h"
41
42
class OpenXRInteractionProfileEditorBase : public HBoxContainer {
43
GDCLASS(OpenXRInteractionProfileEditorBase, HBoxContainer);
44
45
private:
46
OpenXRBindingModifiersDialog *binding_modifiers_dialog = nullptr;
47
VBoxContainer *toolbar_vb = nullptr;
48
Button *binding_modifiers_btn = nullptr;
49
50
void _on_open_binding_modifiers();
51
52
protected:
53
EditorUndoRedoManager *undo_redo;
54
Ref<OpenXRInteractionProfile> interaction_profile;
55
Ref<OpenXRActionMap> action_map;
56
57
ScrollContainer *interaction_profile_sc = nullptr;
58
59
bool is_dirty = false;
60
61
static void _bind_methods();
62
void _notification(int p_what);
63
64
const OpenXRInteractionProfileMetadata::InteractionProfile *profile_def = nullptr;
65
66
public:
67
String tooltip; // Tooltip text to show on tab
68
69
Ref<OpenXRInteractionProfile> get_interaction_profile() { return interaction_profile; }
70
71
virtual void _update_interaction_profile();
72
virtual void _theme_changed();
73
74
void _do_update_interaction_profile();
75
void _add_binding(const String p_action, const String p_path);
76
void _remove_binding(const String p_action, const String p_path);
77
78
void remove_all_for_action_set(Ref<OpenXRActionSet> p_action_set);
79
void remove_all_for_action(Ref<OpenXRAction> p_action);
80
81
virtual void setup(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile);
82
83
OpenXRInteractionProfileEditorBase();
84
};
85
86
class OpenXRInteractionProfileEditor : public OpenXRInteractionProfileEditorBase {
87
GDCLASS(OpenXRInteractionProfileEditor, OpenXRInteractionProfileEditorBase);
88
89
private:
90
String selecting_for_io_path;
91
HBoxContainer *interaction_profile_hb = nullptr;
92
93
OpenXRSelectActionDialog *select_action_dialog = nullptr;
94
95
void _add_io_path(VBoxContainer *p_container, const OpenXRInteractionProfileMetadata::IOPath *p_io_path);
96
97
public:
98
void select_action_for(const String p_io_path);
99
void _on_action_selected(const String p_action);
100
void _on_remove_pressed(const String p_action, const String p_for_io_path);
101
102
virtual void _update_interaction_profile() override;
103
virtual void _theme_changed() override;
104
virtual void setup(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile) override;
105
106
OpenXRInteractionProfileEditor();
107
};
108
109