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 //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;
52 isDisposeQueued = true;
53 DisposeQueue.Instance.Add(this);
58 /// To make Color instance be disposed.
62 //Throw excpetion if Dispose() is called in separate thread.
63 if (!Window.IsInstalled())
65 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
70 Dispose(DisposeTypes.Implicit);
74 Dispose(DisposeTypes.Explicit);
75 System.GC.SuppressFinalize(this);
79 protected virtual void Dispose(DisposeTypes type)
86 if(type == DisposeTypes.Explicit)
89 //Release your own managed resources here.
90 //You should release all of your own disposable objects here.
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.
97 if (swigCPtr.Handle != global::System.IntPtr.Zero)
102 NDalicPINVOKE.delete_Vector4(swigCPtr);
104 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
110 /// Addition operator.
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)
117 Color result = arg1.Add(arg2);
123 /// Subtraction operator.
125 /// <param name="arg1">First value</param>
126 /// <param name="arg2">Second value</param>
127 /// <returns>A Color containing the result of the subtraction</returns>
128 public static Color operator -(Color arg1, Color arg2)
130 Color result = arg1.Subtract(arg2);
136 /// Unary negation operator.
138 /// <param name="arg1">Target Value</param>
139 /// <returns>A Color containg the negation</returns>
140 public static Color operator -(Color arg1)
142 Color result = arg1.Subtract();
148 /// Multiplication operator.
150 /// <param name="arg1">First Value</param>
151 /// <param name="arg2">Second Value</param>
152 /// <returns>A Color containing the result of the multiplication</returns>
153 public static Color operator *(Color arg1, Color arg2)
155 Color result = arg1.Multiply(arg2);
160 public static Color operator*(Color arg1, float arg2)
162 Color result = arg1.Multiply(arg2);
168 /// Division operator.
170 /// <param name="arg1">First Value</param>
171 /// <param name="arg2">Second Value</param>
172 /// <returns>A Color containing the result of the division</returns>
173 public static Color operator /(Color arg1, Color arg2)
175 Color result = arg1.Divide(arg2);
180 public static Color operator/(Color arg1, float arg2)
182 Color result = arg1.Divide(arg2);
188 /// Array subscript operator overload.
190 /// <param name="index">Subscript index</param>
191 /// <returns>The float at the given index</returns>
192 public float this[uint index]
196 return ValueOfIndex(index);
200 internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
202 Color ret = new Color(cPtr, false);
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208 /// Default constructor
210 public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 /// <param name="r">red component</param>
220 /// <param name="g">green component</param>
221 /// <param name="b">blue component</param>
222 /// <param name="a">alpha component</param>
223 public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 /// Conversion constructor from an array of four floats.
235 /// <param name="array">array Array of R,G,B,A</param>
236 public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
238 ValueCheck(ref array[0]);
239 ValueCheck(ref array[1]);
240 ValueCheck(ref array[2]);
241 ValueCheck(ref array[3]);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
245 private Color Add(Color rhs)
247 Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
252 private Color AddAssign(Vector4 rhs)
254 Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
255 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
259 private Color Subtract(Color rhs)
261 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
266 private Color SubtractAssign(Color rhs)
268 Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
273 private Color Multiply(Color rhs)
275 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
276 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
280 private Color Multiply(float rhs)
282 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
287 private Color MultiplyAssign(Color rhs)
289 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
294 private Color MultiplyAssign(float rhs)
296 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
297 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
301 private Color Divide(Vector4 rhs)
303 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
308 private Color Divide(float rhs)
310 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
311 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315 private Color DivideAssign(Color rhs)
317 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
318 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322 private Color DivideAssign(float rhs)
324 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
329 private Color Subtract()
331 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
337 /// Check if two Color classes are same.
339 /// <param name="rhs">A Color to be compared</param>
340 /// <returns>If two Colors are are same, then true.</returns>
341 public bool EqualTo(Color rhs)
343 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
345 if (rhs == null) return false;
347 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
352 /// Check if two Color classes are different.
354 /// <param name="rhs">A Color to be compared</param>
355 /// <returns>If two Colors are are different, then true.</returns>
356 public bool NotEqualTo(Color rhs)
358 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 private float ValueOfIndex(uint index)
366 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 ValueCheck(ref value);
379 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
385 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 ValueCheck(ref value);
398 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
403 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
416 ValueCheck(ref value);
417 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
435 ValueCheck(ref value);
436 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
441 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 /// Get black colored Color class.
450 public static readonly Color Black = new Color(0.0f, 0.0f, 0.0f, 1.0f);
453 /// Get white colored Color class.
455 public static readonly Color White = new Color(1.0f, 1.0f, 1.0f, 1.0f);
458 /// Get red colored Color class.
460 public static readonly Color Red = new Color(1.0f, 0.0f, 0.0f, 1.0f);
463 /// Get green colored Color class.
465 public static readonly Color Green = new Color(0.0f, 1.0f, 0.0f, 1.0f);
468 /// Get blue colored Color class.
470 public static readonly Color Blue = new Color(0.0f, 0.0f, 1.0f, 1.0f);
473 /// Get yellow colored Color class.
475 public static readonly Color Yellow = new Color(1.0f, 1.0f, 0.0f, 1.0f);
478 /// Get magenta colored Color class.
480 public static readonly Color Magenta = new Color(1.0f, 0.0f, 1.0f, 1.0f);
483 /// Get cyan colored Color class.
485 public static readonly Color Cyan = new Color(0.0f, 1.0f, 1.0f, 1.0f);
488 /// Get transparent colored Color class.
490 public static readonly Color Transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f);
493 /// convert Color class to Vector4 class implicitly.
495 /// <param name="color">A Color to be converted to Vector4</param>
496 public static implicit operator Vector4(Color color)
498 return new Vector4(color.R, color.G, color.B, color.A);
502 /// convert Vector4 class to Color class implicitly.
504 /// <param name="vec">A Vector4 to be converted to Color</param></param>
505 public static implicit operator Color(Vector4 vec)
507 return new Color(vec.R, vec.G, vec.B, vec.A);
510 internal static void ValueCheck(Color color)
515 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
517 else if (color.R > 1.0f)
520 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
525 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
527 else if (color.G > 1.0f)
530 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
535 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
537 else if (color.B > 1.0f)
540 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
545 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
547 else if (color.A > 1.0f)
550 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
554 internal static void ValueCheck(ref float value)
559 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
561 else if (value > 1.0f)
564 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");