5a72491ccfc0f679369fd9c0f6d0ed09e963dce2
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / Color.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 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 // Some have been manually changed
18
19 namespace Tizen.NUI
20 {
21
22     using System;
23
24     /// <summary>
25     /// Color class.
26     /// </summary>
27     public class Color : global::System.IDisposable
28     {
29         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30         protected bool swigCMemOwn;
31
32         internal Color(global::System.IntPtr cPtr, bool cMemoryOwn)
33         {
34             swigCMemOwn = cMemoryOwn;
35             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36         }
37
38         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
39         {
40             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
41         }
42
43         //A Flag to check who called Dispose(). (By User or DisposeQueue)
44         private bool isDisposeQueued = false;
45         //A Flat to check if it is already disposed.
46         protected bool disposed = false;
47
48         ~Color()
49         {
50             if(!isDisposeQueued)
51             {
52                 isDisposeQueued = true;
53                 DisposeQueue.Instance.Add(this);
54             }
55         }
56
57         /// <summary>
58         /// To make Color instance be disposed.
59         /// </summary>
60         public void Dispose()
61         {
62             //Throw excpetion if Dispose() is called in separate thread.
63             if (!Window.IsInstalled())
64             {
65                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
66             }
67
68             if (isDisposeQueued)
69             {
70                 Dispose(DisposeTypes.Implicit);
71             }
72             else
73             {
74                 Dispose(DisposeTypes.Explicit);
75                 System.GC.SuppressFinalize(this);
76             }
77         }
78
79         protected virtual void Dispose(DisposeTypes type)
80         {
81             if (disposed)
82             {
83                 return;
84             }
85
86             if(type == DisposeTypes.Explicit)
87             {
88                 //Called by User
89                 //Release your own managed resources here.
90                 //You should release all of your own disposable objects here.
91             }
92
93             //Release your own unmanaged resources here.
94             //You should not access any managed member here except static instance.
95             //because the execution order of Finalizes is non-deterministic.
96
97             if (swigCPtr.Handle != global::System.IntPtr.Zero)
98             {
99                 if (swigCMemOwn)
100                 {
101                     swigCMemOwn = false;
102                     NDalicPINVOKE.delete_Vector4(swigCPtr);
103                 }
104                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
105             }
106             disposed = true;
107         }
108
109         /// <summary>
110         /// Addition operator.
111         /// </summary>
112         /// <param name="arg1">First value</param>
113         /// <param name="arg2">Second value</param>
114         /// <returns>A Color containing the result of the addition</returns>
115         public static Color operator +(Color arg1, Color arg2)
116         {
117             return arg1.Add(arg2);
118         }
119
120         /// <summary>
121         /// Subtraction operator.
122         /// </summary>
123         /// <param name="arg1">First value</param>
124         /// <param name="arg2">Second value</param>
125         /// <returns>A Color containing the result of the subtraction</returns>
126         public static Color operator -(Color arg1, Color arg2)
127         {
128             return arg1.Subtract(arg2);
129         }
130
131         /// <summary>
132         /// Unary negation operator.
133         /// </summary>
134         /// <param name="arg1">Target Value</param>
135         /// <returns>A Color containg the negation</returns>
136         public static Color operator -(Color arg1)
137         {
138             return arg1.Subtract();
139         }
140
141         /// <summary>
142         /// Multiplication operator.
143         /// </summary>
144         /// <param name="arg1">First Value</param>
145         /// <param name="arg2">Second Value</param>
146         /// <returns>A Color containing the result of the multiplication</returns>
147         public static Color operator *(Color arg1, Color arg2)
148         {
149             return arg1.Multiply(arg2);
150         }
151
152         public static Color operator*(Color arg1, float arg2)
153         {
154             return arg1.Multiply(arg2);
155         }
156
157         /// <summary>
158         /// Division operator.
159         /// </summary>
160         /// <param name="arg1">First Value</param>
161         /// <param name="arg2">Second Value</param>
162         /// <returns>A Color containing the result of the division</returns>
163         public static Color operator /(Color arg1, Color arg2)
164         {
165             return arg1.Divide(arg2);
166         }
167
168         public static Color operator/(Color arg1, float arg2)
169         {
170             return arg1.Divide(arg2);
171         }
172
173         /// <summary>
174         /// Array subscript operator overload.
175         /// </summary>
176         /// <param name="index">Subscript index</param>
177         /// <returns>The float at the given index</returns>
178         public float this[uint index]
179         {
180             get
181             {
182                 return ValueOfIndex(index);
183             }
184         }
185
186         internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
187         {
188             Color ret = new Color(cPtr, false);
189             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190             return ret;
191         }
192
193         /// <summary>
194         /// Default constructor
195         /// </summary>
196         public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
197         {
198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199         }
200
201
202         /// <summary>
203         /// Constructor.
204         /// </summary>
205         /// <param name="r">red component</param>
206         /// <param name="g">green component</param>
207         /// <param name="b">blue component</param>
208         /// <param name="a">alpha component</param>
209         public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
210         {
211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212         }
213
214         /// <summary>
215         /// Conversion constructor from an array of four floats.
216         /// </summary>
217         /// <param name="array">array Array of R,G,B,A</param>
218         public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
219         {
220             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221         }
222
223         private Color Add(Color rhs)
224         {
225             Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
226             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227             return ret;
228         }
229
230         private Color AddAssign(Vector4 rhs)
231         {
232             Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
233             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234             return ret;
235         }
236
237         private Color Subtract(Color rhs)
238         {
239             Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
241             return ret;
242         }
243
244         private Color SubtractAssign(Color rhs)
245         {
246             Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
247             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
248             return ret;
249         }
250
251         private Color Multiply(Color rhs)
252         {
253             Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
254             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255             return ret;
256         }
257
258         private Color Multiply(float rhs)
259         {
260             Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
261             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262             return ret;
263         }
264
265         private Color MultiplyAssign(Color rhs)
266         {
267             Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
268             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269             return ret;
270         }
271
272         private Color MultiplyAssign(float rhs)
273         {
274             Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
275             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276             return ret;
277         }
278
279         private Color Divide(Vector4 rhs)
280         {
281             Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
282             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283             return ret;
284         }
285
286         private Color Divide(float rhs)
287         {
288             Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
289             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290             return ret;
291         }
292
293         private Color DivideAssign(Color rhs)
294         {
295             Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297             return ret;
298         }
299
300         private Color DivideAssign(float rhs)
301         {
302             Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
303             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304             return ret;
305         }
306
307         private Color Subtract()
308         {
309             Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
310             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311             return ret;
312         }
313
314         /// <summary>
315         /// Check if two Color classes are same.
316         /// </summary>
317         /// <param name="rhs">A Color to be compared</param>
318         /// <returns>If two Colors are are same, then true.</returns>
319         public bool EqualTo(Color rhs)
320         {
321             bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
322
323             if (rhs == null) return false;
324
325             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
326             return ret;
327         }
328
329         /// <summary>
330         /// Check if two Color classes are different.
331         /// </summary>
332         /// <param name="rhs">A Color to be compared</param>
333         /// <returns>If two Colors are are different, then true.</returns>
334         public bool NotEqualTo(Color rhs)
335         {
336             bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
337             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
338             return ret;
339         }
340
341
342         private float ValueOfIndex(uint index)
343         {
344             float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
345             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346             return ret;
347         }
348
349         /// <summary>
350         /// red component.
351         /// </summary>
352         public float R
353         {
354             set
355             {
356                 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
357                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358             }
359             get
360             {
361                 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
362                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363                 return ret;
364             }
365         }
366
367         /// <summary>
368         /// green component.
369         /// </summary>
370         public float G
371         {
372             set
373             {
374                 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
375                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376             }
377             get
378             {
379                 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
380                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381                 return ret;
382             }
383         }
384
385         /// <summary>
386         /// blue component.
387         /// </summary>
388         public float B
389         {
390             set
391             {
392                 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
393                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394             }
395             get
396             {
397                 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
398                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399                 return ret;
400             }
401         }
402
403         /// <summary>
404         /// alpha component.
405         /// </summary>
406         public float A
407         {
408             set
409             {
410                 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
411                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412             }
413             get
414             {
415                 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
416                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417                 return ret;
418             }
419         }
420
421         /// <summary>
422         /// Get black colored Color class.
423         /// </summary>
424         public static readonly Color Black = new Color(0.0f, 0.0f, 0.0f, 1.0f);
425
426         /// <summary>
427         /// Get white colored Color class.
428         /// </summary>
429         public static readonly Color White = new Color(1.0f, 1.0f, 1.0f, 1.0f);
430
431         /// <summary>
432         /// Get red colored Color class.
433         /// </summary>
434         public static readonly Color Red = new Color(1.0f, 0.0f, 0.0f, 1.0f);
435
436         /// <summary>
437         /// Get green colored Color class.
438         /// </summary>
439         public static readonly Color Green = new Color(0.0f, 1.0f, 0.0f, 1.0f);
440
441         /// <summary>
442         /// Get blue colored Color class.
443         /// </summary>
444         public static readonly Color Blue = new Color(0.0f, 0.0f, 1.0f, 1.0f);
445
446         /// <summary>
447         /// Get yellow colored Color class.
448         /// </summary>
449         public static readonly Color Yellow = new Color(1.0f, 1.0f, 0.0f, 1.0f);
450
451         /// <summary>
452         /// Get magenta colored Color class.
453         /// </summary>
454         public static readonly Color Magenta = new Color(1.0f, 0.0f, 1.0f, 1.0f);
455
456         /// <summary>
457         /// Get cyan colored Color class.
458         /// </summary>
459         public static readonly Color Cyan = new Color(0.0f, 1.0f, 1.0f, 1.0f);
460
461         /// <summary>
462         /// Get transparent colored Color class.
463         /// </summary>
464         public static readonly Color Transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f);
465
466         /// <summary>
467         /// convert Color class to Vector4 class implicitly.
468         /// </summary>
469         /// <param name="color">A Color to be converted to Vector4</param>
470         public static implicit operator Vector4(Color color)
471         {
472             return new Vector4(color.R, color.G, color.B, color.A);
473         }
474
475         /// <summary>
476         /// convert Vector4 class to Color class implicitly.
477         /// </summary>
478         /// <param name="vec">A Vector4 to be converted to Color</param></param>
479         public static implicit operator Color(Vector4 vec)
480         {
481             return new Color(vec.R, vec.G, vec.B, vec.A);
482         }
483
484     }
485
486 }
487
488