1 /** 2 Color picker control. 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.colorpicker; 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.boxcontainer; 25 import godot.container; 26 import godot.control; 27 import godot.inputevent; 28 /** 29 Color picker control. 30 31 $(D Control) node displaying a color picker widget. It's useful for selecting a color from an RGB/RGBA colorspace. 32 */ 33 @GodotBaseClass struct ColorPicker 34 { 35 package(godot) enum string _GODOT_internal_name = "ColorPicker"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ BoxContainer _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("_add_preset_pressed") GodotMethod!(void) _addPresetPressed; 46 @GodotName("_focus_enter") GodotMethod!(void) _focusEnter; 47 @GodotName("_focus_exit") GodotMethod!(void) _focusExit; 48 @GodotName("_hsv_draw") GodotMethod!(void, long, Control) _hsvDraw; 49 @GodotName("_html_entered") GodotMethod!(void, String) _htmlEntered; 50 @GodotName("_html_focus_exit") GodotMethod!(void) _htmlFocusExit; 51 @GodotName("_preset_input") GodotMethod!(void, InputEvent) _presetInput; 52 @GodotName("_sample_draw") GodotMethod!(void) _sampleDraw; 53 @GodotName("_screen_input") GodotMethod!(void, InputEvent) _screenInput; 54 @GodotName("_screen_pick_pressed") GodotMethod!(void) _screenPickPressed; 55 @GodotName("_text_type_toggled") GodotMethod!(void) _textTypeToggled; 56 @GodotName("_update_presets") GodotMethod!(void) _updatePresets; 57 @GodotName("_uv_input") GodotMethod!(void, InputEvent) _uvInput; 58 @GodotName("_value_changed") GodotMethod!(void, double) _valueChanged; 59 @GodotName("_w_input") GodotMethod!(void, InputEvent) _wInput; 60 @GodotName("add_preset") GodotMethod!(void, Color) addPreset; 61 @GodotName("are_presets_enabled") GodotMethod!(bool) arePresetsEnabled; 62 @GodotName("are_presets_visible") GodotMethod!(bool) arePresetsVisible; 63 @GodotName("erase_preset") GodotMethod!(void, Color) erasePreset; 64 @GodotName("get_pick_color") GodotMethod!(Color) getPickColor; 65 @GodotName("get_presets") GodotMethod!(PoolColorArray) getPresets; 66 @GodotName("is_deferred_mode") GodotMethod!(bool) isDeferredMode; 67 @GodotName("is_editing_alpha") GodotMethod!(bool) isEditingAlpha; 68 @GodotName("is_hsv_mode") GodotMethod!(bool) isHsvMode; 69 @GodotName("is_raw_mode") GodotMethod!(bool) isRawMode; 70 @GodotName("set_deferred_mode") GodotMethod!(void, bool) setDeferredMode; 71 @GodotName("set_edit_alpha") GodotMethod!(void, bool) setEditAlpha; 72 @GodotName("set_hsv_mode") GodotMethod!(void, bool) setHsvMode; 73 @GodotName("set_pick_color") GodotMethod!(void, Color) setPickColor; 74 @GodotName("set_presets_enabled") GodotMethod!(void, bool) setPresetsEnabled; 75 @GodotName("set_presets_visible") GodotMethod!(void, bool) setPresetsVisible; 76 @GodotName("set_raw_mode") GodotMethod!(void, bool) setRawMode; 77 } 78 /// 79 pragma(inline, true) bool opEquals(in ColorPicker other) const 80 { return _godot_object.ptr is other._godot_object.ptr; } 81 /// 82 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 83 { _godot_object.ptr = n; return null; } 84 /// 85 pragma(inline, true) bool opEquals(typeof(null) n) const 86 { return _godot_object.ptr is n; } 87 /// 88 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 89 mixin baseCasts; 90 /// Construct a new instance of ColorPicker. 91 /// Note: use `memnew!ColorPicker` instead. 92 static ColorPicker _new() 93 { 94 static godot_class_constructor constructor; 95 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ColorPicker"); 96 if(constructor is null) return typeof(this).init; 97 return cast(ColorPicker)(constructor()); 98 } 99 @disable new(size_t s); 100 /** 101 102 */ 103 void _addPresetPressed() 104 { 105 Array _GODOT_args = Array.make(); 106 String _GODOT_method_name = String("_add_preset_pressed"); 107 this.callv(_GODOT_method_name, _GODOT_args); 108 } 109 /** 110 111 */ 112 void _focusEnter() 113 { 114 Array _GODOT_args = Array.make(); 115 String _GODOT_method_name = String("_focus_enter"); 116 this.callv(_GODOT_method_name, _GODOT_args); 117 } 118 /** 119 120 */ 121 void _focusExit() 122 { 123 Array _GODOT_args = Array.make(); 124 String _GODOT_method_name = String("_focus_exit"); 125 this.callv(_GODOT_method_name, _GODOT_args); 126 } 127 /** 128 129 */ 130 void _hsvDraw(in long arg0, Control arg1) 131 { 132 Array _GODOT_args = Array.make(); 133 _GODOT_args.append(arg0); 134 _GODOT_args.append(arg1); 135 String _GODOT_method_name = String("_hsv_draw"); 136 this.callv(_GODOT_method_name, _GODOT_args); 137 } 138 /** 139 140 */ 141 void _htmlEntered(in String arg0) 142 { 143 Array _GODOT_args = Array.make(); 144 _GODOT_args.append(arg0); 145 String _GODOT_method_name = String("_html_entered"); 146 this.callv(_GODOT_method_name, _GODOT_args); 147 } 148 /** 149 150 */ 151 void _htmlFocusExit() 152 { 153 Array _GODOT_args = Array.make(); 154 String _GODOT_method_name = String("_html_focus_exit"); 155 this.callv(_GODOT_method_name, _GODOT_args); 156 } 157 /** 158 159 */ 160 void _presetInput(InputEvent arg0) 161 { 162 Array _GODOT_args = Array.make(); 163 _GODOT_args.append(arg0); 164 String _GODOT_method_name = String("_preset_input"); 165 this.callv(_GODOT_method_name, _GODOT_args); 166 } 167 /** 168 169 */ 170 void _sampleDraw() 171 { 172 Array _GODOT_args = Array.make(); 173 String _GODOT_method_name = String("_sample_draw"); 174 this.callv(_GODOT_method_name, _GODOT_args); 175 } 176 /** 177 178 */ 179 void _screenInput(InputEvent arg0) 180 { 181 Array _GODOT_args = Array.make(); 182 _GODOT_args.append(arg0); 183 String _GODOT_method_name = String("_screen_input"); 184 this.callv(_GODOT_method_name, _GODOT_args); 185 } 186 /** 187 188 */ 189 void _screenPickPressed() 190 { 191 Array _GODOT_args = Array.make(); 192 String _GODOT_method_name = String("_screen_pick_pressed"); 193 this.callv(_GODOT_method_name, _GODOT_args); 194 } 195 /** 196 197 */ 198 void _textTypeToggled() 199 { 200 Array _GODOT_args = Array.make(); 201 String _GODOT_method_name = String("_text_type_toggled"); 202 this.callv(_GODOT_method_name, _GODOT_args); 203 } 204 /** 205 206 */ 207 void _updatePresets() 208 { 209 Array _GODOT_args = Array.make(); 210 String _GODOT_method_name = String("_update_presets"); 211 this.callv(_GODOT_method_name, _GODOT_args); 212 } 213 /** 214 215 */ 216 void _uvInput(InputEvent arg0) 217 { 218 Array _GODOT_args = Array.make(); 219 _GODOT_args.append(arg0); 220 String _GODOT_method_name = String("_uv_input"); 221 this.callv(_GODOT_method_name, _GODOT_args); 222 } 223 /** 224 225 */ 226 void _valueChanged(in double arg0) 227 { 228 Array _GODOT_args = Array.make(); 229 _GODOT_args.append(arg0); 230 String _GODOT_method_name = String("_value_changed"); 231 this.callv(_GODOT_method_name, _GODOT_args); 232 } 233 /** 234 235 */ 236 void _wInput(InputEvent arg0) 237 { 238 Array _GODOT_args = Array.make(); 239 _GODOT_args.append(arg0); 240 String _GODOT_method_name = String("_w_input"); 241 this.callv(_GODOT_method_name, _GODOT_args); 242 } 243 /** 244 Adds the given color to a list of color presets. The presets are displayed in the color picker and the user will be able to select them. 245 $(B Note:) the presets list is only for $(I this) color picker. 246 */ 247 void addPreset(in Color color) 248 { 249 checkClassBinding!(typeof(this))(); 250 ptrcall!(void)(GDNativeClassBinding.addPreset, _godot_object, color); 251 } 252 /** 253 254 */ 255 bool arePresetsEnabled() const 256 { 257 checkClassBinding!(typeof(this))(); 258 return ptrcall!(bool)(GDNativeClassBinding.arePresetsEnabled, _godot_object); 259 } 260 /** 261 262 */ 263 bool arePresetsVisible() const 264 { 265 checkClassBinding!(typeof(this))(); 266 return ptrcall!(bool)(GDNativeClassBinding.arePresetsVisible, _godot_object); 267 } 268 /** 269 Removes the given color from the list of color presets of this color picker. 270 */ 271 void erasePreset(in Color color) 272 { 273 checkClassBinding!(typeof(this))(); 274 ptrcall!(void)(GDNativeClassBinding.erasePreset, _godot_object, color); 275 } 276 /** 277 278 */ 279 Color getPickColor() const 280 { 281 checkClassBinding!(typeof(this))(); 282 return ptrcall!(Color)(GDNativeClassBinding.getPickColor, _godot_object); 283 } 284 /** 285 Returns the list of colors in the presets of the color picker. 286 */ 287 PoolColorArray getPresets() const 288 { 289 checkClassBinding!(typeof(this))(); 290 return ptrcall!(PoolColorArray)(GDNativeClassBinding.getPresets, _godot_object); 291 } 292 /** 293 294 */ 295 bool isDeferredMode() const 296 { 297 checkClassBinding!(typeof(this))(); 298 return ptrcall!(bool)(GDNativeClassBinding.isDeferredMode, _godot_object); 299 } 300 /** 301 302 */ 303 bool isEditingAlpha() const 304 { 305 checkClassBinding!(typeof(this))(); 306 return ptrcall!(bool)(GDNativeClassBinding.isEditingAlpha, _godot_object); 307 } 308 /** 309 310 */ 311 bool isHsvMode() const 312 { 313 checkClassBinding!(typeof(this))(); 314 return ptrcall!(bool)(GDNativeClassBinding.isHsvMode, _godot_object); 315 } 316 /** 317 318 */ 319 bool isRawMode() const 320 { 321 checkClassBinding!(typeof(this))(); 322 return ptrcall!(bool)(GDNativeClassBinding.isRawMode, _godot_object); 323 } 324 /** 325 326 */ 327 void setDeferredMode(in bool mode) 328 { 329 checkClassBinding!(typeof(this))(); 330 ptrcall!(void)(GDNativeClassBinding.setDeferredMode, _godot_object, mode); 331 } 332 /** 333 334 */ 335 void setEditAlpha(in bool show) 336 { 337 checkClassBinding!(typeof(this))(); 338 ptrcall!(void)(GDNativeClassBinding.setEditAlpha, _godot_object, show); 339 } 340 /** 341 342 */ 343 void setHsvMode(in bool mode) 344 { 345 checkClassBinding!(typeof(this))(); 346 ptrcall!(void)(GDNativeClassBinding.setHsvMode, _godot_object, mode); 347 } 348 /** 349 350 */ 351 void setPickColor(in Color color) 352 { 353 checkClassBinding!(typeof(this))(); 354 ptrcall!(void)(GDNativeClassBinding.setPickColor, _godot_object, color); 355 } 356 /** 357 358 */ 359 void setPresetsEnabled(in bool enabled) 360 { 361 checkClassBinding!(typeof(this))(); 362 ptrcall!(void)(GDNativeClassBinding.setPresetsEnabled, _godot_object, enabled); 363 } 364 /** 365 366 */ 367 void setPresetsVisible(in bool visible) 368 { 369 checkClassBinding!(typeof(this))(); 370 ptrcall!(void)(GDNativeClassBinding.setPresetsVisible, _godot_object, visible); 371 } 372 /** 373 374 */ 375 void setRawMode(in bool mode) 376 { 377 checkClassBinding!(typeof(this))(); 378 ptrcall!(void)(GDNativeClassBinding.setRawMode, _godot_object, mode); 379 } 380 /** 381 The currently selected color. 382 */ 383 @property Color color() 384 { 385 return getPickColor(); 386 } 387 /// ditto 388 @property void color(Color v) 389 { 390 setPickColor(v); 391 } 392 /** 393 If `true`, the color will apply only after the user releases the mouse button, otherwise it will apply immediately even in mouse motion event (which can cause performance issues). 394 */ 395 @property bool deferredMode() 396 { 397 return isDeferredMode(); 398 } 399 /// ditto 400 @property void deferredMode(bool v) 401 { 402 setDeferredMode(v); 403 } 404 /** 405 If `true`, shows an alpha channel slider (transparency). 406 */ 407 @property bool editAlpha() 408 { 409 return isEditingAlpha(); 410 } 411 /// ditto 412 @property void editAlpha(bool v) 413 { 414 setEditAlpha(v); 415 } 416 /** 417 If `true`, allows editing the color with Hue/Saturation/Value sliders. 418 $(B Note:) Cannot be enabled if raw mode is on. 419 */ 420 @property bool hsvMode() 421 { 422 return isHsvMode(); 423 } 424 /// ditto 425 @property void hsvMode(bool v) 426 { 427 setHsvMode(v); 428 } 429 /** 430 If `true`, the "add preset" button is enabled. 431 */ 432 @property bool presetsEnabled() 433 { 434 return arePresetsEnabled(); 435 } 436 /// ditto 437 @property void presetsEnabled(bool v) 438 { 439 setPresetsEnabled(v); 440 } 441 /** 442 If `true`, saved color presets are visible. 443 */ 444 @property bool presetsVisible() 445 { 446 return arePresetsVisible(); 447 } 448 /// ditto 449 @property void presetsVisible(bool v) 450 { 451 setPresetsVisible(v); 452 } 453 /** 454 If `true`, allows the color R, G, B component values to go beyond 1.0, which can be used for certain special operations that require it (like tinting without darkening or rendering sprites in HDR). 455 $(B Note:) Cannot be enabled if HSV mode is on. 456 */ 457 @property bool rawMode() 458 { 459 return isRawMode(); 460 } 461 /// ditto 462 @property void rawMode(bool v) 463 { 464 setRawMode(v); 465 } 466 }