1 /** 2 A helper node for displaying scrollable elements (e.g. 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.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.container; 24 import godot.inputevent; 25 import godot.hscrollbar; 26 import godot.vscrollbar; 27 import godot.control; 28 import godot.canvasitem; 29 import godot.node; 30 /** 31 A helper node for displaying scrollable elements (e.g. lists). 32 33 A ScrollContainer node with a $(D Control) child and scrollbar child ($(D HScrollbar), $(D VScrollBar), or both) 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 minimum_size of the Control relative to the ScrollContainer. Works great with a $(D Panel) control. You can set EXPAND on children size flags, so they will upscale to ScrollContainer size if ScrollContainer size is bigger (scroll is invisible for chosen dimension). 34 */ 35 @GodotBaseClass struct ScrollContainer 36 { 37 enum string _GODOT_internal_name = "ScrollContainer"; 38 public: 39 @nogc nothrow: 40 union { godot_object _godot_object; Container _GODOT_base; } 41 alias _GODOT_base this; 42 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 43 package(godot) __gshared bool _classBindingInitialized = false; 44 package(godot) static struct _classBinding 45 { 46 __gshared: 47 @GodotName("_scroll_moved") GodotMethod!(void, double) _scrollMoved; 48 @GodotName("_gui_input") GodotMethod!(void, InputEvent) _guiInput; 49 @GodotName("set_enable_h_scroll") GodotMethod!(void, bool) setEnableHScroll; 50 @GodotName("is_h_scroll_enabled") GodotMethod!(bool) isHScrollEnabled; 51 @GodotName("set_enable_v_scroll") GodotMethod!(void, bool) setEnableVScroll; 52 @GodotName("is_v_scroll_enabled") GodotMethod!(bool) isVScrollEnabled; 53 @GodotName("_update_scrollbar_position") GodotMethod!(void) _updateScrollbarPosition; 54 @GodotName("set_h_scroll") GodotMethod!(void, long) setHScroll; 55 @GodotName("get_h_scroll") GodotMethod!(long) getHScroll; 56 @GodotName("set_v_scroll") GodotMethod!(void, long) setVScroll; 57 @GodotName("get_v_scroll") GodotMethod!(long) getVScroll; 58 @GodotName("set_deadzone") GodotMethod!(void, long) setDeadzone; 59 @GodotName("get_deadzone") GodotMethod!(long) getDeadzone; 60 @GodotName("get_h_scrollbar") GodotMethod!(HScrollBar) getHScrollbar; 61 @GodotName("get_v_scrollbar") GodotMethod!(VScrollBar) getVScrollbar; 62 } 63 bool opEquals(in ScrollContainer other) const { return _godot_object.ptr is other._godot_object.ptr; } 64 ScrollContainer opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 65 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 66 mixin baseCasts; 67 static ScrollContainer _new() 68 { 69 static godot_class_constructor constructor; 70 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ScrollContainer"); 71 if(constructor is null) return typeof(this).init; 72 return cast(ScrollContainer)(constructor()); 73 } 74 @disable new(size_t s); 75 /** 76 77 */ 78 void _scrollMoved(in double arg0) 79 { 80 Array _GODOT_args = Array.empty_array; 81 _GODOT_args.append(arg0); 82 String _GODOT_method_name = String("_scroll_moved"); 83 this.callv(_GODOT_method_name, _GODOT_args); 84 } 85 /** 86 87 */ 88 void _guiInput(InputEvent arg0) 89 { 90 Array _GODOT_args = Array.empty_array; 91 _GODOT_args.append(arg0); 92 String _GODOT_method_name = String("_gui_input"); 93 this.callv(_GODOT_method_name, _GODOT_args); 94 } 95 /** 96 97 */ 98 void setEnableHScroll(in bool enable) 99 { 100 checkClassBinding!(typeof(this))(); 101 ptrcall!(void)(_classBinding.setEnableHScroll, _godot_object, enable); 102 } 103 /** 104 105 */ 106 bool isHScrollEnabled() const 107 { 108 checkClassBinding!(typeof(this))(); 109 return ptrcall!(bool)(_classBinding.isHScrollEnabled, _godot_object); 110 } 111 /** 112 113 */ 114 void setEnableVScroll(in bool enable) 115 { 116 checkClassBinding!(typeof(this))(); 117 ptrcall!(void)(_classBinding.setEnableVScroll, _godot_object, enable); 118 } 119 /** 120 121 */ 122 bool isVScrollEnabled() const 123 { 124 checkClassBinding!(typeof(this))(); 125 return ptrcall!(bool)(_classBinding.isVScrollEnabled, _godot_object); 126 } 127 /** 128 129 */ 130 void _updateScrollbarPosition() 131 { 132 Array _GODOT_args = Array.empty_array; 133 String _GODOT_method_name = String("_update_scrollbar_position"); 134 this.callv(_GODOT_method_name, _GODOT_args); 135 } 136 /** 137 138 */ 139 void setHScroll(in long value) 140 { 141 checkClassBinding!(typeof(this))(); 142 ptrcall!(void)(_classBinding.setHScroll, _godot_object, value); 143 } 144 /** 145 146 */ 147 long getHScroll() const 148 { 149 checkClassBinding!(typeof(this))(); 150 return ptrcall!(long)(_classBinding.getHScroll, _godot_object); 151 } 152 /** 153 154 */ 155 void setVScroll(in long value) 156 { 157 checkClassBinding!(typeof(this))(); 158 ptrcall!(void)(_classBinding.setVScroll, _godot_object, value); 159 } 160 /** 161 162 */ 163 long getVScroll() const 164 { 165 checkClassBinding!(typeof(this))(); 166 return ptrcall!(long)(_classBinding.getVScroll, _godot_object); 167 } 168 /** 169 170 */ 171 void setDeadzone(in long deadzone) 172 { 173 checkClassBinding!(typeof(this))(); 174 ptrcall!(void)(_classBinding.setDeadzone, _godot_object, deadzone); 175 } 176 /** 177 178 */ 179 long getDeadzone() const 180 { 181 checkClassBinding!(typeof(this))(); 182 return ptrcall!(long)(_classBinding.getDeadzone, _godot_object); 183 } 184 /** 185 186 */ 187 HScrollBar getHScrollbar() 188 { 189 checkClassBinding!(typeof(this))(); 190 return ptrcall!(HScrollBar)(_classBinding.getHScrollbar, _godot_object); 191 } 192 /** 193 194 */ 195 VScrollBar getVScrollbar() 196 { 197 checkClassBinding!(typeof(this))(); 198 return ptrcall!(VScrollBar)(_classBinding.getVScrollbar, _godot_object); 199 } 200 /** 201 If `true`, enables horizontal scrolling. 202 */ 203 @property bool scrollHorizontalEnabled() 204 { 205 return isHScrollEnabled(); 206 } 207 /// ditto 208 @property void scrollHorizontalEnabled(bool v) 209 { 210 setEnableHScroll(v); 211 } 212 /** 213 The current horizontal scroll value. 214 */ 215 @property long scrollHorizontal() 216 { 217 return getHScroll(); 218 } 219 /// ditto 220 @property void scrollHorizontal(long v) 221 { 222 setHScroll(v); 223 } 224 /** 225 If `true`, enables vertical scrolling. 226 */ 227 @property bool scrollVerticalEnabled() 228 { 229 return isVScrollEnabled(); 230 } 231 /// ditto 232 @property void scrollVerticalEnabled(bool v) 233 { 234 setEnableVScroll(v); 235 } 236 /** 237 The current vertical scroll value. 238 */ 239 @property long scrollVertical() 240 { 241 return getVScroll(); 242 } 243 /// ditto 244 @property void scrollVertical(long v) 245 { 246 setVScroll(v); 247 } 248 /** 249 250 */ 251 @property long scrollDeadzone() 252 { 253 return getDeadzone(); 254 } 255 /// ditto 256 @property void scrollDeadzone(long v) 257 { 258 setDeadzone(v); 259 } 260 }