openxr_action_map_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef OPENXR_ACTION_MAP_EDITOR_H
  31. #define OPENXR_ACTION_MAP_EDITOR_H
  32. #include "../action_map/openxr_action_map.h"
  33. #include "openxr_action_set_editor.h"
  34. #include "openxr_interaction_profile_editor.h"
  35. #include "openxr_select_interaction_profile_dialog.h"
  36. #include "editor/editor_undo_redo_manager.h"
  37. #include "editor/plugins/editor_plugin.h"
  38. #include "scene/gui/box_container.h"
  39. #include "scene/gui/button.h"
  40. #include "scene/gui/label.h"
  41. #include "scene/gui/scroll_container.h"
  42. #include "scene/gui/tab_container.h"
  43. class OpenXRActionMapEditor : public VBoxContainer {
  44. GDCLASS(OpenXRActionMapEditor, VBoxContainer);
  45. private:
  46. EditorUndoRedoManager *undo_redo;
  47. String edited_path;
  48. Ref<OpenXRActionMap> action_map;
  49. HBoxContainer *top_hb = nullptr;
  50. Label *header_label = nullptr;
  51. Button *add_action_set = nullptr;
  52. Button *add_interaction_profile = nullptr;
  53. Button *load = nullptr;
  54. Button *save_as = nullptr;
  55. Button *_default = nullptr;
  56. TabContainer *tabs = nullptr;
  57. ScrollContainer *actionsets_scroll = nullptr;
  58. VBoxContainer *actionsets_vb = nullptr;
  59. OpenXRSelectInteractionProfileDialog *select_interaction_profile_dialog = nullptr;
  60. OpenXRActionSetEditor *_add_action_set_editor(Ref<OpenXRActionSet> p_action_set);
  61. void _create_action_sets();
  62. OpenXRInteractionProfileEditorBase *_add_interaction_profile_editor(Ref<OpenXRInteractionProfile> p_interaction_profile);
  63. void _create_interaction_profiles();
  64. OpenXRActionSetEditor *_add_action_set(String p_name);
  65. void _remove_action_set(String p_name);
  66. void _on_add_action_set();
  67. void _set_focus_on_action_set(OpenXRActionSetEditor *p_action_set_editor);
  68. void _on_remove_action_set(Object *p_action_set_editor);
  69. void _on_action_removed(Ref<OpenXRAction> p_action);
  70. void _on_add_interaction_profile();
  71. void _on_interaction_profile_selected(const String p_path);
  72. void _load_action_map(const String p_path, bool p_create_new_if_missing = false);
  73. void _on_save_action_map();
  74. void _on_reset_to_default_layout();
  75. void _on_tabs_tab_changed(int p_tab);
  76. void _on_tab_button_pressed(int p_tab);
  77. protected:
  78. static void _bind_methods();
  79. void _notification(int p_what);
  80. void _clear_action_map();
  81. // used for undo/redo
  82. void _do_add_action_set_editor(OpenXRActionSetEditor *p_action_set_editor);
  83. void _do_remove_action_set_editor(OpenXRActionSetEditor *p_action_set_editor);
  84. void _do_add_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor);
  85. void _do_remove_interaction_profile_editor(OpenXRInteractionProfileEditorBase *p_interaction_profile_editor);
  86. public:
  87. void open_action_map(String p_path);
  88. OpenXRActionMapEditor();
  89. ~OpenXRActionMapEditor();
  90. };
  91. #endif // OPENXR_ACTION_MAP_EDITOR_H