1 /** 2 Scalable texture-based frame that tiles the texture's centers and sides, but keeps the corners' original size. Perfect for panels and dialog boxes. 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.ninepatchrect; 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.classdb; 23 import godot.control; 24 import godot.texture; 25 import godot.canvasitem; 26 import godot.node; 27 /** 28 Scalable texture-based frame that tiles the texture's centers and sides, but keeps the corners' original size. Perfect for panels and dialog boxes. 29 30 Better known as 9-slice panels, NinePatchRect produces clean panels of any size, based on a small texture. To do so, it splits the texture in a 3 by 3 grid. When you scale the node, it tiles the texture's sides horizontally or vertically, the center on both axes but it doesn't scale or tile the corners. 31 */ 32 @GodotBaseClass struct NinePatchRect 33 { 34 enum string _GODOT_internal_name = "NinePatchRect"; 35 public: 36 @nogc nothrow: 37 union { godot_object _godot_object; Control _GODOT_base; } 38 alias _GODOT_base this; 39 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 40 package(godot) __gshared bool _classBindingInitialized = false; 41 package(godot) static struct _classBinding 42 { 43 __gshared: 44 @GodotName("set_texture") GodotMethod!(void, Texture) setTexture; 45 @GodotName("get_texture") GodotMethod!(Texture) getTexture; 46 @GodotName("set_patch_margin") GodotMethod!(void, long, long) setPatchMargin; 47 @GodotName("get_patch_margin") GodotMethod!(long, long) getPatchMargin; 48 @GodotName("set_region_rect") GodotMethod!(void, Rect2) setRegionRect; 49 @GodotName("get_region_rect") GodotMethod!(Rect2) getRegionRect; 50 @GodotName("set_draw_center") GodotMethod!(void, bool) setDrawCenter; 51 @GodotName("is_draw_center_enabled") GodotMethod!(bool) isDrawCenterEnabled; 52 @GodotName("set_h_axis_stretch_mode") GodotMethod!(void, long) setHAxisStretchMode; 53 @GodotName("get_h_axis_stretch_mode") GodotMethod!(NinePatchRect.AxisStretchMode) getHAxisStretchMode; 54 @GodotName("set_v_axis_stretch_mode") GodotMethod!(void, long) setVAxisStretchMode; 55 @GodotName("get_v_axis_stretch_mode") GodotMethod!(NinePatchRect.AxisStretchMode) getVAxisStretchMode; 56 } 57 bool opEquals(in NinePatchRect other) const { return _godot_object.ptr is other._godot_object.ptr; } 58 NinePatchRect opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 59 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 60 mixin baseCasts; 61 static NinePatchRect _new() 62 { 63 static godot_class_constructor constructor; 64 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("NinePatchRect"); 65 if(constructor is null) return typeof(this).init; 66 return cast(NinePatchRect)(constructor()); 67 } 68 @disable new(size_t s); 69 /// 70 enum AxisStretchMode : int 71 { 72 /** 73 Doesn't do anything at the time of writing. Default value for `axis_stretch_horizontal` and `axis_stretch_vertical`. 74 */ 75 axisStretchModeStretch = 0, 76 /** 77 Doesn't do anything at the time of writing. 78 */ 79 axisStretchModeTile = 1, 80 /** 81 Doesn't do anything at the time of writing. 82 */ 83 axisStretchModeTileFit = 2, 84 } 85 /// 86 enum Constants : int 87 { 88 axisStretchModeStretch = 0, 89 axisStretchModeTile = 1, 90 axisStretchModeTileFit = 2, 91 } 92 /** 93 94 */ 95 void setTexture(Texture texture) 96 { 97 checkClassBinding!(typeof(this))(); 98 ptrcall!(void)(_classBinding.setTexture, _godot_object, texture); 99 } 100 /** 101 102 */ 103 Ref!Texture getTexture() const 104 { 105 checkClassBinding!(typeof(this))(); 106 return ptrcall!(Texture)(_classBinding.getTexture, _godot_object); 107 } 108 /** 109 110 */ 111 void setPatchMargin(in long margin, in long value) 112 { 113 checkClassBinding!(typeof(this))(); 114 ptrcall!(void)(_classBinding.setPatchMargin, _godot_object, margin, value); 115 } 116 /** 117 118 */ 119 long getPatchMargin(in long margin) const 120 { 121 checkClassBinding!(typeof(this))(); 122 return ptrcall!(long)(_classBinding.getPatchMargin, _godot_object, margin); 123 } 124 /** 125 126 */ 127 void setRegionRect(in Rect2 rect) 128 { 129 checkClassBinding!(typeof(this))(); 130 ptrcall!(void)(_classBinding.setRegionRect, _godot_object, rect); 131 } 132 /** 133 134 */ 135 Rect2 getRegionRect() const 136 { 137 checkClassBinding!(typeof(this))(); 138 return ptrcall!(Rect2)(_classBinding.getRegionRect, _godot_object); 139 } 140 /** 141 142 */ 143 void setDrawCenter(in bool draw_center) 144 { 145 checkClassBinding!(typeof(this))(); 146 ptrcall!(void)(_classBinding.setDrawCenter, _godot_object, draw_center); 147 } 148 /** 149 150 */ 151 bool isDrawCenterEnabled() const 152 { 153 checkClassBinding!(typeof(this))(); 154 return ptrcall!(bool)(_classBinding.isDrawCenterEnabled, _godot_object); 155 } 156 /** 157 158 */ 159 void setHAxisStretchMode(in long mode) 160 { 161 checkClassBinding!(typeof(this))(); 162 ptrcall!(void)(_classBinding.setHAxisStretchMode, _godot_object, mode); 163 } 164 /** 165 166 */ 167 NinePatchRect.AxisStretchMode getHAxisStretchMode() const 168 { 169 checkClassBinding!(typeof(this))(); 170 return ptrcall!(NinePatchRect.AxisStretchMode)(_classBinding.getHAxisStretchMode, _godot_object); 171 } 172 /** 173 174 */ 175 void setVAxisStretchMode(in long mode) 176 { 177 checkClassBinding!(typeof(this))(); 178 ptrcall!(void)(_classBinding.setVAxisStretchMode, _godot_object, mode); 179 } 180 /** 181 182 */ 183 NinePatchRect.AxisStretchMode getVAxisStretchMode() const 184 { 185 checkClassBinding!(typeof(this))(); 186 return ptrcall!(NinePatchRect.AxisStretchMode)(_classBinding.getVAxisStretchMode, _godot_object); 187 } 188 /** 189 The node's texture resource. 190 */ 191 @property Texture texture() 192 { 193 return getTexture(); 194 } 195 /// ditto 196 @property void texture(Texture v) 197 { 198 setTexture(v); 199 } 200 /** 201 If `true`, draw the panel's center. Else, only draw the 9-slice's borders. Default value: `true` 202 */ 203 @property bool drawCenter() 204 { 205 return isDrawCenterEnabled(); 206 } 207 /// ditto 208 @property void drawCenter(bool v) 209 { 210 setDrawCenter(v); 211 } 212 /** 213 Rectangular region of the texture to sample from. If you're working with an atlas, use this property to define the area the 9-slice should use. All other properties are relative to this one. 214 */ 215 @property Rect2 regionRect() 216 { 217 return getRegionRect(); 218 } 219 /// ditto 220 @property void regionRect(Rect2 v) 221 { 222 setRegionRect(v); 223 } 224 /** 225 The height of the 9-slice's left column. 226 */ 227 @property long patchMarginLeft() 228 { 229 return getPatchMargin(0); 230 } 231 /// ditto 232 @property void patchMarginLeft(long v) 233 { 234 setPatchMargin(0, v); 235 } 236 /** 237 The height of the 9-slice's top row. 238 */ 239 @property long patchMarginTop() 240 { 241 return getPatchMargin(1); 242 } 243 /// ditto 244 @property void patchMarginTop(long v) 245 { 246 setPatchMargin(1, v); 247 } 248 /** 249 The height of the 9-slice's right column. 250 */ 251 @property long patchMarginRight() 252 { 253 return getPatchMargin(2); 254 } 255 /// ditto 256 @property void patchMarginRight(long v) 257 { 258 setPatchMargin(2, v); 259 } 260 /** 261 The height of the 9-slice'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. 262 */ 263 @property long patchMarginBottom() 264 { 265 return getPatchMargin(3); 266 } 267 /// ditto 268 @property void patchMarginBottom(long v) 269 { 270 setPatchMargin(3, v); 271 } 272 /** 273 Doesn't do anything at the time of writing. 274 */ 275 @property NinePatchRect.AxisStretchMode axisStretchHorizontal() 276 { 277 return getHAxisStretchMode(); 278 } 279 /// ditto 280 @property void axisStretchHorizontal(long v) 281 { 282 setHAxisStretchMode(v); 283 } 284 /** 285 Doesn't do anything at the time of writing. 286 */ 287 @property NinePatchRect.AxisStretchMode axisStretchVertical() 288 { 289 return getVAxisStretchMode(); 290 } 291 /// ditto 292 @property void axisStretchVertical(long v) 293 { 294 setVAxisStretchMode(v); 295 } 296 }