Debian Codegraph @

scene/gui/texture_button.h

raw symbols SCIP
1 /**************************************************************************/
2 /* texture_button.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/base_button.h"
34 #include "scene/resources/bit_map.h"
35 class TextureButton : public BaseButton {
36 GDCLASS(TextureButton, BaseButton);
37
38 public:
39 enum StretchMode {
40 STRETCH_SCALE,
41 STRETCH_TILE,
42 STRETCH_KEEP,
43 STRETCH_KEEP_CENTERED,
44 STRETCH_KEEP_ASPECT,
45 STRETCH_KEEP_ASPECT_CENTERED,
46 STRETCH_KEEP_ASPECT_COVERED,
47 };
48
49 private:
50 Ref<Texture2D> normal;
51 Ref<Texture2D> pressed;
52 Ref<Texture2D> hover;
53 Ref<Texture2D> disabled;
54 Ref<Texture2D> focused;
55 Ref<BitMap> click_mask;
56 bool ignore_texture_size = false;
57 StretchMode stretch_mode = STRETCH_KEEP;
58
59 Rect2 _texture_region;
60 Rect2 _position_rect;
61 bool _tile = false;
62
63 bool hflip = false;
64 bool vflip = false;
65
66 void _set_texture(Ref<Texture2D> *p_destination, const Ref<Texture2D> &p_texture);
67 void _texture_changed();
68
69 protected:
70 virtual Size2 get_minimum_size() const override;
71 virtual bool has_point(const Point2 &p_point) const override;
72 void _notification(int p_what);
73 static void _bind_methods();
74
75 public:
76 void set_texture_normal(const Ref<Texture2D> &p_normal);
77 void set_texture_pressed(const Ref<Texture2D> &p_pressed);
78 void set_texture_hover(const Ref<Texture2D> &p_hover);
79 void set_texture_disabled(const Ref<Texture2D> &p_disabled);
80 void set_texture_focused(const Ref<Texture2D> &p_focused);
81 void set_click_mask(const Ref<BitMap> &p_click_mask);
82
83 Ref<Texture2D> get_texture_normal() const;
84 Ref<Texture2D> get_texture_pressed() const;
85 Ref<Texture2D> get_texture_hover() const;
86 Ref<Texture2D> get_texture_disabled() const;
87 Ref<Texture2D> get_texture_focused() const;
88 Ref<BitMap> get_click_mask() const;
89
90 bool get_ignore_texture_size() const;
91 void set_ignore_texture_size(bool p_ignore);
92
93 void set_stretch_mode(StretchMode p_stretch_mode);
94 StretchMode get_stretch_mode() const;
95
96 void set_flip_h(bool p_flip);
97 bool is_flipped_h() const;
98
99 void set_flip_v(bool p_flip);
100 bool is_flipped_v() const;
101 };
102
103 VARIANT_ENUM_CAST(TextureButton::StretchMode);