1 #ifndef __DALI_TOOLKIT_STYLE_MANAGER_H__
2 #define __DALI_TOOLKIT_STYLE_MANAGER_H__
5 * Copyright (c) 2015 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/devel-api/adaptor-framework/orientation.h>
22 #include <dali/public-api/adaptor-framework/style-change.h>
25 #include <dali-toolkit/public-api/controls/control.h>
33 namespace Internal DALI_INTERNAL
39 * @brief StyleManager provides the following functionalities:
41 * Applies various styles to Controls using the properties system.
42 * On theme change a signal is raised that controls can be configured to listen to.
44 * The default theme is automatically loaded and applied.
46 * If the application wants to customize the theme, RequestThemeChange
47 * needs to be called. Internal::Control can be configured to
48 * register for the signals that are required from StyleManager, such
51 class DALI_IMPORT_API StyleManager : public BaseHandle
56 typedef Signal< void ( StyleManager, StyleChange::Type ) > StyleChangedSignalType;
59 * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
60 * Calling member functions with an uninitialised handle is not allowed.
67 * This is non-virtual since derived Handle types must not contain data or virtual methods.
72 * @brief Get the singleton of StyleManager object.
74 * @return A handle to the StyleManager control.
76 static StyleManager Get();
79 * @brief Specify the orientation value directly for the style manager
81 * @param[in] orientation The orientation in degrees
83 void SetOrientationValue( int orientation );
86 * @brief Return the orientation value
88 * @return The orientation value
90 int GetOrientationValue();
93 * @brief Set the orientation object. This will take precedence over setting the orientation value.
95 * @param[in] orientation Device orientation
97 void SetOrientation( Orientation orientation );
100 * @brief Return the orientation object
102 * @return The orientation.
104 Orientation GetOrientation();
107 * @brief Retrieves the default font family.
108 * @return The default font family.
110 std::string GetDefaultFontFamily() const;
113 * @brief Make a request to set the theme JSON file to one that exists in the Toolkit package.
115 * Multiple requests per event processing cycle can be made, but only the final one will be acted
116 * on in the event processing finished callback.
118 * @param[in] themeFile This is just the JSON theme file name and not the full path.
120 void RequestThemeChange( const std::string& themeFile );
123 * @brief Request a change to the default theme
125 void RequestDefaultTheme();
128 * @brief Set a constant for use when building styles
130 * A constant is used in JSON files e.g. "myImage":"{ROOT_PATH}/mypath/image.jpg"
131 * where the string "{ROOT_PATH}" is substituted with the value.
133 * @param[in] key The key of the constant
134 * @param[in] value The value of the constant
136 void SetStyleConstant( const std::string& key, const Property::Value& value );
139 * @brief Return the style constant set for a specific key
141 * @param[in] key The key of the constant
142 * @param[out] valueOut The value of the constant if it exists
144 * @return If the constant for key exists then return the constant in valueOut and return true
146 bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
149 * @brief Apply the specified style to the control.
151 * The JSON file will be cached and subsequent calls using the same JSON file name will
152 * use the already loaded cached values instead.
154 * @param[in] control The control to apply style.
155 * @param[in] jsonFileName The name of the JSON style file to apply.
156 * @param[in] styleName The name of the style within the JSON file to apply.
158 void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
163 * @brief This signal is emitted after the style (e.g. theme/font change) has changed
164 * and the controls have been informed.
166 * A callback of the following type may be connected:
168 * void YourCallbackName( StyleManager styleManager, StyleChange change );
170 * @return The signal to connect to.
172 StyleChangedSignalType& StyleChangedSignal();
177 * @brief Creates a new handle from the implementation.
179 * @param[in] impl A pointer to the object.
181 explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl );
183 }; // class StyleManager
185 } // namespace Toolkit
190 #endif /* __DALI_TOOLKIT_STYLE_MANAGER_H__ */