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