From ea3f83e7991c175471dcc041fdabeadabc2d0864 Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Mon, 30 Aug 2021 15:07:55 +0900 Subject: [PATCH] [NUI] Add SelectionHandleImage struct to Text Components Add a SelectionHandleImage struct to pass data of DALi SelectionHandleImageLeft, SelectionHandleImageRight PropertyMap. The SelectionHandleImage struct can be used as an argument to SetSelectionHandleImage, GetSelectionHandleImage, SetSelectionHandlePressedImage, GetSelectionHandlePressedImage, SetSelectionHandleMarkerImage and GetSelectionHandleMarkerImage methods. // example var selectionHandleImage = new Tizen.NUI.Text.SelectionHandleImage(); selectionHandleImage.LeftImageUrl = "handle_downleft.png"; selectionHandleImage.RightImageUrl = "handle_downright.png"; field.SetSelectionHandleImage(selectionHandleImage); Signed-off-by: Bowon Ryu --- .../src/public/BaseComponents/TextEditor.cs | 129 +++++++++++++++++++++ .../src/public/BaseComponents/TextField.cs | 129 +++++++++++++++++++++ .../src/public/BaseComponents/TextUtils.cs | 36 ++++++ src/Tizen.NUI/src/public/Common/NUIConstants.cs | 30 +++++ 4 files changed, 324 insertions(+) diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 849bf4c..aac7d7b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -508,6 +508,49 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set SelectionHandleImage to TextEditor.
+ ///
+ /// The SelectionHandleImage + /// + /// SetSelectionHandleImage specifies the display image used for the selection handle through .
+ ///
+ /// + /// The following example demonstrates how to use the SetSelectionHandleImage method. + /// + /// var selectionHandleImage = new Tizen.NUI.Text.SelectionHandleImage(); + /// selectionHandleImage.LeftImageUrl = "handle_downleft.png"; + /// selectionHandleImage.RightImageUrl = "handle_downright.png"; + /// editor.SetSelectionHandleImage(selectionHandleImage); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSelectionHandleImage(SelectionHandleImage selectionHandleImage) + { + if (!String.IsNullOrEmpty(selectionHandleImage.LeftImageUrl)) + { + SetValue(SelectionHandleImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleImage.LeftImageUrl)); + } + + if (!String.IsNullOrEmpty(selectionHandleImage.RightImageUrl)) + { + SetValue(SelectionHandleImageRightProperty, TextUtils.GetFileNameMap(selectionHandleImage.RightImageUrl)); + } + } + + /// + /// Get SelectionHandleImage from TextEditor.
+ ///
+ /// The SelectionHandleImage + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionHandleImage GetSelectionHandleImage() + { + return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleImageLeftProperty), (PropertyMap)GetValue(SelectionHandleImageRightProperty)); + } + + /// /// The SelectionHandlePressedImageLeft property. /// The selectionHandlePressedImageLeft map contains the following key :
/// @@ -550,6 +593,49 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set SelectionHandlePressedImage to TextEditor.
+ ///
+ /// The SelectionHandleImage + /// + /// SetSelectionHandlePressedImage specifies the display image used for the selection handle through .
+ ///
+ /// + /// The following example demonstrates how to use the SetSelectionHandlePressedImage method. + /// + /// var selectionHandlePressedImage = new Tizen.NUI.Text.SelectionHandleImage(); + /// selectionHandlePressedImage.LeftImageUrl = "handle_pressed_downleft.png"; + /// selectionHandlePressedImage.RightImageUrl = "handle_pressed_downright.png"; + /// editor.SetSelectionHandlePressedImage(selectionHandlePressedImage); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSelectionHandlePressedImage(SelectionHandleImage selectionHandlePressedImage) + { + if (!String.IsNullOrEmpty(selectionHandlePressedImage.LeftImageUrl)) + { + SetValue(SelectionHandlePressedImageLeftProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.LeftImageUrl)); + } + + if (!String.IsNullOrEmpty(selectionHandlePressedImage.RightImageUrl)) + { + SetValue(SelectionHandlePressedImageRightProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.RightImageUrl)); + } + } + + /// + /// Get SelectionHandlePressedImage from TextEditor.
+ ///
+ /// The SelectionHandlePressedImage + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionHandleImage GetSelectionHandlePressedImage() + { + return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty), (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty)); + } + + /// /// The SelectionHandleMarkerImageLeft property. /// The selectionHandleMarkerImageLeft map contains the following key :
/// @@ -592,6 +678,49 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set SelectionHandleMarkerImage to TextEditor.
+ ///
+ /// The SelectionHandleImage + /// + /// SetSelectionHandleMarkerImage specifies the display image used for the selection handle through .
+ ///
+ /// + /// The following example demonstrates how to use the SetSelectionHandleMarkerImage method. + /// + /// var selectionHandleMarkerImage = new Tizen.NUI.Text.SelectionHandleImage(); + /// selectionHandleMarkerImage.LeftImageUrl = "handle_pressed_downleft.png"; + /// selectionHandleMarkerImage.RightImageUrl = "handle_pressed_downright.png"; + /// editor.SetSelectionHandleMarkerImage(selectionHandleMarkerImage); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSelectionHandleMarkerImage(SelectionHandleImage selectionHandleMarkerImage) + { + if (!String.IsNullOrEmpty(selectionHandleMarkerImage.LeftImageUrl)) + { + SetValue(SelectionHandleMarkerImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.LeftImageUrl)); + } + + if (!String.IsNullOrEmpty(selectionHandleMarkerImage.RightImageUrl)) + { + SetValue(SelectionHandleMarkerImageRightProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.RightImageUrl)); + } + } + + /// + /// Get SelectionHandleMarkerImage from TextEditor.
+ ///
+ /// The SelectionHandleMarkerImage + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionHandleImage GetSelectionHandleMarkerImage() + { + return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty), (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty)); + } + + /// /// The SelectionHighlightColor property. /// /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 6717678..3724b2c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -748,6 +748,49 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set SelectionHandleImage to TextField.
+ ///
+ /// The SelectionHandleImage + /// + /// SetSelectionHandleImage specifies the display image used for the selection handle through .
+ ///
+ /// + /// The following example demonstrates how to use the SetSelectionHandleImage method. + /// + /// var selectionHandleImage = new Tizen.NUI.Text.SelectionHandleImage(); + /// selectionHandleImage.LeftImageUrl = "handle_downleft.png"; + /// selectionHandleImage.RightImageUrl = "handle_downright.png"; + /// field.SetSelectionHandleImage(selectionHandleImage); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSelectionHandleImage(SelectionHandleImage selectionHandleImage) + { + if (!String.IsNullOrEmpty(selectionHandleImage.LeftImageUrl)) + { + SetValue(SelectionHandleImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleImage.LeftImageUrl)); + } + + if (!String.IsNullOrEmpty(selectionHandleImage.RightImageUrl)) + { + SetValue(SelectionHandleImageRightProperty, TextUtils.GetFileNameMap(selectionHandleImage.RightImageUrl)); + } + } + + /// + /// Get SelectionHandleImage from TextField.
+ ///
+ /// The SelectionHandleImage + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionHandleImage GetSelectionHandleImage() + { + return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleImageLeftProperty), (PropertyMap)GetValue(SelectionHandleImageRightProperty)); + } + + /// /// The SelectionHandlePressedImageLeft property. /// The selectionHandlePressedImageLeft map contains the following key :
/// @@ -790,6 +833,49 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set SelectionHandlePressedImage to TextField.
+ ///
+ /// The SelectionHandleImage + /// + /// SetSelectionHandlePressedImage specifies the display image used for the selection handle through .
+ ///
+ /// + /// The following example demonstrates how to use the SetSelectionHandlePressedImage method. + /// + /// var selectionHandlePressedImage = new Tizen.NUI.Text.SelectionHandleImage(); + /// selectionHandlePressedImage.LeftImageUrl = "handle_pressed_downleft.png"; + /// selectionHandlePressedImage.RightImageUrl = "handle_pressed_downright.png"; + /// field.SetSelectionHandlePressedImage(selectionHandlePressedImage); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSelectionHandlePressedImage(SelectionHandleImage selectionHandlePressedImage) + { + if (!String.IsNullOrEmpty(selectionHandlePressedImage.LeftImageUrl)) + { + SetValue(SelectionHandlePressedImageLeftProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.LeftImageUrl)); + } + + if (!String.IsNullOrEmpty(selectionHandlePressedImage.RightImageUrl)) + { + SetValue(SelectionHandlePressedImageRightProperty, TextUtils.GetFileNameMap(selectionHandlePressedImage.RightImageUrl)); + } + } + + /// + /// Get SelectionHandlePressedImage from TextField.
+ ///
+ /// The SelectionHandlePressedImage + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionHandleImage GetSelectionHandlePressedImage() + { + return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandlePressedImageLeftProperty), (PropertyMap)GetValue(SelectionHandlePressedImageRightProperty)); + } + + /// /// The SelectionHandleMarkerImageLeft property. /// The selectionHandleMarkerImageLeft map contains the following key :
/// @@ -832,6 +918,49 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set SelectionHandleMarkerImage to TextField.
+ ///
+ /// The SelectionHandleImage + /// + /// SetSelectionHandleMarkerImage specifies the display image used for the selection handle through .
+ ///
+ /// + /// The following example demonstrates how to use the SetSelectionHandleMarkerImage method. + /// + /// var selectionHandleMarkerImage = new Tizen.NUI.Text.SelectionHandleImage(); + /// selectionHandleMarkerImage.LeftImageUrl = "handle_pressed_downleft.png"; + /// selectionHandleMarkerImage.RightImageUrl = "handle_pressed_downright.png"; + /// field.SetSelectionHandleMarkerImage(selectionHandleMarkerImage); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetSelectionHandleMarkerImage(SelectionHandleImage selectionHandleMarkerImage) + { + if (!String.IsNullOrEmpty(selectionHandleMarkerImage.LeftImageUrl)) + { + SetValue(SelectionHandleMarkerImageLeftProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.LeftImageUrl)); + } + + if (!String.IsNullOrEmpty(selectionHandleMarkerImage.RightImageUrl)) + { + SetValue(SelectionHandleMarkerImageRightProperty, TextUtils.GetFileNameMap(selectionHandleMarkerImage.RightImageUrl)); + } + } + + /// + /// Get SelectionHandleMarkerImage from TextField.
+ ///
+ /// The SelectionHandleMarkerImage + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public SelectionHandleImage GetSelectionHandleMarkerImage() + { + return TextUtils.GetSelectionHandleImageStruct((PropertyMap)GetValue(SelectionHandleMarkerImageLeftProperty), (PropertyMap)GetValue(SelectionHandleMarkerImageRightProperty)); + } + + /// /// The SelectionHighlightColor property. /// /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs index bed09c3..618de4f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs @@ -1751,6 +1751,42 @@ namespace Tizen.NUI.BaseComponents } /// + /// This method converts a fileName string to a PropertyMap and returns it. + /// The returned map can be used for set SelectionHandleImageLeft, SelectionHandleImageRight PropertyMap in the SetSelectionHandleImage method. + /// The file path string value for SelectionHandleImage. + /// A PropertyMap for SelectionHandleImageLeft, SelectionHandleImageRight properties. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetFileNameMap(string fileName) + { + return new PropertyMap().Add("filename", new PropertyValue(fileName)); + } + + /// + /// This method converts a SelectionHandleImageLeft, SelectionHandleImageRight map to a struct and returns it. + /// The returned struct can be returned to the user as a SelectionHandleImage in the GetSelectionHandleImage method. + /// The SelectionHandleImageLeft PropertyMap. + /// The SelectionHandleImageRight PropertyMap. + /// A SelectionHandleImage struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static SelectionHandleImage GetSelectionHandleImageStruct(PropertyMap leftImageMap, PropertyMap rightImageMap) + { + string leftImageUrl = null; + string rightImageUrl = null; + + var selectionHandleImage = new SelectionHandleImage(); + + leftImageMap.Find(0, "filename")?.Get(out leftImageUrl); + rightImageMap.Find(0, "filename")?.Get(out rightImageUrl); + + selectionHandleImage.LeftImageUrl = leftImageUrl; + selectionHandleImage.RightImageUrl = rightImageUrl; + + return selectionHandleImage; + } + + /// /// Copy the previously selected text into the clipboard and return the copied value. /// /// The textEditor control from which the text is copied. diff --git a/src/Tizen.NUI/src/public/Common/NUIConstants.cs b/src/Tizen.NUI/src/public/Common/NUIConstants.cs index 95aef4a..a58b67a 100755 --- a/src/Tizen.NUI/src/public/Common/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/Common/NUIConstants.cs @@ -2314,5 +2314,35 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public int? ShowLastCharacterDuration { get; set; } } + + /// + /// A struct to pass data of SelectionHandleImageLeft, SelectionHandleImageRight, SelectionHandlePressedImageLeft, SelectionHandlePressedImageRight, SelectionHandleMarkerImageLeft and SelectionHandleMarkerImageRight PropertyMap.
+ ///
+ /// + /// The SelectionHandleImage struct is used as an argument to SetSelectionHandleImage, GetSelectionHandleImage methods, SetSelectionHandlePressedImage, GetSelectionHandlePressedImage, SetSelectionHandleMarkerImage and GetSelectionHandleMarkerImage.
+ /// See , , , , , ,
+ /// , , , , and .
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public struct SelectionHandleImage + { + /// + /// The image path to display for the left selection handle.
+ /// It means the handle in the bottom-left.
+ /// If the handle needs to be displayed in the top-left, this image will be vertically flipped.
+ /// If null or empty string, it doesn't change the property.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public string LeftImageUrl { get; set; } + + /// + /// The image path to display for the right selection handle.
+ /// It means the handle in the bottom-right.
+ /// If the handle needs to be displayed in the top-right, this image will be vertically flipped.
+ /// If null or empty string, it doesn't change the property.
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public string RightImageUrl { get; set; } + } } } -- 2.7.4