1 /**
2 Theme for controls.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.theme;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.resource;
25 import godot.reference;
26 import godot.font;
27 import godot.texture;
28 import godot.stylebox;
29 /**
30 Theme for controls.
31 
32 A theme for skinning controls. Controls can be skinned individually, but for complex applications, it's more practical to just create a global theme that defines everything. This theme can be applied to any $(D Control); the Control and its children will automatically use it.
33 Theme resources can alternatively be loaded by writing them in a `.theme` file, see the documentation for more information.
34 */
35 @GodotBaseClass struct Theme
36 {
37 	package(godot) enum string _GODOT_internal_name = "Theme";
38 public:
39 @nogc nothrow:
40 	union { /** */ godot_object _godot_object; /** */ Resource _GODOT_base; }
41 	alias _GODOT_base this;
42 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
43 	package(godot) __gshared bool _classBindingInitialized = false;
44 	package(godot) static struct GDNativeClassBinding
45 	{
46 		__gshared:
47 		@GodotName("_emit_theme_changed") GodotMethod!(void) _emitThemeChanged;
48 		@GodotName("clear") GodotMethod!(void) clear;
49 		@GodotName("clear_color") GodotMethod!(void, String, String) clearColor;
50 		@GodotName("clear_constant") GodotMethod!(void, String, String) clearConstant;
51 		@GodotName("clear_font") GodotMethod!(void, String, String) clearFont;
52 		@GodotName("clear_icon") GodotMethod!(void, String, String) clearIcon;
53 		@GodotName("clear_stylebox") GodotMethod!(void, String, String) clearStylebox;
54 		@GodotName("copy_default_theme") GodotMethod!(void) copyDefaultTheme;
55 		@GodotName("copy_theme") GodotMethod!(void, Theme) copyTheme;
56 		@GodotName("get_color") GodotMethod!(Color, String, String) getColor;
57 		@GodotName("get_color_list") GodotMethod!(PoolStringArray, String) getColorList;
58 		@GodotName("get_constant") GodotMethod!(long, String, String) getConstant;
59 		@GodotName("get_constant_list") GodotMethod!(PoolStringArray, String) getConstantList;
60 		@GodotName("get_default_font") GodotMethod!(Font) getDefaultFont;
61 		@GodotName("get_font") GodotMethod!(Font, String, String) getFont;
62 		@GodotName("get_font_list") GodotMethod!(PoolStringArray, String) getFontList;
63 		@GodotName("get_icon") GodotMethod!(Texture, String, String) getIcon;
64 		@GodotName("get_icon_list") GodotMethod!(PoolStringArray, String) getIconList;
65 		@GodotName("get_stylebox") GodotMethod!(StyleBox, String, String) getStylebox;
66 		@GodotName("get_stylebox_list") GodotMethod!(PoolStringArray, String) getStyleboxList;
67 		@GodotName("get_stylebox_types") GodotMethod!(PoolStringArray) getStyleboxTypes;
68 		@GodotName("get_type_list") GodotMethod!(PoolStringArray, String) getTypeList;
69 		@GodotName("has_color") GodotMethod!(bool, String, String) hasColor;
70 		@GodotName("has_constant") GodotMethod!(bool, String, String) hasConstant;
71 		@GodotName("has_font") GodotMethod!(bool, String, String) hasFont;
72 		@GodotName("has_icon") GodotMethod!(bool, String, String) hasIcon;
73 		@GodotName("has_stylebox") GodotMethod!(bool, String, String) hasStylebox;
74 		@GodotName("set_color") GodotMethod!(void, String, String, Color) setColor;
75 		@GodotName("set_constant") GodotMethod!(void, String, String, long) setConstant;
76 		@GodotName("set_default_font") GodotMethod!(void, Font) setDefaultFont;
77 		@GodotName("set_font") GodotMethod!(void, String, String, Font) setFont;
78 		@GodotName("set_icon") GodotMethod!(void, String, String, Texture) setIcon;
79 		@GodotName("set_stylebox") GodotMethod!(void, String, String, StyleBox) setStylebox;
80 	}
81 	/// 
82 	pragma(inline, true) bool opEquals(in Theme other) const
83 	{ return _godot_object.ptr is other._godot_object.ptr; }
84 	/// 
85 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
86 	{ _godot_object.ptr = n; return null; }
87 	/// 
88 	pragma(inline, true) bool opEquals(typeof(null) n) const
89 	{ return _godot_object.ptr is n; }
90 	/// 
91 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
92 	mixin baseCasts;
93 	/// Construct a new instance of Theme.
94 	/// Note: use `memnew!Theme` instead.
95 	static Theme _new()
96 	{
97 		static godot_class_constructor constructor;
98 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Theme");
99 		if(constructor is null) return typeof(this).init;
100 		return cast(Theme)(constructor());
101 	}
102 	@disable new(size_t s);
103 	/**
104 	
105 	*/
106 	void _emitThemeChanged()
107 	{
108 		Array _GODOT_args = Array.make();
109 		String _GODOT_method_name = String("_emit_theme_changed");
110 		this.callv(_GODOT_method_name, _GODOT_args);
111 	}
112 	/**
113 	Clears all values on the theme.
114 	*/
115 	void clear()
116 	{
117 		checkClassBinding!(typeof(this))();
118 		ptrcall!(void)(GDNativeClassBinding.clear, _godot_object);
119 	}
120 	/**
121 	Clears the $(D Color) at `name` if the theme has `node_type`.
122 	*/
123 	void clearColor(in String name, in String node_type)
124 	{
125 		checkClassBinding!(typeof(this))();
126 		ptrcall!(void)(GDNativeClassBinding.clearColor, _godot_object, name, node_type);
127 	}
128 	/**
129 	Clears the constant at `name` if the theme has `node_type`.
130 	*/
131 	void clearConstant(in String name, in String node_type)
132 	{
133 		checkClassBinding!(typeof(this))();
134 		ptrcall!(void)(GDNativeClassBinding.clearConstant, _godot_object, name, node_type);
135 	}
136 	/**
137 	Clears the $(D Font) at `name` if the theme has `node_type`.
138 	*/
139 	void clearFont(in String name, in String node_type)
140 	{
141 		checkClassBinding!(typeof(this))();
142 		ptrcall!(void)(GDNativeClassBinding.clearFont, _godot_object, name, node_type);
143 	}
144 	/**
145 	Clears the icon at `name` if the theme has `node_type`.
146 	*/
147 	void clearIcon(in String name, in String node_type)
148 	{
149 		checkClassBinding!(typeof(this))();
150 		ptrcall!(void)(GDNativeClassBinding.clearIcon, _godot_object, name, node_type);
151 	}
152 	/**
153 	Clears $(D StyleBox) at `name` if the theme has `node_type`.
154 	*/
155 	void clearStylebox(in String name, in String node_type)
156 	{
157 		checkClassBinding!(typeof(this))();
158 		ptrcall!(void)(GDNativeClassBinding.clearStylebox, _godot_object, name, node_type);
159 	}
160 	/**
161 	Sets the theme's values to a copy of the default theme values.
162 	*/
163 	void copyDefaultTheme()
164 	{
165 		checkClassBinding!(typeof(this))();
166 		ptrcall!(void)(GDNativeClassBinding.copyDefaultTheme, _godot_object);
167 	}
168 	/**
169 	Sets the theme's values to a copy of a given theme.
170 	*/
171 	void copyTheme(Theme other)
172 	{
173 		checkClassBinding!(typeof(this))();
174 		ptrcall!(void)(GDNativeClassBinding.copyTheme, _godot_object, other);
175 	}
176 	/**
177 	Returns the $(D Color) at `name` if the theme has `node_type`.
178 	*/
179 	Color getColor(in String name, in String node_type) const
180 	{
181 		checkClassBinding!(typeof(this))();
182 		return ptrcall!(Color)(GDNativeClassBinding.getColor, _godot_object, name, node_type);
183 	}
184 	/**
185 	Returns all the $(D Color)s as a $(D PoolStringArray) filled with each $(D Color)'s name, for use in $(D getColor), if the theme has `node_type`.
186 	*/
187 	PoolStringArray getColorList(in String node_type) const
188 	{
189 		checkClassBinding!(typeof(this))();
190 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getColorList, _godot_object, node_type);
191 	}
192 	/**
193 	Returns the constant at `name` if the theme has `node_type`.
194 	*/
195 	long getConstant(in String name, in String node_type) const
196 	{
197 		checkClassBinding!(typeof(this))();
198 		return ptrcall!(long)(GDNativeClassBinding.getConstant, _godot_object, name, node_type);
199 	}
200 	/**
201 	Returns all the constants as a $(D PoolStringArray) filled with each constant's name, for use in $(D getConstant), if the theme has `node_type`.
202 	*/
203 	PoolStringArray getConstantList(in String node_type) const
204 	{
205 		checkClassBinding!(typeof(this))();
206 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getConstantList, _godot_object, node_type);
207 	}
208 	/**
209 	
210 	*/
211 	Ref!Font getDefaultFont() const
212 	{
213 		checkClassBinding!(typeof(this))();
214 		return ptrcall!(Font)(GDNativeClassBinding.getDefaultFont, _godot_object);
215 	}
216 	/**
217 	Returns the $(D Font) at `name` if the theme has `node_type`.
218 	*/
219 	Ref!Font getFont(in String name, in String node_type) const
220 	{
221 		checkClassBinding!(typeof(this))();
222 		return ptrcall!(Font)(GDNativeClassBinding.getFont, _godot_object, name, node_type);
223 	}
224 	/**
225 	Returns all the $(D Font)s as a $(D PoolStringArray) filled with each $(D Font)'s name, for use in $(D getFont), if the theme has `node_type`.
226 	*/
227 	PoolStringArray getFontList(in String node_type) const
228 	{
229 		checkClassBinding!(typeof(this))();
230 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getFontList, _godot_object, node_type);
231 	}
232 	/**
233 	Returns the icon $(D Texture) at `name` if the theme has `node_type`.
234 	*/
235 	Ref!Texture getIcon(in String name, in String node_type) const
236 	{
237 		checkClassBinding!(typeof(this))();
238 		return ptrcall!(Texture)(GDNativeClassBinding.getIcon, _godot_object, name, node_type);
239 	}
240 	/**
241 	Returns all the icons as a $(D PoolStringArray) filled with each $(D Texture)'s name, for use in $(D getIcon), if the theme has `node_type`.
242 	*/
243 	PoolStringArray getIconList(in String node_type) const
244 	{
245 		checkClassBinding!(typeof(this))();
246 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getIconList, _godot_object, node_type);
247 	}
248 	/**
249 	Returns the $(D StyleBox) at `name` if the theme has `node_type`.
250 	Valid `name`s may be found using $(D getStyleboxList). Valid `node_type`s may be found using $(D getStyleboxTypes).
251 	*/
252 	Ref!StyleBox getStylebox(in String name, in String node_type) const
253 	{
254 		checkClassBinding!(typeof(this))();
255 		return ptrcall!(StyleBox)(GDNativeClassBinding.getStylebox, _godot_object, name, node_type);
256 	}
257 	/**
258 	Returns all the $(D StyleBox)s as a $(D PoolStringArray) filled with each $(D StyleBox)'s name, for use in $(D getStylebox), if the theme has `node_type`.
259 	Valid `node_type`s may be found using $(D getStyleboxTypes).
260 	*/
261 	PoolStringArray getStyleboxList(in String node_type) const
262 	{
263 		checkClassBinding!(typeof(this))();
264 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getStyleboxList, _godot_object, node_type);
265 	}
266 	/**
267 	Returns all the $(D StyleBox) types as a $(D PoolStringArray) filled with each $(D StyleBox)'s type, for use in $(D getStylebox) and/or $(D getStyleboxList), if the theme has `node_type`.
268 	*/
269 	PoolStringArray getStyleboxTypes() const
270 	{
271 		checkClassBinding!(typeof(this))();
272 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getStyleboxTypes, _godot_object);
273 	}
274 	/**
275 	Returns all the types in `node_type` as a $(D PoolStringArray) for use in any of the `get_*` functions, if the theme has `node_type`.
276 	*/
277 	PoolStringArray getTypeList(in String node_type) const
278 	{
279 		checkClassBinding!(typeof(this))();
280 		return ptrcall!(PoolStringArray)(GDNativeClassBinding.getTypeList, _godot_object, node_type);
281 	}
282 	/**
283 	Returns `true` if $(D Color) with `name` is in `node_type`.
284 	Returns `false` if the theme does not have `node_type`.
285 	*/
286 	bool hasColor(in String name, in String node_type) const
287 	{
288 		checkClassBinding!(typeof(this))();
289 		return ptrcall!(bool)(GDNativeClassBinding.hasColor, _godot_object, name, node_type);
290 	}
291 	/**
292 	Returns `true` if constant with `name` is in `node_type`.
293 	Returns `false` if the theme does not have `node_type`.
294 	*/
295 	bool hasConstant(in String name, in String node_type) const
296 	{
297 		checkClassBinding!(typeof(this))();
298 		return ptrcall!(bool)(GDNativeClassBinding.hasConstant, _godot_object, name, node_type);
299 	}
300 	/**
301 	Returns `true` if $(D Font) with `name` is in `node_type`.
302 	Returns `false` if the theme does not have `node_type`.
303 	*/
304 	bool hasFont(in String name, in String node_type) const
305 	{
306 		checkClassBinding!(typeof(this))();
307 		return ptrcall!(bool)(GDNativeClassBinding.hasFont, _godot_object, name, node_type);
308 	}
309 	/**
310 	Returns `true` if icon $(D Texture) with `name` is in `node_type`.
311 	Returns `false` if the theme does not have `node_type`.
312 	*/
313 	bool hasIcon(in String name, in String node_type) const
314 	{
315 		checkClassBinding!(typeof(this))();
316 		return ptrcall!(bool)(GDNativeClassBinding.hasIcon, _godot_object, name, node_type);
317 	}
318 	/**
319 	Returns `true` if $(D StyleBox) with `name` is in `node_type`.
320 	Returns `false` if the theme does not have `node_type`.
321 	*/
322 	bool hasStylebox(in String name, in String node_type) const
323 	{
324 		checkClassBinding!(typeof(this))();
325 		return ptrcall!(bool)(GDNativeClassBinding.hasStylebox, _godot_object, name, node_type);
326 	}
327 	/**
328 	Sets the theme's $(D Color) to `color` at `name` in `node_type`.
329 	Does nothing if the theme does not have `node_type`.
330 	*/
331 	void setColor(in String name, in String node_type, in Color color)
332 	{
333 		checkClassBinding!(typeof(this))();
334 		ptrcall!(void)(GDNativeClassBinding.setColor, _godot_object, name, node_type, color);
335 	}
336 	/**
337 	Sets the theme's constant to `constant` at `name` in `node_type`.
338 	Does nothing if the theme does not have `node_type`.
339 	*/
340 	void setConstant(in String name, in String node_type, in long constant)
341 	{
342 		checkClassBinding!(typeof(this))();
343 		ptrcall!(void)(GDNativeClassBinding.setConstant, _godot_object, name, node_type, constant);
344 	}
345 	/**
346 	
347 	*/
348 	void setDefaultFont(Font font)
349 	{
350 		checkClassBinding!(typeof(this))();
351 		ptrcall!(void)(GDNativeClassBinding.setDefaultFont, _godot_object, font);
352 	}
353 	/**
354 	Sets the theme's $(D Font) to `font` at `name` in `node_type`.
355 	Does nothing if the theme does not have `node_type`.
356 	*/
357 	void setFont(in String name, in String node_type, Font font)
358 	{
359 		checkClassBinding!(typeof(this))();
360 		ptrcall!(void)(GDNativeClassBinding.setFont, _godot_object, name, node_type, font);
361 	}
362 	/**
363 	Sets the theme's icon $(D Texture) to `texture` at `name` in `node_type`.
364 	Does nothing if the theme does not have `node_type`.
365 	*/
366 	void setIcon(in String name, in String node_type, Texture texture)
367 	{
368 		checkClassBinding!(typeof(this))();
369 		ptrcall!(void)(GDNativeClassBinding.setIcon, _godot_object, name, node_type, texture);
370 	}
371 	/**
372 	Sets theme's $(D StyleBox) to `stylebox` at `name` in `node_type`.
373 	Does nothing if the theme does not have `node_type`.
374 	*/
375 	void setStylebox(in String name, in String node_type, StyleBox texture)
376 	{
377 		checkClassBinding!(typeof(this))();
378 		ptrcall!(void)(GDNativeClassBinding.setStylebox, _godot_object, name, node_type, texture);
379 	}
380 	/**
381 	The theme's default font.
382 	*/
383 	@property Font defaultFont()
384 	{
385 		return getDefaultFont();
386 	}
387 	/// ditto
388 	@property void defaultFont(Font v)
389 	{
390 		setDefaultFont(v);
391 	}
392 }