X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Fpublic%2FExtents.cs;h=b73e40c849ba9502010de272903199101f080291;hb=013550adda2b112b0b8aba069d01b0d8d43e554e;hp=f5dc8e7234bc69ff744c427431b2d0663246ee3b;hpb=3c5a026c8e86e0e53fbc3bc7387e82ecf4aeb5ab;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.NUI/src/public/Extents.cs b/src/Tizen.NUI/src/public/Extents.cs index f5dc8e7..b73e40c 100755 --- a/src/Tizen.NUI/src/public/Extents.cs +++ b/src/Tizen.NUI/src/public/Extents.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017 Samsung Electronics Co., Ltd. +* Copyright (c) 2019 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. @@ -15,115 +15,49 @@ * */ +using System; +using System.ComponentModel; +using Tizen.NUI.Binding; + namespace Tizen.NUI { /// /// Extents class describing the a collection of uint16_t. /// - public class Extents : global::System.IDisposable + /// 4 + [Binding.TypeConverter(typeof(ExtentsTypeConverter))] + public class Extents : Disposable, ICloneable { - private global::System.Runtime.InteropServices.HandleRef swigCPtr; - protected bool swigCMemOwn; - - internal Extents(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(Extents 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; - - /// - /// Destructor. - /// - /// 4 - ~Extents() - { - if (!isDisposeQueued) - { - isDisposeQueued = true; - DisposeQueue.Instance.Add(this); - } - } /// - /// To make a Extents instance be disposed. + /// Constructor. /// /// 4 - public void Dispose() + public Extents() : this(Interop.Extents.NewExtents(), true) { - //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_Extents(swigCPtr); - } - swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); - } - disposed = true; + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Constructor. /// + /// A reference to the copied Extents. /// 4 - public Extents() : this(NDalicPINVOKE.new_Extents__SWIG_0(), true) + public Extents(Extents copy) : this(Interop.Extents.NewExtents(Extents.getCPtr(copy)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// - /// Constructor. + /// The type cast operator, ushort to Extents. /// - /// A reference to the copied Extents. - /// 4 - public Extents(Extents copy) : this(NDalicPINVOKE.new_Extents__SWIG_1(Extents.getCPtr(copy)), true) + /// A value of ushort type. + /// return a Extents instance + [EditorBrowsable(EditorBrowsableState.Never)] + public static implicit operator Extents(ushort value) { - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Extents(value, value, value, value); } /// @@ -134,65 +68,90 @@ namespace Tizen.NUI /// Bottom extent. /// /// 4 - public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(NDalicPINVOKE.new_Extents__SWIG_2(start, end, top, bottom), true) + public Extents(ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.NewExtents(start, end, top, bottom), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal Extents Assign(SWIGTYPE_p_uint16_t array) + internal Extents(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { - Extents ret = new Extents(NDalicPINVOKE.Extents_Assign__SWIG_1(swigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } - internal Extents Assign(Extents copy) + /// + /// Constructor + /// + /// + /// + /// + /// + /// + /// Only used by Tizen.NUI.Components, will not be opened + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public Extents(ExtentsChangedCallback cb, ushort start, ushort end, ushort top, ushort bottom) : this(Interop.Extents.NewExtents(start, end, top, bottom), true) { - Extents ret = new Extents(NDalicPINVOKE.Extents_Assign__SWIG_0(swigCPtr, Extents.getCPtr(copy)), false); + callback = cb; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } /// - /// Equality operator. + /// Copy other extents /// - /// The Extents to test against. - /// True if the extents are not equal. - /// 4 - public bool EqualTo(Extents rhs) + /// + /// Thrown when that is null. + /// Only used by Tizen.NUI.Components, will not be opened + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public void CopyFrom(Extents that) { - bool ret = NDalicPINVOKE.Extents_EqualTo(swigCPtr, Extents.getCPtr(rhs)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; + if (null == that) + { + throw new ArgumentNullException(nameof(that)); + } + Interop.Extents.StartSet(swigCPtr, that.Start); + Interop.Extents.EndSet(swigCPtr, that.End); + Interop.Extents.TopSet(swigCPtr, that.Top); + Interop.Extents.BottomSet(swigCPtr, that.Bottom); } /// - /// Inequality operator. + /// Constructor /// - /// The Extents to test against. - /// True if the extents are not equal. - /// 4 - public bool NotEqualTo(Extents rhs) - { - bool ret = NDalicPINVOKE.Extents_NotEqualTo(swigCPtr, Extents.getCPtr(rhs)); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } + /// + /// + /// + /// + /// Only used by Tizen.NUI.Components, will not be opened + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public delegate void ExtentsChangedCallback(ushort start, ushort end, ushort top, ushort bottom); + private ExtentsChangedCallback callback = null; /// /// The Start extent. /// + /// + /// The setter is deprecated in API8 and will be removed in API10. Please use new Extents(...) constructor. + /// + /// + /// // DO NOT use like the followings! + /// Extents extents = new Extents(); + /// extents.Start = 1; + /// // Please USE like this + /// ushort start = 1, end = 2, top = 3, bottom = 4; + /// Extents extents = new Extents(start, end, top, bottom); + /// /// 4 public ushort Start { set { - NDalicPINVOKE.Extents_start_set(swigCPtr, value); + Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Extents(...) constructor"); + Interop.Extents.StartSet(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + callback?.Invoke(Start, End, Top, Bottom); } get { - ushort ret = NDalicPINVOKE.Extents_start_get(swigCPtr); + ushort ret = Interop.Extents.StartGet(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -201,17 +160,32 @@ namespace Tizen.NUI /// /// The End extend. /// + /// + /// The setter is deprecated in API8 and will be removed in API10. Please use new Extents(...) constructor. + /// + /// + /// // DO NOT use like the followings! + /// Extents extents = new Extents(); + /// extents.End = 2; + /// // Please USE like this + /// ushort start = 1, end = 2, top = 3, bottom = 4; + /// Extents extents = new Extents(start, end, top, bottom); + /// /// 4 public ushort End { set { - NDalicPINVOKE.Extents_end_set(swigCPtr, value); + Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Extents(...) constructor"); + + Interop.Extents.EndSet(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + callback?.Invoke(Start, End, Top, Bottom); } get { - ushort ret = NDalicPINVOKE.Extents_end_get(swigCPtr); + ushort ret = Interop.Extents.EndGet(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -220,17 +194,32 @@ namespace Tizen.NUI /// /// The Top extend. /// + /// + /// The setter is deprecated in API8 and will be removed in API10. Please use new Extents(...) constructor. + /// + /// + /// // DO NOT use like the followings! + /// Extents extents = new Extents(); + /// extents.Top = 3; + /// // Please USE like this + /// ushort start = 1, end = 2, top = 3, bottom = 4; + /// Extents extents = new Extents(start, end, top, bottom); + /// /// 4 public ushort Top { set { - NDalicPINVOKE.Extents_top_set(swigCPtr, value); + Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Extents(...) constructor"); + + Interop.Extents.TopSet(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + callback?.Invoke(Start, End, Top, Bottom); } get { - ushort ret = NDalicPINVOKE.Extents_top_get(swigCPtr); + ushort ret = Interop.Extents.TopGet(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } @@ -239,22 +228,91 @@ namespace Tizen.NUI /// /// The Bottom Extend. /// + /// + /// The setter is deprecated in API8 and will be removed in API10. Please use new Extents(...) constructor. + /// + /// + /// // DO NOT use like the followings! + /// Extents extents = new Extents(); + /// extents.Bottom = 4; + /// // Please USE like this + /// ushort start = 1, end = 2, top = 3, bottom = 4; + /// Extents extents = new Extents(start, end, top, bottom); + /// /// 4 public ushort Bottom { set { - NDalicPINVOKE.Extents_bottom_set(swigCPtr, value); + Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Extents(...) constructor"); + + Interop.Extents.BottomSet(swigCPtr, value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + + callback?.Invoke(Start, End, Top, Bottom); } get { - ushort ret = NDalicPINVOKE.Extents_bottom_get(swigCPtr); + ushort ret = Interop.Extents.BottomGet(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } } - } + /// + /// Equality operator. + /// + /// The Extents to test against. + /// True if the extents are not equal. + /// 4 + public bool EqualTo(Extents rhs) + { + bool ret = Interop.Extents.EqualTo(swigCPtr, Extents.getCPtr(rhs)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + /// Inequality operator. + /// + /// The Extents to test against. + /// True if the extents are not equal. + /// 4 + public bool NotEqualTo(Extents rhs) + { + bool ret = Interop.Extents.NotEqualTo(swigCPtr, Extents.getCPtr(rhs)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Clone() => new Extents(this); + + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Extents obj) + { + return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; + } + internal Extents Assign(SWIGTYPE_p_uint16_t array) + { + Extents ret = new Extents(Interop.Extents.AssignUint16(swigCPtr, SWIGTYPE_p_uint16_t.getCPtr(array)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + internal Extents Assign(Extents copy) + { + Extents ret = new Extents(Interop.Extents.Assign(swigCPtr, Extents.getCPtr(copy)), false); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + + /// This will not be public opened. + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { + Interop.Extents.DeleteExtents(swigCPtr); + } + } }