1 #ifndef __DALI_TOOLKIT_STYLE_MANAGER_H__
2 #define __DALI_TOOLKIT_STYLE_MANAGER_H__
5 * Copyright (c) 2016 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
58 * | %Signal Name | Method |
59 * |------------------------------------------------------------|
60 * | styleChanged | @ref StyleChangedSignal() |
63 class DALI_IMPORT_API StyleManager : public BaseHandle
67 /// @brief Style Changed signal. Emitted after controls have been updated
68 typedef Signal< void ( StyleManager, StyleChange::Type ) > StyleChangedSignalType;
71 * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
73 * Calling member functions with an uninitialised handle is not allowed.
81 * This is non-virtual since derived Handle types must not contain data or virtual methods.
87 * @brief Get the singleton of StyleManager object.
90 * @return A handle to the StyleManager control.
92 static StyleManager Get();
95 * @brief Apply a new theme to the application. This will be merged
96 * on top of the default Toolkit theme.
98 * If the application theme file doesn't style all controls that the
99 * application uses, then the default Toolkit theme will be used
100 * instead for those controls.
102 * On application startup, it is suggested that the theme file name is
103 * passed to Application::New instead of using this API to prevent
104 * controls being styled more than once.
105 * @sa Application::New()
108 * @param[in] themeFile If a relative path is specified, then this is relative
109 * to the directory returned by app_get_resource_path().
111 void ApplyTheme( const std::string& themeFile );
114 * @brief Apply the default Toolkit theme.
116 * Request that any application specific styling is removed
117 * and that the default Toolkit theme is re-applied.
121 void ApplyDefaultTheme();
124 * @brief Set a constant for use when building styles
126 * A constant is used in JSON files e.g. "myImage":"{RELATIVE_PATH}/image.jpg"
127 * where the string "{RELATIVE_PATH}" is substituted with the value.
130 * @param[in] key The key of the constant
131 * @param[in] value The value of the constant
133 void SetStyleConstant( const std::string& key, const Property::Value& value );
136 * @brief Return the style constant set for a specific key
139 * @param[in] key The key of the constant
140 * @param[out] valueOut The value of the constant if it exists
142 * @return If the constant for key exists then return the constant in valueOut and return true
144 bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
147 * @brief Apply the specified style to the control.
150 * @param[in] control The control to which to apply the style.
151 * @param[in] jsonFileName The name of the JSON style file to apply. If a
152 * relative path is specified, then this is relative to the directory
153 * returned by app_get_resource_path().
154 * @param[in] styleName The name of the style within the JSON file to apply.
156 void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
161 * @brief This signal is emitted after the style (e.g. theme/font change) has changed
162 * and the controls have been informed.
165 * A callback of the following type may be connected:
167 * void YourCallbackName( StyleManager styleManager, StyleChange change );
169 * @return The signal to connect to.
171 StyleChangedSignalType& StyleChangedSignal();
176 * @brief Allows the creation of a StyleManager handle from an internal pointer.
178 * @note Not intended for application developers
180 * @param[in] impl A pointer to the object.
182 explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl );
184 }; // class StyleManager
189 } // namespace Toolkit
194 #endif /* __DALI_TOOLKIT_STYLE_MANAGER_H__ */