// Copyright (c) 2017 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//
// This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
// Some have been manually changed
namespace Tizen.NUI
{
using System;
///
/// Color class.
///
public class Color : global::System.IDisposable
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;
internal Color(global::System.IntPtr cPtr, bool cMemoryOwn)
{
swigCMemOwn = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
//A Flag to check who called Dispose(). (By User or DisposeQueue)
private bool isDisposeQueued = false;
//A Flat to check if it is already disposed.
protected bool disposed = false;
~Color()
{
if(!isDisposeQueued)
{
isDisposeQueued = true;
DisposeQueue.Instance.Add(this);
}
}
///
/// To make Color instance be disposed.
///
public void Dispose()
{
//Throw excpetion if Dispose() is called in separate thread.
if (!Window.IsInstalled())
{
throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
}
if (isDisposeQueued)
{
Dispose(DisposeTypes.Implicit);
}
else
{
Dispose(DisposeTypes.Explicit);
System.GC.SuppressFinalize(this);
}
}
protected virtual void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
if(type == DisposeTypes.Explicit)
{
//Called by User
//Release your own managed resources here.
//You should release all of your own disposable objects here.
}
//Release your own unmanaged resources here.
//You should not access any managed member here except static instance.
//because the execution order of Finalizes is non-deterministic.
if (swigCPtr.Handle != global::System.IntPtr.Zero)
{
if (swigCMemOwn)
{
swigCMemOwn = false;
NDalicPINVOKE.delete_Vector4(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
disposed = true;
}
///
/// Addition operator.
///
/// First value
/// Second value
/// A Color containing the result of the addition
public static Color operator +(Color arg1, Color arg2)
{
Color result = arg1.Add(arg2);
ValueCheck(result);
return result;
}
///
/// Subtraction operator.
///
/// First value
/// Second value
/// A Color containing the result of the subtraction
public static Color operator -(Color arg1, Color arg2)
{
Color result = arg1.Subtract(arg2);
ValueCheck(result);
return result;
}
///
/// Unary negation operator.
///
/// Target Value
/// A Color containg the negation
public static Color operator -(Color arg1)
{
Color result = arg1.Subtract();
ValueCheck(result);
return result;
}
///
/// Multiplication operator.
///
/// First Value
/// Second Value
/// A Color containing the result of the multiplication
public static Color operator *(Color arg1, Color arg2)
{
Color result = arg1.Multiply(arg2);
ValueCheck(result);
return result;
}
public static Color operator*(Color arg1, float arg2)
{
Color result = arg1.Multiply(arg2);
ValueCheck(result);
return result;
}
///
/// Division operator.
///
/// First Value
/// Second Value
/// A Color containing the result of the division
public static Color operator /(Color arg1, Color arg2)
{
Color result = arg1.Divide(arg2);
ValueCheck(result);
return result;
}
public static Color operator/(Color arg1, float arg2)
{
Color result = arg1.Divide(arg2);
ValueCheck(result);
return result;
}
///
/// Array subscript operator overload.
///
/// Subscript index
/// The float at the given index
public float this[uint index]
{
get
{
return ValueOfIndex(index);
}
}
internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
{
Color ret = new Color(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Default constructor
///
public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Constructor.
///
/// red component
/// green component
/// blue component
/// alpha component
public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
{
ValueCheck(ref r);
ValueCheck(ref g);
ValueCheck(ref b);
ValueCheck(ref a);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Conversion constructor from an array of four floats.
///
/// array Array of R,G,B,A
public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
{
ValueCheck(ref array[0]);
ValueCheck(ref array[1]);
ValueCheck(ref array[2]);
ValueCheck(ref array[3]);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
private Color Add(Color rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color AddAssign(Vector4 rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color Subtract(Color rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color SubtractAssign(Color rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color Multiply(Color rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color Multiply(float rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color MultiplyAssign(Color rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color MultiplyAssign(float rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color Divide(Vector4 rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color Divide(float rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color DivideAssign(Color rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color DivideAssign(float rhs)
{
Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Color Subtract()
{
Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Check if two Color classes are same.
///
/// A Color to be compared
/// If two Colors are are same, then true.
public bool EqualTo(Color rhs)
{
bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
if (rhs == null) return false;
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Check if two Color classes are different.
///
/// A Color to be compared
/// If two Colors are are different, then true.
public bool NotEqualTo(Color rhs)
{
bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private float ValueOfIndex(uint index)
{
float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// red component.
///
public float R
{
set
{
ValueCheck(ref value);
NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// green component.
///
public float G
{
set
{
ValueCheck(ref value);
NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// blue component.
///
public float B
{
set
{
ValueCheck(ref value);
NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// alpha component.
///
public float A
{
set
{
ValueCheck(ref value);
NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// Get black colored Color class.
///
public static readonly Color Black = new Color(0.0f, 0.0f, 0.0f, 1.0f);
///
/// Get white colored Color class.
///
public static readonly Color White = new Color(1.0f, 1.0f, 1.0f, 1.0f);
///
/// Get red colored Color class.
///
public static readonly Color Red = new Color(1.0f, 0.0f, 0.0f, 1.0f);
///
/// Get green colored Color class.
///
public static readonly Color Green = new Color(0.0f, 1.0f, 0.0f, 1.0f);
///
/// Get blue colored Color class.
///
public static readonly Color Blue = new Color(0.0f, 0.0f, 1.0f, 1.0f);
///
/// Get yellow colored Color class.
///
public static readonly Color Yellow = new Color(1.0f, 1.0f, 0.0f, 1.0f);
///
/// Get magenta colored Color class.
///
public static readonly Color Magenta = new Color(1.0f, 0.0f, 1.0f, 1.0f);
///
/// Get cyan colored Color class.
///
public static readonly Color Cyan = new Color(0.0f, 1.0f, 1.0f, 1.0f);
///
/// Get transparent colored Color class.
///
public static readonly Color Transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f);
///
/// convert Color class to Vector4 class implicitly.
///
/// A Color to be converted to Vector4
public static implicit operator Vector4(Color color)
{
return new Vector4(color.R, color.G, color.B, color.A);
}
///
/// convert Vector4 class to Color class implicitly.
///
/// A Vector4 to be converted to Color
public static implicit operator Color(Vector4 vec)
{
return new Color(vec.R, vec.G, vec.B, vec.A);
}
internal static void ValueCheck(Color color)
{
if (color.R < 0.0f)
{
color.R = 0.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
else if (color.R > 1.0f)
{
color.R = 1.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
if (color.G < 0.0f)
{
color.G = 0.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
else if (color.G > 1.0f)
{
color.G = 1.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
if (color.B < 0.0f)
{
color.B = 0.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
else if (color.B > 1.0f)
{
color.B = 1.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
if (color.A < 0.0f)
{
color.A = 0.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
else if (color.A > 1.0f)
{
color.A = 1.0f;
Tizen.Log.Fatal("NUI", "The value of Result is invalid! Should be between [0, 1].");
}
}
internal static void ValueCheck(ref float value)
{
if (value < 0.0f)
{
value = 0.0f;
Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
}
else if (value > 1.0f)
{
value = 1.0f;
Tizen.Log.Fatal("NUI", "The value of Parameters is invalid! Should be between [0, 1].");
}
}
}
}