/*
* 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.
*
*/
using System;
namespace Tizen.NUI
{
[Obsolete("Please do not use! This will be changed to internal class")]
public class Size : global::System.IDisposable
{
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
protected bool swigCMemOwn;
internal Size(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(Size 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;
///
/// Dispose
///
~Size()
{
if (!isDisposeQueued)
{
isDisposeQueued = true;
DisposeQueue.Instance.Add(this);
}
}
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_Vector3(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
disposed = true;
}
///
/// Addition operator for A+B
///
/// Size, A
/// Size to assign, B
/// A Size containing the result of the addition
public static Size operator +(Size arg1, Size arg2)
{
return arg1.Add(arg2);
}
///
/// Subtraction operator for A-B
///
/// Size, A
/// Size to subtract, B
/// A Size containing the result of the subtraction
public static Size operator -(Size arg1, Size arg2)
{
return arg1.Subtract(arg2);
}
///
/// Unary negation operator.
///
/// Size for unary negation
/// A Size containg the negation
public static Size operator -(Size arg1)
{
return arg1.Subtract();
}
///
/// Multiplication operator.
///
/// Size for multiplication
/// The Size to multipl
/// A Size containing the result of the multiplication
public static Size operator *(Size arg1, Size arg2)
{
return arg1.Multiply(arg2);
}
///
/// Multiplication operator.
///
/// Size for multiplication
/// The float value to scale the Size
/// A Size containing the result of the scaling
public static Size operator *(Size arg1, float arg2)
{
return arg1.Multiply(arg2);
}
///
/// Division operator.
///
/// Size for division
/// The Size to divide
/// A Size containing the result of the division>
public static Size operator /(Size arg1, Size arg2)
{
return arg1.Divide(arg2);
}
///
/// Division operator.
///
/// Size for division
/// The float value to scale the Size by
/// A Size containing the result of the scaling
public static Size operator /(Size arg1, float arg2)
{
return arg1.Divide(arg2);
}
///
/// Array subscript operator.
///
/// Subscript index
/// The float at the given index
public float this[uint index]
{
get
{
return ValueOfIndex(index);
}
}
internal static Size GetSizeFromPtr(global::System.IntPtr cPtr)
{
Size ret = new Size(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Constructor.
///
public Size() : this(NDalicPINVOKE.new_Vector3__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Constructor.
///
/// x (or width) component
/// y (or height) component
/// z (or depth) component
public Size(float x, float y, float z) : this(NDalicPINVOKE.new_Vector3__SWIG_1(x, y, z), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Constructor.
///
/// Size2D with x (width) and y (height)
public Size(Size2D size2d) : this(NDalicPINVOKE.new_Vector3__SWIG_3(Size2D.getCPtr(size2d)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
///
/// Zero constant, (0.0f, 0.0f, 0.0f).
///
public static Size Zero
{
get
{
global::System.IntPtr cPtr = NDalicPINVOKE.Vector3_ZERO_get();
Size ret = (cPtr == global::System.IntPtr.Zero) ? null : new Size(cPtr, false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
private Size Add(Size rhs)
{
Size ret = new Size(NDalicPINVOKE.Vector3_Add(swigCPtr, Size.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Size Subtract(Size rhs)
{
Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Size Multiply(Size rhs)
{
Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Size Multiply(float rhs)
{
Size ret = new Size(NDalicPINVOKE.Vector3_Multiply__SWIG_1(swigCPtr, rhs), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Size Divide(Size rhs)
{
Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_0(swigCPtr, Size.getCPtr(rhs)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Size Divide(float rhs)
{
Size ret = new Size(NDalicPINVOKE.Vector3_Divide__SWIG_1(swigCPtr, rhs), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private Size Subtract()
{
Size ret = new Size(NDalicPINVOKE.Vector3_Subtract__SWIG_1(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
private float ValueOfIndex(uint index)
{
float ret = NDalicPINVOKE.Vector3_ValueOfIndex__SWIG_0(swigCPtr, index);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Check equality.
/// Utilizes appropriate machine epsilon values.
///
/// The Size to test against
/// True if the Sizes are equal
public bool EqualTo(Size rhs)
{
bool ret = NDalicPINVOKE.Vector3_EqualTo(swigCPtr, Size.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Check inequality.
/// Utilizes appropriate machine epsilon values.
///
/// The Size to test against
/// True if the Sizes are not equal
public bool NotEqualTo(Size rhs)
{
bool ret = NDalicPINVOKE.Vector3_NotEqualTo(swigCPtr, Size.getCPtr(rhs));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Width property for width component of Siz
///
public float Width
{
set
{
NDalicPINVOKE.Vector3_Width_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector3_Width_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// Height property for height component of Size
///
public float Height
{
set
{
NDalicPINVOKE.Vector3_Height_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector3_Height_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// Depth property for depth component of Size
///
public float Depth
{
set
{
NDalicPINVOKE.Vector3_Depth_set(swigCPtr, value);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
get
{
float ret = NDalicPINVOKE.Vector3_Depth_get(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
}
///
/// Type cast operator, Size to Vector3.
///
/// Object of Size type
public static implicit operator Vector3(Size size)
{
return new Vector3(size.Width, size.Height, size.Depth);
}
///
/// Type cast operator, Vector3 to Size type.
///
/// Object of Vector3 type
public static implicit operator Size(Vector3 vec)
{
return new Size(vec.Width, vec.Height, vec.Depth);
}
}
}