graph_element.h 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**************************************************************************/
  2. /* graph_element.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 GRAPH_ELEMENT_H
  31. #define GRAPH_ELEMENT_H
  32. #include "scene/gui/container.h"
  33. class GraphElement : public Container {
  34. GDCLASS(GraphElement, Container);
  35. protected:
  36. bool selected = false;
  37. bool resizable = false;
  38. bool resizing = false;
  39. bool draggable = true;
  40. bool selectable = true;
  41. Vector2 drag_from;
  42. Vector2 resizing_from;
  43. Vector2 resizing_from_size;
  44. Vector2 position_offset;
  45. struct ThemeCache {
  46. Ref<Texture2D> resizer;
  47. } theme_cache;
  48. #ifdef TOOLS_ENABLED
  49. void _edit_set_position(const Point2 &p_position) override;
  50. #endif
  51. protected:
  52. virtual void gui_input(const Ref<InputEvent> &p_ev) override;
  53. void _notification(int p_what);
  54. static void _bind_methods();
  55. virtual void _resort();
  56. void _validate_property(PropertyInfo &p_property) const;
  57. public:
  58. void set_position_offset(const Vector2 &p_offset);
  59. Vector2 get_position_offset() const;
  60. void set_selected(bool p_selected);
  61. bool is_selected();
  62. void set_drag(bool p_drag);
  63. Vector2 get_drag_from();
  64. void set_resizable(bool p_enable);
  65. bool is_resizable() const;
  66. void set_draggable(bool p_draggable);
  67. bool is_draggable();
  68. void set_selectable(bool p_selectable);
  69. bool is_selectable();
  70. virtual Size2 get_minimum_size() const override;
  71. bool is_resizing() const {
  72. return resizing;
  73. }
  74. GraphElement() {}
  75. };
  76. #endif // GRAPH_ELEMENT_H