Debian Codegraph @

scene/gui/texture_rect.h

raw symbols SCIP
1 /**************************************************************************/
2 /* texture_rect.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/gui/control.h"
34
35 class TextureRect : public Control {
36 GDCLASS(TextureRect, Control);
37
38 public:
39 enum ExpandMode {
40 EXPAND_KEEP_SIZE,
41 EXPAND_IGNORE_SIZE,
42 EXPAND_FIT_WIDTH,
43 EXPAND_FIT_WIDTH_PROPORTIONAL,
44 EXPAND_FIT_HEIGHT,
45 EXPAND_FIT_HEIGHT_PROPORTIONAL,
46 };
47
48 enum StretchMode {
49 STRETCH_SCALE,
50 STRETCH_TILE,
51 STRETCH_KEEP,
52 STRETCH_KEEP_CENTERED,
53 STRETCH_KEEP_ASPECT,
54 STRETCH_KEEP_ASPECT_CENTERED,
55 STRETCH_KEEP_ASPECT_COVERED,
56 };
57
58 private:
59 bool hflip = false;
60 bool vflip = false;
61 Ref<Texture2D> texture;
62 ExpandMode expand_mode = EXPAND_KEEP_SIZE;
63 StretchMode stretch_mode = STRETCH_SCALE;
64
65 void _texture_changed();
66
67 protected:
68 void _notification(int p_what);
69 virtual Size2 get_minimum_size() const override;
70 static void _bind_methods();
71 #ifndef DISABLE_DEPRECATED
72 bool _set(const StringName &p_name, const Variant &p_value);
73 #endif
74
75 public:
76 void set_texture(const Ref<Texture2D> &p_tex);
77 Ref<Texture2D> get_texture() const;
78
79 void set_expand_mode(ExpandMode p_mode);
80 ExpandMode get_expand_mode() const;
81
82 void set_stretch_mode(StretchMode p_mode);
83 StretchMode get_stretch_mode() const;
84
85 void set_flip_h(bool p_flip);
86 bool is_flipped_h() const;
87
88 void set_flip_v(bool p_flip);
89 bool is_flipped_v() const;
90
91 TextureRect();
92 ~TextureRect();
93 };
94
95 VARIANT_ENUM_CAST(TextureRect::ExpandMode);
96 VARIANT_ENUM_CAST(TextureRect::StretchMode);