Debian Codegraph @

scene/resources/style_box_texture.h

raw symbols SCIP
1 /**************************************************************************/
2 /* style_box_texture.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 #pragma once
32
33 #include "scene/resources/style_box.h"
34 #include "scene/resources/texture.h"
35
36 class StyleBoxTexture : public StyleBox {
37 GDCLASS(StyleBoxTexture, StyleBox);
38
39 public:
40 enum AxisStretchMode {
41 AXIS_STRETCH_MODE_STRETCH,
42 AXIS_STRETCH_MODE_TILE,
43 AXIS_STRETCH_MODE_TILE_FIT,
44 };
45
46 private:
47 float expand_margin[4] = {};
48 float texture_margin[4] = {};
49 Rect2 region_rect;
50 Ref<Texture2D> texture;
51 bool draw_center = true;
52 Color modulate = Color(1, 1, 1, 1);
53 AxisStretchMode axis_h = AXIS_STRETCH_MODE_STRETCH;
54 AxisStretchMode axis_v = AXIS_STRETCH_MODE_STRETCH;
55
56 protected:
57 virtual float get_style_margin(Side p_side) const override;
58 static void _bind_methods();
59
60 public:
61 void set_texture(Ref<Texture2D> p_texture);
62 Ref<Texture2D> get_texture() const;
63
64 void set_texture_margin(Side p_side, float p_size);
65 void set_texture_margin_all(float p_size);
66 void set_texture_margin_individual(float p_left, float p_top, float p_right, float p_bottom);
67 float get_texture_margin(Side p_side) const;
68
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
74 void set_region_rect(const Rect2 &p_region_rect);
75 Rect2 get_region_rect() const;
76
77 void set_draw_center(bool p_enabled);
78 bool is_draw_center_enabled() const;
79
80 void set_h_axis_stretch_mode(AxisStretchMode p_mode);
81 AxisStretchMode get_h_axis_stretch_mode() const;
82
83 void set_v_axis_stretch_mode(AxisStretchMode p_mode);
84 AxisStretchMode get_v_axis_stretch_mode() const;
85
86 void set_modulate(const Color &p_modulate);
87 Color get_modulate() const;
88
89 virtual Rect2 get_draw_rect(const Rect2 &p_rect) const override;
90 virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const override;
91 };
92
93 VARIANT_ENUM_CAST(StyleBoxTexture::AxisStretchMode)