1 /*************************************************************************/
2 /*  texture_frame.h                                                      */
3 /*************************************************************************/
4 /*                       This file is part of:                           */
5 /*                           GODOT ENGINE                                */
6 /*                      https://godotengine.org                          */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur.                 */
9 /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md)    */
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 #ifndef TEXTURE_FRAME_H
31 #define TEXTURE_FRAME_H
32 
33 #include "scene/gui/control.h"
34 /**
35 	@author Juan Linietsky <reduzio@gmail.com>
36 */
37 class TextureFrame : public Control {
38 
39 	OBJ_TYPE(TextureFrame, Control);
40 
41 public:
42 	enum StretchMode {
43 		STRETCH_SCALE_ON_EXPAND, //default, for backwards compatibility
44 		STRETCH_SCALE,
45 		STRETCH_TILE,
46 		STRETCH_KEEP,
47 		STRETCH_KEEP_CENTERED,
48 		STRETCH_KEEP_ASPECT,
49 		STRETCH_KEEP_ASPECT_CENTERED,
50 		STRETCH_KEEP_ASPECT_COVERED,
51 	};
52 
53 private:
54 	bool expand;
55 	Color modulate;
56 	Ref<Texture> texture;
57 	StretchMode stretch_mode;
58 
59 protected:
60 	void _notification(int p_what);
61 	virtual Size2 get_minimum_size() const;
62 	static void _bind_methods();
63 
64 public:
65 	void set_texture(const Ref<Texture> &p_tex);
66 	Ref<Texture> get_texture() const;
67 
68 	void set_modulate(const Color &p_tex);
69 	Color get_modulate() const;
70 
71 	void set_expand(bool p_expand);
72 	bool has_expand() const;
73 
74 	void set_stretch_mode(StretchMode p_mode);
75 	StretchMode get_stretch_mode() const;
76 
77 	TextureFrame();
78 	~TextureFrame();
79 };
80 
81 VARIANT_ENUM_CAST(TextureFrame::StretchMode);
82 #endif // TEXTURE_FRAME_H
83