Added BACKGROUND_BORDER property to TextSelectionPopup 57/116057/1
authorPaul Wisbey <p.wisbey@samsung.com>
Wed, 22 Feb 2017 17:19:34 +0000 (17:19 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Wed, 22 Feb 2017 17:25:32 +0000 (17:25 +0000)
(Version which does not depend on ImageVisual mixColor)

Change-Id: I14a7929f75c5502fbb740d1768fd032486bc052b

dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.cpp
dali-toolkit/internal/controls/text-controls/text-selection-popup-impl.h
dali-toolkit/styles/1920x1080/dali-toolkit-default-theme.json
dali-toolkit/styles/480x800/dali-toolkit-default-theme.json
dali-toolkit/styles/720x1280/dali-toolkit-default-theme.json
dali-toolkit/styles/images-common/selection-popup-background.9.png [new file with mode: 0644]
dali-toolkit/styles/images-common/selection-popup-border.9.png [new file with mode: 0644]

index 5201c08..31cf939 100644 (file)
@@ -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
     };
   };
 
index 4e07ba8..6876ff2 100644 (file)
@@ -35,6 +35,7 @@
 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
 #include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup-callback-interface.h>
+#include <dali-toolkit/internal/helpers/color-conversion.h>
 
 namespace Dali
 {
@@ -47,7 +48,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" );
@@ -113,6 +114,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()
 
@@ -232,6 +234,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<Property::Map>();
+        impl.CreateBackgroundBorder( map );
+        break;
+      }
     } // switch
   } // TextSelectionPopup
 }
@@ -337,6 +345,11 @@ Property::Value TextSelectionPopup::GetProperty( BaseObject* object, Property::I
         value = impl.mFadeOutDuration;
         break;
       }
+      case Toolkit::TextSelectionPopup::Property::BACKGROUND_BORDER:
+      {
+        value = impl.mBackgroundBorderProperties;
+        break;
+      }
     } // switch
   }
   return value;
@@ -825,6 +838,34 @@ std::string TextSelectionPopup::GetPressedImage() const
    }
  }
 
+void TextSelectionPopup::CreateBackgroundBorder( Property::Map& propertyMap )
+{
+  // Removes previous image if necessary
+  UnparentAndReset( mBackgroundBorder );
+
+  mBackgroundBorderProperties = propertyMap;
+
+  if( ! propertyMap.Empty() )
+  {
+    mBackgroundBorder = Dali::Toolkit::ImageView::New();
+    mBackgroundBorder.SetProperty( Dali::Toolkit::ImageView::Property::IMAGE, propertyMap );
+    mBackgroundBorder.SetParentOrigin( ParentOrigin::CENTER );
+    mBackgroundBorder.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+    Property::Value* colorValue = propertyMap.Find( "borderColor" );
+    if( colorValue )
+    {
+      Vector4 color;
+      if( ConvertPropertyToColor( *colorValue, color ) )
+      {
+        mBackgroundBorder.SetColor( color );
+      }
+    }
+
+    Self().Add( mBackgroundBorder );
+  }
+}
+
 TextSelectionPopup::TextSelectionPopup( TextSelectionPopupCallbackInterface* callbackInterface )
 : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
   mToolbar(),
index e2a9497..734d105 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 // INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/control-impl.h>
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
 
 // EXTERNAL INCLUDES
 #include <dali/public-api/actors/layer.h>
+#include <dali/public-api/object/property-map.h>
 
 namespace Dali
 {
@@ -247,6 +249,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 );
@@ -277,6 +286,9 @@ private: // Data
   Image mSelectIconImage;
   Image mSelectAllIconImage;
 
+  Dali::Toolkit::ImageView mBackgroundBorder; ///< The popup background can have a separate border with a different color
+  Property::Map mBackgroundBorderProperties;  ///< The properties used to create mBackgroundBorder
+
   Size mPopupMaxSize;                   // Maximum size of the Popup
   Size mOptionMaxSize;                  // Maximum size of an Option button
   Size mOptionMinSize;                  // Minimum size of an Option button
index dbf5ffb..1274cf0 100644 (file)
       "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",
+        "borderColor":[0.24,0.72,0.8,1.0]
         },
       "popupFadeInDuration":0.25,
       "popupFadeOutDuration":0.25
index 83740e1..2548843 100644 (file)
       "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",
+        "borderColor":[0.24,0.72,0.8,1.0]
         },
       "popupFadeInDuration":0.25,
       "popupFadeOutDuration":0.25
index 89f1670..0958f29 100644 (file)
       "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",
+        "borderColor":[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 (file)
index 0000000..0b59668
Binary files /dev/null and b/dali-toolkit/styles/images-common/selection-popup-background.9.png differ
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 (file)
index 0000000..d7454f5
Binary files /dev/null and b/dali-toolkit/styles/images-common/selection-popup-border.9.png differ