From 5fd094705e1a90d9b385b8d7fad0dde69091b863 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Fri, 13 May 2022 16:46:12 +0900 Subject: [PATCH] [NUI] Add TextSelectionPopupStyle for 7.0 UX Signed-off-by: Bowon Ryu --- .../res/IoT-selection-popup-background.9.png | Bin 0 -> 395 bytes src/Tizen.NUI/res/IoT-selection-popup-border.9.png | Bin 0 -> 597 bytes .../src/internal/Interop/Interop.TextEditor.cs | 3 + .../src/internal/Interop/Interop.TextField.cs | 3 + .../src/internal/Interop/ManualPINVOKE.cs | 42 +++++++++++ .../public/BaseComponents/Style/TextEditorStyle.cs | 20 ++++++ .../public/BaseComponents/Style/TextFieldStyle.cs | 20 ++++++ .../src/public/BaseComponents/TextEditor.cs | 19 +++++ .../BaseComponents/TextEditorBindableProperty.cs | 18 +++++ .../src/public/BaseComponents/TextField.cs | 19 +++++ .../BaseComponents/TextFieldBindableProperty.cs | 19 +++++ src/Tizen.NUI/src/public/Common/NUIConstants.cs | 77 +++++++++++++++++++++ .../src/public/Theme/DefaultThemeCommon.cs | 36 ++++++++++ 13 files changed, 276 insertions(+) create mode 100644 src/Tizen.NUI/res/IoT-selection-popup-background.9.png create mode 100644 src/Tizen.NUI/res/IoT-selection-popup-border.9.png diff --git a/src/Tizen.NUI/res/IoT-selection-popup-background.9.png b/src/Tizen.NUI/res/IoT-selection-popup-background.9.png new file mode 100644 index 0000000000000000000000000000000000000000..b27254bbaa5d33e0242729a9b95a012c6541c99a GIT binary patch literal 395 zcmV;60d)R}P)n#{PMog)RA&@>hzI8`+=X)0(oYRC9F$V6tM~$PXl|VN3UZwL;uFY` zaO2h(K@eKwu3}NCV|J7Hi$jW6Z{nfEOapQ}eaJq? z!}DH2d~W1w-tI^r1cvgMM<3l+ear=Q$S^$FPy=IN*yF7pQ@|8x*1W*&l(_alKQaJq p6ZvMLwtX@*uctSyT0DZVs26?}>KneRTfYDR002ovPDHLkV1mZppppOp literal 0 HcmV?d00001 diff --git a/src/Tizen.NUI/res/IoT-selection-popup-border.9.png b/src/Tizen.NUI/res/IoT-selection-popup-border.9.png new file mode 100644 index 0000000000000000000000000000000000000000..553056e890e6f03e7a09f958a21d0c5708d33a4f GIT binary patch literal 597 zcmV-b0;>IqP)$Epz>7EO0PH|+UVLB&Sb`#z!MfBfuZwe-a;jh*w1{2=zRz8UFBDB*cz;SPuNUaYACJ zD#a5^xinElsTC_+lX035uQ1|&r>xpI04>pDF|ihKnF3$H>ws4wv-Po?Y$t~ + { + var textEditorStyle = (TextEditorStyle)bindable; + textEditorStyle.selectionPopupStyle = (PropertyMap)newValue; + }, + defaultValueCreator: (bindable) => + { + var textEditorStyle = (TextEditorStyle)bindable; + return textEditorStyle.selectionPopupStyle; + }); + private HorizontalAlignment? horizontalAlignment; private VerticalAlignment? verticalAlignment; private Vector4 secondaryCursorColor; @@ -309,6 +321,7 @@ namespace Tizen.NUI.BaseComponents private Color placeholderTextColor; private Vector4 primaryCursorColor; private PropertyMap fontStyle; + private PropertyMap selectionPopupStyle; private bool? ellipsis; private float? lineSpacing; private float? minLineSize; @@ -698,5 +711,12 @@ namespace Tizen.NUI.BaseComponents get => (float?)GetValue(RelativeLineHeightProperty); set => SetValue(RelativeLineHeightProperty, value); } + + [EditorBrowsable(EditorBrowsableState.Never)] + public PropertyMap SelectionPopupStyle + { + get => (PropertyMap)GetValue(SelectionPopupStyleProperty); + set => SetValue(SelectionPopupStyleProperty, value); + } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index 223693e..965aaab 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -497,6 +497,18 @@ namespace Tizen.NUI.BaseComponents return textFieldStyle.fontStyle; }); + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty SelectionPopupStyleProperty = BindableProperty.Create(nameof(SelectionPopupStyle), typeof(PropertyMap), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textFieldStyle = (TextFieldStyle)bindable; + textFieldStyle.selectionPopupStyle = (PropertyMap)newValue; + }, + defaultValueCreator: (bindable) => + { + var textFieldStyle = (TextFieldStyle)bindable; + return textFieldStyle.selectionPopupStyle; + }); + private string placeholderText; private string placeholderTextFocused; private int? maxLength; @@ -536,6 +548,7 @@ namespace Tizen.NUI.BaseComponents private Vector4 placeholderTextColor; private Vector4 primaryCursorColor; private PropertyMap fontStyle; + private PropertyMap selectionPopupStyle; static TextFieldStyle() { } @@ -859,5 +872,12 @@ namespace Tizen.NUI.BaseComponents get => (PropertyMap)GetValue(FontStyleProperty); set => SetValue(FontStyleProperty, value); } + + [EditorBrowsable(EditorBrowsableState.Never)] + public PropertyMap SelectionPopupStyle + { + get => (PropertyMap)GetValue(SelectionPopupStyleProperty); + set => SetValue(SelectionPopupStyleProperty, value); + } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 9de2008..ea57f6a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -531,6 +531,24 @@ namespace Tizen.NUI.BaseComponents } /// + /// The SelectionPopupStyle property.
+ /// The style of the text selection popup can be set through SelectionPopupStyle property. + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public PropertyMap SelectionPopupStyle + { + get + { + return (PropertyMap)GetValue(SelectionPopupStyleProperty); + } + set + { + SetValue(SelectionPopupStyleProperty, value); + NotifyPropertyChanged(); + } + } + + /// /// The SelectionHandleImageLeft property.
/// The image to display for the left selection handle.
/// The selectionHandleImageLeft map contains the following key :
@@ -2557,6 +2575,7 @@ namespace Tizen.NUI.BaseComponents internal static readonly int CursorWidth = Interop.TextEditor.CursorWidthGet(); internal static readonly int GrabHandleImage = Interop.TextEditor.GrabHandleImageGet(); internal static readonly int GrabHandlePressedImage = Interop.TextEditor.GrabHandlePressedImageGet(); + internal static readonly int SelectionPopupStyle = Interop.TextEditor.SelectionPopupStyleGet(); internal static readonly int SelectionHandleImageLeft = Interop.TextEditor.SelectionHandleImageLeftGet(); internal static readonly int SelectionHandleImageRight = Interop.TextEditor.SelectionHandleImageRightGet(); internal static readonly int SelectionHandlePressedImageLeft = Interop.TextEditor.SelectionHandlePressedImageLeftGet(); diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs index 6964033..482c060 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditorBindableProperty.cs @@ -324,6 +324,24 @@ namespace Tizen.NUI.BaseComponents Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textEditor.SwigCPtr, TextEditor.Property.GrabHandlePressedImage).Get(out temp); return temp; })); + + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty SelectionPopupStyleProperty = BindableProperty.Create(nameof(SelectionPopupStyle), typeof(PropertyMap), typeof(TextEditor), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => + { + var textEditor = (TextEditor)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)textEditor.SwigCPtr, TextEditor.Property.SelectionPopupStyle, new Tizen.NUI.PropertyValue((PropertyMap)newValue)); + } + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => + { + var textEditor = (TextEditor)bindable; + PropertyMap temp = new PropertyMap(); + Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textEditor.SwigCPtr, TextEditor.Property.SelectionPopupStyle).Get(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 SelectionHandleImageLeftProperty = BindableProperty.Create(nameof(SelectionHandleImageLeft), typeof(PropertyMap), typeof(TextEditor), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 31d6126..42afe43 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -783,6 +783,24 @@ namespace Tizen.NUI.BaseComponents } /// + /// The SelectionPopupStyle property.
+ /// The style of the text selection popup can be set through SelectionPopupStyle property. + ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public PropertyMap SelectionPopupStyle + { + get + { + return (PropertyMap)GetValue(SelectionPopupStyleProperty); + } + set + { + SetValue(SelectionPopupStyleProperty, value); + NotifyPropertyChanged(); + } + } + + /// /// The SelectionHandleImageLeft property.
/// The image to display for the left selection handle.
/// The selectionHandleImageLeft map contains the following key :
@@ -2572,6 +2590,7 @@ namespace Tizen.NUI.BaseComponents internal static readonly int GrabHandlePressedImage = Interop.TextField.GrabHandlePressedImageGet(); internal static readonly int ScrollThreshold = Interop.TextField.ScrollThresholdGet(); internal static readonly int ScrollSpeed = Interop.TextField.ScrollSpeedGet(); + internal static readonly int SelectionPopupStyle = Interop.TextField.SelectionPopupStyleGet(); internal static readonly int SelectionHandleImageLeft = Interop.TextField.SelectionHandleImageLeftGet(); internal static readonly int SelectionHandleImageRight = Interop.TextField.SelectionHandleImageRightGet(); internal static readonly int SelectionHandlePressedImageLeft = Interop.TextField.SelectionHandlePressedImageLeftGet(); diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs index bc8ecb6..3d56dc1 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs @@ -164,6 +164,7 @@ namespace Tizen.NUI.BaseComponents Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textField.SwigCPtr, TextField.Property.FontStyle).Get(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 PointSizeProperty = BindableProperty.Create(nameof(PointSize), typeof(float), typeof(TextField), default(float), propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => @@ -495,6 +496,24 @@ namespace Tizen.NUI.BaseComponents Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textField.SwigCPtr, TextField.Property.ScrollSpeed).Get(out temp); return temp; })); + + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty SelectionPopupStyleProperty = BindableProperty.Create(nameof(SelectionPopupStyle), typeof(PropertyMap), typeof(TextField), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + if (newValue != null) + { + Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)textField.SwigCPtr, TextField.Property.SelectionPopupStyle, new Tizen.NUI.PropertyValue((PropertyMap)newValue)); + } + }), + defaultValueCreator: (BindableProperty.CreateDefaultValueDelegate)((bindable) => + { + var textField = (TextField)bindable; + PropertyMap temp = new PropertyMap(); + Tizen.NUI.Object.GetProperty((System.Runtime.InteropServices.HandleRef)textField.SwigCPtr, TextField.Property.SelectionPopupStyle).Get(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 SelectionHandleImageLeftProperty = BindableProperty.Create(nameof(TextField.SelectionHandleImageLeft), typeof(PropertyMap), typeof(TextField), null, propertyChanged: (BindableProperty.BindingPropertyChangedDelegate)((bindable, oldValue, newValue) => diff --git a/src/Tizen.NUI/src/public/Common/NUIConstants.cs b/src/Tizen.NUI/src/public/Common/NUIConstants.cs index 1c916a1..eed9837 100755 --- a/src/Tizen.NUI/src/public/Common/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/Common/NUIConstants.cs @@ -1170,6 +1170,83 @@ namespace Tizen.NUI } /// + /// The SelectionPopupStyle property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public struct SelectionPopupStyleProperty + { + /// + /// The maximum size the Popup can be. + /// + public static readonly int MaxSize = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupMaxSizeGet(); + + /// + /// TThe size of the divider between popup buttons. + /// + public static readonly int DividerSize = NDalicManualPINVOKE.TextSelectionPopupPropertyOptionDividerSizeGet(); + + /// + /// The padding of the divider between popup buttons. + /// + public static readonly int DividerPadding = NDalicManualPINVOKE.TextSelectionPopupPropertyOptionDividerPaddingGet(); + + /// + /// The color of the divider between popup buttons. + /// + public static readonly int DividerColor = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupDividerColorGet(); + + /// + /// The color of the button when pressed. + /// + public static readonly int PressedColor = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupPressedColorGet(); + + /// + /// The corner radius of the button when pressed. + /// + public static readonly int PressedCornerRadius = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupPressedCornerRadiusGet(); + + /// + /// The duration of the fade-in animation. + /// + public static readonly int FadeInDuration = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupFadeInDurationGet(); + + /// + /// The duration of the fade-out animation. + /// + public static readonly int FadeOutDuration = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupFadeOutDurationGet(); + + /// + /// The popup background. + /// + public static readonly int Background = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupBackgroundGet(); + + /// + /// The popup background can have a separate border with a different color. + /// + public static readonly int BackgroundBorder = NDalicManualPINVOKE.TextSelectionPopupPropertyPopupBackgroundBorderGet(); + + /// + /// The minimum size of popup label. + /// + public static readonly int LabelMinimumSize = NDalicManualPINVOKE.TextSelectionPopupPropertyLabelMinimumSizeGet(); + + /// + /// The padding of popup label. + /// + public static readonly int LabelPadding = NDalicManualPINVOKE.TextSelectionPopupPropertyLabelPaddingGet(); + + /// + /// The text visual map of popup label. + /// + public static readonly int LabelTextVisual = NDalicManualPINVOKE.TextSelectionPopupPropertyLabelTextVisualGet(); + + /// + /// Whether the scroll-bar is enabled. + /// + public static readonly int EnableScrollBar = NDalicManualPINVOKE.TextSelectionPopupPropertyEnableScrollBarGet(); + }; + + /// /// ParentOrigin constants. /// /// 3 diff --git a/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs b/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs index bab72c0..7a63ef0 100644 --- a/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs +++ b/src/Tizen.NUI/src/public/Theme/DefaultThemeCommon.cs @@ -60,6 +60,24 @@ namespace Tizen.NUI GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png", SelectionHandleImageLeft = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downleftW.png")), SelectionHandleImageRight = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downrightW.png")), + SelectionPopupStyle = new PropertyMap() + .Add(SelectionPopupStyleProperty.MaxSize, new PropertyValue(new Vector2(1200.0f, 40.0f))) + .Add(SelectionPopupStyleProperty.DividerSize, new PropertyValue(new Vector2(0.0f, 0.0f))) + .Add(SelectionPopupStyleProperty.DividerPadding, new PropertyValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f))) + .Add(SelectionPopupStyleProperty.Background, new PropertyValue(new PropertyMap().Add(ImageVisualProperty.URL, new PropertyValue(FrameworkInformation.ResourcePath + "IoT-selection-popup-background.9.png")))) + .Add(SelectionPopupStyleProperty.BackgroundBorder, new PropertyValue(new PropertyMap().Add(ImageVisualProperty.URL, new PropertyValue(FrameworkInformation.ResourcePath + "IoT-selection-popup-border.9.png")))) + .Add(SelectionPopupStyleProperty.PressedColor, new PropertyValue(new Vector4(1.0f, 0.39f, 0.0f, 0.16f))) + .Add(SelectionPopupStyleProperty.PressedCornerRadius, new PropertyValue(12.0f)) + .Add(SelectionPopupStyleProperty.FadeInDuration, new PropertyValue(0.25f)) + .Add(SelectionPopupStyleProperty.FadeOutDuration, new PropertyValue(0.25f)) + .Add(SelectionPopupStyleProperty.EnableScrollBar, new PropertyValue(false)) + .Add(SelectionPopupStyleProperty.LabelMinimumSize, new PropertyValue(new Vector2(0, 40.0f))) + .Add(SelectionPopupStyleProperty.LabelPadding, new PropertyValue(new Vector4(-4.0f, -4.0f, 0.0f, 0.0f))) + .Add(SelectionPopupStyleProperty.LabelTextVisual, new PropertyValue(new PropertyMap() + .Add(TextVisualProperty.PointSize, new PropertyValue(6.0f)) + .Add(TextVisualProperty.TextColor, new PropertyValue(new Vector4(1.00f, 0.38f, 0.00f, 1))) + .Add(TextVisualProperty.FontFamily, new PropertyValue("TizenSans")) + .Add(TextVisualProperty.FontStyle, new PropertyValue(new PropertyMap().Add("weight", new PropertyValue("regular")))))), }); // TextEditor style. @@ -78,6 +96,24 @@ namespace Tizen.NUI GrabHandleImage = FrameworkInformation.ResourcePath + "IoT_handler_center_downW.png", SelectionHandleImageLeft = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downleftW.png")), SelectionHandleImageRight = new PropertyMap().Add("filename", new PropertyValue(FrameworkInformation.ResourcePath + "IoT_handler_downrightW.png")), + SelectionPopupStyle = new PropertyMap() + .Add(SelectionPopupStyleProperty.MaxSize, new PropertyValue(new Vector2(1200.0f, 40.0f))) + .Add(SelectionPopupStyleProperty.DividerSize, new PropertyValue(new Vector2(0.0f, 0.0f))) + .Add(SelectionPopupStyleProperty.DividerPadding, new PropertyValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f))) + .Add(SelectionPopupStyleProperty.Background, new PropertyValue(new PropertyMap().Add(ImageVisualProperty.URL, new PropertyValue(FrameworkInformation.ResourcePath + "IoT-selection-popup-background.9.png")))) + .Add(SelectionPopupStyleProperty.BackgroundBorder, new PropertyValue(new PropertyMap().Add(ImageVisualProperty.URL, new PropertyValue(FrameworkInformation.ResourcePath + "IoT-selection-popup-border.9.png")))) + .Add(SelectionPopupStyleProperty.PressedColor, new PropertyValue(new Vector4(1.0f, 0.39f, 0.0f, 0.16f))) + .Add(SelectionPopupStyleProperty.PressedCornerRadius, new PropertyValue(12.0f)) + .Add(SelectionPopupStyleProperty.FadeInDuration, new PropertyValue(0.25f)) + .Add(SelectionPopupStyleProperty.FadeOutDuration, new PropertyValue(0.25f)) + .Add(SelectionPopupStyleProperty.EnableScrollBar, new PropertyValue(false)) + .Add(SelectionPopupStyleProperty.LabelMinimumSize, new PropertyValue(new Vector2(0, 40.0f))) + .Add(SelectionPopupStyleProperty.LabelPadding, new PropertyValue(new Vector4(-4.0f, -4.0f, 0.0f, 0.0f))) + .Add(SelectionPopupStyleProperty.LabelTextVisual, new PropertyValue(new PropertyMap() + .Add(TextVisualProperty.PointSize, new PropertyValue(6.0f)) + .Add(TextVisualProperty.TextColor, new PropertyValue(new Vector4(1.00f, 0.38f, 0.00f, 1))) + .Add(TextVisualProperty.FontFamily, new PropertyValue("TizenSans")) + .Add(TextVisualProperty.FontStyle, new PropertyValue(new PropertyMap().Add("weight", new PropertyValue("regular")))))), }); return theme; -- 2.7.4