Add more comments for API reference of part 2
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Color.cs
1 /*
2  * Copyright (c) 2017 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
21     using System;
22
23     /// <summary>
24     /// Color Class
25     /// </summary>
26     public class Color : global::System.IDisposable
27     {
28         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29         protected bool swigCMemOwn;
30
31         internal Color(global::System.IntPtr cPtr, bool cMemoryOwn)
32         {
33             swigCMemOwn = cMemoryOwn;
34             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
35         }
36
37         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
38         {
39             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
40         }
41
42         ~Color()
43         {
44             DisposeQueue.Instance.Add(this);
45         }
46
47         public virtual void Dispose()
48         {
49             if (!Stage.IsInstalled())
50             {
51                 DisposeQueue.Instance.Add(this);
52                 return;
53             }
54
55             lock (this)
56             {
57                 if (swigCPtr.Handle != global::System.IntPtr.Zero)
58                 {
59                     if (swigCMemOwn)
60                     {
61                         swigCMemOwn = false;
62                         NDalicPINVOKE.delete_Vector4(swigCPtr);
63                     }
64                     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
65                 }
66                 global::System.GC.SuppressFinalize(this);
67             }
68         }
69
70
71         /// <summary>
72         /// Addition operator.
73         /// </summary>
74         public static Color operator +(Color arg1, Color arg2)
75         {
76             return arg1.Add(arg2);
77         }
78
79         /// <summary>
80         /// Subtraction operator.
81         /// </summary>
82         public static Color operator -(Color arg1, Color arg2)
83         {
84             return arg1.Subtract(arg2);
85         }
86
87         /// <summary>
88         /// Subtraction operator, void
89         /// </summary>
90         public static Color operator -(Color arg1)
91         {
92             return arg1.Subtract();
93         }
94
95         /// <summary>
96         /// Multiplication operator.
97         /// </summary>
98         public static Color operator *(Color arg1, Color arg2)
99         {
100             return arg1.Multiply(arg2);
101         }
102
103         /// <summary>
104         /// Multiplication operator, using float.
105         /// </summary>
106         public static Color operator *(Color arg1, float arg2)
107         {
108             return arg1.Multiply(arg2);
109         }
110
111         /// <summary>
112         /// Division operator.
113         /// </summary>
114         public static Color operator /(Color arg1, Color arg2)
115         {
116             return arg1.Divide(arg2);
117         }
118
119         /// <summary>
120         /// Division operator, using float.
121         /// </summary>
122         public static Color operator /(Color arg1, float arg2)
123         {
124             return arg1.Divide(arg2);
125         }
126
127         /// <summary>
128         /// Array subscript operator.
129         /// </summary>
130         public float this[uint index]
131         {
132             get
133             {
134                 return ValueOfIndex(index);
135             }
136         }
137
138         /// <summary>
139         /// GetColorFromPtr
140         /// </summary>
141         public static Color GetColorFromPtr(global::System.IntPtr cPtr)
142         {
143             Color ret = new Color(cPtr, false);
144             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
145             return ret;
146         }
147
148
149         /// <summary>
150         /// Constructor.
151         /// </summary>
152         public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
153         {
154             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155         }
156
157         /// <summary>
158         /// Constructor.
159         /// </summary>
160         /// <param name="r">The red component</param>
161         /// <param name="g">The green component</param>
162         /// <param name="b">The blue component</param>
163         /// <param name="a">The alpha component</param>
164         public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
165         {
166             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
167         }
168
169         /// <summary>
170         /// Constructor.
171         /// </summary>
172         /// <param name="array">The array</param>
173         public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
174         {
175             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
176         }
177
178         /// <summary>
179         /// Add Color.
180         /// </summary>
181         /// <param name="rhs">A reference to the copied handle</param>
182         /// <returns>A reference to this</returns>
183         private Color Add(Color rhs)
184         {
185             Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
186             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
187             return ret;
188         }
189
190         /// <summary>
191         /// Add assignment operator.
192         /// </summary>
193         /// <param name="rhs">A reference to the copied handle</param>
194         /// <returns>A reference to this</returns>
195         private Color AddAssign(Vector4 rhs)
196         {
197             Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199             return ret;
200         }
201
202         private Color Subtract(Color rhs)
203         {
204             Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
205             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206             return ret;
207         }
208
209         private Color SubtractAssign(Color rhs)
210         {
211             Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213             return ret;
214         }
215
216         private Color Multiply(Color rhs)
217         {
218             Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
219             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220             return ret;
221         }
222
223         private Color Multiply(float rhs)
224         {
225             Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227             return ret;
228         }
229
230         private Color MultiplyAssign(Color rhs)
231         {
232             Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
233             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234             return ret;
235         }
236
237         private Color MultiplyAssign(float rhs)
238         {
239             Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241             return ret;
242         }
243
244         private Color Divide(Vector4 rhs)
245         {
246             Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
247             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248             return ret;
249         }
250
251         private Color Divide(float rhs)
252         {
253             Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
254             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255             return ret;
256         }
257
258         private Color DivideAssign(Color rhs)
259         {
260             Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262             return ret;
263         }
264
265         private Color DivideAssign(float rhs)
266         {
267             Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
268             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269             return ret;
270         }
271
272         private Color Subtract()
273         {
274             Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
275             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276             return ret;
277         }
278
279         /// <summary>
280         /// Assignment operator.
281         /// </summary>
282         /// <param name="rhs">A reference to the copied handle</param>
283         /// <returns>A reference to this</returns>
284         public bool EqualTo(Color rhs)
285         {
286             bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
287
288             if (rhs == null) return false;
289
290             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
291             return ret;
292         }
293
294         /// <summary>
295         /// Assignment operator.
296         /// </summary>
297         /// <param name="rhs">A reference to the copied handle</param>
298         /// <returns>A reference to this</returns>      
299         public bool NotEqualTo(Color rhs)
300         {
301             bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
302             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303             return ret;
304         }
305
306
307         private float ValueOfIndex(uint index)
308         {
309             float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
310             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311             return ret;
312         }
313
314         /// <summary>
315         /// The red component
316         /// </summary>
317         public float R
318         {
319             set
320             {
321                 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
322                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
323             }
324             get
325             {
326                 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
327                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328                 return ret;
329             }
330         }
331
332         /// <summary>
333         /// The Green Component.
334         /// </summary>
335         public float G
336         {
337             set
338             {
339                 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
340                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341             }
342             get
343             {
344                 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
345                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346                 return ret;
347             }
348         }
349
350         /// <summary>
351         /// The Blue Component.
352         /// </summary>
353         public float B
354         {
355             set
356             {
357                 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
358                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359             }
360             get
361             {
362                 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
363                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364                 return ret;
365             }
366         }
367
368         /// <summary>
369         /// The Alpha Component.
370         /// </summary>
371         public float A
372         {
373             set
374             {
375                 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
376                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
377             }
378             get
379             {
380                 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
381                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382                 return ret;
383             }
384         }
385
386         /// <summary>
387         /// The Black Color.
388         /// </summary>
389         public static Color Black
390         {
391             get
392             {
393                 global::System.IntPtr cPtr = NDalicPINVOKE.BLACK_get();
394                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
395                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
396                 return ret;
397             }
398         }
399
400         /// <summary>
401         /// The White Color.
402         /// </summary>
403         public static Color White
404         {
405             get
406             {
407                 global::System.IntPtr cPtr = NDalicPINVOKE.WHITE_get();
408                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
409                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
410                 return ret;
411             }
412         }
413
414         /// <summary>
415         /// The Red Color.
416         /// </summary>
417         public static Color Red
418         {
419             get
420             {
421                 global::System.IntPtr cPtr = NDalicPINVOKE.RED_get();
422                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
423                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424                 return ret;
425             }
426         }
427
428         /// <summary>
429         /// The Green Color.
430         /// </summary>
431         public static Color Green
432         {
433             get
434             {
435                 global::System.IntPtr cPtr = NDalicPINVOKE.GREEN_get();
436                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
437                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438                 return ret;
439             }
440         }
441
442         /// <summary>
443         /// The Blue Color.
444         /// </summary>
445         public static Color Blue
446         {
447             get
448             {
449                 global::System.IntPtr cPtr = NDalicPINVOKE.BLUE_get();
450                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
451                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452                 return ret;
453             }
454         }
455
456         /// <summary>
457         /// The Yellow Color.
458         /// </summary>
459         public static Color Yellow
460         {
461             get
462             {
463                 global::System.IntPtr cPtr = NDalicPINVOKE.YELLOW_get();
464                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
465                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466                 return ret;
467             }
468         }
469
470         /// <summary>
471         /// The Magenta Color.
472         /// </summary>
473         public static Color Magenta
474         {
475             get
476             {
477                 global::System.IntPtr cPtr = NDalicPINVOKE.MAGENTA_get();
478                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
479                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480                 return ret;
481             }
482         }
483
484         /// <summary>
485         /// The Cyan Color.
486         /// </summary>
487         public static Color Cyan
488         {
489             get
490             {
491                 global::System.IntPtr cPtr = NDalicPINVOKE.CYAN_get();
492                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
493                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
494                 return ret;
495             }
496         }
497
498         /// <summary>
499         /// The Transparent Color.
500         /// </summary>
501         public static Color Transparent
502         {
503             get
504             {
505                 global::System.IntPtr cPtr = NDalicPINVOKE.TRANSPARENT_get();
506                 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
507                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508                 return ret;
509             }
510         }
511
512         public static implicit operator Vector4(Color color)
513         {
514             return new Vector4(color.R, color.G, color.B, color.A);
515         }
516
517         public static implicit operator Color(Vector4 vec)
518         {
519             return new Color(vec.R, vec.G, vec.B, vec.A);
520         }
521
522     }
523
524 }
525
526