graph_frame.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /**************************************************************************/
  2. /* graph_frame.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_FRAME_H
  31. #define GRAPH_FRAME_H
  32. #include "scene/gui/graph_element.h"
  33. class HBoxContainer;
  34. class GraphFrame : public GraphElement {
  35. GDCLASS(GraphFrame, GraphElement);
  36. struct _MinSizeCache {
  37. int min_size = 0;
  38. bool will_stretch = false;
  39. int final_size = 0;
  40. };
  41. struct ThemeCache {
  42. Ref<StyleBox> panel;
  43. Ref<StyleBox> panel_selected;
  44. Ref<StyleBox> titlebar;
  45. Ref<StyleBox> titlebar_selected;
  46. Ref<Texture2D> resizer;
  47. Color resizer_color;
  48. } theme_cache;
  49. private:
  50. String title;
  51. HBoxContainer *titlebar_hbox = nullptr;
  52. Label *title_label = nullptr;
  53. bool autoshrink_enabled = true;
  54. int autoshrink_margin = 40;
  55. int drag_margin = 16;
  56. bool tint_color_enabled = false;
  57. Color tint_color = Color(0.3, 0.3, 0.3, 0.75);
  58. protected:
  59. virtual void gui_input(const Ref<InputEvent> &p_event) override;
  60. virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const override;
  61. void _notification(int p_what);
  62. static void _bind_methods();
  63. void _validate_property(PropertyInfo &p_property) const;
  64. virtual void _resort() override;
  65. public:
  66. void set_title(const String &p_title);
  67. String get_title() const;
  68. void set_autoshrink_enabled(bool p_enable);
  69. bool is_autoshrink_enabled() const;
  70. void set_autoshrink_margin(const int &p_margin);
  71. int get_autoshrink_margin() const;
  72. HBoxContainer *get_titlebar_hbox();
  73. Size2 get_titlebar_size() const;
  74. void set_drag_margin(int p_margin);
  75. int get_drag_margin() const;
  76. void set_tint_color_enabled(bool p_enable);
  77. bool is_tint_color_enabled() const;
  78. void set_tint_color(const Color &p_tint_color);
  79. Color get_tint_color() const;
  80. virtual bool has_point(const Point2 &p_point) const override;
  81. virtual Size2 get_minimum_size() const override;
  82. GraphFrame();
  83. };
  84. #endif // GRAPH_FRAME_H