[NUI] Format all files
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Visuals / VisualBase.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System.ComponentModel;
19
20 namespace Tizen.NUI
21 {
22
23     /// <summary>
24     /// Sets whether the actor should be focusable by keyboard navigation.<br />
25     /// Visuals reuse geometry, shader etc. across controls. They ensure that the renderer and texture sets exist only when control is on window.<br />
26     /// Each visual also responds to actor size and color change, and provides clipping at the renderer level.<br />
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public class VisualBase : BaseHandle
30     {
31
32         /// <summary>
33         /// Creates an empty visual handle.
34         /// </summary>
35         /// <since_tizen> 3 </since_tizen>
36         public VisualBase() : this(Interop.VisualBase.NewVisualBase(), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         internal VisualBase(VisualBase handle) : this(Interop.VisualBase.NewVisualBase(VisualBase.getCPtr(handle)), true)
42         {
43             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
44         }
45         internal VisualBase(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
46         {
47         }
48
49         /// <summary>
50         /// The name of the visual.
51         /// </summary>
52         /// <since_tizen> 3 </since_tizen>
53         public string Name
54         {
55             set
56             {
57                 SetName(value);
58             }
59             get
60             {
61                 return GetName();
62             }
63         }
64
65         /// <summary>
66         /// The depth index of this visual.
67         /// </summary>
68         /// <since_tizen> 3 </since_tizen>
69         public int DepthIndex
70         {
71             set
72             {
73                 SetDepthIndex(value);
74             }
75             get
76             {
77                 return GetDepthIndex();
78             }
79         }
80
81         /// <summary>
82         /// Creates the property map representing this visual.
83         /// </summary>
84         /// <since_tizen> 3 </since_tizen>
85         public PropertyMap Creation
86         {
87             get
88             {
89                 PropertyMap map = new PropertyMap();
90                 CreatePropertyMap(map);
91                 return map;
92             }
93         }
94
95         /// <summary>
96         /// Sets the transform and the control size.
97         /// </summary>
98         /// <param name="transform">A property map describing the transform.</param>
99         /// <param name="controlSize">The size of the parent control for visuals that need to scale internally.</param>
100         /// <since_tizen> 3 </since_tizen>
101         public void SetTransformAndSize(PropertyMap transform, Vector2 controlSize)
102         {
103             Interop.VisualBase.SetTransformAndSize(SwigCPtr, PropertyMap.getCPtr(transform), Vector2.getCPtr(controlSize));
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105         }
106
107         /// <summary>
108         /// Returns the height for a given width.
109         /// </summary>
110         /// <param name="width">The width to use.</param>
111         /// <returns>The height based on the width.</returns>
112         /// <since_tizen> 3 </since_tizen>
113         public float GetHeightForWidth(float width)
114         {
115             float ret = Interop.VisualBase.GetHeightForWidth(SwigCPtr, width);
116             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117             return ret;
118         }
119
120         /// <summary>
121         /// Returns the width for a given height.
122         /// </summary>
123         /// <param name="height">The height to use.</param>
124         /// <returns>The width based on the height.</returns>
125         /// <since_tizen> 3 </since_tizen>
126         public float GetWidthForHeight(float height)
127         {
128             float ret = Interop.VisualBase.GetWidthForHeight(SwigCPtr, height);
129             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130             return ret;
131         }
132
133         /// <summary>
134         /// Returns the natural size of the visual.<br />
135         /// Deriving classes stipulate the natural size and by default a visual has a zero natural size.<br />
136         /// A visual may not actually have a natural size until it has been placed on window and acquired all it's resources.<br />
137         /// </summary>
138         /// <param name="naturalSize">The visual's natural size.</param>
139         /// <since_tizen> 3 </since_tizen>
140         public void GetNaturalSize(Size2D naturalSize)
141         {
142             Interop.VisualBase.GetNaturalSize(SwigCPtr, Size2D.getCPtr(naturalSize));
143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144         }
145
146         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(VisualBase obj)
147         {
148             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
149         }
150
151         internal void SetName(string name)
152         {
153             Interop.VisualBase.SetName(SwigCPtr, name);
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155         }
156
157         internal string GetName()
158         {
159             string ret = Interop.VisualBase.GetName(SwigCPtr);
160             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
161             return ret;
162         }
163
164         internal void SetDepthIndex(int index)
165         {
166             Interop.VisualBase.SetDepthIndex(SwigCPtr, index);
167             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
168         }
169
170         internal int GetDepthIndex()
171         {
172             int ret = Interop.VisualBase.GetDepthIndex(SwigCPtr);
173             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174             return ret;
175         }
176
177         internal void CreatePropertyMap(PropertyMap map)
178         {
179             Interop.VisualBase.CreatePropertyMap(SwigCPtr, PropertyMap.getCPtr(map));
180             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181         }
182
183         /// This will not be public opened.
184         [EditorBrowsable(EditorBrowsableState.Never)]
185         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
186         {
187             Interop.VisualBase.DeleteVisualBase(swigCPtr);
188         }
189     }
190 }