1 /** 2 A helper node for displaying scrollable elements such as lists. 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.scrollcontainer; 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.container; 25 import godot.control; 26 import godot.canvasitem; 27 import godot.node; 28 import godot.inputevent; 29 import godot.hscrollbar; 30 import godot.vscrollbar; 31 /** 32 A helper node for displaying scrollable elements such as lists. 33 34 A ScrollContainer node meant to contain a $(D Control) child. ScrollContainers will automatically create a scrollbar child ($(D HScrollBar), $(D VScrollBar), or both) when needed and will only draw the Control within the ScrollContainer area. Scrollbars will automatically be drawn at the right (for vertical) or bottom (for horizontal) and will enable dragging to move the viewable Control (and its children) within the ScrollContainer. Scrollbars will also automatically resize the grabber based on the $(D Control.rectMinSize) of the Control relative to the ScrollContainer. Works great with a $(D Panel) control. You can set `EXPAND` on the children's size flags, so they will upscale to the ScrollContainer's size if it's larger (scroll is invisible for the chosen dimension). 35 */ 36 @GodotBaseClass struct ScrollContainer 37 { 38 package(godot) enum string _GODOT_internal_name = "ScrollContainer"; 39 public: 40 @nogc nothrow: 41 union { /** */ godot_object _godot_object; /** */ Container _GODOT_base; } 42 alias _GODOT_base this; 43 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 44 package(godot) __gshared bool _classBindingInitialized = false; 45 package(godot) static struct GDNativeClassBinding 46 { 47 __gshared: 48 @GodotName("_ensure_focused_visible") GodotMethod!(void, Control) _ensureFocusedVisible; 49 @GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput; 50 @GodotName("_scroll_moved") GodotMethod!(void, double) _scrollMoved; 51 @GodotName("_update_scrollbar_position") GodotMethod!(void) _updateScrollbarPosition; 52 @GodotName("get_deadzone") GodotMethod!(long) getDeadzone; 53 @GodotName("get_h_scroll") GodotMethod!(long) getHScroll; 54 @GodotName("get_h_scrollbar") GodotMethod!(HScrollBar) getHScrollbar; 55 @GodotName("get_v_scroll") GodotMethod!(long) getVScroll; 56 @GodotName("get_v_scrollbar") GodotMethod!(VScrollBar) getVScrollbar; 57 @GodotName("is_following_focus") GodotMethod!(bool) isFollowingFocus; 58 @GodotName("is_h_scroll_enabled") GodotMethod!(bool) isHScrollEnabled; 59 @GodotName("is_v_scroll_enabled") GodotMethod!(bool) isVScrollEnabled; 60 @GodotName("set_deadzone") GodotMethod!(void, long) setDeadzone; 61 @GodotName("set_enable_h_scroll") GodotMethod!(void, bool) setEnableHScroll; 62 @GodotName("set_enable_v_scroll") GodotMethod!(void, bool) setEnableVScroll; 63 @GodotName("set_follow_focus") GodotMethod!(void, bool) setFollowFocus; 64 @GodotName("set_h_scroll") GodotMethod!(void, long) setHScroll; 65 @GodotName("set_v_scroll") GodotMethod!(void, long) setVScroll; 66 } 67 /// 68 pragma(inline, true) bool opEquals(in ScrollContainer other) const 69 { return _godot_object.ptr is other._godot_object.ptr; } 70 /// 71 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 72 { _godot_object.ptr = n; return null; } 73 /// 74 pragma(inline, true) bool opEquals(typeof(null) n) const 75 { return _godot_object.ptr is n; } 76 /// 77 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 78 mixin baseCasts; 79 /// Construct a new instance of ScrollContainer. 80 /// Note: use `memnew!ScrollContainer` instead. 81 static ScrollContainer _new() 82 { 83 static godot_class_constructor constructor; 84 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ScrollContainer"); 85 if(constructor is null) return typeof(this).init; 86 return cast(ScrollContainer)(constructor()); 87 } 88 @disable new(size_t s); 89 /** 90 91 */ 92 void _ensureFocusedVisible(Control arg0) 93 { 94 Array _GODOT_args = Array.make(); 95 _GODOT_args.append(arg0); 96 String _GODOT_method_name = String("_ensure_focused_visible"); 97 this.callv(_GODOT_method_name, _GODOT_args); 98 } 99 /** 100 101 */ 102 void _guiInput(InputEvent arg0) 103 { 104 Array _GODOT_args = Array.make(); 105 _GODOT_args.append(arg0); 106 String _GODOT_method_name = String("_gui_input"); 107 this.callv(_GODOT_method_name, _GODOT_args); 108 } 109 /** 110 111 */ 112 void _scrollMoved(in double arg0) 113 { 114 Array _GODOT_args = Array.make(); 115 _GODOT_args.append(arg0); 116 String _GODOT_method_name = String("_scroll_moved"); 117 this.callv(_GODOT_method_name, _GODOT_args); 118 } 119 /** 120 121 */ 122 void _updateScrollbarPosition() 123 { 124 Array _GODOT_args = Array.make(); 125 String _GODOT_method_name = String("_update_scrollbar_position"); 126 this.callv(_GODOT_method_name, _GODOT_args); 127 } 128 /** 129 130 */ 131 long getDeadzone() const 132 { 133 checkClassBinding!(typeof(this))(); 134 return ptrcall!(long)(GDNativeClassBinding.getDeadzone, _godot_object); 135 } 136 /** 137 138 */ 139 long getHScroll() const 140 { 141 checkClassBinding!(typeof(this))(); 142 return ptrcall!(long)(GDNativeClassBinding.getHScroll, _godot_object); 143 } 144 /** 145 Returns the horizontal scrollbar $(D HScrollBar) of this $(D ScrollContainer). 146 */ 147 HScrollBar getHScrollbar() 148 { 149 checkClassBinding!(typeof(this))(); 150 return ptrcall!(HScrollBar)(GDNativeClassBinding.getHScrollbar, _godot_object); 151 } 152 /** 153 154 */ 155 long getVScroll() const 156 { 157 checkClassBinding!(typeof(this))(); 158 return ptrcall!(long)(GDNativeClassBinding.getVScroll, _godot_object); 159 } 160 /** 161 Returns the vertical scrollbar $(D VScrollBar) of this $(D ScrollContainer). 162 */ 163 VScrollBar getVScrollbar() 164 { 165 checkClassBinding!(typeof(this))(); 166 return ptrcall!(VScrollBar)(GDNativeClassBinding.getVScrollbar, _godot_object); 167 } 168 /** 169 170 */ 171 bool isFollowingFocus() const 172 { 173 checkClassBinding!(typeof(this))(); 174 return ptrcall!(bool)(GDNativeClassBinding.isFollowingFocus, _godot_object); 175 } 176 /** 177 178 */ 179 bool isHScrollEnabled() const 180 { 181 checkClassBinding!(typeof(this))(); 182 return ptrcall!(bool)(GDNativeClassBinding.isHScrollEnabled, _godot_object); 183 } 184 /** 185 186 */ 187 bool isVScrollEnabled() const 188 { 189 checkClassBinding!(typeof(this))(); 190 return ptrcall!(bool)(GDNativeClassBinding.isVScrollEnabled, _godot_object); 191 } 192 /** 193 194 */ 195 void setDeadzone(in long deadzone) 196 { 197 checkClassBinding!(typeof(this))(); 198 ptrcall!(void)(GDNativeClassBinding.setDeadzone, _godot_object, deadzone); 199 } 200 /** 201 202 */ 203 void setEnableHScroll(in bool enable) 204 { 205 checkClassBinding!(typeof(this))(); 206 ptrcall!(void)(GDNativeClassBinding.setEnableHScroll, _godot_object, enable); 207 } 208 /** 209 210 */ 211 void setEnableVScroll(in bool enable) 212 { 213 checkClassBinding!(typeof(this))(); 214 ptrcall!(void)(GDNativeClassBinding.setEnableVScroll, _godot_object, enable); 215 } 216 /** 217 218 */ 219 void setFollowFocus(in bool enabled) 220 { 221 checkClassBinding!(typeof(this))(); 222 ptrcall!(void)(GDNativeClassBinding.setFollowFocus, _godot_object, enabled); 223 } 224 /** 225 226 */ 227 void setHScroll(in long value) 228 { 229 checkClassBinding!(typeof(this))(); 230 ptrcall!(void)(GDNativeClassBinding.setHScroll, _godot_object, value); 231 } 232 /** 233 234 */ 235 void setVScroll(in long value) 236 { 237 checkClassBinding!(typeof(this))(); 238 ptrcall!(void)(GDNativeClassBinding.setVScroll, _godot_object, value); 239 } 240 /** 241 If `true`, the ScrollContainer will automatically scroll to focused children (including indirect children) to make sure they are fully visible. 242 */ 243 @property bool followFocus() 244 { 245 return isFollowingFocus(); 246 } 247 /// ditto 248 @property void followFocus(bool v) 249 { 250 setFollowFocus(v); 251 } 252 /** 253 254 */ 255 @property long scrollDeadzone() 256 { 257 return getDeadzone(); 258 } 259 /// ditto 260 @property void scrollDeadzone(long v) 261 { 262 setDeadzone(v); 263 } 264 /** 265 The current horizontal scroll value. 266 */ 267 @property long scrollHorizontal() 268 { 269 return getHScroll(); 270 } 271 /// ditto 272 @property void scrollHorizontal(long v) 273 { 274 setHScroll(v); 275 } 276 /** 277 If `true`, enables horizontal scrolling. 278 */ 279 @property bool scrollHorizontalEnabled() 280 { 281 return isHScrollEnabled(); 282 } 283 /// ditto 284 @property void scrollHorizontalEnabled(bool v) 285 { 286 setEnableHScroll(v); 287 } 288 /** 289 The current vertical scroll value. 290 */ 291 @property long scrollVertical() 292 { 293 return getVScroll(); 294 } 295 /// ditto 296 @property void scrollVertical(long v) 297 { 298 setVScroll(v); 299 } 300 /** 301 If `true`, enables vertical scrolling. 302 */ 303 @property bool scrollVerticalEnabled() 304 { 305 return isVScrollEnabled(); 306 } 307 /// ditto 308 @property void scrollVerticalEnabled(bool v) 309 { 310 setEnableVScroll(v); 311 } 312 }