1 /** 2 Base dialog for user notification. 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.acceptdialog; 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.windowdialog; 25 import godot.button; 26 import godot.label; 27 import godot.node; 28 /** 29 Base dialog for user notification. 30 31 This dialog is useful for small notifications to the user about an event. It can only be accepted or closed, with the same result. 32 */ 33 @GodotBaseClass struct AcceptDialog 34 { 35 package(godot) enum string _GODOT_internal_name = "AcceptDialog"; 36 public: 37 @nogc nothrow: 38 union { /** */ godot_object _godot_object; /** */ WindowDialog _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("_builtin_text_entered") GodotMethod!(void, String) _builtinTextEntered; 46 @GodotName("_custom_action") GodotMethod!(void, String) _customAction; 47 @GodotName("_ok") GodotMethod!(void) _ok; 48 @GodotName("add_button") GodotMethod!(Button, String, bool, String) addButton; 49 @GodotName("add_cancel") GodotMethod!(Button, String) addCancel; 50 @GodotName("get_hide_on_ok") GodotMethod!(bool) getHideOnOk; 51 @GodotName("get_label") GodotMethod!(Label) getLabel; 52 @GodotName("get_ok") GodotMethod!(Button) getOk; 53 @GodotName("get_text") GodotMethod!(String) getText; 54 @GodotName("has_autowrap") GodotMethod!(bool) hasAutowrap; 55 @GodotName("register_text_enter") GodotMethod!(void, Node) registerTextEnter; 56 @GodotName("set_autowrap") GodotMethod!(void, bool) setAutowrap; 57 @GodotName("set_hide_on_ok") GodotMethod!(void, bool) setHideOnOk; 58 @GodotName("set_text") GodotMethod!(void, String) setText; 59 } 60 /// 61 pragma(inline, true) bool opEquals(in AcceptDialog other) const 62 { return _godot_object.ptr is other._godot_object.ptr; } 63 /// 64 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 65 { _godot_object.ptr = n; return null; } 66 /// 67 pragma(inline, true) bool opEquals(typeof(null) n) const 68 { return _godot_object.ptr is n; } 69 /// 70 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 71 mixin baseCasts; 72 /// Construct a new instance of AcceptDialog. 73 /// Note: use `memnew!AcceptDialog` instead. 74 static AcceptDialog _new() 75 { 76 static godot_class_constructor constructor; 77 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("AcceptDialog"); 78 if(constructor is null) return typeof(this).init; 79 return cast(AcceptDialog)(constructor()); 80 } 81 @disable new(size_t s); 82 /** 83 84 */ 85 void _builtinTextEntered(in String arg0) 86 { 87 Array _GODOT_args = Array.make(); 88 _GODOT_args.append(arg0); 89 String _GODOT_method_name = String("_builtin_text_entered"); 90 this.callv(_GODOT_method_name, _GODOT_args); 91 } 92 /** 93 94 */ 95 void _customAction(in String arg0) 96 { 97 Array _GODOT_args = Array.make(); 98 _GODOT_args.append(arg0); 99 String _GODOT_method_name = String("_custom_action"); 100 this.callv(_GODOT_method_name, _GODOT_args); 101 } 102 /** 103 104 */ 105 void _ok() 106 { 107 Array _GODOT_args = Array.make(); 108 String _GODOT_method_name = String("_ok"); 109 this.callv(_GODOT_method_name, _GODOT_args); 110 } 111 /** 112 Adds a button with label `text` and a custom `action` to the dialog and returns the created button. `action` will be passed to the $(D customAction) signal when pressed. 113 If `true`, `right` will place the button to the right of any sibling buttons. 114 */ 115 Button addButton(in String text, in bool right = false, in String action = gs!"") 116 { 117 checkClassBinding!(typeof(this))(); 118 return ptrcall!(Button)(GDNativeClassBinding.addButton, _godot_object, text, right, action); 119 } 120 /** 121 Adds a button with label `name` and a cancel action to the dialog and returns the created button. 122 */ 123 Button addCancel(in String name) 124 { 125 checkClassBinding!(typeof(this))(); 126 return ptrcall!(Button)(GDNativeClassBinding.addCancel, _godot_object, name); 127 } 128 /** 129 130 */ 131 bool getHideOnOk() const 132 { 133 checkClassBinding!(typeof(this))(); 134 return ptrcall!(bool)(GDNativeClassBinding.getHideOnOk, _godot_object); 135 } 136 /** 137 Returns the label used for built-in text. 138 */ 139 Label getLabel() 140 { 141 checkClassBinding!(typeof(this))(); 142 return ptrcall!(Label)(GDNativeClassBinding.getLabel, _godot_object); 143 } 144 /** 145 Returns the OK $(D Button) instance. 146 */ 147 Button getOk() 148 { 149 checkClassBinding!(typeof(this))(); 150 return ptrcall!(Button)(GDNativeClassBinding.getOk, _godot_object); 151 } 152 /** 153 154 */ 155 String getText() const 156 { 157 checkClassBinding!(typeof(this))(); 158 return ptrcall!(String)(GDNativeClassBinding.getText, _godot_object); 159 } 160 /** 161 162 */ 163 bool hasAutowrap() 164 { 165 checkClassBinding!(typeof(this))(); 166 return ptrcall!(bool)(GDNativeClassBinding.hasAutowrap, _godot_object); 167 } 168 /** 169 Registers a $(D LineEdit) in the dialog. When the enter key is pressed, the dialog will be accepted. 170 */ 171 void registerTextEnter(Node line_edit) 172 { 173 checkClassBinding!(typeof(this))(); 174 ptrcall!(void)(GDNativeClassBinding.registerTextEnter, _godot_object, line_edit); 175 } 176 /** 177 178 */ 179 void setAutowrap(in bool autowrap) 180 { 181 checkClassBinding!(typeof(this))(); 182 ptrcall!(void)(GDNativeClassBinding.setAutowrap, _godot_object, autowrap); 183 } 184 /** 185 186 */ 187 void setHideOnOk(in bool enabled) 188 { 189 checkClassBinding!(typeof(this))(); 190 ptrcall!(void)(GDNativeClassBinding.setHideOnOk, _godot_object, enabled); 191 } 192 /** 193 194 */ 195 void setText(in String text) 196 { 197 checkClassBinding!(typeof(this))(); 198 ptrcall!(void)(GDNativeClassBinding.setText, _godot_object, text); 199 } 200 /** 201 Sets autowrapping for the text in the dialog. 202 */ 203 @property bool dialogAutowrap() 204 { 205 return hasAutowrap(); 206 } 207 /// ditto 208 @property void dialogAutowrap(bool v) 209 { 210 setAutowrap(v); 211 } 212 /** 213 If `true`, the dialog is hidden when the OK button is pressed. You can set it to `false` if you want to do e.g. input validation when receiving the $(D confirmed) signal, and handle hiding the dialog in your own logic. 214 $(B Note:) Some nodes derived from this class can have a different default value, and potentially their own built-in logic overriding this setting. For example $(D FileDialog) defaults to `false`, and has its own input validation code that is called when you press OK, which eventually hides the dialog if the input is valid. As such, this property can't be used in $(D FileDialog) to disable hiding the dialog when pressing OK. 215 */ 216 @property bool dialogHideOnOk() 217 { 218 return getHideOnOk(); 219 } 220 /// ditto 221 @property void dialogHideOnOk(bool v) 222 { 223 setHideOnOk(v); 224 } 225 /** 226 The text displayed by the dialog. 227 */ 228 @property String dialogText() 229 { 230 return getText(); 231 } 232 /// ditto 233 @property void dialogText(String v) 234 { 235 setText(v); 236 } 237 }