1 /** 2 Texture-based nine-patch $(D StyleBox). 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.styleboxtexture; 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.stylebox; 25 import godot.resource; 26 import godot.reference; 27 import godot.texture; 28 /** 29 Texture-based nine-patch $(D StyleBox). 30 31 Texture-based nine-patch $(D StyleBox), in a way similar to $(D NinePatchRect). This stylebox performs a 3×3 scaling of a texture, where only the center cell is fully stretched. This makes it possible to design bordered styles regardless of the stylebox's size. 32 */ 33 @GodotBaseClass struct StyleBoxTexture 34 { 35 package(godot) enum string _GODOT_internal_name = "StyleBoxTexture"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ StyleBox _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("get_expand_margin_size") GodotMethod!(double, long) getExpandMarginSize; 46 @GodotName("get_h_axis_stretch_mode") GodotMethod!(StyleBoxTexture.AxisStretchMode) getHAxisStretchMode; 47 @GodotName("get_margin_size") GodotMethod!(double, long) getMarginSize; 48 @GodotName("get_modulate") GodotMethod!(Color) getModulate; 49 @GodotName("get_normal_map") GodotMethod!(Texture) getNormalMap; 50 @GodotName("get_region_rect") GodotMethod!(Rect2) getRegionRect; 51 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 52 @GodotName("get_v_axis_stretch_mode") GodotMethod!(StyleBoxTexture.AxisStretchMode) getVAxisStretchMode; 53 @GodotName("is_draw_center_enabled") GodotMethod!(bool) isDrawCenterEnabled; 54 @GodotName("set_draw_center") GodotMethod!(void, bool) setDrawCenter; 55 @GodotName("set_expand_margin_all") GodotMethod!(void, double) setExpandMarginAll; 56 @GodotName("set_expand_margin_individual") GodotMethod!(void, double, double, double, double) setExpandMarginIndividual; 57 @GodotName("set_expand_margin_size") GodotMethod!(void, long, double) setExpandMarginSize; 58 @GodotName("set_h_axis_stretch_mode") GodotMethod!(void, long) setHAxisStretchMode; 59 @GodotName("set_margin_size") GodotMethod!(void, long, double) setMarginSize; 60 @GodotName("set_modulate") GodotMethod!(void, Color) setModulate; 61 @GodotName("set_normal_map") GodotMethod!(void, Texture) setNormalMap; 62 @GodotName("set_region_rect") GodotMethod!(void, Rect2) setRegionRect; 63 @GodotName("set_texture") GodotMethod!(void, Texture) setTexture; 64 @GodotName("set_v_axis_stretch_mode") GodotMethod!(void, long) setVAxisStretchMode; 65 } 66 /// 67 pragma(inline, true) bool opEquals(in StyleBoxTexture 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 StyleBoxTexture. 79 /// Note: use `memnew!StyleBoxTexture` instead. 80 static StyleBoxTexture _new() 81 { 82 static godot_class_constructor constructor; 83 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("StyleBoxTexture"); 84 if(constructor is null) return typeof(this).init; 85 return cast(StyleBoxTexture)(constructor()); 86 } 87 @disable new(size_t s); 88 /// 89 enum AxisStretchMode : int 90 { 91 /** 92 Stretch the stylebox's texture. This results in visible distortion unless the texture size matches the stylebox's size perfectly. 93 */ 94 axisStretchModeStretch = 0, 95 /** 96 Repeats the stylebox's texture to match the stylebox's size according to the nine-patch system. 97 */ 98 axisStretchModeTile = 1, 99 /** 100 Repeats the stylebox's texture to match the stylebox's size according to the nine-patch system. Unlike $(D constant AXIS_STRETCH_MODE_TILE), the texture may be slightly stretched to make the nine-patch texture tile seamlessly. 101 */ 102 axisStretchModeTileFit = 2, 103 } 104 /// 105 enum Constants : int 106 { 107 axisStretchModeStretch = 0, 108 axisStretchModeTile = 1, 109 axisStretchModeTileFit = 2, 110 } 111 /** 112 Returns the size of the given `margin`'s expand margin. See $(D margin) for possible values. 113 */ 114 double getExpandMarginSize(in long margin) const 115 { 116 checkClassBinding!(typeof(this))(); 117 return ptrcall!(double)(GDNativeClassBinding.getExpandMarginSize, _godot_object, margin); 118 } 119 /** 120 121 */ 122 StyleBoxTexture.AxisStretchMode getHAxisStretchMode() const 123 { 124 checkClassBinding!(typeof(this))(); 125 return ptrcall!(StyleBoxTexture.AxisStretchMode)(GDNativeClassBinding.getHAxisStretchMode, _godot_object); 126 } 127 /** 128 Returns the size of the given `margin`. See $(D margin) for possible values. 129 */ 130 double getMarginSize(in long margin) const 131 { 132 checkClassBinding!(typeof(this))(); 133 return ptrcall!(double)(GDNativeClassBinding.getMarginSize, _godot_object, margin); 134 } 135 /** 136 137 */ 138 Color getModulate() const 139 { 140 checkClassBinding!(typeof(this))(); 141 return ptrcall!(Color)(GDNativeClassBinding.getModulate, _godot_object); 142 } 143 /** 144 145 */ 146 Ref!Texture getNormalMap() const 147 { 148 checkClassBinding!(typeof(this))(); 149 return ptrcall!(Texture)(GDNativeClassBinding.getNormalMap, _godot_object); 150 } 151 /** 152 153 */ 154 Rect2 getRegionRect() const 155 { 156 checkClassBinding!(typeof(this))(); 157 return ptrcall!(Rect2)(GDNativeClassBinding.getRegionRect, _godot_object); 158 } 159 /** 160 161 */ 162 Ref!Texture getTexture() const 163 { 164 checkClassBinding!(typeof(this))(); 165 return ptrcall!(Texture)(GDNativeClassBinding.getTexture, _godot_object); 166 } 167 /** 168 169 */ 170 StyleBoxTexture.AxisStretchMode getVAxisStretchMode() const 171 { 172 checkClassBinding!(typeof(this))(); 173 return ptrcall!(StyleBoxTexture.AxisStretchMode)(GDNativeClassBinding.getVAxisStretchMode, _godot_object); 174 } 175 /** 176 177 */ 178 bool isDrawCenterEnabled() const 179 { 180 checkClassBinding!(typeof(this))(); 181 return ptrcall!(bool)(GDNativeClassBinding.isDrawCenterEnabled, _godot_object); 182 } 183 /** 184 185 */ 186 void setDrawCenter(in bool enable) 187 { 188 checkClassBinding!(typeof(this))(); 189 ptrcall!(void)(GDNativeClassBinding.setDrawCenter, _godot_object, enable); 190 } 191 /** 192 Sets the expand margin to `size` pixels for all margins. 193 */ 194 void setExpandMarginAll(in double size) 195 { 196 checkClassBinding!(typeof(this))(); 197 ptrcall!(void)(GDNativeClassBinding.setExpandMarginAll, _godot_object, size); 198 } 199 /** 200 Sets the expand margin for each margin to `size_left`, `size_top`, `size_right`, and `size_bottom` pixels. 201 */ 202 void setExpandMarginIndividual(in double size_left, in double size_top, in double size_right, in double size_bottom) 203 { 204 checkClassBinding!(typeof(this))(); 205 ptrcall!(void)(GDNativeClassBinding.setExpandMarginIndividual, _godot_object, size_left, size_top, size_right, size_bottom); 206 } 207 /** 208 Sets the expand margin to `size` pixels for the given `margin`. See $(D margin) for possible values. 209 */ 210 void setExpandMarginSize(in long margin, in double size) 211 { 212 checkClassBinding!(typeof(this))(); 213 ptrcall!(void)(GDNativeClassBinding.setExpandMarginSize, _godot_object, margin, size); 214 } 215 /** 216 217 */ 218 void setHAxisStretchMode(in long mode) 219 { 220 checkClassBinding!(typeof(this))(); 221 ptrcall!(void)(GDNativeClassBinding.setHAxisStretchMode, _godot_object, mode); 222 } 223 /** 224 Sets the margin to `size` pixels for the given `margin`. See $(D margin) for possible values. 225 */ 226 void setMarginSize(in long margin, in double size) 227 { 228 checkClassBinding!(typeof(this))(); 229 ptrcall!(void)(GDNativeClassBinding.setMarginSize, _godot_object, margin, size); 230 } 231 /** 232 233 */ 234 void setModulate(in Color color) 235 { 236 checkClassBinding!(typeof(this))(); 237 ptrcall!(void)(GDNativeClassBinding.setModulate, _godot_object, color); 238 } 239 /** 240 241 */ 242 void setNormalMap(Texture normal_map) 243 { 244 checkClassBinding!(typeof(this))(); 245 ptrcall!(void)(GDNativeClassBinding.setNormalMap, _godot_object, normal_map); 246 } 247 /** 248 249 */ 250 void setRegionRect(in Rect2 region) 251 { 252 checkClassBinding!(typeof(this))(); 253 ptrcall!(void)(GDNativeClassBinding.setRegionRect, _godot_object, region); 254 } 255 /** 256 257 */ 258 void setTexture(Texture texture) 259 { 260 checkClassBinding!(typeof(this))(); 261 ptrcall!(void)(GDNativeClassBinding.setTexture, _godot_object, texture); 262 } 263 /** 264 265 */ 266 void setVAxisStretchMode(in long mode) 267 { 268 checkClassBinding!(typeof(this))(); 269 ptrcall!(void)(GDNativeClassBinding.setVAxisStretchMode, _godot_object, mode); 270 } 271 /** 272 Controls how the stylebox's texture will be stretched or tiled horizontally. See $(D axisstretchmode) for possible values. 273 */ 274 @property StyleBoxTexture.AxisStretchMode axisStretchHorizontal() 275 { 276 return getHAxisStretchMode(); 277 } 278 /// ditto 279 @property void axisStretchHorizontal(long v) 280 { 281 setHAxisStretchMode(v); 282 } 283 /** 284 Controls how the stylebox's texture will be stretched or tiled vertically. See $(D axisstretchmode) for possible values. 285 */ 286 @property StyleBoxTexture.AxisStretchMode axisStretchVertical() 287 { 288 return getVAxisStretchMode(); 289 } 290 /// ditto 291 @property void axisStretchVertical(long v) 292 { 293 setVAxisStretchMode(v); 294 } 295 /** 296 If `true`, the nine-patch texture's center tile will be drawn. 297 */ 298 @property bool drawCenter() 299 { 300 return isDrawCenterEnabled(); 301 } 302 /// ditto 303 @property void drawCenter(bool v) 304 { 305 setDrawCenter(v); 306 } 307 /** 308 Expands the bottom margin of this style box when drawing, causing it to be drawn larger than requested. 309 */ 310 @property double expandMarginBottom() 311 { 312 return getExpandMarginSize(3); 313 } 314 /// ditto 315 @property void expandMarginBottom(double v) 316 { 317 setExpandMarginSize(3, v); 318 } 319 /** 320 Expands the left margin of this style box when drawing, causing it to be drawn larger than requested. 321 */ 322 @property double expandMarginLeft() 323 { 324 return getExpandMarginSize(0); 325 } 326 /// ditto 327 @property void expandMarginLeft(double v) 328 { 329 setExpandMarginSize(0, v); 330 } 331 /** 332 Expands the right margin of this style box when drawing, causing it to be drawn larger than requested. 333 */ 334 @property double expandMarginRight() 335 { 336 return getExpandMarginSize(2); 337 } 338 /// ditto 339 @property void expandMarginRight(double v) 340 { 341 setExpandMarginSize(2, v); 342 } 343 /** 344 Expands the top margin of this style box when drawing, causing it to be drawn larger than requested. 345 */ 346 @property double expandMarginTop() 347 { 348 return getExpandMarginSize(1); 349 } 350 /// ditto 351 @property void expandMarginTop(double v) 352 { 353 setExpandMarginSize(1, v); 354 } 355 /** 356 Increases the bottom margin of the 3×3 texture box. 357 A higher value means more of the source texture is considered to be part of the bottom border of the 3×3 box. 358 This is also the value used as fallback for $(D StyleBox.contentMarginBottom) if it is negative. 359 */ 360 @property double marginBottom() 361 { 362 return getMarginSize(3); 363 } 364 /// ditto 365 @property void marginBottom(double v) 366 { 367 setMarginSize(3, v); 368 } 369 /** 370 Increases the left margin of the 3×3 texture box. 371 A higher value means more of the source texture is considered to be part of the left border of the 3×3 box. 372 This is also the value used as fallback for $(D StyleBox.contentMarginLeft) if it is negative. 373 */ 374 @property double marginLeft() 375 { 376 return getMarginSize(0); 377 } 378 /// ditto 379 @property void marginLeft(double v) 380 { 381 setMarginSize(0, v); 382 } 383 /** 384 Increases the right margin of the 3×3 texture box. 385 A higher value means more of the source texture is considered to be part of the right border of the 3×3 box. 386 This is also the value used as fallback for $(D StyleBox.contentMarginRight) if it is negative. 387 */ 388 @property double marginRight() 389 { 390 return getMarginSize(2); 391 } 392 /// ditto 393 @property void marginRight(double v) 394 { 395 setMarginSize(2, v); 396 } 397 /** 398 Increases the top margin of the 3×3 texture box. 399 A higher value means more of the source texture is considered to be part of the top border of the 3×3 box. 400 This is also the value used as fallback for $(D StyleBox.contentMarginTop) if it is negative. 401 */ 402 @property double marginTop() 403 { 404 return getMarginSize(1); 405 } 406 /// ditto 407 @property void marginTop(double v) 408 { 409 setMarginSize(1, v); 410 } 411 /** 412 Modulates the color of the texture when this style box is drawn. 413 */ 414 @property Color modulateColor() 415 { 416 return getModulate(); 417 } 418 /// ditto 419 @property void modulateColor(Color v) 420 { 421 setModulate(v); 422 } 423 /** 424 The normal map to use when drawing this style box. 425 $(B Note:) Godot expects the normal map to use X+, Y-, and Z+ coordinates. See $(D url=http://wiki.polycount.com/wiki/Normal_Map_Technical_Details#Common_Swizzle_Coordinates)this page$(D /url) for a comparison of normal map coordinates expected by popular engines. 426 */ 427 @property Texture normalMap() 428 { 429 return getNormalMap(); 430 } 431 /// ditto 432 @property void normalMap(Texture v) 433 { 434 setNormalMap(v); 435 } 436 /** 437 Species a sub-region of the texture to use. 438 This is equivalent to first wrapping the texture in an $(D AtlasTexture) with the same region. 439 */ 440 @property Rect2 regionRect() 441 { 442 return getRegionRect(); 443 } 444 /// ditto 445 @property void regionRect(Rect2 v) 446 { 447 setRegionRect(v); 448 } 449 /** 450 The texture to use when drawing this style box. 451 */ 452 @property Texture texture() 453 { 454 return getTexture(); 455 } 456 /// ditto 457 @property void texture(Texture v) 458 { 459 setTexture(v); 460 } 461 }