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 a color instance be disposed.
60 /// <since_tizen> 3 </since_tizen>
63 //Throw excpetion if Dispose() is called in separate thread.
64 if (!Window.IsInstalled())
66 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
71 Dispose(DisposeTypes.Implicit);
75 Dispose(DisposeTypes.Explicit);
76 System.GC.SuppressFinalize(this);
80 protected virtual void Dispose(DisposeTypes type)
87 if(type == DisposeTypes.Explicit)
90 //Release your own managed resources here.
91 //You should release all of your own disposable objects here.
94 //Release your own unmanaged resources here.
95 //You should not access any managed member here except static instance.
96 //because the execution order of Finalizes is non-deterministic.
98 if (swigCPtr.Handle != global::System.IntPtr.Zero)
103 NDalicPINVOKE.delete_Vector4(swigCPtr);
105 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
111 /// The addition operator.
113 /// <param name="arg1">The first value.</param>
114 /// <param name="arg2">The second value.</param>
115 /// <returns>The color containing the result of the addition.</returns>
116 /// <since_tizen> 3 </since_tizen>
117 public static Color operator +(Color arg1, Color arg2)
119 Color result = arg1.Add(arg2);
125 /// The subtraction operator.
127 /// <param name="arg1">The first value.</param>
128 /// <param name="arg2">The second value.</param>
129 /// <returns>The color containing the result of the subtraction.</returns>
130 /// <since_tizen> 3 </since_tizen>
131 public static Color operator -(Color arg1, Color arg2)
133 Color result = arg1.Subtract(arg2);
139 /// The unary negation operator.
141 /// <param name="arg1">The target value.</param>
142 /// <returns>The color containg the negation.</returns>
143 /// <since_tizen> 3 </since_tizen>
144 public static Color operator -(Color arg1)
146 Color result = arg1.Subtract();
152 /// The multiplication operator.
154 /// <param name="arg1">The first value.</param>
155 /// <param name="arg2">The second value.</param>
156 /// <returns>The color containing the result of the multiplication.</returns>
157 /// <since_tizen> 3 </since_tizen>
158 public static Color operator *(Color arg1, Color arg2)
160 Color result = arg1.Multiply(arg2);
165 public static Color operator*(Color arg1, float arg2)
167 Color result = arg1.Multiply(arg2);
173 /// The division operator.
175 /// <param name="arg1">The first value.</param>
176 /// <param name="arg2">The second value.</param>
177 /// <returns>The color containing the result of the division.</returns>
178 /// <since_tizen> 3 </since_tizen>
179 public static Color operator /(Color arg1, Color arg2)
181 Color result = arg1.Divide(arg2);
186 public static Color operator/(Color arg1, float arg2)
188 Color result = arg1.Divide(arg2);
194 /// The array subscript operator overload.
196 /// <param name="index">The subscript index.</param>
197 /// <returns>The float at the given index.</returns>
198 /// <since_tizen> 3 </since_tizen>
199 public float this[uint index]
203 return ValueOfIndex(index);
207 internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
209 Color ret = new Color(cPtr, false);
210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Default constructor
217 /// <since_tizen> 3 </since_tizen>
218 public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 /// <param name="r">The red component.</param>
228 /// <param name="g">The green component.</param>
229 /// <param name="b">The blue component.</param>
230 /// <param name="a">The alpha component.</param>
231 /// <since_tizen> 3 </since_tizen>
232 public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 /// The conversion constructor from an array of four floats.
244 /// <param name="array">array Array of R,G,B,A.</param>
245 /// <since_tizen> 3 </since_tizen>
246 public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
248 ValueCheck(ref array[0]);
249 ValueCheck(ref array[1]);
250 ValueCheck(ref array[2]);
251 ValueCheck(ref array[3]);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
255 private Color Add(Color rhs)
257 Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
262 private Color AddAssign(Vector4 rhs)
264 Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
269 private Color Subtract(Color rhs)
271 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276 private Color SubtractAssign(Color rhs)
278 Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283 private Color Multiply(Color rhs)
285 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
286 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
290 private Color Multiply(float rhs)
292 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
297 private Color MultiplyAssign(Color rhs)
299 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
304 private Color MultiplyAssign(float rhs)
306 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
311 private Color Divide(Vector4 rhs)
313 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 private Color Divide(float rhs)
320 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 private Color DivideAssign(Color rhs)
327 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332 private Color DivideAssign(float rhs)
334 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
335 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 private Color Subtract()
341 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
342 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 /// Checks if two color classes are same.
349 /// <param name="rhs">A color to be compared.</param>
350 /// <returns>If two colors are are same, then true.</returns>
351 /// <since_tizen> 3 </since_tizen>
352 public bool EqualTo(Color rhs)
354 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
356 if (rhs == null) return false;
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 /// Checks if two color classes are different.
365 /// <param name="rhs">A color to be compared.</param>
366 /// <returns>If two colors are are different, then true.</returns>
367 /// <since_tizen> 3 </since_tizen>
368 public bool NotEqualTo(Color rhs)
370 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 private float ValueOfIndex(uint index)
378 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
384 /// The red component.
386 /// <since_tizen> 3 </since_tizen>
391 ValueCheck(ref value);
392 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 /// The green component.
406 /// <since_tizen> 3 </since_tizen>
411 ValueCheck(ref value);
412 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 /// The blue component.
426 /// <since_tizen> 3 </since_tizen>
431 ValueCheck(ref value);
432 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
438 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 /// The alpha component.
446 /// <since_tizen> 3 </since_tizen>
451 ValueCheck(ref value);
452 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
457 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 /// Gets the black colored Color class.
466 /// <since_tizen> 3 </since_tizen>
467 public static readonly Color Black = new Color(0.0f, 0.0f, 0.0f, 1.0f);
470 /// Gets the white colored Color class.
472 /// <since_tizen> 3 </since_tizen>
473 public static readonly Color White = new Color(1.0f, 1.0f, 1.0f, 1.0f);
476 /// Gets the red colored Color class.
478 /// <since_tizen> 3 </since_tizen>
479 public static readonly Color Red = new Color(1.0f, 0.0f, 0.0f, 1.0f);
482 /// Gets the green colored Color class.
484 /// <since_tizen> 3 </since_tizen>
485 public static readonly Color Green = new Color(0.0f, 1.0f, 0.0f, 1.0f);
488 /// Gets the blue colored Color class.
490 /// <since_tizen> 3 </since_tizen>
491 public static readonly Color Blue = new Color(0.0f, 0.0f, 1.0f, 1.0f);
494 /// Gets the yellow colored Color class.
496 /// <since_tizen> 3 </since_tizen>
497 public static readonly Color Yellow = new Color(1.0f, 1.0f, 0.0f, 1.0f);
500 /// Gets the magenta colored Color class.
502 /// <since_tizen> 3 </since_tizen>
503 public static readonly Color Magenta = new Color(1.0f, 0.0f, 1.0f, 1.0f);
506 /// Gets the cyan colored Color class.
508 /// <since_tizen> 3 </since_tizen>
509 public static readonly Color Cyan = new Color(0.0f, 1.0f, 1.0f, 1.0f);
512 /// Gets the transparent colored Color class.
514 /// <since_tizen> 3 </since_tizen>
515 public static readonly Color Transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f);
518 /// Converts the Color class to Vector4 class implicitly.
520 /// <param name="color">A color to be converted to Vector4</param>
521 /// <since_tizen> 3 </since_tizen>
522 public static implicit operator Vector4(Color color)
524 return new Vector4(color.R, color.G, color.B, color.A);
528 /// Converts Vector4 class to Color class implicitly.
530 /// <param name="vec">A Vector4 to be converted to color.</param></param>
531 /// <since_tizen> 3 </since_tizen>
532 public static implicit operator Color(Vector4 vec)
534 return new Color(vec.R, vec.G, vec.B, vec.A);
537 internal static void ValueCheck(Color color)
542 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
544 else if (color.R > 1.0f)
547 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
552 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
554 else if (color.G > 1.0f)
557 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
562 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
564 else if (color.B > 1.0f)
567 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
572 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
574 else if (color.A > 1.0f)
577 Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
581 internal static void ValueCheck(ref float value)
586 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
588 else if (value > 1.0f)
591 Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");