From abef903718c23c14234b57c75437b2a03b873229 Mon Sep 17 00:00:00 2001
From: Paul Wisbey
Date: Sun, 19 Feb 2017 12:22:49 +0000
Subject: [PATCH] Added BACKGROUND_BORDER property to TextSelectionPopup
(Version which DOES depend on ImageVisual mixColor)
Change-Id: Ie03b09c6a3460d4975a8dd777071e2519b53457c
---
.../dali-toolkit/utc-Dali-TextSelectionPopup.cpp | 34 ++++++
.../controls/text-controls/text-selection-popup.h | 125 ++++++++++++++++++---
.../text-controls/text-selection-popup-impl.cpp | 39 ++++++-
.../text-controls/text-selection-popup-impl.h | 9 ++
.../1920x1080/dali-toolkit-default-theme.json | 7 +-
.../styles/480x800/dali-toolkit-default-theme.json | 7 +-
.../720x1280/dali-toolkit-default-theme.json | 7 +-
.../images-common/selection-popup-background.9.png | Bin 0 -> 319 bytes
.../images-common/selection-popup-border.9.png | Bin 0 -> 472 bytes
9 files changed, 207 insertions(+), 21 deletions(-)
create mode 100644 dali-toolkit/styles/images-common/selection-popup-background.9.png
create mode 100644 dali-toolkit/styles/images-common/selection-popup-border.9.png
diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp
index b1d76da..9b7c6fc 100644
--- a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp
+++ b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopup.cpp
@@ -25,6 +25,13 @@
using namespace Dali;
using namespace Toolkit;
+namespace
+{
+
+const char* TEST_IMAGE_FILE_NAME = "selection-popup-border.9.png";
+
+}
+
void dali_textselectionpopup_startup(void)
{
test_return_value = TET_UNDEF;
@@ -107,6 +114,33 @@ int UtcDaliToolkitTextSelectionPopupDownCastP(void)
END_TEST;
}
+int UtcDaliToolkitTextSelectionPopupBackgroundBorderP(void)
+{
+ ToolkitTestApplication application;
+ TextSelectionPopup textSelectionPopup;
+ textSelectionPopup = TextSelectionPopup::New( NULL );
+
+ textSelectionPopup.SetProperty( TextSelectionPopup::Property::BACKGROUND_BORDER,
+ Property::Map().Add( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ) );
+
+ Property::Value value = textSelectionPopup.GetProperty( TextSelectionPopup::Property::BACKGROUND_BORDER );
+
+ Property::Map map;
+ value.Get( map );
+
+ Property::Value* returnValue = map.Find( Dali::Toolkit::ImageVisual::Property::URL );
+ DALI_TEST_CHECK( NULL != returnValue );
+
+ if( returnValue )
+ {
+ std::string url;
+ returnValue->Get( url );
+ DALI_TEST_EQUALS( TEST_IMAGE_FILE_NAME, url, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
// TextSelectionToolBar is used TextSelectionPopup, below tests it individually
int UtcDaliToolkitTextSelectionToolBarP(void)
diff --git a/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h b/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h
index 5201c08..31cf939 100644
--- a/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h
+++ b/dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h
@@ -75,23 +75,114 @@ public:
{
enum
{
- POPUP_MAX_SIZE = PROPERTY_START_INDEX, ///< name "popupMaxSize", maximum size the Popup can be, type VECTOR2
- POPUP_MIN_SIZE, ///< name "popupMinSize", minimum size the Popup can be, type VECTOR2
- OPTION_MAX_SIZE, ///< name "optionMaxSize", maximum size an option can be, type VECTOR2
- OPTION_MIN_SIZE, ///< name "optionMinSize", minimum size an option can be, type VECTOR2
- OPTION_DIVIDER_SIZE, ///< name "optionDividerSize", size of the divider between options type VECTOR2
- POPUP_CLIPBOARD_BUTTON_ICON_IMAGE, ///< name "popupClipboardButtonImage", The image to use as the popup clipboard icon, type STRING
- POPUP_CUT_BUTTON_ICON_IMAGE, ///< name "popupCutButtonImage", The image to use as the popup cut icon, type STRING
- POPUP_COPY_BUTTON_ICON_IMAGE, ///< name "popupCopyButtonImage", The image to use as the popup copy icon, type STRING
- POPUP_PASTE_BUTTON_ICON_IMAGE, ///< name "popupPasteButtonImage", The image to use as the popup paste icon, type STRING
- POPUP_SELECT_BUTTON_ICON_IMAGE, ///< name "popupSelectButtonImage", The image to use as the popup select icon, type STRING
- POPUP_SELECT_ALL_BUTTON_ICON_IMAGE, ///< name "popupSelectAllButtonImage", The image to use as the popup select all icon, type STRING
- POPUP_DIVIDER_COLOR, ///< name "popupDividerColor", The color of the divider between options, type VECTOR4
- POPUP_ICON_COLOR, ///< name "popupIconColor", The color of the icons (if supplied), type VECTOR4
- POPUP_PRESSED_COLOR, ///< name "popupPressedColor", The color of the option when pressed, type VECTOR4
- POPUP_PRESSED_IMAGE, ///< name "popupPressedImage", The image to use for the option when pressed, type STRING
- POPUP_FADE_IN_DURATION, ///< name "popupFadeInDuration", The duration of the fade-in animation, type FLOAT
- POPUP_FADE_OUT_DURATION, ///< name "popupFadeOutDuration", The duration of the fade-out animation, type FLOAT
+ /**
+ * @brief The maximum size the Popup can be.
+ * @details Name "popupMaxSize", type Vector2.
+ */
+ POPUP_MAX_SIZE = PROPERTY_START_INDEX,
+
+ /**
+ * @brief The minimum size the Popup can be.
+ * @details Name "popupMinSize", type Vector2.
+ */
+ POPUP_MIN_SIZE,
+
+ /**
+ * @brief The maximum size an option can be.
+ * @details Name "optionMaxSize", type Vector2.
+ */
+ OPTION_MAX_SIZE,
+
+ /**
+ * @brief The minimum size an option can be.
+ * @details Name "optionMinSize", type Vector2.
+ */
+ OPTION_MIN_SIZE,
+
+ /**
+ * @brief The size of the divider between options.
+ * @details Name "optionDividerSize", type Vector2.
+ */
+ OPTION_DIVIDER_SIZE,
+
+ /**
+ * @brief The image to use as the popup clipboard icon.
+ * @details Name "popupClipboardButtonImage", type string.
+ */
+ POPUP_CLIPBOARD_BUTTON_ICON_IMAGE,
+
+ /**
+ * @brief The image to use as the popup cut icon.
+ * @details Name "popupCutButtonImage", type string.
+ */
+ POPUP_CUT_BUTTON_ICON_IMAGE,
+
+ /**
+ * @brief The image to use as the popup copy icon.
+ * @details Name "popupCopyButtonImage", type string.
+ */
+ POPUP_COPY_BUTTON_ICON_IMAGE,
+
+ /**
+ * @brief The image to use as the popup paste icon.
+ * @details Name "popupPasteButtonImage", type string.
+ */
+ POPUP_PASTE_BUTTON_ICON_IMAGE,
+
+ /**
+ * @brief The image to use as the popup select icon.
+ * @details Name "popupSelectButtonImage", type string.
+ */
+ POPUP_SELECT_BUTTON_ICON_IMAGE,
+
+ /**
+ * @brief The image to use as the popup select all icon.
+ * @details Name "popupSelectAllButtonImage", type string.
+ */
+ POPUP_SELECT_ALL_BUTTON_ICON_IMAGE,
+
+ /**
+ * @brief The color of the divider between options.
+ * @details Name "popupDividerColor", type Vector4.
+ */
+ POPUP_DIVIDER_COLOR,
+
+ /**
+ * @brief The color of the icons (if supplied).
+ * @details Name "popupIconColor", type Vector4.
+ */
+ POPUP_ICON_COLOR,
+
+ /**
+ * @brief The color of the option when pressed.
+ * @details Name "popupPressedColor", type Vector4.
+ */
+ POPUP_PRESSED_COLOR,
+
+ /**
+ * @brief The image to use for the option when pressed.
+ * @details Name "popupPressedImage", type string.
+ */
+ POPUP_PRESSED_IMAGE,
+
+ /**
+ * @brief The duration of the fade-in animation.
+ * @details Name "popupFadeInDuration", type float.
+ */
+ POPUP_FADE_IN_DURATION,
+
+ /**
+ * @brief The duration of the fade-out animation.
+ * @details Name "popupFadeOutDuration", type float.
+ */
+ POPUP_FADE_OUT_DURATION,
+
+ /**
+ * @brief The popup background can have a separate border with a different color.
+ * @details Name "backgroundBorder", type Property::Map.
+ * @note Optional.
+ */
+ BACKGROUND_BORDER
};
};
diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
index 459e534..6d95ac2 100644
--- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
+++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
@@ -36,6 +36,8 @@
#include
#include
#include
+#include
+#include
namespace Dali
{
@@ -48,7 +50,7 @@ namespace Internal
namespace
{
-// todo Move this to adaptor??
+
#define GET_LOCALE_TEXT(string) dgettext("dali-toolkit", string)
const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME( "TextSelectionPopupButton" );
@@ -111,6 +113,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popupPressedColor", VE
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popupPressedImage", STRING, POPUP_PRESSED_IMAGE )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popupFadeInDuration", FLOAT, POPUP_FADE_IN_DURATION )
DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "popupFadeOutDuration", FLOAT, POPUP_FADE_OUT_DURATION )
+DALI_PROPERTY_REGISTRATION( Toolkit, TextSelectionPopup, "backgroundBorder", MAP, BACKGROUND_BORDER )
DALI_TYPE_REGISTRATION_END()
@@ -230,6 +233,12 @@ void TextSelectionPopup::SetProperty( BaseObject* object, Property::Index index,
impl.mFadeOutDuration = value.Get < float >();
break;
}
+ case Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER:
+ {
+ Property::Map map = value.Get();
+ impl.CreateBackgroundBorder( map );
+ break;
+ }
} // switch
} // TextSelectionPopup
}
@@ -335,6 +344,17 @@ Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::I
value = impl.mFadeOutDuration;
break;
}
+ case Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER:
+ {
+ Property::Map map;
+ Toolkit::Visual::Base visual = impl.GetVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER );
+ if( visual )
+ {
+ visual.CreatePropertyMap( map );
+ }
+ value = map;
+ break;
+ }
} // switch
}
return value;
@@ -796,6 +816,23 @@ std::string TextSelectionPopup::GetPressedImage() const
}
}
+void TextSelectionPopup::CreateBackgroundBorder( Property::Map& propertyMap )
+{
+ // Removes previous image if necessary
+ UnregisterVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER );
+
+ if( ! propertyMap.Empty() )
+ {
+ Toolkit::Visual::Base visual = Toolkit::VisualFactory::Get().CreateVisual( propertyMap );
+
+ if( visual )
+ {
+ RegisterVisual( Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER, visual );
+ visual.SetDepthIndex( DepthIndex::CONTENT );
+ }
+ }
+}
+
TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface )
: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mToolbar(),
diff --git a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
index 419720f..c437361 100644
--- a/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
+++ b/dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
@@ -21,12 +21,14 @@
// INTERNAL INCLUDES
#include
#include
+#include
#include
#include
#include
// EXTERNAL INCLUDES
#include
+#include
namespace Dali
{
@@ -242,6 +244,13 @@ private: // Implementation
void AddPopupOptionsToToolbar( bool showIcons, bool showCaptions );
/**
+ * Creates the background-border image
+ *
+ * @param[in] propertyMap The properties describing the background-border
+ */
+ void CreateBackgroundBorder( Property::Map& propertyMap );
+
+ /**
* Construct a new TextField.
*/
TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface );
diff --git a/dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json b/dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
index ba775a2..ff865b0 100644
--- a/dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
+++ b/dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
@@ -125,7 +125,12 @@
"popupPressedColor":[0.24,0.72,0.8,0.11],
"background": {
"rendererType": "image",
- "url": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
+ "url": "{DALI_IMAGE_DIR}selection-popup-background.9.png"
+ },
+ "backgroundBorder": {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}selection-popup-border.9.png",
+ "mixColor":[0.24,0.72,0.8,1.0]
},
"popupFadeInDuration":0.25,
"popupFadeOutDuration":0.25
diff --git a/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json b/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
index 02b527d..105b87b 100644
--- a/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
+++ b/dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
@@ -124,7 +124,12 @@
"popupPressedColor":[0.24,0.72,0.8,0.11],
"background": {
"visualType": "IMAGE",
- "url": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
+ "url": "{DALI_IMAGE_DIR}selection-popup-background.9.png"
+ },
+ "backgroundBorder": {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}selection-popup-border.9.png",
+ "mixColor":[0.24,0.72,0.8,1.0]
},
"popupFadeInDuration":0.25,
"popupFadeOutDuration":0.25
diff --git a/dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json b/dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
index e0e0c6a..db96431 100644
--- a/dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
+++ b/dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
@@ -98,7 +98,12 @@
"popupPressedColor":[0.24,0.72,0.8,0.11],
"background": {
"visualType": "IMAGE",
- "url": "{DALI_IMAGE_DIR}selection-popup-bg.9.png"
+ "url": "{DALI_IMAGE_DIR}selection-popup-background.9.png"
+ },
+ "backgroundBorder": {
+ "visualType": "IMAGE",
+ "url": "{DALI_IMAGE_DIR}selection-popup-border.9.png",
+ "mixColor":[0.24,0.72,0.8,1.0]
},
"popupFadeInDuration":0.25,
"popupFadeOutDuration":0.25
diff --git a/dali-toolkit/styles/images-common/selection-popup-background.9.png b/dali-toolkit/styles/images-common/selection-popup-background.9.png
new file mode 100644
index 0000000000000000000000000000000000000000..0b596682e196a00e6008fced07fca9e2edbcc80d
GIT binary patch
literal 319
zcmeAS@N?(olHy`uVBq!ia0vp^+91rq1|%QG79IdnY)RhkE({qACm60@=VGq`if|Tq
zL>4nJa0`PlBg3pY5H=O_J>Tuf*jo0{=tDjp);N?jv*0;-`?EF*W|#%_TXE?
z(Id+X)4$G)yjv+HEc@Zd+$u}Qm_19%Pu}mHaA0~6N3LkY6u!{b4h{z0s#pdizs*h>QtQuBDTe@F)crnlbQ3fZ01ae5KugJ!|ATF4bCgRv-32(J9VJ?)8Eq*H<<0-
z-uc;hou0?;^_HLJ9y-pXVt;V`!TAf_rQOcEeOhs~iuoD86KAZ;2~VKE7(8A5T-G@y
GGywpR4}S^(
literal 0
HcmV?d00001
diff --git a/dali-toolkit/styles/images-common/selection-popup-border.9.png b/dali-toolkit/styles/images-common/selection-popup-border.9.png
new file mode 100644
index 0000000000000000000000000000000000000000..d7454f54f22dc2ff0ab39dd98cbf8e7b4536db4a
GIT binary patch
literal 472
zcmeAS@N?(olHy`uVBq!ia0vp^+91rq1|%QG79IdnY)RhkE({qACm60@=VGq`if|Tq
zL>4nJa0`PlBg3pY5H=O_J>TuLj0n4+}+kNFfgWix;TbJ9DaK87vJL<~3R_D4wOVM)+K1ecn%Y2f3RLLf`#`
zRko_0of39NW$W4P$GuJ|zwiml56n50E}lDWyLe@s>ei&3{VjFtUOWEFd8To&*7LU^
zx6O^xlFK<0oMt48{BH7X5uG4z-I^xmp?Yn%Y~?i0h*p6p#aUY!UV8K^M)UC>eh}Z1
zEc-g*xYf0deWh