touch_actions_panel.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**************************************************************************/
  2. /* touch_actions_panel.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. #pragma once
  31. #include "scene/gui/panel_container.h"
  32. class BoxContainer;
  33. class Button;
  34. class TextureRect;
  35. class TouchActionsPanel : public PanelContainer {
  36. GDCLASS(TouchActionsPanel, PanelContainer);
  37. private:
  38. BoxContainer *box = nullptr;
  39. Button *save_button = nullptr;
  40. Button *delete_button = nullptr;
  41. Button *undo_button = nullptr;
  42. Button *redo_button = nullptr;
  43. Button *cut_button = nullptr;
  44. Button *copy_button = nullptr;
  45. Button *paste_button = nullptr;
  46. TextureRect *drag_handle = nullptr;
  47. Button *layout_toggle_button = nullptr;
  48. Button *lock_panel_button = nullptr;
  49. Button *panel_pos_button = nullptr;
  50. bool locked_panel = false;
  51. bool dragging = false;
  52. Vector2 drag_offset;
  53. enum Modifier {
  54. MODIFIER_CTRL,
  55. MODIFIER_SHIFT,
  56. MODIFIER_ALT
  57. };
  58. bool ctrl_btn_pressed = false;
  59. bool shift_btn_pressed = false;
  60. bool alt_btn_pressed = false;
  61. bool is_floating = false; // Embedded panel mode is default.
  62. int embedded_panel_index = 0;
  63. void _notification(int p_what);
  64. virtual void input(const Ref<InputEvent> &event) override;
  65. void _simulate_editor_shortcut(const String &p_shortcut_name);
  66. void _simulate_key_press(Key p_keycode);
  67. void _on_drag_handle_gui_input(const Ref<InputEvent> &p_event);
  68. void _switch_layout();
  69. void _lock_panel_toggled(bool p_pressed);
  70. void _switch_embedded_panel_side();
  71. Button *_add_new_action_button(const String &p_shortcut, const String &p_name, Key p_keycode = Key::NONE);
  72. void _add_new_modifier_button(Modifier p_modifier);
  73. void _on_modifier_button_toggled(bool p_pressed, int p_modifier);
  74. void _hardware_keyboard_connected(bool p_connected);
  75. public:
  76. TouchActionsPanel();
  77. };