From 17350c245c0f5fd80631ff86bd3e95ddda73ad3e Mon Sep 17 00:00:00 2001 From: huiyueun <35286162+huiyueun@users.noreply.github.com> Date: Tue, 13 Nov 2018 16:53:25 +0900 Subject: [PATCH] [NUI] Sync dalihub/TizenFX and Samsung/TizenFX[NUI (#548) * [NUI] Set LayoutItem Width/Height specification Change-Id: Idec264329f6dc20db4692fba84ac8ee1f95067aa Signed-off-by: huiyu.eun * [NUI] Fix build error Change-Id: Ib1ff4dcb142ce09539dbef3b567f649e40459527 Signed-off-by: huiyu.eun * LayoutGroup to layout children Change-Id: Idff81189013e4cb0e85a8bbf13e268170b8aad31 * [NUI] Public some apis for TCT and fix an issue Here are some changes: 1. public ScrollViewPagePathEffect class 2. public TypeRegistry class 3. public PinchGesture constructor 4. public SetScrollPropertySource api 5. Fix ScrollInterval event issue Change-Id: I649f0fc464a5af0453475b7ef0dcf4df614eb34e --- .../src/internal/Layouting/LayoutGroup.cs | 27 ++++++++++++ src/Tizen.NUI/src/internal/Layouting/LayoutItem.cs | 1 + src/Tizen.NUI/src/public/BaseComponents/View.cs | 16 +++++--- src/Tizen.NUI/src/public/Layer.cs | 2 +- src/Tizen.NUI/src/public/PinchGesture.cs | 5 ++- .../ScrollViewPagePathEffect.cs | 38 +++++++++++++++-- .../src/{internal => public}/TypeRegistry.cs | 48 ++++++++++++++++++++-- src/Tizen.NUI/src/public/UIComponents/ScrollBar.cs | 22 ++++++++-- 8 files changed, 139 insertions(+), 20 deletions(-) rename src/Tizen.NUI/src/{internal => public}/ScrollViewPagePathEffect.cs (61%) rename src/Tizen.NUI/src/{internal => public}/TypeRegistry.cs (65%) diff --git a/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs b/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs index bfe9cfe..8c47ac7 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LayoutGroup.cs @@ -84,6 +84,7 @@ namespace Tizen.NUI /// vertical space requirements as imposed by the parent. protected override void OnMeasure(LayoutMeasureSpec widthMeasureSpec, LayoutMeasureSpec heightMeasureSpec) { + Log.Info("NUI", "OnMeasure\n"); LayoutLength childWidth = new LayoutLength( 0 ); LayoutLength childHeight = new LayoutLength( 0 ); @@ -127,7 +128,33 @@ namespace Tizen.NUI /// Bottom position, relative to parent. protected virtual void OnLayout(bool changed, LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom) { + Log.Info("NUI", "OnLayout\n"); + for( uint i = 0; i < ChildCount; ++i ) + { + var childLayout = GetChildAt( i ); + if( childLayout ) + { + View childOwner = childLayout.GetOwner(); + + // Use position if explicitly set to child otherwise will be top left. + var childLeft = new LayoutLength( childOwner.Position2D.X ); + var childTop = new LayoutLength( childOwner.Position2D.Y ); + + View owner = GetOwner(); + + if ( owner ) + { + // Margin and Padding only supported when child anchor point is TOP_LEFT. + if ( owner.PivotPoint == PivotPoint.TopLeft || ( owner.PositionUsesPivotPoint == false ) ) + { + childLeft = childLeft + owner.Padding.Start + childOwner.Margin.Start; + childTop = childTop + owner.Padding.Top + childOwner.Margin.Top; + } + } + childLayout.Layout( childLeft, childTop, childLeft + childLayout.MeasuredWidth, childTop + childLayout.MeasuredHeight ); + } + } } /// diff --git a/src/Tizen.NUI/src/internal/Layouting/LayoutItem.cs b/src/Tizen.NUI/src/internal/Layouting/LayoutItem.cs index b8b1fbd..730781d 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LayoutItem.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LayoutItem.cs @@ -86,6 +86,7 @@ namespace Tizen.NUI /// Bottom position, relative to parent. public void Layout(LayoutLength left, LayoutLength top, LayoutLength right, LayoutLength bottom) { + Log.Info("NUI", "LayoutItem Layout\n"); layoutItemWrapperImpl.Layout(left, top, right, bottom); } diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 48b439f..69f25c6 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -1282,14 +1282,14 @@ namespace Tizen.NUI.BaseComponents /// 4 public override void Add(View child) { - Log.Info("NUI", "Add child:" + child.Name + " to " + Name + "\n"); - if (null == child) { Tizen.Log.Fatal("NUI", "Child is null"); return; } + Log.Info("NUI", "Adding Child:" + child.Name + " to " + Name + "\n"); + Container oldParent = child.GetParent(); if (oldParent != this) { @@ -1304,19 +1304,19 @@ namespace Tizen.NUI.BaseComponents // layoutSet flag is true when the View became a layout using the SetLayout API if (true == layoutSet && null == child.Layout) { - Log.Info("NUI", "Add child Parent[" + Name + "] Layout set\n"); + Log.Info("NUI", "Parent[" + Name + "] Layout set[" + layoutSet.ToString() + "] Pure View[" + (!layoutSet).ToString() + "]\n"); // If child is a View or explicitly set to require layouting then set child as a LayoutGroup. // If the child is derived from a View then it may be a legacy or existing container hence will do layouting itself. if( child.GetType() == typeof(View) || true == child.LayoutingRequired ) { - Log.Info("NUI", "Add child Creating LayoutGroup\n"); + Log.Info("NUI", "Creating LayoutGroup for " + child.Name + " LayoutingRequired[" + child.LayoutingRequired.ToString() + "]\n"); child.Layout = new LayoutGroup(); } else { - // Adding child as a leaf, layouting will not propogate past this child. + // Adding child as a leaf, layouting will not propagate past this child. // Legacy containers will be a LayoutItems too and layout their children how they wish. - Log.Info("NUI", "Add child Creating LayoutItem for " + child.Name + "\n"); + Log.Info("NUI", "Creating LayoutItem for " + child.Name + "\n"); child.Layout = new LayoutItem(); } } @@ -5315,6 +5315,10 @@ namespace Tizen.NUI.BaseComponents set { SetValue(SizeProperty, value); + // Set Specification so when layouts measure this View it matches the value set here. + // All Views are currently Layouts. + SetProperty(LayoutItemWrapper.ChildProperty.WIDTH_SPECIFICATION, new Tizen.NUI.PropertyValue(value.Width)); + SetProperty(LayoutItemWrapper.ChildProperty.HEIGHT_SPECIFICATION, new Tizen.NUI.PropertyValue(value.Height)); NotifyPropertyChanged(); } } diff --git a/src/Tizen.NUI/src/public/Layer.cs b/src/Tizen.NUI/src/public/Layer.cs index 24e94eb..62c0152 100755 --- a/src/Tizen.NUI/src/public/Layer.cs +++ b/src/Tizen.NUI/src/public/Layer.cs @@ -74,7 +74,7 @@ namespace Tizen.NUI // If adding a View then set layout required flag if( child.GetType() == typeof(View) ) { - Log.Info("NUI", "Add child LayoutingRequired for:" + child.Name + "\n"); + Log.Info("NUI", "Add child[" + child.Name + "] LayoutingRequired set as pure view\n"); child.LayoutingRequired = true; } diff --git a/src/Tizen.NUI/src/public/PinchGesture.cs b/src/Tizen.NUI/src/public/PinchGesture.cs index 7ca17f7..f1b122a 100755 --- a/src/Tizen.NUI/src/public/PinchGesture.cs +++ b/src/Tizen.NUI/src/public/PinchGesture.cs @@ -14,6 +14,7 @@ * limitations under the License. * */ +using System.ComponentModel; namespace Tizen.NUI { @@ -136,7 +137,9 @@ namespace Tizen.NUI /// The default constructor. /// /// The state of the gesture. - internal PinchGesture(Gesture.StateType state) : this(NDalicPINVOKE.new_PinchGesture__SWIG_0((int)state), true) + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public PinchGesture(Gesture.StateType state) : this(NDalicPINVOKE.new_PinchGesture__SWIG_0((int)state), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } diff --git a/src/Tizen.NUI/src/internal/ScrollViewPagePathEffect.cs b/src/Tizen.NUI/src/public/ScrollViewPagePathEffect.cs similarity index 61% rename from src/Tizen.NUI/src/internal/ScrollViewPagePathEffect.cs rename to src/Tizen.NUI/src/public/ScrollViewPagePathEffect.cs index 044eb8f..fdf9abf 100755 --- a/src/Tizen.NUI/src/internal/ScrollViewPagePathEffect.cs +++ b/src/Tizen.NUI/src/public/ScrollViewPagePathEffect.cs @@ -14,11 +14,20 @@ * limitations under the License. * */ +using System.ComponentModel; +using Tizen.NUI.BaseComponents; namespace Tizen.NUI { - using Tizen.NUI.BaseComponents; - internal class ScrollViewPagePathEffect : ScrollViewEffect + /// + /// ScrollView Page Path Effect. + /// This effect causes Views to follow a given path. The opacity of the view will be 0.0 at + /// the beginning of the path and will go to 1.0 as it is approximating to half of the path to return + /// to 0.0 at the end of the path. + /// + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class ScrollViewPagePathEffect : ScrollViewEffect { private global::System.Runtime.InteropServices.HandleRef swigCPtr; @@ -32,6 +41,9 @@ namespace Tizen.NUI return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } + /// + /// Dispose. + /// protected override void Dispose(DisposeTypes type) { if (disposed) @@ -64,18 +76,36 @@ namespace Tizen.NUI base.Dispose(type); } + /// + /// Creates an initialized ScrollViewPagePathEffect. + /// + /// The path that will be used by the scroll effect. + /// Vector in page object space which will be aligned with the tangent of the path. + /// Index of a property of the scroll-view which will be used as the input for the path. + /// Size of a page in the scrollview. + /// Total number of pages in the scrollview. + /// A handle to a newly allocated Dali resource. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public ScrollViewPagePathEffect(Path path, Vector3 forward, int inputPropertyIndex, Vector3 pageSize, uint pageCount) : this(NDalicPINVOKE.ScrollViewPagePathEffect_New(Path.getCPtr(path), Vector3.getCPtr(forward), inputPropertyIndex, Vector3.getCPtr(pageSize), pageCount), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - } - public static ScrollViewPagePathEffect DownCast(BaseHandle handle) + + internal static ScrollViewPagePathEffect DownCast(BaseHandle handle) { ScrollViewPagePathEffect ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as ScrollViewPagePathEffect; if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } + /// + /// Manually apply effect to a page in the scroll-view. + /// + /// The page to be affected by this effect. + /// The order of the page in the scroll view. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public void ApplyToPage(View page, uint pageOrder) { NDalicPINVOKE.ScrollViewPagePathEffect_ApplyToPage(swigCPtr, View.getCPtr(page), pageOrder); diff --git a/src/Tizen.NUI/src/internal/TypeRegistry.cs b/src/Tizen.NUI/src/public/TypeRegistry.cs similarity index 65% rename from src/Tizen.NUI/src/internal/TypeRegistry.cs rename to src/Tizen.NUI/src/public/TypeRegistry.cs index 078e355..64f9f9a 100755 --- a/src/Tizen.NUI/src/internal/TypeRegistry.cs +++ b/src/Tizen.NUI/src/public/TypeRegistry.cs @@ -14,11 +14,17 @@ * limitations under the License. * */ +using System.ComponentModel; namespace Tizen.NUI { - - internal class TypeRegistry : BaseHandle + /// + /// The TypeRegistry allows registration of type instance creation functions. + /// These can then be created later by name and down cast to the appropriate type. + /// + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public class TypeRegistry : BaseHandle { private global::System.Runtime.InteropServices.HandleRef swigCPtr; @@ -32,6 +38,9 @@ namespace Tizen.NUI return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } + /// + /// Dispose. + /// protected override void Dispose(DisposeTypes type) { if (disposed) @@ -64,6 +73,12 @@ namespace Tizen.NUI base.Dispose(type); } + /// + /// Gets Type Registry handle. + /// + /// TypeRegistry handle. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public static TypeRegistry Get() { TypeRegistry ret = new TypeRegistry(NDalicPINVOKE.TypeRegistry_Get(), true); @@ -71,23 +86,35 @@ namespace Tizen.NUI return ret; } + /// + /// Allows the creation of an empty typeRegistry handle. + /// + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public TypeRegistry() : this(NDalicPINVOKE.new_TypeRegistry__SWIG_0(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - public TypeRegistry(TypeRegistry handle) : this(NDalicPINVOKE.new_TypeRegistry__SWIG_1(TypeRegistry.getCPtr(handle)), true) + internal TypeRegistry(TypeRegistry handle) : this(NDalicPINVOKE.new_TypeRegistry__SWIG_1(TypeRegistry.getCPtr(handle)), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - public TypeRegistry Assign(TypeRegistry rhs) + internal TypeRegistry Assign(TypeRegistry rhs) { TypeRegistry ret = new TypeRegistry(NDalicPINVOKE.TypeRegistry_Assign(swigCPtr, TypeRegistry.getCPtr(rhs)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } + /// + /// Gets TypeInfo for a registered type. + /// + /// A unique type name. + /// TypeInfo if the type exists, otherwise an empty handle. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public Tizen.NUI.TypeInfo GetTypeInfo(string uniqueTypeName) { Tizen.NUI.TypeInfo ret = new Tizen.NUI.TypeInfo(NDalicPINVOKE.TypeRegistry_GetTypeInfo__SWIG_0(swigCPtr, uniqueTypeName), true); @@ -102,6 +129,12 @@ namespace Tizen.NUI return ret; } + /// + /// Gets type name count. + /// + /// The counte. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public uint GetTypeNameCount() { uint ret = NDalicPINVOKE.TypeRegistry_GetTypeNameCount(swigCPtr); @@ -109,6 +142,13 @@ namespace Tizen.NUI return ret; } + /// + /// Gets type names by index. + /// + /// The index to get the type name. + /// The type name or an empty string when index is not valid. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public string GetTypeName(uint index) { string ret = NDalicPINVOKE.TypeRegistry_GetTypeName(swigCPtr, index); diff --git a/src/Tizen.NUI/src/public/UIComponents/ScrollBar.cs b/src/Tizen.NUI/src/public/UIComponents/ScrollBar.cs index 9db3bd2..3a15ed3 100755 --- a/src/Tizen.NUI/src/public/UIComponents/ScrollBar.cs +++ b/src/Tizen.NUI/src/public/UIComponents/ScrollBar.cs @@ -313,13 +313,14 @@ namespace Tizen.NUI.UIComponents private PanFinishedEventCallbackDelegate _scrollBarPanFinishedEventCallbackDelegate; [UnmanagedFunctionPointer(CallingConvention.StdCall)] - private delegate void ScrollPositionIntervalReachedEventCallbackDelegate(); + private delegate void ScrollPositionIntervalReachedEventCallbackDelegate(float position); private EventHandler _scrollBarScrollPositionIntervalReachedEventHandler; private ScrollPositionIntervalReachedEventCallbackDelegate _scrollBarScrollPositionIntervalReachedEventCallbackDelegate; /// /// The event emitted when panning is finished on the scroll indicator. /// + /// Event only emitted when the source of the scroll position properties are set. /// 3 public event EventHandler PanFinished { @@ -356,8 +357,9 @@ namespace Tizen.NUI.UIComponents /// - /// This is the event emitted when the current scroll position of the scrollable content. + /// This is the event emitted when the current scroll position of the scrollable content goes above or below the values specified by ScrollPositionIntervals property. /// + /// Event only emitted when the source of the scroll position properties are set. /// 3 public event EventHandler ScrollInterval { @@ -381,9 +383,10 @@ namespace Tizen.NUI.UIComponents } // Callback for ScrollBar ScrollPositionIntervalReachedSignal - private void OnScrollBarScrollPositionIntervalReached() + private void OnScrollBarScrollPositionIntervalReached(float position) { ScrollIntervalEventArgs e = new ScrollIntervalEventArgs(); + e.CurrentScrollPosition = position; if (_scrollBarScrollPositionIntervalReachedEventHandler != null) { @@ -430,7 +433,18 @@ namespace Tizen.NUI.UIComponents if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - internal void SetScrollPropertySource(Animatable handle, int propertyScrollPosition, int propertyMinScrollPosition, int propertyMaxScrollPosition, int propertyScrollContentSize) + /// + /// Sets the source of the scroll position properties. + /// + /// The handle of the object owing the scroll properties. + /// The index of the scroll position property(The scroll position, type float). + /// The index of the minimum scroll position property(The minimum scroll position, type float). + /// The index of the maximum scroll position property(The maximum scroll position, type float). + /// The index of the scroll content size property(The size of the scrollable content in actor coordinates, type float). + /// The handle to the object owing the scroll properties has been initialised and the property index must be valid. + /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetScrollPropertySource(Animatable handle, int propertyScrollPosition, int propertyMinScrollPosition, int propertyMaxScrollPosition, int propertyScrollContentSize) { NDalicPINVOKE.ScrollBar_SetScrollPropertySource(swigCPtr, Animatable.getCPtr(handle), propertyScrollPosition, propertyMinScrollPosition, propertyMaxScrollPosition, propertyScrollContentSize); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); -- 2.7.4