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.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.control;
25 import godot.canvasitem;
26 import godot.node;
27 /**
28 Base container control for popups and dialogs.
29 
30 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. All popup methods ensure correct placement within the viewport.
31 */
32 @GodotBaseClass struct Popup
33 {
34 	package(godot) enum string _GODOT_internal_name = "Popup";
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 GDNativeClassBinding
42 	{
43 		__gshared:
44 		@GodotName("is_exclusive") GodotMethod!(bool) isExclusive;
45 		@GodotName("popup") GodotMethod!(void, Rect2) popup;
46 		@GodotName("popup_centered") GodotMethod!(void, Vector2) popupCentered;
47 		@GodotName("popup_centered_clamped") GodotMethod!(void, Vector2, double) popupCenteredClamped;
48 		@GodotName("popup_centered_minsize") GodotMethod!(void, Vector2) popupCenteredMinsize;
49 		@GodotName("popup_centered_ratio") GodotMethod!(void, double) popupCenteredRatio;
50 		@GodotName("set_as_minsize") GodotMethod!(void) setAsMinsize;
51 		@GodotName("set_exclusive") GodotMethod!(void, bool) setExclusive;
52 	}
53 	/// 
54 	pragma(inline, true) bool opEquals(in Popup other) const
55 	{ return _godot_object.ptr is other._godot_object.ptr; }
56 	/// 
57 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
58 	{ _godot_object.ptr = n; return null; }
59 	/// 
60 	pragma(inline, true) bool opEquals(typeof(null) n) const
61 	{ return _godot_object.ptr is n; }
62 	/// 
63 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
64 	mixin baseCasts;
65 	/// Construct a new instance of Popup.
66 	/// Note: use `memnew!Popup` instead.
67 	static Popup _new()
68 	{
69 		static godot_class_constructor constructor;
70 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("Popup");
71 		if(constructor is null) return typeof(this).init;
72 		return cast(Popup)(constructor());
73 	}
74 	@disable new(size_t s);
75 	/// 
76 	enum Constants : int
77 	{
78 		/**
79 		Notification sent right after the popup is shown.
80 		*/
81 		notificationPostPopup = 80,
82 		/**
83 		Notification sent right after the popup is hidden.
84 		*/
85 		notificationPopupHide = 81,
86 	}
87 	/**
88 	
89 	*/
90 	bool isExclusive() const
91 	{
92 		checkClassBinding!(typeof(this))();
93 		return ptrcall!(bool)(GDNativeClassBinding.isExclusive, _godot_object);
94 	}
95 	/**
96 	Popup (show the control in modal form).
97 	*/
98 	void popup(in Rect2 bounds = Rect2(0, 0, 0, 0))
99 	{
100 		checkClassBinding!(typeof(this))();
101 		ptrcall!(void)(GDNativeClassBinding.popup, _godot_object, bounds);
102 	}
103 	/**
104 	Popup (show the control in modal form) in the center of the screen relative to its current canvas transform, at the current size, or at a size determined by `size`.
105 	*/
106 	void popupCentered(in Vector2 size = Vector2(0, 0))
107 	{
108 		checkClassBinding!(typeof(this))();
109 		ptrcall!(void)(GDNativeClassBinding.popupCentered, _godot_object, size);
110 	}
111 	/**
112 	Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, clamping the size to `size`, then ensuring the popup is no larger than the viewport size multiplied by `fallback_ratio`.
113 	*/
114 	void popupCenteredClamped(in Vector2 size = Vector2(0, 0), in double fallback_ratio = 0.75)
115 	{
116 		checkClassBinding!(typeof(this))();
117 		ptrcall!(void)(GDNativeClassBinding.popupCenteredClamped, _godot_object, size, fallback_ratio);
118 	}
119 	/**
120 	Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, ensuring the size is never smaller than `minsize`.
121 	*/
122 	void popupCenteredMinsize(in Vector2 minsize = Vector2(0, 0))
123 	{
124 		checkClassBinding!(typeof(this))();
125 		ptrcall!(void)(GDNativeClassBinding.popupCenteredMinsize, _godot_object, minsize);
126 	}
127 	/**
128 	Popup (show the control in modal form) in the center of the screen relative to the current canvas transform, scaled at a ratio of size of the screen.
129 	*/
130 	void popupCenteredRatio(in double ratio = 0.75)
131 	{
132 		checkClassBinding!(typeof(this))();
133 		ptrcall!(void)(GDNativeClassBinding.popupCenteredRatio, _godot_object, ratio);
134 	}
135 	/**
136 	Shrink popup to keep to the minimum size of content.
137 	*/
138 	void setAsMinsize()
139 	{
140 		checkClassBinding!(typeof(this))();
141 		ptrcall!(void)(GDNativeClassBinding.setAsMinsize, _godot_object);
142 	}
143 	/**
144 	
145 	*/
146 	void setExclusive(in bool enable)
147 	{
148 		checkClassBinding!(typeof(this))();
149 		ptrcall!(void)(GDNativeClassBinding.setExclusive, _godot_object, enable);
150 	}
151 	/**
152 	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.
153 	$(B Note:) Enabling this property doesn't affect the Close or Cancel buttons' behavior in dialogs that inherit from this class. As a workaround, you can use $(D WindowDialog.getCloseButton) or $(D ConfirmationDialog.getCancel) and hide the buttons in question by setting their $(D CanvasItem.visible) property to `false`.
154 	*/
155 	@property bool popupExclusive()
156 	{
157 		return isExclusive();
158 	}
159 	/// ditto
160 	@property void popupExclusive(bool v)
161 	{
162 		setExclusive(v);
163 	}
164 }