style_box_flat.h 4.5 KB

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