X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Fpublic%2FBaseComponents%2FView.cs;h=15d421fb8deea9a5bc6c01fc49e34838ddb87382;hb=adb636bd7ce4547374b6451672efb27ca8dc6f7e;hp=4f9a003045bdbf6fd1bf20e3691dc5a7c4ef96ad;hpb=9949fb60f68361cee6f5918da567ec449db23455;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 4f9a003..15d421f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -32,7 +32,10 @@ namespace Tizen.NUI.BaseComponents internal View(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.View_SWIGUpcast(cPtr), cMemoryOwn) { swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); - PositionUsesPivotPoint = false; + if (HasBody()) + { + PositionUsesPivotPoint = false; + } } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(View obj) @@ -49,11 +52,18 @@ namespace Tizen.NUI.BaseComponents /// 4 public override void Add(View child) { - NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child)); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - - Children.Add(child); + Container oldParent = child.GetParent(); + if(oldParent != this) + { + if (oldParent != null) + { + oldParent.Remove(child); + } + NDalicPINVOKE.Actor_Add(swigCPtr, View.getCPtr(child)); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + Children.Add(child); + } } /// @@ -104,9 +114,12 @@ namespace Tizen.NUI.BaseComponents /// 4 public override Container GetParent() { + //to fix memory leak issue, match the handle count with native side. IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr); - - BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(cPtr); + HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle); + NDalicPINVOKE.delete_BaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -116,7 +129,7 @@ namespace Tizen.NUI.BaseComponents internal bool IsTopLevelView() { - if(GetParent() is Layer) + if (GetParent() is Layer) { return true; } @@ -130,12 +143,12 @@ namespace Tizen.NUI.BaseComponents /// 3 protected override void Dispose(DisposeTypes type) { - if(disposed) + if (disposed) { return; } - if(type == DisposeTypes.Explicit) + if (type == DisposeTypes.Explicit) { //Called by User //Release your own managed resources here. @@ -145,8 +158,10 @@ namespace Tizen.NUI.BaseComponents //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. - - DisConnectFromSignals(); + if (this != null) + { + DisConnectFromSignals(); + } if (swigCPtr.Handle != global::System.IntPtr.Zero) { @@ -401,6 +416,12 @@ namespace Tizen.NUI.BaseComponents private bool OnKeyEvent(IntPtr view, IntPtr keyEvent) { + if (keyEvent == global::System.IntPtr.Zero) + { + NUILog.Error("keyEvent should not be null!"); + return true; + } + KeyEventArgs e = new KeyEventArgs(); bool result = false; @@ -412,9 +433,9 @@ namespace Tizen.NUI.BaseComponents Delegate[] delegateList = _keyEventHandler.GetInvocationList(); // Oring the result of each callback. - foreach ( EventHandlerWithReturnType del in delegateList ) + foreach (EventHandlerWithReturnType del in delegateList) { - result |= del( this, e ); + result |= del(this, e); } } @@ -528,6 +549,12 @@ namespace Tizen.NUI.BaseComponents // Callback for View TouchSignal private bool OnTouch(IntPtr view, IntPtr touchData) { + if (touchData == global::System.IntPtr.Zero) + { + NUILog.Error("touchData should not be null!"); + return true; + } + TouchEventArgs e = new TouchEventArgs(); e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData); @@ -603,6 +630,12 @@ namespace Tizen.NUI.BaseComponents // Callback for View Hover signal private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent) { + if (hoverEvent == global::System.IntPtr.Zero) + { + NUILog.Error("hoverEvent should not be null!"); + return true; + } + HoverEventArgs e = new HoverEventArgs(); e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent); @@ -678,6 +711,12 @@ namespace Tizen.NUI.BaseComponents // Callback for View Wheel signal private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent) { + if (wheelEvent == global::System.IntPtr.Zero) + { + NUILog.Error("wheelEvent should not be null!"); + return true; + } + WheelEventArgs e = new WheelEventArgs(); e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent); @@ -1092,7 +1131,6 @@ namespace Tizen.NUI.BaseComponents internal static readonly int SIZE_SCALE_POLICY = NDalicPINVOKE.Actor_Property_SIZE_SCALE_POLICY_get(); internal static readonly int WIDTH_FOR_HEIGHT = NDalicPINVOKE.Actor_Property_WIDTH_FOR_HEIGHT_get(); internal static readonly int HEIGHT_FOR_WIDTH = NDalicPINVOKE.Actor_Property_HEIGHT_FOR_WIDTH_get(); - internal static readonly int PADDING = NDalicPINVOKE.Actor_Property_PADDING_get(); internal static readonly int MINIMUM_SIZE = NDalicPINVOKE.Actor_Property_MINIMUM_SIZE_get(); internal static readonly int MAXIMUM_SIZE = NDalicPINVOKE.Actor_Property_MAXIMUM_SIZE_get(); internal static readonly int INHERIT_POSITION = NDalicPINVOKE.Actor_Property_INHERIT_POSITION_get(); @@ -1100,7 +1138,7 @@ namespace Tizen.NUI.BaseComponents internal static readonly int INHERIT_LAYOUT_DIRECTION = NDalicManualPINVOKE.Actor_Property_INHERIT_LAYOUT_DIRECTION_get(); internal static readonly int LAYOUT_DIRECTION = NDalicManualPINVOKE.Actor_Property_LAYOUT_DIRECTION_get(); internal static readonly int MARGIN = NDalicPINVOKE.View_Property_MARGIN_get(); - internal static readonly int PADDINGEX = NDalicPINVOKE.View_Property_PADDING_get(); + internal static readonly int PADDING = NDalicPINVOKE.View_Property_PADDING_get(); } /// @@ -1155,39 +1193,6 @@ namespace Tizen.NUI.BaseComponents if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - /// - /// Downcasts a handle to view handle.
- /// If handle points to a view, the downcast produces a valid handle.
- /// If not, the returned handle is left uninitialized.
- ///
- /// A handle to an object. - /// A handle to a view or an uninitialized handle. - /// 3 - [Obsolete("Please do not use! this will be deprecated, instead please use as keyword.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public static View DownCast(BaseHandle handle) - { - View ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as View; - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; - } - - /// - /// [Obsolete("Please do not use! this will be deprecated, instead please use as keyword.")] - /// - /// 3 - [Obsolete("Please do not use! this will be deprecated, instead please use as keyword.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public static T DownCast(View view) where T : View - { - T ret = Registry.GetManagedBaseHandleFromNativePtr(view) as T; - if (ret != null) - { - return ret; - } - return null; - } - private View ConvertIdToView(uint id) { View view = null; @@ -1392,7 +1397,7 @@ namespace Tizen.NUI.BaseComponents /// background visual, creates one with transparent black as it's mixColor. ///
/// 3 - public Animation AnimateBackgroundColor( object destinationValue, + public Animation AnimateBackgroundColor(object destinationValue, int startTime, int endTime, AlphaFunction.BuiltinFunctions? alphaFunction = null, @@ -1400,51 +1405,51 @@ namespace Tizen.NUI.BaseComponents { Tizen.NUI.PropertyMap background = Background; - if( background.Empty() ) + if (background.Empty()) { // If there is no background yet, ensure there is a transparent // color visual BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f); background = Background; } - return AnimateColor( "background", destinationValue, startTime, endTime, alphaFunction, initialValue ); + return AnimateColor("background", destinationValue, startTime, endTime, alphaFunction, initialValue); } /// /// Creates an animation to animate the mixColor of the named visual. /// /// 3 - public Animation AnimateColor( string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions? alphaFunction = null, object initialColor = null ) + public Animation AnimateColor(string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions? alphaFunction = null, object initialColor = null) { Animation animation = null; { PropertyMap _animator = new PropertyMap(); - if( alphaFunction != null ) + if (alphaFunction != null) { - _animator.Add("alphaFunction", new PropertyValue( AlphaFunction.BuiltinToPropertyKey(alphaFunction) ) ); + _animator.Add("alphaFunction", new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction))); } PropertyMap _timePeriod = new PropertyMap(); - _timePeriod.Add( "duration", new PropertyValue((endTime-startTime)/1000.0f) ); - _timePeriod.Add( "delay", new PropertyValue( startTime/1000.0f ) ); - _animator.Add( "timePeriod", new PropertyValue( _timePeriod ) ); + _timePeriod.Add("duration", new PropertyValue((endTime - startTime) / 1000.0f)); + _timePeriod.Add("delay", new PropertyValue(startTime / 1000.0f)); + _animator.Add("timePeriod", new PropertyValue(_timePeriod)); PropertyMap _transition = new PropertyMap(); - _transition.Add( "animator", new PropertyValue( _animator ) ); - _transition.Add( "target", new PropertyValue( targetVisual ) ); - _transition.Add( "property", new PropertyValue( "mixColor" ) ); + _transition.Add("animator", new PropertyValue(_animator)); + _transition.Add("target", new PropertyValue(targetVisual)); + _transition.Add("property", new PropertyValue("mixColor")); - if( initialColor != null ) + if (initialColor != null) { - PropertyValue initValue = PropertyValue.CreateFromObject( initialColor ); - _transition.Add( "initialValue", initValue ); + PropertyValue initValue = PropertyValue.CreateFromObject(initialColor); + _transition.Add("initialValue", initValue); } - PropertyValue destValue = PropertyValue.CreateFromObject( destinationColor ); - _transition.Add( "targetValue", destValue ); - TransitionData _transitionData = new TransitionData( _transition ); + PropertyValue destValue = PropertyValue.CreateFromObject(destinationColor); + _transition.Add("targetValue", destValue); + TransitionData _transitionData = new TransitionData(_transition); - animation = new Animation( NDalicManualPINVOKE.View_CreateTransition(swigCPtr, TransitionData.getCPtr(_transitionData)), true ); + animation = new Animation(NDalicManualPINVOKE.View_CreateTransition(swigCPtr, TransitionData.getCPtr(_transitionData)), true); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -1486,7 +1491,7 @@ namespace Tizen.NUI.BaseComponents get { Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap(); - GetProperty( View.Property.BACKGROUND ).Get(temp); + GetProperty(View.Property.BACKGROUND).Get(temp); return temp; } set @@ -1512,21 +1517,21 @@ namespace Tizen.NUI.BaseComponents switch (temp) { case 0: - { - return States.Normal; - } + { + return States.Normal; + } case 1: - { - return States.Focused; - } + { + return States.Focused; + } case 2: - { - return States.Disabled; - } + { + return States.Disabled; + } default: - { - return States.Normal; - } + { + return States.Normal; + } } } set @@ -1566,25 +1571,25 @@ namespace Tizen.NUI.BaseComponents switch (value) { case States.Normal: - { - valueToString = "NORMAL"; - break; - } + { + valueToString = "NORMAL"; + break; + } case States.Focused: - { - valueToString = "FOCUSED"; - break; - } + { + valueToString = "FOCUSED"; + break; + } case States.Disabled: - { - valueToString = "DISABLED"; - break; - } + { + valueToString = "DISABLED"; + break; + } default: - { - valueToString = "NORMAL"; - break; - } + { + valueToString = "NORMAL"; + break; + } } SetProperty(View.Property.SUB_STATE, new Tizen.NUI.PropertyValue(valueToString)); } @@ -1820,25 +1825,25 @@ namespace Tizen.NUI.BaseComponents switch (value) { case Tizen.NUI.HorizontalAlignmentType.Left: - { - valueToString = "left"; - break; - } + { + valueToString = "left"; + break; + } case Tizen.NUI.HorizontalAlignmentType.Center: - { - valueToString = "center"; - break; - } + { + valueToString = "center"; + break; + } case Tizen.NUI.HorizontalAlignmentType.Right: - { - valueToString = "right"; - break; - } + { + valueToString = "right"; + break; + } default: - { - valueToString = "left"; - break; - } + { + valueToString = "left"; + break; + } } SetProperty(TableView.ChildProperty.CELL_HORIZONTAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString)); } @@ -1876,25 +1881,25 @@ namespace Tizen.NUI.BaseComponents switch (value) { case Tizen.NUI.VerticalAlignmentType.Top: - { - valueToString = "top"; - break; - } + { + valueToString = "top"; + break; + } case Tizen.NUI.VerticalAlignmentType.Center: - { - valueToString = "center"; - break; - } + { + valueToString = "center"; + break; + } case Tizen.NUI.VerticalAlignmentType.Bottom: - { - valueToString = "bottom"; - break; - } + { + valueToString = "bottom"; + break; + } default: - { - valueToString = "top"; - break; - } + { + valueToString = "top"; + break; + } } SetProperty(TableView.ChildProperty.CELL_VERTICAL_ALIGNMENT, new Tizen.NUI.PropertyValue(valueToString)); } @@ -1919,7 +1924,7 @@ namespace Tizen.NUI.BaseComponents } set { - if(value) + if (value) { LeftFocusableViewId = (int)value.GetId(); } @@ -1949,7 +1954,7 @@ namespace Tizen.NUI.BaseComponents } set { - if(value) + if (value) { RightFocusableViewId = (int)value.GetId(); } @@ -1979,7 +1984,7 @@ namespace Tizen.NUI.BaseComponents } set { - if(value) + if (value) { UpFocusableViewId = (int)value.GetId(); } @@ -2009,7 +2014,7 @@ namespace Tizen.NUI.BaseComponents } set { - if(value) + if (value) { DownFocusableViewId = (int)value.GetId(); } @@ -2105,20 +2110,6 @@ namespace Tizen.NUI.BaseComponents } /// - /// [Obsolete("Please do not use! this will be deprecated. Please use Visibility instead.")] - /// - /// 3 - [Obsolete("Please do not use! this will be deprecated. Please use Visibility instead.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public bool Visible - { - get - { - return IsVisible(); - } - } - - /// /// Retrieves and sets the view's opacity.
///
/// 3 @@ -2198,7 +2189,11 @@ namespace Tizen.NUI.BaseComponents /// Please do not use! this will be deprecated! /// Instead please use PositionUsesPivotPoint. /// 3 - [Obsolete("Please do not use! this will be deprecated, instead please use PositionUsesPivotPoint")] + [Obsolete("Please do not use! This will be deprecated! Please use PositionUsesPivotPoint instead! " + + "Like: " + + "View view = new View(); " + + "view.PivotPoint = PivotPoint.Center; " + + "view.PositionUsesPivotPoint = true;")] [EditorBrowsable(EditorBrowsableState.Never)] public bool PositionUsesAnchorPoint { @@ -2255,7 +2250,7 @@ namespace Tizen.NUI.BaseComponents /// Sets the sibling order of the view so the depth position can be defined within the same parent. ///
/// - /// Note the initial value is 0. + /// Note the initial value is 0. SiblingOrder should be bigger than 0 or equal to 0. /// Raise, Lower, RaiseToTop, LowerToBottom, RaiseAbove, and LowerBelow will override the sibling order. /// The values set by this property will likely change. /// @@ -2264,13 +2259,58 @@ namespace Tizen.NUI.BaseComponents { get { - int temp = 0; - GetProperty(View.Property.SIBLING_ORDER).Get(out temp); - return temp; + var parentChildren = GetParent()?.Children; + int currentOrder = 0; + if (parentChildren != null) + { + currentOrder = parentChildren.IndexOf(this); + + if (currentOrder < 0) + { + return 0; + } + else if (currentOrder < parentChildren.Count) + { + return currentOrder; + } + } + + return 0; } set { - SetProperty(View.Property.SIBLING_ORDER, new Tizen.NUI.PropertyValue(value)); + if(value < 0) + { + NUILog.Error("SiblingOrder should be bigger than 0 or equal to 0."); + return; + } + var siblings = GetParent()?.Children; + if (siblings != null) + { + int currentOrder = siblings.IndexOf(this); + if (value != currentOrder) + { + if (value == 0) + { + LowerToBottom(); + } + else if (value < siblings.Count - 1) + { + if (value > currentOrder) + { + RaiseAbove(siblings[value]); + } + else + { + LowerBelow(siblings[value]); + } + } + else + { + RaiseToTop(); + } + } + } } } @@ -2283,7 +2323,10 @@ namespace Tizen.NUI.BaseComponents /// /// Please do not use! this will be deprecated! /// Instead please use NaturalSize2D. /// 3 - [Obsolete("Please do not use! this will be deprecated, please use NaturalSize2D instead")] + [Obsolete("Please do not use! This will be deprecated! Please use NaturalSize2D instead! " + + "Like: " + + "TextLabel label = new TextLabel(\"Hello World!\"); " + + "Size2D size = label.NaturalSize2D;")] [EditorBrowsable(EditorBrowsableState.Never)] public Vector3 NaturalSize { @@ -2343,46 +2386,47 @@ namespace Tizen.NUI.BaseComponents internal void Raise() { - var parentChildren = Parent?.Children; + var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); // If the view is not already the last item in the list. - if (currentIndex != parentChildren.Count -1) + if (currentIndex >= 0 && currentIndex < parentChildren.Count -1) { View temp = parentChildren[currentIndex + 1]; parentChildren[currentIndex + 1] = this; parentChildren[currentIndex] = temp; + + NDalicPINVOKE.Raise(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } - NDalicPINVOKE.Raise(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal void Lower() { - var parentChildren = Parent?.Children; + var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); // If the view is not already the first item in the list. - if (currentIndex > 0) + if (currentIndex > 0 && currentIndex < parentChildren.Count) { View temp = parentChildren[currentIndex - 1]; parentChildren[currentIndex - 1] = this; parentChildren[currentIndex] = temp; + + NDalicPINVOKE.Lower(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } - - NDalicPINVOKE.Lower(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// @@ -2395,17 +2439,18 @@ namespace Tizen.NUI.BaseComponents /// 3 public void RaiseToTop() { - var parentChildren = Parent?.Children; + var parentChildren = GetParent()?.Children; if (parentChildren != null) { parentChildren.Remove(this); parentChildren.Add(this); + + NDalicPINVOKE.RaiseToTop(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - NDalicPINVOKE.RaiseToTop(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// @@ -2418,17 +2463,17 @@ namespace Tizen.NUI.BaseComponents /// 3 public void LowerToBottom() { - var parentChildren = Parent?.Children; + var parentChildren = GetParent()?.Children; if (parentChildren != null) { parentChildren.Remove(this); parentChildren.Insert(0, this); - } - NDalicPINVOKE.LowerToBottom(swigCPtr); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + NDalicPINVOKE.LowerToBottom(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } } /// @@ -2455,24 +2500,31 @@ namespace Tizen.NUI.BaseComponents /// Will be raised above this view. internal void RaiseAbove(View target) { - var parentChildren = Parent?.Children; + var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); int targetIndex = parentChildren.IndexOf(target); + if(currentIndex < 0 || targetIndex < 0 || + currentIndex >= parentChildren.Count || targetIndex >= parentChildren.Count) + { + NUILog.Error("index should be bigger than 0 and less than children of layer count"); + return; + } // If the currentIndex is less than the target index and the target has the same parent. if (currentIndex < targetIndex) { parentChildren.Remove(this); parentChildren.Insert(targetIndex, this); + + NDalicPINVOKE.RaiseAbove(swigCPtr, View.getCPtr(target)); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } - NDalicPINVOKE.RaiseAbove(swigCPtr, View.getCPtr(target)); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// @@ -2485,12 +2537,18 @@ namespace Tizen.NUI.BaseComponents /// Will be lowered below this view. internal void LowerBelow(View target) { - var parentChildren = Parent?.Children; + var parentChildren = GetParent()?.Children; if (parentChildren != null) { int currentIndex = parentChildren.IndexOf(this); int targetIndex = parentChildren.IndexOf(target); + if(currentIndex < 0 || targetIndex < 0 || + currentIndex >= parentChildren.Count ||targetIndex >= parentChildren.Count) + { + NUILog.Error("index should be bigger than 0 and less than children of layer count"); + return; + } // If the currentIndex is not already the 0th index and the target has the same parent. if ((currentIndex != 0) && (targetIndex != -1) && @@ -2498,12 +2556,13 @@ namespace Tizen.NUI.BaseComponents { parentChildren.Remove(this); parentChildren.Insert(targetIndex, this); + + NDalicPINVOKE.LowerBelow(swigCPtr, View.getCPtr(target)); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } } - NDalicPINVOKE.LowerBelow(swigCPtr, View.getCPtr(target)); - if (NDalicPINVOKE.SWIGPendingException.Pending) - throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal string GetName() @@ -2554,8 +2613,12 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Layer GetLayer() { + //to fix memory leak issue, match the handle count with native side. IntPtr cPtr = NDalicPINVOKE.Actor_GetLayer(swigCPtr); - Layer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Layer; + HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + Layer ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Layer; + NDalicPINVOKE.delete_BaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -2582,9 +2645,12 @@ namespace Tizen.NUI.BaseComponents /// 3 public View FindChildByName(string viewName) { + //to fix memory leak issue, match the handle count with native side. IntPtr cPtr = NDalicPINVOKE.Actor_FindChildByName(swigCPtr, viewName); - - View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View; + HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View; + NDalicPINVOKE.delete_BaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -2593,9 +2659,12 @@ namespace Tizen.NUI.BaseComponents internal View FindChildById(uint id) { + //to fix memory leak issue, match the handle count with native side. IntPtr cPtr = NDalicPINVOKE.Actor_FindChildById(swigCPtr, id); - - View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View; + HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + View ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as View; + NDalicPINVOKE.delete_BaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -3189,8 +3258,12 @@ namespace Tizen.NUI.BaseComponents /// 3 public Renderer GetRendererAt(uint index) { + //to fix memory leak issue, match the handle count with native side. IntPtr cPtr = NDalicPINVOKE.Actor_GetRendererAt(swigCPtr, index); - Renderer ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Renderer; + HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + Renderer ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Renderer; + NDalicPINVOKE.delete_BaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -3261,14 +3334,16 @@ namespace Tizen.NUI.BaseComponents return ret; } - internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view) { + internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view) + { ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(NDalicPINVOKE.VisibilityChangedSignal(View.getCPtr(view)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } - internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view) { + internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view) + { ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(NDalicManualPINVOKE.LayoutDirectionChangedSignal(View.getCPtr(view)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -3863,13 +3938,13 @@ namespace Tizen.NUI.BaseComponents switch (temp) { case "NORMAL": - return DrawModeType.Normal; + return DrawModeType.Normal; case "OVERLAY_2D": - return DrawModeType.Overlay2D; + return DrawModeType.Overlay2D; case "STENCIL": - return DrawModeType.Stencil; + return DrawModeType.Stencil; default: - return DrawModeType.Normal; + return DrawModeType.Normal; } } set @@ -4075,12 +4150,12 @@ namespace Tizen.NUI.BaseComponents /// /// Gets or sets the padding for use in layout. /// - /// 3 - public Vector4 Padding + /// 4 + public Extents Padding { get { - Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); + Extents temp = new Extents(0, 0, 0, 0); GetProperty(View.Property.PADDING).Get(temp); return temp; } @@ -4162,13 +4237,13 @@ namespace Tizen.NUI.BaseComponents switch (temp) { case "DISABLED": - return ClippingModeType.Disabled; + return ClippingModeType.Disabled; case "CLIP_CHILDREN": - return ClippingModeType.ClipChildren; + return ClippingModeType.ClipChildren; case "CLIP_TO_BOUNDING_BOX": - return ClippingModeType.ClipToBoundingBox; + return ClippingModeType.ClipToBoundingBox; default: - return ClippingModeType.Disabled; + return ClippingModeType.Disabled; } } set @@ -4189,114 +4264,17 @@ namespace Tizen.NUI.BaseComponents } } - - - /// - /// [Obsolete("Please do not use! this will be deprecated")] - /// - /// 3 - /// Please do not use! this will be deprecated! - /// Instead please use TouchEvent. - [Obsolete("Please do not use! this will be deprecated, instead please use TouchEvent.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandlerWithReturnType Touched - { - add - { - if (_touchDataEventHandler == null) - { - _touchDataCallback = OnTouch; - this.TouchSignal().Connect(_touchDataCallback); - } - - _touchDataEventHandler += value; - } - - remove - { - _touchDataEventHandler -= value; - - if (_touchDataEventHandler == null && TouchSignal().Empty() == false) - { - this.TouchSignal().Disconnect(_touchDataCallback); - } - - } - } - - /// - /// [Obsolete("Please do not use! this will be deprecated")] - /// - /// 3 - /// Please do not use! this will be deprecated! - /// Instead please use HoverEvent. - [Obsolete("Please do not use! this will be deprecated, instead please use HoverEvent.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandlerWithReturnType Hovered - { - add - { - if (_hoverEventHandler == null) - { - _hoverEventCallback = OnHoverEvent; - this.HoveredSignal().Connect(_hoverEventCallback); - } - - _hoverEventHandler += value; - } - - remove - { - _hoverEventHandler -= value; - - if (_hoverEventHandler == null && HoveredSignal().Empty() == false) - { - this.HoveredSignal().Disconnect(_hoverEventCallback); - } - - } - } - - /// - /// Please do not use! this will be deprecated. - /// - /// 3 - /// Please do not use! this will be deprecated! - /// Instead please use WheelEvent. - [Obsolete("Please do not use! this will be deprecated, instead please use WheelEvent.")] - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandlerWithReturnType WheelMoved - { - add - { - if (_wheelEventHandler == null) - { - _wheelEventCallback = OnWheelEvent; - this.WheelEventSignal().Connect(_wheelEventCallback); - } - - _wheelEventHandler += value; - } - - remove - { - _wheelEventHandler -= value; - - if (_wheelEventHandler == null && WheelEventSignal().Empty() == false) - { - this.WheelEventSignal().Disconnect(_wheelEventCallback); - } - - } - } - /// /// [Obsolete("Please do not use! this will be deprecated")] /// /// 3 /// Please do not use! this will be deprecated! /// Instead please use PivotPoint. - [Obsolete("Please do not use! this will be deprecated, instead please use PivotPoint")] + [Obsolete("Please do not use! This will be deprecated! Please use PivotPoint instead! " + + "Like: " + + "View view = new View(); " + + "view.PivotPoint = PivotPoint.Center; " + + "view.PositionUsesPivotPoint = true;")] [EditorBrowsable(EditorBrowsableState.Never)] public Position AnchorPoint { @@ -4316,7 +4294,10 @@ namespace Tizen.NUI.BaseComponents /// [Obsolete("Please do not use! this will be deprecated")] /// /// 3 - [Obsolete("Please do not use! this will be deprecated, please use Size2D instead")] + [Obsolete("Please do not use! This will be deprecated! Please use Size2D instead! " + + "Like: " + + "View view = new View(); " + + "view.Size2D = new Size2D(100, 100);")] [EditorBrowsable(EditorBrowsableState.Never)] public Size Size { @@ -4333,117 +4314,25 @@ namespace Tizen.NUI.BaseComponents } /// - /// [Obsolete("Please do not use! this will be deprecated")] - /// - /// 3 - /// Please do not use! this will be deprecated! - /// Instead please use AddedToWindow. - [Obsolete("Please do not use! this will be deprecated, instead please use AddedToWindow")] - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler OnWindowEvent - { - add - { - if (_onWindowEventHandler == null) - { - _onWindowEventCallback = OnWindow; - this.OnWindowSignal().Connect(_onWindowEventCallback); - } - - _onWindowEventHandler += value; - } - - remove - { - _onWindowEventHandler -= value; - - if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false) - { - this.OnWindowSignal().Disconnect(_onWindowEventCallback); - } - } - } - - /// - /// [Obsolete("Please do not use! this will be deprecated")] - /// - /// 3 - /// Please do not use! this will be deprecated! - /// Instead please use RemovedFromWindow. - [Obsolete("Please do not use! this will be deprecated, instead please use RemovedFromWindow")] - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler OffWindowEvent - { - add - { - if (_offWindowEventHandler == null) - { - _offWindowEventCallback = OffWindow; - this.OffWindowSignal().Connect(_offWindowEventCallback); - } - - _offWindowEventHandler += value; - } - - remove - { - _offWindowEventHandler -= value; - - if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false) - { - this.OffWindowSignal().Disconnect(_offWindowEventCallback); - } - } - } - - /// - /// [Obsolete("Please do not use! this will be deprecated")] - /// - /// 3 - /// Please do not use! this will be deprecated! - /// Instead please use Relayout. - [Obsolete("Please do not use! this will be deprecated, instead please use Relayout")] - [EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler OnRelayoutEvent - { - add - { - if (_onRelayoutEventHandler == null) - { - _onRelayoutEventCallback = OnRelayout; - this.OnRelayoutSignal().Connect(_onRelayoutEventCallback); - } - - _onRelayoutEventHandler += value; - } - - remove - { - _onRelayoutEventHandler -= value; - - if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false) - { - this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback); - } - - } - } - - /// /// "Please DO NOT use! This will be deprecated! Please use 'Container GetParent() for derived class' instead!" /// /// 3 - //"Please DO NOT use! This will be deprecated! Please use 'Container GetParent() for derived class' instead!" - /// 3 - [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + [Obsolete("Please do not use! This will be deprecated! Please use 'Container GetParent() for derived class' instead! " + + "Like: " + + "Container parent = view.GetParent(); " + + "View view = parent as View;")] + [EditorBrowsable(EditorBrowsableState.Never)] public new View Parent { get { View ret; IntPtr cPtr = NDalicPINVOKE.Actor_GetParent(swigCPtr); - BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(cPtr); + //HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); + //BaseHandle basehandle = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle); + //NDalicPINVOKE.delete_BaseHandle(CPtr); + //CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (basehandle is Layer) { @@ -4518,22 +4407,43 @@ namespace Tizen.NUI.BaseComponents } /// - /// Gets or sets the Padding for use in layout. + /// [Obsolete("Please do not use! this will be deprecated")] /// + /// Please do not use! this will be deprecated! + /// Instead please use Padding. /// 4 + [Obsolete("Please do not use! this will be deprecated, instead please use Padding.")] + [EditorBrowsable(EditorBrowsableState.Never)] public Extents PaddingEX { get { Extents temp = new Extents(0, 0, 0, 0); - GetProperty(View.Property.PADDINGEX).Get(temp); + GetProperty(View.Property.PADDING).Get(temp); return temp; } set { - SetProperty(View.Property.PADDINGEX, new Tizen.NUI.PropertyValue(value)); + SetProperty(View.Property.PADDING, new Tizen.NUI.PropertyValue(value)); } } + + /// + /// Perform an action on a visual registered to this view.
+ /// Visuals will have actions, this API is used to perform one of these actions with the given attributes. + ///
+ /// The Property index of the visual. + /// The action to perform. See Visual to find supported actions. + /// Optional attributes for the action. + /// 5 + /// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void DoAction(int propertyIndexOfVisual, int propertyIndexOfActionId, PropertyValue attributes) + { + NDalicManualPINVOKE.View_DoAction(swigCPtr, propertyIndexOfVisual, propertyIndexOfActionId, PropertyValue.getCPtr(attributes)); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } ///