1 #ifndef DALI_TOOLKIT_STYLE_MANAGER_H
2 #define DALI_TOOLKIT_STYLE_MANAGER_H
5 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/public-api/adaptor-framework/style-change.h>
24 #include <dali-toolkit/public-api/controls/control.h>
32 namespace Internal DALI_INTERNAL
38 * @addtogroup dali_toolkit_managers
43 * @brief StyleManager informs applications of system theme change,
44 * and supports application theme change at runtime.
46 * Applies various styles to Controls using the properties system.
48 * On theme change, it automatically updates all controls, then raises
49 * a signal to inform the application.
51 * The default theme is automatically loaded and applied, followed by
52 * any application specific theme defined in Application::New().
54 * If the application wants to customize the theme, RequestThemeChange
57 * To supply resource paths ( in json ) the following constant is available: APPLICATION_RESOURCE_PATH.
58 * It provides the path to the application resource root folder, from there the filename can an be specified along with
59 * any sub folders, e.g Images, Models etc.
60 * The APPLICATION_RESOURCE_PATH can be retrieved using Application::GetResourcePath()
63 * | %Signal Name | Method |
64 * |------------------------------------------------------------|
65 * | styleChanged | @ref StyleChangedSignal() |
68 class DALI_TOOLKIT_API StyleManager : public BaseHandle
72 /// @brief Style Changed signal. Emitted after controls have been updated.
73 typedef Signal< void ( StyleManager, StyleChange::Type ) > StyleChangedSignalType;
76 * @brief Creates a StyleManager handle; this can be initialized with StyleManager::Get().
78 * Calling member functions with an uninitialized handle is not allowed.
86 * This is non-virtual since derived Handle types must not contain data or virtual methods.
92 * @brief Gets the singleton of StyleManager object.
95 * @return A handle to the StyleManager control
97 static StyleManager Get();
100 * @brief Applies a new theme to the application. This will be merged
101 * on top of the default Toolkit theme.
103 * If the application theme file doesn't style all controls that the
104 * application uses, then the default Toolkit theme will be used
105 * instead for those controls.
107 * On application startup, it is suggested that the theme file name is
108 * passed to Application::New instead of using this API to prevent
109 * controls being styled more than once.
110 * @sa Application::New().
113 * @param[in] themeFile If a relative path is specified, then this is relative
114 * to the directory returned by Application::GetResourcePath()
116 void ApplyTheme( const std::string& themeFile );
119 * @brief Applies the default Toolkit theme.
121 * Request that any application specific styling is removed
122 * and that the default Toolkit theme is re-applied.
126 void ApplyDefaultTheme();
129 * @brief Sets a constant for use when building styles.
131 * A constant is used in JSON files e.g. "myImage":"{RELATIVE_PATH}/image.jpg"
132 * where the string "{RELATIVE_PATH}" is substituted with the value.
135 * @param[in] key The key of the constant
136 * @param[in] value The value of the constant
138 void SetStyleConstant( const std::string& key, const Property::Value& value );
141 * @brief Returns the style constant set for a specific key.
144 * @param[in] key The key of the constant
145 * @param[out] valueOut The value of the constant if it exists
147 * @return If the constant for key exists, then return the constant in valueOut and return true
149 bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
152 * @brief Applies the specified style to the control.
155 * @param[in] control The control to which to apply the style
156 * @param[in] jsonFileName The name of the JSON style file to apply. If a
157 * relative path is specified, then this is relative to the directory
158 * returned by Application::GetResourcePath()
159 * @param[in] styleName The name of the style within the JSON file to apply
161 void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
166 * @brief This signal is emitted after the style (e.g. theme/font change) has changed
167 * and the controls have been informed.
170 * A callback of the following type may be connected:
172 * void YourCallbackName( StyleManager styleManager, StyleChange change );
174 * @return The signal to connect to
176 StyleChangedSignalType& StyleChangedSignal();
182 * @brief Allows the creation of a StyleManager handle from an internal pointer.
184 * @note Not intended for application developers
186 * @param[in] impl A pointer to the object
188 explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl );
191 }; // class StyleManager
197 } // namespace Toolkit
201 #endif // DALI_TOOLKIT_STYLE_MANAGER_H