openxr_interaction_profile_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #ifndef OPENXR_INTERACTION_PROFILE_EDITOR_H
  31. #define OPENXR_INTERACTION_PROFILE_EDITOR_H
  32. #include "../action_map/openxr_action_map.h"
  33. #include "../action_map/openxr_interaction_profile.h"
  34. #include "../action_map/openxr_interaction_profile_metadata.h"
  35. #include "../editor/openxr_binding_modifiers_dialog.h"
  36. #include "editor/editor_undo_redo_manager.h"
  37. #include "openxr_select_action_dialog.h"
  38. #include "scene/gui/box_container.h"
  39. #include "scene/gui/button.h"
  40. class OpenXRInteractionProfileEditorBase : public HBoxContainer {
  41. GDCLASS(OpenXRInteractionProfileEditorBase, HBoxContainer);
  42. private:
  43. OpenXRBindingModifiersDialog *binding_modifiers_dialog = nullptr;
  44. VBoxContainer *toolbar_vb = nullptr;
  45. Button *binding_modifiers_btn = nullptr;
  46. void _on_open_binding_modifiers();
  47. protected:
  48. EditorUndoRedoManager *undo_redo;
  49. Ref<OpenXRInteractionProfile> interaction_profile;
  50. Ref<OpenXRActionMap> action_map;
  51. ScrollContainer *interaction_profile_sc = nullptr;
  52. bool is_dirty = false;
  53. static void _bind_methods();
  54. void _notification(int p_what);
  55. const OpenXRInteractionProfileMetadata::InteractionProfile *profile_def = nullptr;
  56. public:
  57. String tooltip; // Tooltip text to show on tab
  58. Ref<OpenXRInteractionProfile> get_interaction_profile() { return interaction_profile; }
  59. virtual void _update_interaction_profile();
  60. virtual void _theme_changed();
  61. void _do_update_interaction_profile();
  62. void _add_binding(const String p_action, const String p_path);
  63. void _remove_binding(const String p_action, const String p_path);
  64. void remove_all_for_action_set(Ref<OpenXRActionSet> p_action_set);
  65. void remove_all_for_action(Ref<OpenXRAction> p_action);
  66. virtual void setup(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile);
  67. OpenXRInteractionProfileEditorBase();
  68. };
  69. class OpenXRInteractionProfileEditor : public OpenXRInteractionProfileEditorBase {
  70. GDCLASS(OpenXRInteractionProfileEditor, OpenXRInteractionProfileEditorBase);
  71. private:
  72. String selecting_for_io_path;
  73. HBoxContainer *interaction_profile_hb = nullptr;
  74. OpenXRSelectActionDialog *select_action_dialog = nullptr;
  75. void _add_io_path(VBoxContainer *p_container, const OpenXRInteractionProfileMetadata::IOPath *p_io_path);
  76. public:
  77. void select_action_for(const String p_io_path);
  78. void _on_action_selected(const String p_action);
  79. void _on_remove_pressed(const String p_action, const String p_for_io_path);
  80. virtual void _update_interaction_profile() override;
  81. virtual void _theme_changed() override;
  82. virtual void setup(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile) override;
  83. OpenXRInteractionProfileEditor();
  84. };
  85. #endif // OPENXR_INTERACTION_PROFILE_EDITOR_H