1 /**
2 Abstract base class for range-based 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.range;
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.control;
24 import godot.canvasitem;
25 import godot.node;
26 /**
27 Abstract base class for range-based controls.
28 
29 Range is a base class for $(D Control) nodes that change a floating-point $(I value) between a $(I minimum) and a $(I maximum), using $(I step) and $(I page), for example a $(D ScrollBar).
30 */
31 @GodotBaseClass struct Range
32 {
33 	package(godot) enum string _GODOT_internal_name = "Range";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ Control _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("get_as_ratio") GodotMethod!(double) getAsRatio;
44 		@GodotName("get_max") GodotMethod!(double) getMax;
45 		@GodotName("get_min") GodotMethod!(double) getMin;
46 		@GodotName("get_page") GodotMethod!(double) getPage;
47 		@GodotName("get_step") GodotMethod!(double) getStep;
48 		@GodotName("get_value") GodotMethod!(double) getValue;
49 		@GodotName("is_greater_allowed") GodotMethod!(bool) isGreaterAllowed;
50 		@GodotName("is_lesser_allowed") GodotMethod!(bool) isLesserAllowed;
51 		@GodotName("is_ratio_exp") GodotMethod!(bool) isRatioExp;
52 		@GodotName("is_using_rounded_values") GodotMethod!(bool) isUsingRoundedValues;
53 		@GodotName("set_allow_greater") GodotMethod!(void, bool) setAllowGreater;
54 		@GodotName("set_allow_lesser") GodotMethod!(void, bool) setAllowLesser;
55 		@GodotName("set_as_ratio") GodotMethod!(void, double) setAsRatio;
56 		@GodotName("set_exp_ratio") GodotMethod!(void, bool) setExpRatio;
57 		@GodotName("set_max") GodotMethod!(void, double) setMax;
58 		@GodotName("set_min") GodotMethod!(void, double) setMin;
59 		@GodotName("set_page") GodotMethod!(void, double) setPage;
60 		@GodotName("set_step") GodotMethod!(void, double) setStep;
61 		@GodotName("set_use_rounded_values") GodotMethod!(void, bool) setUseRoundedValues;
62 		@GodotName("set_value") GodotMethod!(void, double) setValue;
63 		@GodotName("share") GodotMethod!(void, Node) share;
64 		@GodotName("unshare") GodotMethod!(void) unshare;
65 	}
66 	/// 
67 	pragma(inline, true) bool opEquals(in Range other) const
68 	{ return _godot_object.ptr is other._godot_object.ptr; }
69 	/// 
70 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
71 	{ _godot_object.ptr = n; return null; }
72 	/// 
73 	pragma(inline, true) bool opEquals(typeof(null) n) const
74 	{ return _godot_object.ptr is n; }
75 	/// 
76 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
77 	mixin baseCasts;
78 	/// Construct a new instance of Range.
79 	/// Note: use `memnew!Range` instead.
80 	static Range _new()
81 	{
82 		static godot_class_constructor constructor;
83 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Range");
84 		if(constructor is null) return typeof(this).init;
85 		return cast(Range)(constructor());
86 	}
87 	@disable new(size_t s);
88 	/**
89 	
90 	*/
91 	double getAsRatio() const
92 	{
93 		checkClassBinding!(typeof(this))();
94 		return ptrcall!(double)(GDNativeClassBinding.getAsRatio, _godot_object);
95 	}
96 	/**
97 	
98 	*/
99 	double getMax() const
100 	{
101 		checkClassBinding!(typeof(this))();
102 		return ptrcall!(double)(GDNativeClassBinding.getMax, _godot_object);
103 	}
104 	/**
105 	
106 	*/
107 	double getMin() const
108 	{
109 		checkClassBinding!(typeof(this))();
110 		return ptrcall!(double)(GDNativeClassBinding.getMin, _godot_object);
111 	}
112 	/**
113 	
114 	*/
115 	double getPage() const
116 	{
117 		checkClassBinding!(typeof(this))();
118 		return ptrcall!(double)(GDNativeClassBinding.getPage, _godot_object);
119 	}
120 	/**
121 	
122 	*/
123 	double getStep() const
124 	{
125 		checkClassBinding!(typeof(this))();
126 		return ptrcall!(double)(GDNativeClassBinding.getStep, _godot_object);
127 	}
128 	/**
129 	
130 	*/
131 	double getValue() const
132 	{
133 		checkClassBinding!(typeof(this))();
134 		return ptrcall!(double)(GDNativeClassBinding.getValue, _godot_object);
135 	}
136 	/**
137 	
138 	*/
139 	bool isGreaterAllowed() const
140 	{
141 		checkClassBinding!(typeof(this))();
142 		return ptrcall!(bool)(GDNativeClassBinding.isGreaterAllowed, _godot_object);
143 	}
144 	/**
145 	
146 	*/
147 	bool isLesserAllowed() const
148 	{
149 		checkClassBinding!(typeof(this))();
150 		return ptrcall!(bool)(GDNativeClassBinding.isLesserAllowed, _godot_object);
151 	}
152 	/**
153 	
154 	*/
155 	bool isRatioExp() const
156 	{
157 		checkClassBinding!(typeof(this))();
158 		return ptrcall!(bool)(GDNativeClassBinding.isRatioExp, _godot_object);
159 	}
160 	/**
161 	
162 	*/
163 	bool isUsingRoundedValues() const
164 	{
165 		checkClassBinding!(typeof(this))();
166 		return ptrcall!(bool)(GDNativeClassBinding.isUsingRoundedValues, _godot_object);
167 	}
168 	/**
169 	
170 	*/
171 	void setAllowGreater(in bool allow)
172 	{
173 		checkClassBinding!(typeof(this))();
174 		ptrcall!(void)(GDNativeClassBinding.setAllowGreater, _godot_object, allow);
175 	}
176 	/**
177 	
178 	*/
179 	void setAllowLesser(in bool allow)
180 	{
181 		checkClassBinding!(typeof(this))();
182 		ptrcall!(void)(GDNativeClassBinding.setAllowLesser, _godot_object, allow);
183 	}
184 	/**
185 	
186 	*/
187 	void setAsRatio(in double value)
188 	{
189 		checkClassBinding!(typeof(this))();
190 		ptrcall!(void)(GDNativeClassBinding.setAsRatio, _godot_object, value);
191 	}
192 	/**
193 	
194 	*/
195 	void setExpRatio(in bool enabled)
196 	{
197 		checkClassBinding!(typeof(this))();
198 		ptrcall!(void)(GDNativeClassBinding.setExpRatio, _godot_object, enabled);
199 	}
200 	/**
201 	
202 	*/
203 	void setMax(in double maximum)
204 	{
205 		checkClassBinding!(typeof(this))();
206 		ptrcall!(void)(GDNativeClassBinding.setMax, _godot_object, maximum);
207 	}
208 	/**
209 	
210 	*/
211 	void setMin(in double minimum)
212 	{
213 		checkClassBinding!(typeof(this))();
214 		ptrcall!(void)(GDNativeClassBinding.setMin, _godot_object, minimum);
215 	}
216 	/**
217 	
218 	*/
219 	void setPage(in double pagesize)
220 	{
221 		checkClassBinding!(typeof(this))();
222 		ptrcall!(void)(GDNativeClassBinding.setPage, _godot_object, pagesize);
223 	}
224 	/**
225 	
226 	*/
227 	void setStep(in double step)
228 	{
229 		checkClassBinding!(typeof(this))();
230 		ptrcall!(void)(GDNativeClassBinding.setStep, _godot_object, step);
231 	}
232 	/**
233 	
234 	*/
235 	void setUseRoundedValues(in bool enabled)
236 	{
237 		checkClassBinding!(typeof(this))();
238 		ptrcall!(void)(GDNativeClassBinding.setUseRoundedValues, _godot_object, enabled);
239 	}
240 	/**
241 	
242 	*/
243 	void setValue(in double value)
244 	{
245 		checkClassBinding!(typeof(this))();
246 		ptrcall!(void)(GDNativeClassBinding.setValue, _godot_object, value);
247 	}
248 	/**
249 	Binds two ranges together along with any ranges previously grouped with either of them. When any of range's member variables change, it will share the new value with all other ranges in its group.
250 	*/
251 	void share(Node _with)
252 	{
253 		checkClassBinding!(typeof(this))();
254 		ptrcall!(void)(GDNativeClassBinding.share, _godot_object, _with);
255 	}
256 	/**
257 	Stops range from sharing its member variables with any other.
258 	*/
259 	void unshare()
260 	{
261 		checkClassBinding!(typeof(this))();
262 		ptrcall!(void)(GDNativeClassBinding.unshare, _godot_object);
263 	}
264 	/**
265 	If `true`, $(D value) may be greater than $(D maxValue).
266 	*/
267 	@property bool allowGreater()
268 	{
269 		return isGreaterAllowed();
270 	}
271 	/// ditto
272 	@property void allowGreater(bool v)
273 	{
274 		setAllowGreater(v);
275 	}
276 	/**
277 	If `true`, $(D value) may be less than $(D minValue).
278 	*/
279 	@property bool allowLesser()
280 	{
281 		return isLesserAllowed();
282 	}
283 	/// ditto
284 	@property void allowLesser(bool v)
285 	{
286 		setAllowLesser(v);
287 	}
288 	/**
289 	If `true`, and `min_value` is greater than 0, `value` will be represented exponentially rather than linearly.
290 	*/
291 	@property bool expEdit()
292 	{
293 		return isRatioExp();
294 	}
295 	/// ditto
296 	@property void expEdit(bool v)
297 	{
298 		setExpRatio(v);
299 	}
300 	/**
301 	Maximum value. Range is clamped if `value` is greater than `max_value`.
302 	*/
303 	@property double maxValue()
304 	{
305 		return getMax();
306 	}
307 	/// ditto
308 	@property void maxValue(double v)
309 	{
310 		setMax(v);
311 	}
312 	/**
313 	Minimum value. Range is clamped if `value` is less than `min_value`.
314 	*/
315 	@property double minValue()
316 	{
317 		return getMin();
318 	}
319 	/// ditto
320 	@property void minValue(double v)
321 	{
322 		setMin(v);
323 	}
324 	/**
325 	Page size. Used mainly for $(D ScrollBar). ScrollBar's length is its size multiplied by `page` over the difference between `min_value` and `max_value`.
326 	*/
327 	@property double page()
328 	{
329 		return getPage();
330 	}
331 	/// ditto
332 	@property void page(double v)
333 	{
334 		setPage(v);
335 	}
336 	/**
337 	The value mapped between 0 and 1.
338 	*/
339 	@property double ratio()
340 	{
341 		return getAsRatio();
342 	}
343 	/// ditto
344 	@property void ratio(double v)
345 	{
346 		setAsRatio(v);
347 	}
348 	/**
349 	If `true`, `value` will always be rounded to the nearest integer.
350 	*/
351 	@property bool rounded()
352 	{
353 		return isUsingRoundedValues();
354 	}
355 	/// ditto
356 	@property void rounded(bool v)
357 	{
358 		setUseRoundedValues(v);
359 	}
360 	/**
361 	If greater than 0, `value` will always be rounded to a multiple of `step`. If `rounded` is also `true`, `value` will first be rounded to a multiple of `step` then rounded to the nearest integer.
362 	*/
363 	@property double step()
364 	{
365 		return getStep();
366 	}
367 	/// ditto
368 	@property void step(double v)
369 	{
370 		setStep(v);
371 	}
372 	/**
373 	Range's current value.
374 	*/
375 	@property double value()
376 	{
377 		return getValue();
378 	}
379 	/// ditto
380 	@property void value(double v)
381 	{
382 		setValue(v);
383 	}
384 }