style_box_flat.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**************************************************************************/
  2. /* style_box_flat.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 STYLE_BOX_FLAT_H
  31. #define STYLE_BOX_FLAT_H
  32. #include "scene/resources/style_box.h"
  33. class StyleBoxFlat : public StyleBox {
  34. GDCLASS(StyleBoxFlat, StyleBox);
  35. Color bg_color = Color(0.6, 0.6, 0.6);
  36. Color shadow_color = Color(0, 0, 0, 0.6);
  37. Color border_color = Color(0.8, 0.8, 0.8);
  38. real_t border_width[4] = {};
  39. real_t expand_margin[4] = {};
  40. real_t corner_radius[4] = {};
  41. bool draw_center = true;
  42. bool blend_border = false;
  43. Vector2 skew;
  44. bool anti_aliased = true;
  45. int corner_detail = 8;
  46. int shadow_size = 0;
  47. Point2 shadow_offset;
  48. real_t aa_size = 1;
  49. protected:
  50. virtual float get_style_margin(Side p_side) const override;
  51. static void _bind_methods();
  52. void _validate_property(PropertyInfo &p_property) const;
  53. public:
  54. void set_bg_color(const Color &p_color);
  55. Color get_bg_color() const;
  56. void set_border_color(const Color &p_color);
  57. Color get_border_color() const;
  58. void set_border_width_all(int p_size);
  59. int get_border_width_min() const;
  60. void set_border_width(Side p_side, int p_width);
  61. int get_border_width(Side p_side) const;
  62. void set_border_blend(bool p_blend);
  63. bool get_border_blend() const;
  64. void set_corner_radius_all(int radius);
  65. void set_corner_radius_individual(const int radius_top_left, const int radius_top_right, const int radius_bottom_right, const int radius_bottom_left);
  66. void set_corner_radius(Corner p_corner, const int radius);
  67. int get_corner_radius(Corner p_corner) const;
  68. void set_corner_detail(const int &p_corner_detail);
  69. int get_corner_detail() const;
  70. void set_expand_margin(Side p_expand_side, float p_size);
  71. void set_expand_margin_all(float p_expand_margin_size);
  72. void set_expand_margin_individual(float p_left, float p_top, float p_right, float p_bottom);
  73. float get_expand_margin(Side p_expand_side) const;
  74. void set_draw_center(bool p_enabled);
  75. bool is_draw_center_enabled() const;
  76. void set_skew(Vector2 p_skew);
  77. Vector2 get_skew() const;
  78. void set_shadow_color(const Color &p_color);
  79. Color get_shadow_color() const;
  80. void set_shadow_size(const int &p_size);
  81. int get_shadow_size() const;
  82. void set_shadow_offset(const Point2 &p_offset);
  83. Point2 get_shadow_offset() const;
  84. void set_anti_aliased(const bool &p_anti_aliased);
  85. bool is_anti_aliased() const;
  86. void set_aa_size(const real_t p_aa_size);
  87. real_t get_aa_size() const;
  88. virtual Rect2 get_draw_rect(const Rect2 &p_rect) const override;
  89. virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override;
  90. StyleBoxFlat();
  91. ~StyleBoxFlat();
  92. };
  93. #endif // STYLE_BOX_FLAT_H