1 /** 2 Texture-based progress bar. Useful for loading screens and life or stamina bars. 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.textureprogress; 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.range; 25 import godot.control; 26 import godot.canvasitem; 27 import godot.node; 28 import godot.texture; 29 /** 30 Texture-based progress bar. Useful for loading screens and life or stamina bars. 31 32 TextureProgress works like $(D ProgressBar), but uses up to 3 textures instead of Godot's $(D Theme) resource. It can be used to create horizontal, vertical and radial progress bars. 33 */ 34 @GodotBaseClass struct TextureProgress 35 { 36 package(godot) enum string _GODOT_internal_name = "TextureProgress"; 37 public: 38 @nogc nothrow: 39 union { /** */ godot_object _godot_object; /** */ Range _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct GDNativeClassBinding 44 { 45 __gshared: 46 @GodotName("get_fill_degrees") GodotMethod!(double) getFillDegrees; 47 @GodotName("get_fill_mode") GodotMethod!(long) getFillMode; 48 @GodotName("get_nine_patch_stretch") GodotMethod!(bool) getNinePatchStretch; 49 @GodotName("get_over_texture") GodotMethod!(Texture) getOverTexture; 50 @GodotName("get_progress_texture") GodotMethod!(Texture) getProgressTexture; 51 @GodotName("get_radial_center_offset") GodotMethod!(Vector2) getRadialCenterOffset; 52 @GodotName("get_radial_initial_angle") GodotMethod!(double) getRadialInitialAngle; 53 @GodotName("get_stretch_margin") GodotMethod!(long, long) getStretchMargin; 54 @GodotName("get_tint_over") GodotMethod!(Color) getTintOver; 55 @GodotName("get_tint_progress") GodotMethod!(Color) getTintProgress; 56 @GodotName("get_tint_under") GodotMethod!(Color) getTintUnder; 57 @GodotName("get_under_texture") GodotMethod!(Texture) getUnderTexture; 58 @GodotName("set_fill_degrees") GodotMethod!(void, double) setFillDegrees; 59 @GodotName("set_fill_mode") GodotMethod!(void, long) setFillMode; 60 @GodotName("set_nine_patch_stretch") GodotMethod!(void, bool) setNinePatchStretch; 61 @GodotName("set_over_texture") GodotMethod!(void, Texture) setOverTexture; 62 @GodotName("set_progress_texture") GodotMethod!(void, Texture) setProgressTexture; 63 @GodotName("set_radial_center_offset") GodotMethod!(void, Vector2) setRadialCenterOffset; 64 @GodotName("set_radial_initial_angle") GodotMethod!(void, double) setRadialInitialAngle; 65 @GodotName("set_stretch_margin") GodotMethod!(void, long, long) setStretchMargin; 66 @GodotName("set_tint_over") GodotMethod!(void, Color) setTintOver; 67 @GodotName("set_tint_progress") GodotMethod!(void, Color) setTintProgress; 68 @GodotName("set_tint_under") GodotMethod!(void, Color) setTintUnder; 69 @GodotName("set_under_texture") GodotMethod!(void, Texture) setUnderTexture; 70 } 71 /// 72 pragma(inline, true) bool opEquals(in TextureProgress other) const 73 { return _godot_object.ptr is other._godot_object.ptr; } 74 /// 75 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 76 { _godot_object.ptr = n; return null; } 77 /// 78 pragma(inline, true) bool opEquals(typeof(null) n) const 79 { return _godot_object.ptr is n; } 80 /// 81 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 82 mixin baseCasts; 83 /// Construct a new instance of TextureProgress. 84 /// Note: use `memnew!TextureProgress` instead. 85 static TextureProgress _new() 86 { 87 static godot_class_constructor constructor; 88 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("TextureProgress"); 89 if(constructor is null) return typeof(this).init; 90 return cast(TextureProgress)(constructor()); 91 } 92 @disable new(size_t s); 93 /// 94 enum FillMode : int 95 { 96 /** 97 The $(D textureProgress) fills from left to right. 98 */ 99 fillLeftToRight = 0, 100 /** 101 The $(D textureProgress) fills from right to left. 102 */ 103 fillRightToLeft = 1, 104 /** 105 The $(D textureProgress) fills from top to bottom. 106 */ 107 fillTopToBottom = 2, 108 /** 109 The $(D textureProgress) fills from bottom to top. 110 */ 111 fillBottomToTop = 3, 112 /** 113 Turns the node into a radial bar. The $(D textureProgress) fills clockwise. See $(D radialCenterOffset), $(D radialInitialAngle) and $(D radialFillDegrees) to control the way the bar fills up. 114 */ 115 fillClockwise = 4, 116 /** 117 Turns the node into a radial bar. The $(D textureProgress) fills counterclockwise. See $(D radialCenterOffset), $(D radialInitialAngle) and $(D radialFillDegrees) to control the way the bar fills up. 118 */ 119 fillCounterClockwise = 5, 120 /** 121 The $(D textureProgress) fills from the center, expanding both towards the left and the right. 122 */ 123 fillBilinearLeftAndRight = 6, 124 /** 125 The $(D textureProgress) fills from the center, expanding both towards the top and the bottom. 126 */ 127 fillBilinearTopAndBottom = 7, 128 /** 129 Turns the node into a radial bar. The $(D textureProgress) fills radially from the center, expanding both clockwise and counterclockwise. See $(D radialCenterOffset), $(D radialInitialAngle) and $(D radialFillDegrees) to control the way the bar fills up. 130 */ 131 fillClockwiseAndCounterClockwise = 8, 132 } 133 /// 134 enum Constants : int 135 { 136 fillLeftToRight = 0, 137 fillRightToLeft = 1, 138 fillTopToBottom = 2, 139 fillBottomToTop = 3, 140 fillClockwise = 4, 141 fillCounterClockwise = 5, 142 fillBilinearLeftAndRight = 6, 143 fillBilinearTopAndBottom = 7, 144 fillClockwiseAndCounterClockwise = 8, 145 } 146 /** 147 148 */ 149 double getFillDegrees() 150 { 151 checkClassBinding!(typeof(this))(); 152 return ptrcall!(double)(GDNativeClassBinding.getFillDegrees, _godot_object); 153 } 154 /** 155 156 */ 157 long getFillMode() 158 { 159 checkClassBinding!(typeof(this))(); 160 return ptrcall!(long)(GDNativeClassBinding.getFillMode, _godot_object); 161 } 162 /** 163 164 */ 165 bool getNinePatchStretch() const 166 { 167 checkClassBinding!(typeof(this))(); 168 return ptrcall!(bool)(GDNativeClassBinding.getNinePatchStretch, _godot_object); 169 } 170 /** 171 172 */ 173 Ref!Texture getOverTexture() const 174 { 175 checkClassBinding!(typeof(this))(); 176 return ptrcall!(Texture)(GDNativeClassBinding.getOverTexture, _godot_object); 177 } 178 /** 179 180 */ 181 Ref!Texture getProgressTexture() const 182 { 183 checkClassBinding!(typeof(this))(); 184 return ptrcall!(Texture)(GDNativeClassBinding.getProgressTexture, _godot_object); 185 } 186 /** 187 188 */ 189 Vector2 getRadialCenterOffset() 190 { 191 checkClassBinding!(typeof(this))(); 192 return ptrcall!(Vector2)(GDNativeClassBinding.getRadialCenterOffset, _godot_object); 193 } 194 /** 195 196 */ 197 double getRadialInitialAngle() 198 { 199 checkClassBinding!(typeof(this))(); 200 return ptrcall!(double)(GDNativeClassBinding.getRadialInitialAngle, _godot_object); 201 } 202 /** 203 204 */ 205 long getStretchMargin(in long margin) const 206 { 207 checkClassBinding!(typeof(this))(); 208 return ptrcall!(long)(GDNativeClassBinding.getStretchMargin, _godot_object, margin); 209 } 210 /** 211 212 */ 213 Color getTintOver() const 214 { 215 checkClassBinding!(typeof(this))(); 216 return ptrcall!(Color)(GDNativeClassBinding.getTintOver, _godot_object); 217 } 218 /** 219 220 */ 221 Color getTintProgress() const 222 { 223 checkClassBinding!(typeof(this))(); 224 return ptrcall!(Color)(GDNativeClassBinding.getTintProgress, _godot_object); 225 } 226 /** 227 228 */ 229 Color getTintUnder() const 230 { 231 checkClassBinding!(typeof(this))(); 232 return ptrcall!(Color)(GDNativeClassBinding.getTintUnder, _godot_object); 233 } 234 /** 235 236 */ 237 Ref!Texture getUnderTexture() const 238 { 239 checkClassBinding!(typeof(this))(); 240 return ptrcall!(Texture)(GDNativeClassBinding.getUnderTexture, _godot_object); 241 } 242 /** 243 244 */ 245 void setFillDegrees(in double mode) 246 { 247 checkClassBinding!(typeof(this))(); 248 ptrcall!(void)(GDNativeClassBinding.setFillDegrees, _godot_object, mode); 249 } 250 /** 251 252 */ 253 void setFillMode(in long mode) 254 { 255 checkClassBinding!(typeof(this))(); 256 ptrcall!(void)(GDNativeClassBinding.setFillMode, _godot_object, mode); 257 } 258 /** 259 260 */ 261 void setNinePatchStretch(in bool stretch) 262 { 263 checkClassBinding!(typeof(this))(); 264 ptrcall!(void)(GDNativeClassBinding.setNinePatchStretch, _godot_object, stretch); 265 } 266 /** 267 268 */ 269 void setOverTexture(Texture tex) 270 { 271 checkClassBinding!(typeof(this))(); 272 ptrcall!(void)(GDNativeClassBinding.setOverTexture, _godot_object, tex); 273 } 274 /** 275 276 */ 277 void setProgressTexture(Texture tex) 278 { 279 checkClassBinding!(typeof(this))(); 280 ptrcall!(void)(GDNativeClassBinding.setProgressTexture, _godot_object, tex); 281 } 282 /** 283 284 */ 285 void setRadialCenterOffset(in Vector2 mode) 286 { 287 checkClassBinding!(typeof(this))(); 288 ptrcall!(void)(GDNativeClassBinding.setRadialCenterOffset, _godot_object, mode); 289 } 290 /** 291 292 */ 293 void setRadialInitialAngle(in double mode) 294 { 295 checkClassBinding!(typeof(this))(); 296 ptrcall!(void)(GDNativeClassBinding.setRadialInitialAngle, _godot_object, mode); 297 } 298 /** 299 300 */ 301 void setStretchMargin(in long margin, in long value) 302 { 303 checkClassBinding!(typeof(this))(); 304 ptrcall!(void)(GDNativeClassBinding.setStretchMargin, _godot_object, margin, value); 305 } 306 /** 307 308 */ 309 void setTintOver(in Color tint) 310 { 311 checkClassBinding!(typeof(this))(); 312 ptrcall!(void)(GDNativeClassBinding.setTintOver, _godot_object, tint); 313 } 314 /** 315 316 */ 317 void setTintProgress(in Color tint) 318 { 319 checkClassBinding!(typeof(this))(); 320 ptrcall!(void)(GDNativeClassBinding.setTintProgress, _godot_object, tint); 321 } 322 /** 323 324 */ 325 void setTintUnder(in Color tint) 326 { 327 checkClassBinding!(typeof(this))(); 328 ptrcall!(void)(GDNativeClassBinding.setTintUnder, _godot_object, tint); 329 } 330 /** 331 332 */ 333 void setUnderTexture(Texture tex) 334 { 335 checkClassBinding!(typeof(this))(); 336 ptrcall!(void)(GDNativeClassBinding.setUnderTexture, _godot_object, tex); 337 } 338 /** 339 The fill direction. See $(D fillmode) for possible values. 340 */ 341 @property long fillMode() 342 { 343 return getFillMode(); 344 } 345 /// ditto 346 @property void fillMode(long v) 347 { 348 setFillMode(v); 349 } 350 /** 351 If `true`, Godot treats the bar's textures like in $(D NinePatchRect). Use the `stretch_margin_*` properties like $(D stretchMarginBottom) to set up the nine patch's 3×3 grid. When using a radial $(D fillMode), this setting will enable stretching. 352 */ 353 @property bool ninePatchStretch() 354 { 355 return getNinePatchStretch(); 356 } 357 /// ditto 358 @property void ninePatchStretch(bool v) 359 { 360 setNinePatchStretch(v); 361 } 362 /** 363 Offsets $(D textureProgress) if $(D fillMode) is $(D constant FILL_CLOCKWISE) or $(D constant FILL_COUNTER_CLOCKWISE). 364 */ 365 @property Vector2 radialCenterOffset() 366 { 367 return getRadialCenterOffset(); 368 } 369 /// ditto 370 @property void radialCenterOffset(Vector2 v) 371 { 372 setRadialCenterOffset(v); 373 } 374 /** 375 Upper limit for the fill of $(D textureProgress) if $(D fillMode) is $(D constant FILL_CLOCKWISE) or $(D constant FILL_COUNTER_CLOCKWISE). When the node's `value` is equal to its `max_value`, the texture fills up to this angle. 376 See $(D Range.value), $(D Range.maxValue). 377 */ 378 @property double radialFillDegrees() 379 { 380 return getFillDegrees(); 381 } 382 /// ditto 383 @property void radialFillDegrees(double v) 384 { 385 setFillDegrees(v); 386 } 387 /** 388 Starting angle for the fill of $(D textureProgress) if $(D fillMode) is $(D constant FILL_CLOCKWISE) or $(D constant FILL_COUNTER_CLOCKWISE). When the node's `value` is equal to its `min_value`, the texture doesn't show up at all. When the `value` increases, the texture fills and tends towards $(D radialFillDegrees). 389 */ 390 @property double radialInitialAngle() 391 { 392 return getRadialInitialAngle(); 393 } 394 /// ditto 395 @property void radialInitialAngle(double v) 396 { 397 setRadialInitialAngle(v); 398 } 399 /** 400 The height of the 9-patch's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders. 401 */ 402 @property long stretchMarginBottom() 403 { 404 return getStretchMargin(3); 405 } 406 /// ditto 407 @property void stretchMarginBottom(long v) 408 { 409 setStretchMargin(3, v); 410 } 411 /** 412 The width of the 9-patch's left column. 413 */ 414 @property long stretchMarginLeft() 415 { 416 return getStretchMargin(0); 417 } 418 /// ditto 419 @property void stretchMarginLeft(long v) 420 { 421 setStretchMargin(0, v); 422 } 423 /** 424 The width of the 9-patch's right column. 425 */ 426 @property long stretchMarginRight() 427 { 428 return getStretchMargin(2); 429 } 430 /// ditto 431 @property void stretchMarginRight(long v) 432 { 433 setStretchMargin(2, v); 434 } 435 /** 436 The height of the 9-patch's top row. 437 */ 438 @property long stretchMarginTop() 439 { 440 return getStretchMargin(1); 441 } 442 /// ditto 443 @property void stretchMarginTop(long v) 444 { 445 setStretchMargin(1, v); 446 } 447 /** 448 $(D Texture) that draws over the progress bar. Use it to add highlights or an upper-frame that hides part of $(D textureProgress). 449 */ 450 @property Texture textureOver() 451 { 452 return getOverTexture(); 453 } 454 /// ditto 455 @property void textureOver(Texture v) 456 { 457 setOverTexture(v); 458 } 459 /** 460 $(D Texture) that clips based on the node's `value` and $(D fillMode). As `value` increased, the texture fills up. It shows entirely when `value` reaches `max_value`. It doesn't show at all if `value` is equal to `min_value`. 461 The `value` property comes from $(D Range). See $(D Range.value), $(D Range.minValue), $(D Range.maxValue). 462 */ 463 @property Texture textureProgress() 464 { 465 return getProgressTexture(); 466 } 467 /// ditto 468 @property void textureProgress(Texture v) 469 { 470 setProgressTexture(v); 471 } 472 /** 473 $(D Texture) that draws under the progress bar. The bar's background. 474 */ 475 @property Texture textureUnder() 476 { 477 return getUnderTexture(); 478 } 479 /// ditto 480 @property void textureUnder(Texture v) 481 { 482 setUnderTexture(v); 483 } 484 /** 485 Multiplies the color of the bar's `texture_over` texture. The effect is similar to $(D CanvasItem.modulate), except it only affects this specific texture instead of the entire node. 486 */ 487 @property Color tintOver() 488 { 489 return getTintOver(); 490 } 491 /// ditto 492 @property void tintOver(Color v) 493 { 494 setTintOver(v); 495 } 496 /** 497 Multiplies the color of the bar's `texture_progress` texture. 498 */ 499 @property Color tintProgress() 500 { 501 return getTintProgress(); 502 } 503 /// ditto 504 @property void tintProgress(Color v) 505 { 506 setTintProgress(v); 507 } 508 /** 509 Multiplies the color of the bar's `texture_under` texture. 510 */ 511 @property Color tintUnder() 512 { 513 return getTintUnder(); 514 } 515 /// ditto 516 @property void tintUnder(Color v) 517 { 518 setTintUnder(v); 519 } 520 }