Merge "Fix a crash when the same image is set repeatedly" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 30 Jun 2017 13:46:45 +0000 (13:46 +0000)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Fri, 30 Jun 2017 13:46:45 +0000 (13:46 +0000)
19 files changed:
automated-tests/src/dali-toolkit-styling/default-theme.json
automated-tests/src/dali-toolkit/utc-Dali-Builder.cpp
build/tizen/dali-toolkit/Makefile.am
dali-toolkit/devel-api/builder/builder.cpp
dali-toolkit/devel-api/builder/builder.h
dali-toolkit/devel-api/file.list
dali-toolkit/devel-api/styling/style-manager-devel.cpp [new file with mode: 0644]
dali-toolkit/devel-api/styling/style-manager-devel.h [new file with mode: 0644]
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/internal/builder/builder-impl.h
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h
dali-toolkit/internal/styling/style-manager-impl.cpp
dali-toolkit/internal/styling/style-manager-impl.h
dali-toolkit/public-api/dali-toolkit-version.cpp
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
packaging/dali-toolkit.spec

index c9e87f8..6b3ddd1 100644 (file)
@@ -1,4 +1,8 @@
 {
+  "config":
+  {
+    "alwaysShowFocus":false
+  },
   "constants":
   {
     "CONFIG_SCRIPT_LOG_LEVEL":"NoLogging"
index 60f4a1b..f134be3 100644 (file)
@@ -1820,3 +1820,33 @@ int UtcDaliBuilderActionsWithParams(void)
 
   END_TEST;
 }
+
+int UtcDaliBuilderConfigurationP(void)
+{
+  ToolkitTestApplication application;
+
+  // JSON with a quit event when the actor is touched
+  std::string json(
+      "{\n"
+      "  \"config\":\n"
+      "  {\n"
+      "    \"alwaysShowFocus\":true\n"
+      "  }\n"
+      "}\n"
+  );
+
+  Builder builder = Builder::New();
+  builder.LoadFromString( json );
+
+  Property::Map map = builder.GetConfigurations();
+
+  Dali::Property::Value* pValue = map.Find( "alwaysShowFocus" );
+
+  DALI_TEST_CHECK( pValue );
+
+  bool value = pValue->Get<bool>();
+
+  DALI_TEST_CHECK( value );
+
+  END_TEST;
+}
index a766f83..c2f73c3 100644 (file)
@@ -118,6 +118,7 @@ develapifocusmanagerdir =       $(develapidir)/focus-manager
 develapiimageloaderdir =        $(develapidir)/image-loader
 develapiscriptingdir =          $(develapidir)/scripting
 develapishadereffectsdir =      $(develapidir)/shader-effects
+develapistylingdir =            $(develapidir)/styling
 develapitransitioneffectsdir =  $(develapidir)/transition-effects
 develapitoolbardir =            $(develapicontrolsdir)/tool-bar
 develapitooltipdir =            $(develapicontrolsdir)/tooltip
@@ -149,6 +150,7 @@ develapivisuals_HEADERS =           $(devel_api_visuals_header_files)
 develapiscripting_HEADERS =         $(devel_api_scripting_header_files)
 develapishadowview_HEADERS =        $(devel_api_shadow_view_header_files)
 develapishadereffects_HEADERS =     $(devel_api_shader_effects_header_files)
+develapistyling_HEADERS =           $(devel_api_styling_header_files)
 develapisuperblurview_HEADERS =     $(devel_api_super_blur_view_header_files)
 develapitoolbar_HEADERS =           $(devel_api_tool_bar_header_files)
 develapitooltip_HEADERS =           $(devel_api_tooltip_header_files)
index 4270b1e..64a08a0 100644 (file)
@@ -64,6 +64,11 @@ void Builder::AddConstant( const std::string& key, const Property::Value& value
   GetImpl(*this).AddConstant( key, value );
 }
 
+const Property::Map& Builder::GetConfigurations() const
+{
+  return GetImpl(*this).GetConfigurations();
+}
+
 const Property::Map& Builder::GetConstants() const
 {
   return GetImpl(*this).GetConstants();
index 530a81a..422a517 100644 (file)
@@ -187,6 +187,14 @@ class DALI_IMPORT_API Builder : public BaseHandle
   void AddConstant( const std::string& key, const Property::Value& value );
 
   /**
+   * @brief Gets all currently defined configurations.
+   *
+   * @pre The Builder has been initialized.
+   * @return A reference to the currently defined configurations.
+   */
+  const Property::Map& GetConfigurations() const;
+
+  /**
    * @brief Gets all currently defined constants.
    *
    * e.g.
index 64fbb88..7f4308b 100644 (file)
@@ -31,6 +31,7 @@ devel_api_src_files = \
   $(devel_api_src_dir)/image-loader/atlas-upload-observer.cpp \
   $(devel_api_src_dir)/image-loader/image-atlas.cpp \
   $(devel_api_src_dir)/scripting/script.cpp \
+  $(devel_api_src_dir)/styling/style-manager-devel.cpp \
   $(devel_api_src_dir)/transition-effects/cube-transition-cross-effect.cpp \
   $(devel_api_src_dir)/transition-effects/cube-transition-effect.cpp \
   $(devel_api_src_dir)/transition-effects/cube-transition-fold-effect.cpp \
@@ -133,6 +134,9 @@ devel_api_shader_effects_header_files = \
   $(devel_api_src_dir)/shader-effects/motion-blur-effect.h \
   $(devel_api_src_dir)/shader-effects/motion-stretch-effect.h
 
+devel_api_styling_header_files= \
+  $(devel_api_src_dir)/styling/style-manager-devel.h
+
 devel_api_super_blur_view_header_files = \
   $(devel_api_src_dir)/controls/super-blur-view/super-blur-view.h
 
diff --git a/dali-toolkit/devel-api/styling/style-manager-devel.cpp b/dali-toolkit/devel-api/styling/style-manager-devel.cpp
new file mode 100644 (file)
index 0000000..7ac5a64
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
+#include <dali-toolkit/internal/styling/style-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelStyleManager
+{
+
+const Property::Map GetConfigurations( StyleManager styleManager )
+{
+  return GetImpl(styleManager).GetConfigurations();
+}
+
+} // namespace DevelStyleManager
+
+} // namespace Toolkit
+
+} // namespace Dali
diff --git a/dali-toolkit/devel-api/styling/style-manager-devel.h b/dali-toolkit/devel-api/styling/style-manager-devel.h
new file mode 100644 (file)
index 0000000..faf3c57
--- /dev/null
@@ -0,0 +1,49 @@
+#ifndef DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
+#define DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/styling/style-manager.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace DevelStyleManager
+{
+
+
+/**
+ * @brief Gets all currently defined configurations.
+ *
+ * @pre The Builder has been initialized.
+ * @param[in] styleManager The instance of StyleManager
+ * @return A property map to the currently defined configurations
+**/
+DALI_IMPORT_API const Property::Map GetConfigurations( StyleManager styleManager );
+
+} // namespace DevelStyleManager
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // DALI_TOOLKIT_STYLE_MANAGER_DEVEL_H
index e4ef639..4a23ed1 100644 (file)
@@ -179,9 +179,10 @@ void Builder::LoadFromString( std::string const& data, Dali::Toolkit::Builder::U
   }
   else
   {
+    // load configuration map
+    LoadConfiguration( *parser.GetRoot(), mConfigurationMap );
     // load constant map (allows the user to override the constants in the json after loading)
     LoadConstants( *parser.GetRoot(), mReplacementMap );
-
     // merge includes
     if( OptionalChild includes = IsChild(*parser.GetRoot(), KEYNAME_INCLUDES) )
     {
@@ -228,6 +229,11 @@ void Builder::AddConstant( const std::string& key, const Property::Value& value
   mReplacementMap[key] = value;
 }
 
+const Property::Map& Builder::GetConfigurations() const
+{
+  return mConfigurationMap;
+}
+
 const Property::Map& Builder::GetConstants() const
 {
   return mReplacementMap;
@@ -773,6 +779,25 @@ Builder::~Builder()
 {
 }
 
+void Builder::LoadConfiguration( const TreeNode& root, Property::Map& intoMap )
+{
+  Replacement replacer(intoMap);
+
+  if( OptionalChild constants = IsChild(root, "config") )
+  {
+    for(TreeNode::ConstIterator iter = (*constants).CBegin();
+        iter != (*constants).CEnd(); ++iter)
+    {
+      Dali::Property::Value property;
+      if( (*iter).second.GetName() )
+      {
+        DeterminePropertyFromNode( (*iter).second, property, replacer );
+        intoMap[ (*iter).second.GetName() ] = property;
+      }
+    }
+  }
+}
+
 void Builder::LoadConstants( const TreeNode& root, Property::Map& intoMap )
 {
   Replacement replacer(intoMap);
index ea0b635..8a90b03 100644 (file)
@@ -95,6 +95,11 @@ public:
   void AddConstant( const std::string& key, const Property::Value& value );
 
   /**
+   * @copydoc Toolkit::Builder::GetConfigurations
+   */
+  const Property::Map& GetConfigurations() const;
+
+  /**
    * @copydoc Toolkit::Builder::GetConstants
    */
   const Property::Map& GetConstants() const;
@@ -257,6 +262,8 @@ private:
 
   void LoadConstants( const TreeNode& root, Property::Map& intoMap );
 
+  void LoadConfiguration( const TreeNode& root, Property::Map& intoMap );
+
   Animation CreateAnimation( const std::string& animationName,
                              const Replacement& replacement,
                              Dali::Actor        sourceActor );
@@ -384,6 +391,7 @@ private:
   LinearConstrainerLut                mLinearConstrainerLut;
   SlotDelegate<Builder>               mSlotDelegate;
   Property::Map                       mReplacementMap;
+  Property::Map                       mConfigurationMap;
   MappingsLut                         mCompleteMappings;
   Dictionary<StylePtr>                mStyles; // State based styles
   Toolkit::Builder::BuilderSignalType mQuitSignal;
index 15e5366..5225c46 100644 (file)
@@ -29,6 +29,7 @@
 #include <dali/public-api/events/touch-data.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
+#include <dali/public-api/object/property-map.h>
 #include <dali/public-api/images/resource-image.h>
 #include <dali/integration-api/debug.h>
 
@@ -38,6 +39,8 @@
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali-toolkit/public-api/accessibility-manager/accessibility-manager.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/public-api/styling/style-manager.h>
+#include <dali-toolkit/devel-api/styling/style-manager-devel.h>
 
 namespace Dali
 {
@@ -116,8 +119,8 @@ KeyboardFocusManager::KeyboardFocusManager()
   mFocusedActorEnterKeySignal(),
   mCurrentFocusActor(),
   mFocusIndicatorActor(),
+  mIsFocusIndicatorEnabled( -1 ),
   mFocusGroupLoopEnabled( false ),
-  mIsFocusIndicatorEnabled( false ),
   mIsWaitingKeyboardFocusChangeCommit( false ),
   mFocusHistory(),
   mSlotDelegate( this ),
@@ -132,10 +135,25 @@ KeyboardFocusManager::~KeyboardFocusManager()
 {
 }
 
+void KeyboardFocusManager::GetConfigurationFromStyleManger()
+{
+    Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+    if( styleManager )
+    {
+      Property::Map config = Toolkit::DevelStyleManager::GetConfigurations( styleManager );
+      mIsFocusIndicatorEnabled = static_cast<int>(config["alwaysShowFocus"].Get<bool>());
+    }
+}
+
 bool KeyboardFocusManager::SetCurrentFocusActor( Actor actor )
 {
   DALI_ASSERT_DEBUG( !mIsWaitingKeyboardFocusChangeCommit && "Calling this function in the PreFocusChangeSignal callback?" );
 
+  if( mIsFocusIndicatorEnabled == -1 )
+  {
+    GetConfigurationFromStyleManger();
+  }
+
   return DoSetCurrentFocusActor( actor );
 }
 
@@ -523,7 +541,7 @@ void KeyboardFocusManager::ClearFocus()
   }
 
   mCurrentFocusActor.Reset();
-  mIsFocusIndicatorEnabled = false;
+  mIsFocusIndicatorEnabled = 0;
 }
 
 void KeyboardFocusManager::SetFocusGroupLoop(bool enabled)
@@ -623,6 +641,11 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
 
   std::string keyName = event.keyPressedName;
 
+  if( mIsFocusIndicatorEnabled == -1 )
+  {
+    GetConfigurationFromStyleManger();
+  }
+
   bool isFocusStartableKey = false;
 
   if(event.state == KeyEvent::Down)
@@ -634,7 +657,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
         if(!mIsFocusIndicatorEnabled)
         {
           // Show focus indicator
-          mIsFocusIndicatorEnabled = true;
+          mIsFocusIndicatorEnabled = 1;
         }
         else
         {
@@ -657,7 +680,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
         if(!mIsFocusIndicatorEnabled)
         {
           // Show focus indicator
-          mIsFocusIndicatorEnabled = true;
+          mIsFocusIndicatorEnabled = 1;
         }
         else
         {
@@ -678,7 +701,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
       else
       {
@@ -693,7 +716,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
       else
       {
@@ -708,7 +731,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
       else
       {
@@ -723,7 +746,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
       else
       {
@@ -738,7 +761,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
       else
       {
@@ -754,7 +777,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
 
       isFocusStartableKey = true;
@@ -765,7 +788,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
 
       isFocusStartableKey = true;
@@ -785,7 +808,7 @@ void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
       if(!mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
       {
         // Show focus indicator
-        mIsFocusIndicatorEnabled = true;
+        mIsFocusIndicatorEnabled = 1;
       }
       else
       {
index 298b3a7..7283b1e 100644 (file)
@@ -165,6 +165,11 @@ private:
   typedef FocusStack::Iterator FocusStackIterator; ///< Define FocusStack::Iterator as FocusStackIterator to navigate FocusStack
 
   /**
+   * Get configuration from StyleManager.
+   */
+  void GetConfigurationFromStyleManger();
+
+  /**
    * Get the focus group of current focused actor.
    * @pre The FocusManager has been initialized.
    * @return A handle to the parent of the current focused actor which is a focus group,
@@ -253,9 +258,9 @@ private:
 
   Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the keyboard focusable actors for highlight
 
-  bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
+  int mIsFocusIndicatorEnabled; ///< Whether indicator should be shown / hidden when getting focus. It could be enabled when keyboard focus feature is enabled and navigation keys or 'Tab' key are pressed.
 
-  bool mIsFocusIndicatorEnabled:1; ///< Whether indicator should be shown / hidden. It could be enabled when keyboard focus feature enabled and navigation keys or 'Tab' key pressed.
+  bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
 
   bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
 
index ba89d88..df885d9 100644 (file)
@@ -228,15 +228,22 @@ void StyleManager::SetTheme( const std::string& themeFile )
 {
   bool themeLoaded = false;
 
-  mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
-
-  // Always load the default theme first, then merge in the custom theme if present
-  themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
-  mThemeFile = themeFile;
+  if( mThemeFile.compare(DEFAULT_THEME) == 0 && mThemeBuilder )
+  {
+    // We have already loaded the default theme into mThemeBuilder
+  }
+  else
+  {
+    // Reload the default theme
+    mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
+    themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
+  }
 
   if( themeFile.compare(DEFAULT_THEME) != 0 )
   {
-    themeLoaded = LoadJSON( mThemeBuilder, mThemeFile );
+    // The theme is different to the default: Merge it
+    themeLoaded = LoadJSON( mThemeBuilder, themeFile );
+    mThemeFile = themeFile;
   }
 
   if( themeLoaded )
@@ -254,6 +261,32 @@ void StyleManager::SetTheme( const std::string& themeFile )
   }
 }
 
+const Property::Map StyleManager::GetConfigurations()
+{
+  Property::Map result;
+  if( mThemeBuilder )
+  {
+    result = mThemeBuilder.GetConfigurations();
+  }
+  else
+  {
+    bool themeLoaded = false;
+
+    mThemeBuilder = CreateBuilder( mThemeBuilderConstants );
+
+    // Load default theme because this is first try to load stylesheet.
+    themeLoaded = LoadJSON( mThemeBuilder, DEFAULT_THEME );
+    mThemeFile = DEFAULT_THEME;
+
+    if( themeLoaded )
+    {
+      result = mThemeBuilder.GetConfigurations();
+    }
+  }
+
+  return result;
+}
+
 bool StyleManager::LoadFile( const std::string& filename, std::string& stringOut )
 {
   DALI_ASSERT_DEBUG( 0 != filename.length());
index aa514ea..d6bc4a1 100644 (file)
@@ -94,6 +94,11 @@ public: // Public API
   bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
 
   /**
+   * @copydoc Toolkit::StyleManager::GetConfigurations
+   */
+  const Property::Map GetConfigurations();
+
+  /**
    * @brief Apply the theme style to a control.
    *
    * @param[in] control The control to apply style.
index b31fe8b..7064c51 100644 (file)
@@ -31,7 +31,7 @@ namespace Toolkit
 
 const unsigned int TOOLKIT_MAJOR_VERSION = 1;
 const unsigned int TOOLKIT_MINOR_VERSION = 2;
-const unsigned int TOOLKIT_MICRO_VERSION = 45;
+const unsigned int TOOLKIT_MICRO_VERSION = 46;
 const char * const TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 7e86b0d..dd06d35 100644 (file)
 //******************************************************************************
 
 {
+  "config":
+  {
+    "alwaysShowFocus":false
+  },
   "styles":
   {
     "Tooltip":
index 6e1db0b..8612b3c 100644 (file)
 //******************************************************************************
 
 {
+  "config":
+  {
+    "alwaysShowFocus":false
+  },
   "styles":
   {
     "Tooltip":
index e84bc65..0c48655 100644 (file)
 //******************************************************************************
 
 {
+  "config":
+  {
+    "alwaysShowFocus":false
+  },
   "styles":
   {
     "TextLabel":
index b5dc3dd..8ef63e7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali-toolkit
 Summary:    The OpenGLES Canvas Core Library Toolkit
-Version:    1.2.45
+Version:    1.2.46
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT