1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 // Some have been manually changed
27 public class Color : global::System.IDisposable
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 protected bool swigCMemOwn;
32 internal Color(global::System.IntPtr cPtr, bool cMemoryOwn)
34 swigCMemOwn = cMemoryOwn;
35 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
40 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
43 //NUI Dispose Pattern written by Jinwoo Nam(jjw.nam)
45 //A Flag to check who called Dispose(). (By User or DisposeQueue)
46 private bool isDisposeQueued = false;
47 //A Flat to check if it is already disposed.
48 protected bool disposed = false;
54 isDisposeQueued = true;
55 DisposeQueue.Instance.Add(this);
60 /// To make Color instance be disposed.
64 //Throw excpetion if Dispose() is called in separate thread.
65 if (!Window.IsInstalled())
67 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
72 Dispose(DisposeTypes.Implicit);
76 Dispose(DisposeTypes.Explicit);
77 System.GC.SuppressFinalize(this);
81 protected virtual void Dispose(DisposeTypes type)
88 if(type == DisposeTypes.Explicit)
91 //Release your own managed resources here.
92 //You should release all of your own disposable objects here.
95 //Release your own unmanaged resources here.
96 //You should not access any managed member here except static instance.
97 //because the execution order of Finalizes is non-deterministic.
99 if (swigCPtr.Handle != global::System.IntPtr.Zero)
104 NDalicPINVOKE.delete_Vector4(swigCPtr);
106 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
112 /// Addition operator.
114 /// <param name="arg1">First value</param>
115 /// <param name="arg2">Second value</param>
116 /// <returns>A Color containing the result of the addition</returns>
117 public static Color operator +(Color arg1, Color arg2)
119 Color result = arg1.Add(arg2);
125 /// Subtraction operator.
127 /// <param name="arg1">First value</param>
128 /// <param name="arg2">Second value</param>
129 /// <returns>A Color containing the result of the subtraction</returns>
130 public static Color operator -(Color arg1, Color arg2)
132 Color result = arg1.Subtract(arg2);
138 /// Unary negation operator.
140 /// <param name="arg1">Target Value</param>
141 /// <returns>A Color containg the negation</returns>
142 public static Color operator -(Color arg1)
144 Color result = arg1.Subtract();
150 /// Multiplication operator.
152 /// <param name="arg1">First Value</param>
153 /// <param name="arg2">Second Value</param>
154 /// <returns>A Color containing the result of the multiplication</returns>
155 public static Color operator *(Color arg1, Color arg2)
157 Color result = arg1.Multiply(arg2);
162 public static Color operator*(Color arg1, float arg2)
164 Color result = arg1.Multiply(arg2);
170 /// Division operator.
172 /// <param name="arg1">First Value</param>
173 /// <param name="arg2">Second Value</param>
174 /// <returns>A Color containing the result of the division</returns>
175 public static Color operator /(Color arg1, Color arg2)
177 Color result = arg1.Divide(arg2);
182 public static Color operator/(Color arg1, float arg2)
184 Color result = arg1.Divide(arg2);
190 /// Array subscript operator overload.
192 /// <param name="index">Subscript index</param>
193 /// <returns>The float at the given index</returns>
194 public float this[uint index]
198 return ValueOfIndex(index);
202 internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
204 Color ret = new Color(cPtr, false);
205 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210 /// Default constructor
212 public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
221 /// <param name="r">red component</param>
222 /// <param name="g">green component</param>
223 /// <param name="b">blue component</param>
224 /// <param name="a">alpha component</param>
225 public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235 /// Conversion constructor from an array of four floats.
237 /// <param name="array">array Array of R,G,B,A</param>
238 public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
240 ValueCheck(ref array[0]);
241 ValueCheck(ref array[1]);
242 ValueCheck(ref array[2]);
243 ValueCheck(ref array[3]);
244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247 private Color Add(Color rhs)
249 Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
250 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254 private Color AddAssign(Vector4 rhs)
256 Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
261 private Color Subtract(Color rhs)
263 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
268 private Color SubtractAssign(Color rhs)
270 Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
275 private Color Multiply(Color rhs)
277 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
282 private Color Multiply(float rhs)
284 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
285 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289 private Color MultiplyAssign(Color rhs)
291 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296 private Color MultiplyAssign(float rhs)
298 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 private Color Divide(Vector4 rhs)
305 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
306 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310 private Color Divide(float rhs)
312 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
313 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 private Color DivideAssign(Color rhs)
319 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
324 private Color DivideAssign(float rhs)
326 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
331 private Color Subtract()
333 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
334 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 /// Check if two Color classes are same.
341 /// <param name="rhs">A Color to be compared</param>
342 /// <returns>If two Colors are are same, then true.</returns>
343 public bool EqualTo(Color rhs)
345 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
347 if (rhs == null) return false;
349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354 /// Check if two Color classes are different.
356 /// <param name="rhs">A Color to be compared</param>
357 /// <returns>If two Colors are are different, then true.</returns>
358 public bool NotEqualTo(Color rhs)
360 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366 private float ValueOfIndex(uint index)
368 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 ValueCheck(ref value);
381 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
387 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 ValueCheck(ref value);
400 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
405 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 ValueCheck(ref value);
419 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
420 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 ValueCheck(ref value);
438 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450 /// Get black colored Color class.
452 public static Color Black
456 global::System.IntPtr cPtr = NDalicPINVOKE.BLACK_get();
457 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 /// Get white colored Color class.
466 public static Color White
470 global::System.IntPtr cPtr = NDalicPINVOKE.WHITE_get();
471 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478 /// Get red colored Color class.
480 public static Color Red
484 global::System.IntPtr cPtr = NDalicPINVOKE.RED_get();
485 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 /// Get green colored Color class.
494 public static Color Green
498 global::System.IntPtr cPtr = NDalicPINVOKE.GREEN_get();
499 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
500 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 /// Get blue colored Color class.
508 public static Color Blue
512 global::System.IntPtr cPtr = NDalicPINVOKE.BLUE_get();
513 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
514 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 /// Get yellow colored Color class.
522 public static Color Yellow
526 global::System.IntPtr cPtr = NDalicPINVOKE.YELLOW_get();
527 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
534 /// Get magenta colored Color class.
536 public static Color Magenta
540 global::System.IntPtr cPtr = NDalicPINVOKE.MAGENTA_get();
541 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 /// Get cyan colored Color class.
550 public static Color Cyan
554 global::System.IntPtr cPtr = NDalicPINVOKE.CYAN_get();
555 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
556 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
562 /// Get transparent colored Color class.
564 public static Color Transparent
568 global::System.IntPtr cPtr = NDalicPINVOKE.TRANSPARENT_get();
569 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576 /// convert Color class to Vector4 class implicitly.
578 /// <param name="color">A Color to be converted to Vector4</param>
579 public static implicit operator Vector4(Color color)
581 return new Vector4(color.R, color.G, color.B, color.A);
585 /// convert Vector4 class to Color class implicitly.
587 /// <param name="vec">A Vector4 to be converted to Color</param></param>
588 public static implicit operator Color(Vector4 vec)
590 return new Color(vec.R, vec.G, vec.B, vec.A);
593 internal static void ValueCheck(Color color)
598 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
600 else if (color.R > 1.0f)
603 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
608 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
610 else if (color.G > 1.0f)
613 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
618 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
620 else if (color.B > 1.0f)
623 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
628 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
630 else if (color.A > 1.0f)
633 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
637 internal static void ValueCheck(ref float value)
642 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
644 else if (value > 1.0f)
647 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");