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