[NUI] Remove duplicate getCPtr from Disposable/View subclasses (#3544)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / Property.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 namespace Tizen.NUI
19 {
20     internal class Property : Disposable
21     {
22         /// <summary>
23         /// This constructor creates a property instance.
24         /// </summary>
25         /// <param name="arg0">A valid handle to the target object.</param>
26         /// <param name="propertyIndex">The index of a property.</param>
27         public Property(Animatable arg0, int propertyIndex) : this(Interop.Property.NewProperty(Animatable.getCPtr(arg0), propertyIndex), true)
28         {
29             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
30         }
31
32         /// <summary>
33         /// This constructor creates a property instance.
34         /// </summary>
35         /// <param name="arg0">A valid handle to the target object.</param>
36         /// <param name="propertyIndex">The index of a property.</param>
37         /// <param name="componentIndex">Index to a sub component of a property, for use with Vector2, Vector3 and Vector4. -1 for the main property (default is -1).</param>
38         public Property(Animatable arg0, int propertyIndex, int componentIndex) : this(Interop.Property.NewProperty(Animatable.getCPtr(arg0), propertyIndex, componentIndex), true)
39         {
40             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41         }
42
43         /// <summary>
44         /// This constructor creates a property instance.<br />
45         /// This performs a property index query and is therefore slower than constructing a property directly with the index.<br />
46         /// </summary>
47         /// <param name="arg0">A valid handle to the target object.</param>
48         /// <param name="propertyName">The property name.</param>
49         public Property(Animatable arg0, string propertyName) : this(Interop.Property.NewProperty(Animatable.getCPtr(arg0), propertyName), true)
50         {
51             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
52         }
53
54         /// <summary>
55         /// This constructor creates a property instance.<br />
56         /// This performs a property index query and is therefore slower than constructing a property directly with the index.<br />
57         /// </summary>
58         /// <param name="arg0">A valid handle to the target object.</param>
59         /// <param name="propertyName">The property name.</param>
60         /// <param name="componentIndex">Index to a sub component of a property, for use with Vector2, Vector3 and Vector4. -1 for main property (default is -1).</param>
61         public Property(Animatable arg0, string propertyName, int componentIndex) : this(Interop.Property.NewProperty(Animatable.getCPtr(arg0), propertyName, componentIndex), true)
62         {
63             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
64         }
65
66         internal Property(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
67         {
68         }
69
70         /// <summary>
71         /// Gets or sets the index of the property.
72         /// </summary>
73         public int propertyIndex
74         {
75             set
76             {
77                 Interop.Property.PropertyIndexSet(SwigCPtr, value);
78                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
79             }
80             get
81             {
82                 int ret = Interop.Property.PropertyIndexGet(SwigCPtr);
83                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
84                 return ret;
85             }
86         }
87
88         /// <summary>
89         /// Gets or sets the component index of the property.
90         /// </summary>
91         public int componentIndex
92         {
93             set
94             {
95                 Interop.Property.ComponentIndexSet(SwigCPtr, value);
96                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97             }
98             get
99             {
100                 int ret = Interop.Property.ComponentIndexGet(SwigCPtr);
101                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102                 return ret;
103             }
104         }
105
106         internal static int InvalidIndex
107         {
108             get
109             {
110                 int ret = Interop.Property.InvalidIndexGet();
111                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112                 return ret;
113             }
114         }
115
116         internal static int InvalidKey
117         {
118             get
119             {
120                 int ret = Interop.Property.InvalidKeyGet();
121                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
122                 return ret;
123             }
124         }
125
126         internal static int InvalidComponentIndex
127         {
128             get
129             {
130                 int ret = Interop.Property.InvalidComponentIndexGet();
131                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
132                 return ret;
133             }
134         }
135
136         internal Animatable Object
137         {
138             set
139             {
140                 Interop.Property.ObjectSet(SwigCPtr, Animatable.getCPtr(value));
141                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142             }
143             get
144             {
145                 Animatable ret = new Animatable(Interop.Property.ObjectGet(SwigCPtr), false);
146                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147                 return ret;
148             }
149         }
150
151         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
152         {
153             Interop.Property.DeleteProperty(swigCPtr);
154         }
155     }
156 }