1 /**
2 Control for holding $(D Viewport)s.
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.viewportcontainer;
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.container;
25 import godot.control;
26 import godot.canvasitem;
27 import godot.node;
28 import godot.inputevent;
29 /**
30 Control for holding $(D Viewport)s.
31 
32 A $(D Container) node that holds a $(D Viewport), automatically setting its size.
33 $(B Note:) Changing a ViewportContainer's $(D Control.rectScale) will cause its contents to appear distorted. To change its visual size without causing distortion, adjust the node's margins instead (if it's not already in a container).
34 */
35 @GodotBaseClass struct ViewportContainer
36 {
37 	package(godot) enum string _GODOT_internal_name = "ViewportContainer";
38 public:
39 @nogc nothrow:
40 	union { /** */ godot_object _godot_object; /** */ Container _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 GDNativeClassBinding
45 	{
46 		__gshared:
47 		@GodotName("_input") GodotMethod!(void, InputEvent) _input;
48 		@GodotName("_unhandled_input") GodotMethod!(void, InputEvent) _unhandledInput;
49 		@GodotName("get_stretch_shrink") GodotMethod!(long) getStretchShrink;
50 		@GodotName("is_stretch_enabled") GodotMethod!(bool) isStretchEnabled;
51 		@GodotName("set_stretch") GodotMethod!(void, bool) setStretch;
52 		@GodotName("set_stretch_shrink") GodotMethod!(void, long) setStretchShrink;
53 	}
54 	/// 
55 	pragma(inline, true) bool opEquals(in ViewportContainer other) const
56 	{ return _godot_object.ptr is other._godot_object.ptr; }
57 	/// 
58 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
59 	{ _godot_object.ptr = n; return null; }
60 	/// 
61 	pragma(inline, true) bool opEquals(typeof(null) n) const
62 	{ return _godot_object.ptr is n; }
63 	/// 
64 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
65 	mixin baseCasts;
66 	/// Construct a new instance of ViewportContainer.
67 	/// Note: use `memnew!ViewportContainer` instead.
68 	static ViewportContainer _new()
69 	{
70 		static godot_class_constructor constructor;
71 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("ViewportContainer");
72 		if(constructor is null) return typeof(this).init;
73 		return cast(ViewportContainer)(constructor());
74 	}
75 	@disable new(size_t s);
76 	/**
77 	
78 	*/
79 	void _input(InputEvent event)
80 	{
81 		Array _GODOT_args = Array.make();
82 		_GODOT_args.append(event);
83 		String _GODOT_method_name = String("_input");
84 		this.callv(_GODOT_method_name, _GODOT_args);
85 	}
86 	/**
87 	
88 	*/
89 	void _unhandledInput(InputEvent event)
90 	{
91 		Array _GODOT_args = Array.make();
92 		_GODOT_args.append(event);
93 		String _GODOT_method_name = String("_unhandled_input");
94 		this.callv(_GODOT_method_name, _GODOT_args);
95 	}
96 	/**
97 	
98 	*/
99 	long getStretchShrink() const
100 	{
101 		checkClassBinding!(typeof(this))();
102 		return ptrcall!(long)(GDNativeClassBinding.getStretchShrink, _godot_object);
103 	}
104 	/**
105 	
106 	*/
107 	bool isStretchEnabled() const
108 	{
109 		checkClassBinding!(typeof(this))();
110 		return ptrcall!(bool)(GDNativeClassBinding.isStretchEnabled, _godot_object);
111 	}
112 	/**
113 	
114 	*/
115 	void setStretch(in bool enable)
116 	{
117 		checkClassBinding!(typeof(this))();
118 		ptrcall!(void)(GDNativeClassBinding.setStretch, _godot_object, enable);
119 	}
120 	/**
121 	
122 	*/
123 	void setStretchShrink(in long amount)
124 	{
125 		checkClassBinding!(typeof(this))();
126 		ptrcall!(void)(GDNativeClassBinding.setStretchShrink, _godot_object, amount);
127 	}
128 	/**
129 	If `true`, the viewport will be scaled to the control's size.
130 	*/
131 	@property bool stretch()
132 	{
133 		return isStretchEnabled();
134 	}
135 	/// ditto
136 	@property void stretch(bool v)
137 	{
138 		setStretch(v);
139 	}
140 	/**
141 	Divides the viewport's effective resolution by this value while preserving its scale. This can be used to speed up rendering.
142 	For example, a 1280×720 viewport with $(D stretchShrink) set to `2` will be rendered at 640×360 while occupying the same size in the container.
143 	$(B Note:) $(D stretch) must be `true` for this property to work.
144 	*/
145 	@property long stretchShrink()
146 	{
147 		return getStretchShrink();
148 	}
149 	/// ditto
150 	@property void stretchShrink(long v)
151 	{
152 		setStretchShrink(v);
153 	}
154 }