1 /**
2 Special button that brings up a $(D PopupMenu) when clicked.
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.menubutton;
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.button;
25 import godot.basebutton;
26 import godot.control;
27 import godot.canvasitem;
28 import godot.node;
29 import godot.inputevent;
30 import godot.popupmenu;
31 /**
32 Special button that brings up a $(D PopupMenu) when clicked.
33 
34 New items can be created inside this $(D PopupMenu) using `get_popup().add_item("My Item Name")`. You can also create them directly from the editor. To do so, select the $(D MenuButton) node, then in the toolbar at the top of the 2D editor, click $(B Items) then click $(B Add) in the popup. You will be able to give each item new properties.
35 See also $(D BaseButton) which contains common properties and methods associated with this node.
36 */
37 @GodotBaseClass struct MenuButton
38 {
39 	package(godot) enum string _GODOT_internal_name = "MenuButton";
40 public:
41 @nogc nothrow:
42 	union { /** */ godot_object _godot_object; /** */ Button _GODOT_base; }
43 	alias _GODOT_base this;
44 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
45 	package(godot) __gshared bool _classBindingInitialized = false;
46 	package(godot) static struct GDNativeClassBinding
47 	{
48 		__gshared:
49 		@GodotName("_get_items") GodotMethod!(Array) _getItems;
50 		@GodotName("_set_items") GodotMethod!(void, Array) _setItems;
51 		@GodotName("_unhandled_key_input") GodotMethod!(void, InputEvent) _unhandledKeyInput;
52 		@GodotName("get_popup") GodotMethod!(PopupMenu) getPopup;
53 		@GodotName("is_switch_on_hover") GodotMethod!(bool) isSwitchOnHover;
54 		@GodotName("set_disable_shortcuts") GodotMethod!(void, bool) setDisableShortcuts;
55 		@GodotName("set_switch_on_hover") GodotMethod!(void, bool) setSwitchOnHover;
56 	}
57 	/// 
58 	pragma(inline, true) bool opEquals(in MenuButton other) const
59 	{ return _godot_object.ptr is other._godot_object.ptr; }
60 	/// 
61 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
62 	{ _godot_object.ptr = n; return null; }
63 	/// 
64 	pragma(inline, true) bool opEquals(typeof(null) n) const
65 	{ return _godot_object.ptr is n; }
66 	/// 
67 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
68 	mixin baseCasts;
69 	/// Construct a new instance of MenuButton.
70 	/// Note: use `memnew!MenuButton` instead.
71 	static MenuButton _new()
72 	{
73 		static godot_class_constructor constructor;
74 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MenuButton");
75 		if(constructor is null) return typeof(this).init;
76 		return cast(MenuButton)(constructor());
77 	}
78 	@disable new(size_t s);
79 	/**
80 	
81 	*/
82 	Array _getItems() const
83 	{
84 		Array _GODOT_args = Array.make();
85 		String _GODOT_method_name = String("_get_items");
86 		return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array);
87 	}
88 	/**
89 	
90 	*/
91 	void _setItems(in Array arg0)
92 	{
93 		Array _GODOT_args = Array.make();
94 		_GODOT_args.append(arg0);
95 		String _GODOT_method_name = String("_set_items");
96 		this.callv(_GODOT_method_name, _GODOT_args);
97 	}
98 	/**
99 	
100 	*/
101 	void _unhandledKeyInput(InputEvent arg0)
102 	{
103 		Array _GODOT_args = Array.make();
104 		_GODOT_args.append(arg0);
105 		String _GODOT_method_name = String("_unhandled_key_input");
106 		this.callv(_GODOT_method_name, _GODOT_args);
107 	}
108 	/**
109 	Returns the $(D PopupMenu) contained in this button.
110 	*/
111 	PopupMenu getPopup() const
112 	{
113 		checkClassBinding!(typeof(this))();
114 		return ptrcall!(PopupMenu)(GDNativeClassBinding.getPopup, _godot_object);
115 	}
116 	/**
117 	
118 	*/
119 	bool isSwitchOnHover()
120 	{
121 		checkClassBinding!(typeof(this))();
122 		return ptrcall!(bool)(GDNativeClassBinding.isSwitchOnHover, _godot_object);
123 	}
124 	/**
125 	If `true`, shortcuts are disabled and cannot be used to trigger the button.
126 	*/
127 	void setDisableShortcuts(in bool disabled)
128 	{
129 		checkClassBinding!(typeof(this))();
130 		ptrcall!(void)(GDNativeClassBinding.setDisableShortcuts, _godot_object, disabled);
131 	}
132 	/**
133 	
134 	*/
135 	void setSwitchOnHover(in bool enable)
136 	{
137 		checkClassBinding!(typeof(this))();
138 		ptrcall!(void)(GDNativeClassBinding.setSwitchOnHover, _godot_object, enable);
139 	}
140 	/**
141 	
142 	*/
143 	@property Array items()
144 	{
145 		return _getItems();
146 	}
147 	/// ditto
148 	@property void items(Array v)
149 	{
150 		_setItems(v);
151 	}
152 	/**
153 	If `true`, when the cursor hovers above another $(D MenuButton) within the same parent which also has `switch_on_hover` enabled, it will close the current $(D MenuButton) and open the other one.
154 	*/
155 	@property bool switchOnHover()
156 	{
157 		return isSwitchOnHover();
158 	}
159 	/// ditto
160 	@property void switchOnHover(bool v)
161 	{
162 		setSwitchOnHover(v);
163 	}
164 }