openxr_interaction_profile_editor.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "openxr_select_action_dialog.h"
  36. #include "editor/editor_undo_redo_manager.h"
  37. #include "scene/gui/scroll_container.h"
  38. class OpenXRInteractionProfileEditorBase : public ScrollContainer {
  39. GDCLASS(OpenXRInteractionProfileEditorBase, ScrollContainer);
  40. protected:
  41. EditorUndoRedoManager *undo_redo;
  42. Ref<OpenXRInteractionProfile> interaction_profile;
  43. Ref<OpenXRActionMap> action_map;
  44. bool is_dirty = false;
  45. static void _bind_methods();
  46. void _notification(int p_what);
  47. const OpenXRInteractionProfileMetadata::InteractionProfile *profile_def = nullptr;
  48. public:
  49. Ref<OpenXRInteractionProfile> get_interaction_profile() { return interaction_profile; }
  50. virtual void _update_interaction_profile() {}
  51. virtual void _theme_changed() {}
  52. void _do_update_interaction_profile();
  53. void _add_binding(const String p_action, const String p_path);
  54. void _remove_binding(const String p_action, const String p_path);
  55. void remove_all_bindings_for_action(Ref<OpenXRAction> p_action);
  56. OpenXRInteractionProfileEditorBase(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile);
  57. };
  58. class OpenXRInteractionProfileEditor : public OpenXRInteractionProfileEditorBase {
  59. GDCLASS(OpenXRInteractionProfileEditor, OpenXRInteractionProfileEditorBase);
  60. private:
  61. String selecting_for_io_path;
  62. HBoxContainer *main_hb = nullptr;
  63. OpenXRSelectActionDialog *select_action_dialog = nullptr;
  64. void _add_io_path(VBoxContainer *p_container, const OpenXRInteractionProfileMetadata::IOPath *p_io_path);
  65. public:
  66. void select_action_for(const String p_io_path);
  67. void action_selected(const String p_action);
  68. void _on_remove_pressed(const String p_action, const String p_for_io_path);
  69. virtual void _update_interaction_profile() override;
  70. virtual void _theme_changed() override;
  71. OpenXRInteractionProfileEditor(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRInteractionProfile> p_interaction_profile);
  72. };
  73. #endif // OPENXR_INTERACTION_PROFILE_EDITOR_H