1 /** 2 Base class for GUI sliders. 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.slider; 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.range; 24 import godot.control; 25 import godot.canvasitem; 26 import godot.node; 27 import godot.inputevent; 28 /** 29 Base class for GUI sliders. 30 31 $(B Note:) The $(D Range.changed) and $(D Range.valueChanged) signals are part of the $(D Range) class which this class inherits from. 32 */ 33 @GodotBaseClass struct Slider 34 { 35 package(godot) enum string _GODOT_internal_name = "Slider"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ Range _GODOT_base; } 39 alias _GODOT_base this; 40 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 41 package(godot) __gshared bool _classBindingInitialized = false; 42 package(godot) static struct GDNativeClassBinding 43 { 44 __gshared: 45 @GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput; 46 @GodotName("get_ticks") GodotMethod!(long) getTicks; 47 @GodotName("get_ticks_on_borders") GodotMethod!(bool) getTicksOnBorders; 48 @GodotName("is_editable") GodotMethod!(bool) isEditable; 49 @GodotName("is_scrollable") GodotMethod!(bool) isScrollable; 50 @GodotName("set_editable") GodotMethod!(void, bool) setEditable; 51 @GodotName("set_scrollable") GodotMethod!(void, bool) setScrollable; 52 @GodotName("set_ticks") GodotMethod!(void, long) setTicks; 53 @GodotName("set_ticks_on_borders") GodotMethod!(void, bool) setTicksOnBorders; 54 } 55 /// 56 pragma(inline, true) bool opEquals(in Slider other) const 57 { return _godot_object.ptr is other._godot_object.ptr; } 58 /// 59 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 60 { _godot_object.ptr = n; return null; } 61 /// 62 pragma(inline, true) bool opEquals(typeof(null) n) const 63 { return _godot_object.ptr is n; } 64 /// 65 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 66 mixin baseCasts; 67 /// Construct a new instance of Slider. 68 /// Note: use `memnew!Slider` instead. 69 static Slider _new() 70 { 71 static godot_class_constructor constructor; 72 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Slider"); 73 if(constructor is null) return typeof(this).init; 74 return cast(Slider)(constructor()); 75 } 76 @disable new(size_t s); 77 /** 78 79 */ 80 void _guiInput(InputEvent arg0) 81 { 82 Array _GODOT_args = Array.make(); 83 _GODOT_args.append(arg0); 84 String _GODOT_method_name = String("_gui_input"); 85 this.callv(_GODOT_method_name, _GODOT_args); 86 } 87 /** 88 89 */ 90 long getTicks() const 91 { 92 checkClassBinding!(typeof(this))(); 93 return ptrcall!(long)(GDNativeClassBinding.getTicks, _godot_object); 94 } 95 /** 96 97 */ 98 bool getTicksOnBorders() const 99 { 100 checkClassBinding!(typeof(this))(); 101 return ptrcall!(bool)(GDNativeClassBinding.getTicksOnBorders, _godot_object); 102 } 103 /** 104 105 */ 106 bool isEditable() const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(bool)(GDNativeClassBinding.isEditable, _godot_object); 110 } 111 /** 112 113 */ 114 bool isScrollable() const 115 { 116 checkClassBinding!(typeof(this))(); 117 return ptrcall!(bool)(GDNativeClassBinding.isScrollable, _godot_object); 118 } 119 /** 120 121 */ 122 void setEditable(in bool editable) 123 { 124 checkClassBinding!(typeof(this))(); 125 ptrcall!(void)(GDNativeClassBinding.setEditable, _godot_object, editable); 126 } 127 /** 128 129 */ 130 void setScrollable(in bool scrollable) 131 { 132 checkClassBinding!(typeof(this))(); 133 ptrcall!(void)(GDNativeClassBinding.setScrollable, _godot_object, scrollable); 134 } 135 /** 136 137 */ 138 void setTicks(in long count) 139 { 140 checkClassBinding!(typeof(this))(); 141 ptrcall!(void)(GDNativeClassBinding.setTicks, _godot_object, count); 142 } 143 /** 144 145 */ 146 void setTicksOnBorders(in bool ticks_on_border) 147 { 148 checkClassBinding!(typeof(this))(); 149 ptrcall!(void)(GDNativeClassBinding.setTicksOnBorders, _godot_object, ticks_on_border); 150 } 151 /** 152 If `true`, the slider can be interacted with. If `false`, the value can be changed only by code. 153 */ 154 @property bool editable() 155 { 156 return isEditable(); 157 } 158 /// ditto 159 @property void editable(bool v) 160 { 161 setEditable(v); 162 } 163 /** 164 If `true`, the value can be changed using the mouse wheel. 165 */ 166 @property bool scrollable() 167 { 168 return isScrollable(); 169 } 170 /// ditto 171 @property void scrollable(bool v) 172 { 173 setScrollable(v); 174 } 175 /** 176 Number of ticks displayed on the slider, including border ticks. Ticks are uniformly-distributed value markers. 177 */ 178 @property long tickCount() 179 { 180 return getTicks(); 181 } 182 /// ditto 183 @property void tickCount(long v) 184 { 185 setTicks(v); 186 } 187 /** 188 If `true`, the slider will display ticks for minimum and maximum values. 189 */ 190 @property bool ticksOnBorders() 191 { 192 return getTicksOnBorders(); 193 } 194 /// ditto 195 @property void ticksOnBorders(bool v) 196 { 197 setTicksOnBorders(v); 198 } 199 }