X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fstyling%2Fstyle-manager-impl.h;h=b6eaff56986756f3052beed75b29e2c2555d08a2;hp=648c11d8d1f885391b28c44c5194ea0bed94fd42;hb=9ddd5fea6278d06b8874988498c7c4c6508750ba;hpb=57869973578f6a0b0f836d396c7232ddb8302c6b diff --git a/dali-toolkit/internal/styling/style-manager-impl.h b/dali-toolkit/internal/styling/style-manager-impl.h index 648c11d..b6eaff5 100644 --- a/dali-toolkit/internal/styling/style-manager-impl.h +++ b/dali-toolkit/internal/styling/style-manager-impl.h @@ -1,8 +1,8 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__ -#define __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__ +#ifndef DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H +#define DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -18,33 +18,33 @@ */ // EXTERNAL INCLUDES -#include -#include -#include -#include +#include +#include +#include #include #include #include +#include // INTERNAL INCLUDES +#include +#include #include -#include namespace Dali { - namespace Toolkit { - namespace Internal { +class FeedbackStyle; + /** * @copydoc Toolkit::StyleManager */ class StyleManager : public Dali::BaseObject, public ConnectionTracker { public: - /** * Singleton access * @@ -57,90 +57,93 @@ public: */ StyleManager(); +protected: /** - * @copydoc Toolkit::StyleManager::SetOrientationValue + * @brief Destructor */ - void SetOrientationValue( int orientation ); + virtual ~StyleManager(); +public: // Public API /** - * @copydoc Toolkit::StyleManager::GetOrientationValue + * @copydoc Toolkit::StyleManager::ApplyTheme */ - int GetOrientationValue(); + void ApplyTheme(const std::string& themeFile); /** - * @copydoc Toolkit::StyleManager::SetOrientation( Orientation orientation ) + * @copydoc Toolkit::StyleManager::ApplyDefaultTheme */ - void SetOrientation( Orientation orientation ); + void ApplyDefaultTheme(); /** - * @copydoc Toolkit::StyleManager::GetOrientation + * @copydoc Toolkit::StyleManager::GetDefaultFontFamily */ - Orientation GetOrientation(); + const std::string& GetDefaultFontFamily() const; /** * @copydoc Toolkit::StyleManager::SetStyleConstant */ - void SetStyleConstant( const std::string& key, const Property::Value& value ); + void SetStyleConstant(const std::string& key, const Property::Value& value); /** * @copydoc Toolkit::StyleManager::GetStyleConstant */ - bool GetStyleConstant( const std::string& key, Property::Value& valueOut ); - - /** - * @copydoc Toolkit::StyleManager::RequestThemeChange - */ - void RequestThemeChange( const std::string& themeFile ); + bool GetStyleConstant(const std::string& key, Property::Value& valueOut); /** - * @copydoc Toolkit::StyleManager::RequestDefaultTheme + * @copydoc Toolkit::StyleManager::GetConfigurations */ - void RequestDefaultTheme(); + const Property::Map GetConfigurations(); /** - * Determine if a theme change has been requested - * @return Whether a theme request is pending + * @brief Apply the theme style to a control. + * + * @param[in] control The control to apply style. */ - bool IsThemeRequestPending(); + void ApplyThemeStyle(Toolkit::Control control); /** - * @brief Apply the theme style to a control. + * @brief Apply the theme style to a control at initialization. * * @param[in] control The control to apply style. */ - void ApplyThemeStyle( Toolkit::Control control ); + void ApplyThemeStyleAtInit(Toolkit::Control control); /** * @copydoc Toolkit::StyleManager::ApplyStyle */ - void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName ); + void ApplyStyle(Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName); + + /** + * Get the state/style information for the given control + * @param[in] control The control to get state information for + * @return The style information (or empty ptr if not found) + */ + const StylePtr GetRecordedStyle(Toolkit::Control control); public: // SIGNALS /** * @copydoc Toolkit::StyleManager::StyleChangeSignal + * This signal is sent after all the controls have been updated + * due to style change */ - Toolkit::StyleManager::StyleChangeSignalType& StyleChangeSignal(); - -protected: + Toolkit::StyleManager::StyleChangedSignalType& StyleChangedSignal(); /** - * @brief Destructor + * This signal is sent to the controls following a style change. + * It should not be exposed in the public API */ - virtual ~StyleManager(); - + Toolkit::StyleManager::StyleChangedSignalType& ControlStyleChangeSignal(); -public: +private: + typedef std::vector StringList; /** * @brief Set the current theme. Called only once per event processing cycle. + * @param[in] themeFile The name of the theme file to read. */ - void SetTheme(); - -private: - - typedef std::list StringList; + void SetTheme(const std::string& themeFile); /** * @brief Internal helper method to read a file from file system. @@ -158,7 +161,7 @@ private: * * @return Return the newly created builder */ - Toolkit::Builder CreateBuilder( const Property::Map& constants ); + Toolkit::Builder CreateBuilder(const Property::Map& constants); /** * @brief Load a JSON file into given builder @@ -167,25 +170,7 @@ private: * @param[in] jsonFileName The name of the JSON file to load * @return Return true if file was loaded */ - bool LoadJSON( Toolkit::Builder builder, const std::string& jsonFileName ); - - /** - * @brief Collect qualifiers (e.g. Landscape, portrait etc) for a given style - * - * @param[in,out] qualifiersOut The list to populate with qualifiers - */ - void CollectQualifiers( StringList& qualifiersOut ); - - /** - * @brief Construct a qualified style name out of qualifiers - * - * A qualifed style name will be in the format: style-qualifier0-qualifier1-qualifierN - * - * @param[in] styleName The root name of the style - * @param[in] qualifiers List of qualifier names - * @param[out] qualifiedStyleOut The qualified style name - */ - void BuildQualifiedStyleName( const std::string& styleName, const StringList& qualifiers, std::string& qualifiedStyleOut ); + bool LoadJSON(Toolkit::Builder builder, const std::string& jsonFileName); /** * @brief Apply a style to the control using the given builder @@ -193,14 +178,7 @@ private: * @param[in] builder The builder to apply the style from * @param[in] control The control to apply the style to */ - void ApplyStyle( Toolkit::Builder builder, Toolkit::Control control ); - - /** - * @brief Callback for orientation changes - * - * @param[in] orientation The orientation object - */ - void OnOrientationChanged( Orientation orientation ); + void ApplyStyle(Toolkit::Builder builder, Toolkit::Control control); /** * Search for a builder in the cache @@ -208,7 +186,7 @@ private: * @param[in] key The key the builder was cached under * @return Return the cached builder if found or an empty builder object if not found */ - Toolkit::Builder FindCachedBuilder( const std::string& key ); + Toolkit::Builder FindCachedBuilder(const std::string& key); /** * Store a given builder in the cache keyed to the given key @@ -216,15 +194,20 @@ private: * @param[in] builder The builder object to store * @param[in] key The key to store the builder under */ - void CacheBuilder( Toolkit::Builder builder, const std::string& key ); + void CacheBuilder(Toolkit::Builder builder, const std::string& key); /** * Callback for when style monitor raises a signal * * @param[in] styleMonitor The style monitor object - * @param[in] styleChange The style change data + * @param[in] styleChange The style change type */ - void StyleMonitorChange( StyleMonitor styleMonitor, StyleChange styleChange ); + void StyleMonitorChange(StyleMonitor styleMonitor, StyleChange::Type styleChange); + + /** + * Emit signals to controls first, app second + */ + void EmitStyleChangeSignals(StyleChange::Type styleChange); // Undefined StyleManager(const StyleManager&); @@ -232,49 +215,51 @@ private: StyleManager& operator=(const StyleManager& rhs); private: - // Map to store builders keyed by JSON file name - typedef std::map< std::string, Toolkit::Builder > BuilderMap; + typedef std::map BuilderMap; - Toolkit::Builder mThemeBuilder; ///< Builder for all default theme properties + Toolkit::Builder mThemeBuilder; ///< Builder for all default theme properties + StyleMonitor mStyleMonitor; ///< Style monitor handle - Orientation mOrientation; ///< Handle to application orientation object - int mOrientationDegrees; ///< Directly set value of orientation + int mDefaultFontSize; ///< Logical size, not a point-size + std::string mDefaultFontFamily; + std::string mDefaultThemeFilePath; ///< The full path of the default theme file + std::string mThemeFile; ///< The full path of the current theme file - std::string mThemeFile; ///< The full path of the current theme file + Property::Map mThemeBuilderConstants; ///< Contants to give the theme builder + Property::Map mStyleBuilderConstants; ///< Constants specific to building styles - Property::Map mThemeBuilderConstants; ///< Contants to give the theme builder - Property::Map mStyleBuilderConstants; ///< Constants specific to building styles + BuilderMap mBuilderCache; ///< Cache of builders keyed by JSON file name - BuilderMap mBuilderCache; ///< Cache of builders keyed by JSON file name + Toolkit::Internal::FeedbackStyle* mFeedbackStyle; ///< Feedback style // Signals - Toolkit::StyleManager::StyleChangeSignalType mStyleChangeSignal; ///< Emitted when the style( theme/font ) changes + Toolkit::StyleManager::StyleChangedSignalType mControlStyleChangeSignal; ///< Emitted when the style( theme/font ) changes for the controls to style themselves + Toolkit::StyleManager::StyleChangedSignalType mStyleChangedSignal; ///< Emitted after the controls have been styled }; } // namespace Internal -inline Internal::StyleManager& GetImpl( Dali::Toolkit::StyleManager& obj ) +inline Internal::StyleManager& GetImpl(Dali::Toolkit::StyleManager& obj) { - DALI_ASSERT_ALWAYS( obj ); + DALI_ASSERT_ALWAYS(obj); Dali::BaseObject& handle = obj.GetBaseObject(); - return static_cast< Internal::StyleManager& >( handle ); + return static_cast(handle); } -inline const Internal::StyleManager& GetImpl( const Dali::Toolkit::StyleManager& obj ) +inline const Internal::StyleManager& GetImpl(const Dali::Toolkit::StyleManager& obj) { - DALI_ASSERT_ALWAYS( obj ); + DALI_ASSERT_ALWAYS(obj); const Dali::BaseObject& handle = obj.GetBaseObject(); - return static_cast< const Internal::StyleManager& >( handle ); + return static_cast(handle); } } // namespace Toolkit } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H__ - +#endif // DALI_TOOLKIT_INTERNAL_STYLE_MANAGER_H