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