From 1b8c0c140ca248eb4356b4109d99bf727bb6bde2 Mon Sep 17 00:00:00 2001 From: Seoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com> Date: Mon, 17 Sep 2018 13:26:52 +0900 Subject: [PATCH] [NUI] Add LinearLayout Alignment and Weight (#469) * [NUI] Add LinearLayout Alignment and Weight Change-Id: I0ed3010fd27f8f4cb26126efc5547a301c69cf38 Signed-off-by: Seoyeon Kim * Update LinearLayout.cs According to Codacy-bot review, changed to 'static' class. --- .../src/internal/Layouting/LayoutPINVOKE.cs | 90 +++++++++++++++++++ .../src/internal/Layouting/LinearLayout.cs | 65 +++++++++++++- .../src/public/BaseComponents/View.cs | 30 +++++++ 3 files changed, 184 insertions(+), 1 deletion(-) diff --git a/src/Tizen.NUI/src/internal/Layouting/LayoutPINVOKE.cs b/src/Tizen.NUI/src/internal/Layouting/LayoutPINVOKE.cs index aa135f3f7..3e21246d7 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LayoutPINVOKE.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LayoutPINVOKE.cs @@ -4538,6 +4538,96 @@ namespace Tizen.NUI } } + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_LinearLayout_SetAlignment")] + public static extern void LinearLayout_SetAlignment_gl(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + [global::System.Runtime.InteropServices.DllImport(Graphics.VulkanCSharpBinder, EntryPoint = "CSharp_Dali_LinearLayout_SetAlignment")] + public static extern void LinearLayout_SetAlignment_vulkan(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2); + + public static void LinearLayout_SetAlignment(global::System.Runtime.InteropServices.HandleRef jarg1, uint jarg2) + { + if (Tizen.NUI.Graphics.Backend == Tizen.NUI.Graphics.BackendType.Vulkan) + { + LinearLayout_SetAlignment_vulkan(jarg1, jarg2); + } + else + { + LinearLayout_SetAlignment_gl(jarg1, jarg2); + } + } + + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_LinearLayout_GetAlignment")] + public static extern uint LinearLayout_GetAlignment_gl(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(Graphics.VulkanCSharpBinder, EntryPoint = "CSharp_Dali_LinearLayout_GetAlignment")] + public static extern uint LinearLayout_GetAlignment_vulkan(global::System.Runtime.InteropServices.HandleRef jarg1); + + public static uint LinearLayout_GetAlignment(global::System.Runtime.InteropServices.HandleRef jarg1) + { + if (Tizen.NUI.Graphics.Backend == Tizen.NUI.Graphics.BackendType.Vulkan) + { + return LinearLayout_GetAlignment_vulkan(jarg1); + } + else + { + return LinearLayout_GetAlignment_gl(jarg1); + } + } + + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_LinearLayout_ChildProperty_WEIGHT_get")] + public static extern int LinearLayout_ChildProperty_WEIGHT_get_gl(); + + [global::System.Runtime.InteropServices.DllImport(Graphics.VulkanCSharpBinder, EntryPoint = "CSharp_Dali_LinearLayout_ChildProperty_WEIGHT_get")] + public static extern int LinearLayout_ChildProperty_WEIGHT_get_vulkan(); + + public static int LinearLayout_ChildProperty_WEIGHT_get() + { + if (Tizen.NUI.Graphics.Backend == Tizen.NUI.Graphics.BackendType.Vulkan) + { + return LinearLayout_ChildProperty_WEIGHT_get_vulkan(); + } + else + { + return LinearLayout_ChildProperty_WEIGHT_get_gl(); + } + } + + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_new_LinearLayout_ChildProperty")] + public static extern global::System.IntPtr new_LinearLayout_ChildProperty_gl(); + + [global::System.Runtime.InteropServices.DllImport(Graphics.VulkanCSharpBinder, EntryPoint = "CSharp_Dali_new_LinearLayout_ChildProperty")] + public static extern global::System.IntPtr new_LinearLayout_ChildProperty_vulkan(); + + public static global::System.IntPtr new_LinearLayout_ChildProperty() + { + if (Tizen.NUI.Graphics.Backend == Tizen.NUI.Graphics.BackendType.Vulkan) + { + return new_LinearLayout_ChildProperty_vulkan(); + } + else + { + return new_LinearLayout_ChildProperty_gl(); + } + } + + [global::System.Runtime.InteropServices.DllImport(Graphics.GlesCSharpBinder, EntryPoint = "CSharp_Dali_delete_LinearLayout_ChildProperty")] + public static extern void delete_LinearLayout_ChildProperty_gl(global::System.Runtime.InteropServices.HandleRef jarg1); + + [global::System.Runtime.InteropServices.DllImport(Graphics.VulkanCSharpBinder, EntryPoint = "CSharp_Dali_delete_LinearLayout_ChildProperty")] + public static extern void delete_LinearLayout_ChildProperty_vulkan(global::System.Runtime.InteropServices.HandleRef jarg1); + + public static void delete_LinearLayout_ChildProperty(global::System.Runtime.InteropServices.HandleRef jarg1) + { + if (Tizen.NUI.Graphics.Backend == Tizen.NUI.Graphics.BackendType.Vulkan) + { + delete_LinearLayout_ChildProperty_vulkan(jarg1); + } + else + { + delete_LinearLayout_ChildProperty_gl(jarg1); + } + } + // Grid Layout // GridLayout_SWIGUpcast diff --git a/src/Tizen.NUI/src/internal/Layouting/LinearLayout.cs b/src/Tizen.NUI/src/internal/Layouting/LinearLayout.cs index 603bf141d..3930f1a93 100755 --- a/src/Tizen.NUI/src/internal/Layouting/LinearLayout.cs +++ b/src/Tizen.NUI/src/internal/Layouting/LinearLayout.cs @@ -64,6 +64,10 @@ namespace Tizen.NUI base.Dispose(type); } + internal static class ChildProperty + { + internal static readonly int WEIGHT = LayoutPINVOKE.LinearLayout_ChildProperty_WEIGHT_get(); + } public LinearLayout() : this(LayoutPINVOKE.LinearLayout_New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); @@ -115,6 +119,19 @@ namespace Tizen.NUI return ret; } + internal void SetAlignment(LinearLayout.Alignment alignment) + { + LayoutPINVOKE.LinearLayout_SetAlignment(swigCPtr, (uint)alignment); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + + internal LinearLayout.Alignment GetAlignment() + { + LinearLayout.Alignment ret = (LinearLayout.Alignment)LayoutPINVOKE.LinearLayout_GetAlignment(swigCPtr); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + internal enum PropertyRange { CHILD_PROPERTY_START_INDEX = PropertyRanges.CHILD_PROPERTY_REGISTRATION_START_INDEX, @@ -152,7 +169,22 @@ namespace Tizen.NUI } /// - /// [Draft] Enumeration for the direction in which the content is laid out */ + /// [Draft] Get/Set the alignment in the layout + /// + public LinearLayout.Alignment LinearAlignment + { + get + { + return GetAlignment(); + } + set + { + SetAlignment(value); + } + } + + /// + /// [Draft] Enumeration for the direction in which the content is laid out /// public enum Orientation { @@ -166,6 +198,37 @@ namespace Tizen.NUI Vertical } + /// + /// [Draft] Enumeration for the alignment of the linear layout items + /// + public enum Alignment + { + /// + /// At the left/right edge of the container (maps to LTR/RTL direction for horizontal orientation) + /// + Begin = 0x1, + /// + /// At the right/left edge of the container (maps to LTR/RTL direction for horizontal orientation) + /// + End = 0x2, + /// + /// At the horizontal center of the container + /// + CenterHorizontal = 0x4, + /// + /// At the top edge of the container + /// + Top = 0x8, + /// + /// At the bottom edge of the container + /// + Bottom = 0x10, + /// + /// At the vertical center of the container + /// + CenterVertical = 0x20 + } + } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index fb3c3fc5e..04f4b51a4 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -394,6 +394,23 @@ namespace Tizen.NUI.BaseComponents }); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty WeightProperty = BindableProperty.Create("Weight", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty(view.swigCPtr, LinearLayout.ChildProperty.WEIGHT, new Tizen.NUI.PropertyValue((float)newValue)); + } + }, + defaultValueCreator:(bindable) => + { + var view = (View)bindable; + float temp = 0.0f; + Tizen.NUI.Object.GetProperty(view.swigCPtr, LinearLayout.ChildProperty.WEIGHT).Get(out temp); + return temp; + }); + /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty LeftFocusableViewProperty = BindableProperty.Create("LeftFocusableView", typeof(View), typeof(View), default(View), propertyChanged: (bindable, oldValue, newValue) => { var view = (View)bindable; @@ -5515,6 +5532,19 @@ namespace Tizen.NUI.BaseComponents } } + internal float Weight + { + get + { + return (float)GetValue(WeightProperty); + } + set + { + SetValue(WeightProperty, value); + NotifyPropertyChanged(); + } + } + } /// -- 2.34.1