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.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.button; 24 import godot.popupmenu; 25 import godot.inputevent; 26 import godot.basebutton; 27 import godot.control; 28 import godot.canvasitem; 29 import godot.node; 30 /** 31 Special button that brings up a $(D PopupMenu) when clicked. 32 33 That's pretty much all it does, as it's just a helper class when building GUIs. 34 */ 35 @GodotBaseClass struct MenuButton 36 { 37 enum string _GODOT_internal_name = "MenuButton"; 38 public: 39 @nogc nothrow: 40 union { godot_object _godot_object; Button _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("get_popup") GodotMethod!(PopupMenu) getPopup; 48 @GodotName("_unhandled_key_input") GodotMethod!(void, InputEvent) _unhandledKeyInput; 49 @GodotName("_set_items") GodotMethod!(void, Array) _setItems; 50 @GodotName("_get_items") GodotMethod!(Array) _getItems; 51 @GodotName("set_disable_shortcuts") GodotMethod!(void, bool) setDisableShortcuts; 52 } 53 bool opEquals(in MenuButton other) const { return _godot_object.ptr is other._godot_object.ptr; } 54 MenuButton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 55 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 56 mixin baseCasts; 57 static MenuButton _new() 58 { 59 static godot_class_constructor constructor; 60 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MenuButton"); 61 if(constructor is null) return typeof(this).init; 62 return cast(MenuButton)(constructor()); 63 } 64 @disable new(size_t s); 65 /** 66 Return the $(D PopupMenu) contained in this button. 67 */ 68 PopupMenu getPopup() const 69 { 70 checkClassBinding!(typeof(this))(); 71 return ptrcall!(PopupMenu)(_classBinding.getPopup, _godot_object); 72 } 73 /** 74 75 */ 76 void _unhandledKeyInput(InputEvent arg0) 77 { 78 Array _GODOT_args = Array.empty_array; 79 _GODOT_args.append(arg0); 80 String _GODOT_method_name = String("_unhandled_key_input"); 81 this.callv(_GODOT_method_name, _GODOT_args); 82 } 83 /** 84 85 */ 86 void _setItems(in Array arg0) 87 { 88 Array _GODOT_args = Array.empty_array; 89 _GODOT_args.append(arg0); 90 String _GODOT_method_name = String("_set_items"); 91 this.callv(_GODOT_method_name, _GODOT_args); 92 } 93 /** 94 95 */ 96 Array _getItems() const 97 { 98 Array _GODOT_args = Array.empty_array; 99 String _GODOT_method_name = String("_get_items"); 100 return this.callv(_GODOT_method_name, _GODOT_args).as!(RefOrT!Array); 101 } 102 /** 103 104 */ 105 void setDisableShortcuts(in bool disabled) 106 { 107 checkClassBinding!(typeof(this))(); 108 ptrcall!(void)(_classBinding.setDisableShortcuts, _godot_object, disabled); 109 } 110 /** 111 112 */ 113 @property Array items() 114 { 115 return _getItems(); 116 } 117 /// ditto 118 @property void items(Array v) 119 { 120 _setItems(v); 121 } 122 }