1 /** 2 Base container control for popups and dialogs. 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.popup; 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.canvasitem; 25 import godot.node; 26 /** 27 Base container control for popups and dialogs. 28 29 Popup is a base $(D Control) used to show dialogs and popups. It's a subwindow and modal by default (see $(D Control)) and has helpers for custom popup behavior. 30 */ 31 @GodotBaseClass struct Popup 32 { 33 enum string _GODOT_internal_name = "Popup"; 34 public: 35 @nogc nothrow: 36 union { godot_object _godot_object; Control _GODOT_base; } 37 alias _GODOT_base this; 38 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 39 package(godot) __gshared bool _classBindingInitialized = false; 40 package(godot) static struct _classBinding 41 { 42 __gshared: 43 @GodotName("popup_centered") GodotMethod!(void, Vector2) popupCentered; 44 @GodotName("popup_centered_ratio") GodotMethod!(void, double) popupCenteredRatio; 45 @GodotName("popup_centered_minsize") GodotMethod!(void, Vector2) popupCenteredMinsize; 46 @GodotName("popup") GodotMethod!(void, Rect2) popup; 47 @GodotName("set_exclusive") GodotMethod!(void, bool) setExclusive; 48 @GodotName("is_exclusive") GodotMethod!(bool) isExclusive; 49 } 50 bool opEquals(in Popup other) const { return _godot_object.ptr is other._godot_object.ptr; } 51 Popup opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 52 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 53 mixin baseCasts; 54 static Popup _new() 55 { 56 static godot_class_constructor constructor; 57 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Popup"); 58 if(constructor is null) return typeof(this).init; 59 return cast(Popup)(constructor()); 60 } 61 @disable new(size_t s); 62 /// 63 enum Constants : int 64 { 65 /** 66 Notification sent right after the popup is shown. 67 */ 68 notificationPostPopup = 80, 69 /** 70 Notification sent right after the popup is hidden. 71 */ 72 notificationPopupHide = 81, 73 } 74 /** 75 Popup (show the control in modal form) in the center of the screen, at the current size, or at a size determined by "size". 76 */ 77 void popupCentered(in Vector2 size = Vector2(0, 0)) 78 { 79 checkClassBinding!(typeof(this))(); 80 ptrcall!(void)(_classBinding.popupCentered, _godot_object, size); 81 } 82 /** 83 Popup (show the control in modal form) in the center of the screen, scaled at a ratio of size of the screen. 84 */ 85 void popupCenteredRatio(in double ratio = 0.75) 86 { 87 checkClassBinding!(typeof(this))(); 88 ptrcall!(void)(_classBinding.popupCenteredRatio, _godot_object, ratio); 89 } 90 /** 91 Popup (show the control in modal form) in the center of the screen, ensuring the size is never smaller than `minsize`. 92 */ 93 void popupCenteredMinsize(in Vector2 minsize = Vector2(0, 0)) 94 { 95 checkClassBinding!(typeof(this))(); 96 ptrcall!(void)(_classBinding.popupCenteredMinsize, _godot_object, minsize); 97 } 98 /** 99 Popup (show the control in modal form). 100 */ 101 void popup(in Rect2 bounds = Rect2(0, 0, 0, 0)) 102 { 103 checkClassBinding!(typeof(this))(); 104 ptrcall!(void)(_classBinding.popup, _godot_object, bounds); 105 } 106 /** 107 108 */ 109 void setExclusive(in bool enable) 110 { 111 checkClassBinding!(typeof(this))(); 112 ptrcall!(void)(_classBinding.setExclusive, _godot_object, enable); 113 } 114 /** 115 116 */ 117 bool isExclusive() const 118 { 119 checkClassBinding!(typeof(this))(); 120 return ptrcall!(bool)(_classBinding.isExclusive, _godot_object); 121 } 122 /** 123 If `true` the popup will not be hidden when a click event occurs outside of it, or when it receives the `ui_cancel` action event. 124 */ 125 @property bool popupExclusive() 126 { 127 return isExclusive(); 128 } 129 /// ditto 130 @property void popupExclusive(bool v) 131 { 132 setExclusive(v); 133 } 134 }