openxr_binding_modifier_editor.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**************************************************************************/
  2. /* openxr_binding_modifier_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_BINDING_MODIFIER_EDITOR_H
  31. #define OPENXR_BINDING_MODIFIER_EDITOR_H
  32. #include "../action_map/openxr_action_map.h"
  33. #include "../action_map/openxr_action_set.h"
  34. #include "../action_map/openxr_binding_modifier.h"
  35. #include "editor/editor_inspector.h"
  36. #include "editor/editor_undo_redo_manager.h"
  37. #include "scene/gui/box_container.h"
  38. #include "scene/gui/button.h"
  39. #include "scene/gui/label.h"
  40. #include "scene/gui/panel_container.h"
  41. class EditorPropertyActionSet : public EditorProperty {
  42. GDCLASS(EditorPropertyActionSet, EditorProperty);
  43. OptionButton *options = nullptr;
  44. void _option_selected(int p_which);
  45. protected:
  46. virtual void _set_read_only(bool p_read_only) override;
  47. public:
  48. void setup(const Ref<OpenXRActionMap> &p_action_map);
  49. virtual void update_property() override;
  50. void set_option_button_clip(bool p_enable);
  51. EditorPropertyActionSet();
  52. };
  53. class EditorPropertyBindingPath : public EditorProperty {
  54. GDCLASS(EditorPropertyBindingPath, EditorProperty);
  55. OptionButton *options = nullptr;
  56. void _option_selected(int p_which);
  57. protected:
  58. virtual void _set_read_only(bool p_read_only) override;
  59. public:
  60. void setup(const String &p_interaction_profile_path, Vector<OpenXRAction::ActionType> p_include_action_types);
  61. virtual void update_property() override;
  62. void set_option_button_clip(bool p_enable);
  63. EditorPropertyBindingPath();
  64. };
  65. class EditorInspectorPluginBindingModifier : public EditorInspectorPlugin {
  66. GDCLASS(EditorInspectorPluginBindingModifier, EditorInspectorPlugin);
  67. public:
  68. virtual bool can_handle(Object *p_object) override;
  69. virtual bool parse_property(Object *p_object, const Variant::Type p_type, const String &p_path, const PropertyHint p_hint, const String &p_hint_text, const BitField<PropertyUsageFlags> p_usage, const bool p_wide) override;
  70. };
  71. class OpenXRBindingModifierEditor : public PanelContainer {
  72. GDCLASS(OpenXRBindingModifierEditor, PanelContainer);
  73. private:
  74. HBoxContainer *header_hb = nullptr;
  75. Label *binding_modifier_title = nullptr;
  76. Button *rem_binding_modifier_btn = nullptr;
  77. EditorInspector *editor_inspector = nullptr;
  78. protected:
  79. VBoxContainer *main_vb = nullptr;
  80. EditorUndoRedoManager *undo_redo;
  81. Ref<OpenXRBindingModifier> binding_modifier;
  82. Ref<OpenXRActionMap> action_map;
  83. static void _bind_methods();
  84. void _notification(int p_what);
  85. void _on_remove_binding_modifier();
  86. public:
  87. Ref<OpenXRBindingModifier> get_binding_modifier() const { return binding_modifier; }
  88. virtual void setup(Ref<OpenXRActionMap> p_action_map, Ref<OpenXRBindingModifier> p_binding_modifier);
  89. OpenXRBindingModifierEditor();
  90. };
  91. #endif // OPENXR_BINDING_MODIFIER_EDITOR_H