Remove deprecated SetRemoveTime API
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / styling / style-manager.h
1 #ifndef __DALI_TOOLKIT_STYLE_MANAGER_H__
2 #define __DALI_TOOLKIT_STYLE_MANAGER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 // EXTERNAL INCLUDES
21
22 // INTERNAL INCLUDES
23 #include <dali/dali.h>
24 #include <dali-toolkit/public-api/controls/control.h>
25
26 namespace Dali DALI_IMPORT_API
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal DALI_INTERNAL
33 {
34 class StyleManager;
35 }
36
37 /**
38  * @brief StyleManager provides the following functionalities:
39  *
40  * Applies various styles to Controls using the properties system.
41  * On theme change a signal is raised that controls can be configured to listen to.
42  *
43  * The default theme is automatically loaded and applied.
44  *
45  * If the application wants to customize the theme, RequestThemeChange needs to be called.
46  * Also, the default orientation is Portrait, if the application wants to adapt to the orientation change, call SetOrientation or SetOrienationValue.
47  * @code
48  *   const char* CUSTOM_THEME = DALI_SCRIPT_DIR "tizen-dark-theme.json";
49  *
50  *   void OnInit(Application& app)
51  *   {
52  *      Toolkit::StyleManager::Get().RequestThemeChange( CUSTOM_THEME );
53  *      Toolkit::StyleManager::Get().SetOrientation( app.GetOrientation() );
54  *      ...
55  *   }
56  * @endcode
57  *
58  * Internal::Control can be configured to register for the signals that are required from StyleManager,
59  * such as theme change.
60  */
61 class StyleManager : public BaseHandle
62 {
63 public:
64
65   // Signals
66   typedef SignalV2< void ( StyleManager, StyleChange ) >  StyleChangeSignalType;
67
68   /**
69    * @brief Create a StyleManager handle; this can be initialised with StyleManager::Get()
70    * Calling member functions with an uninitialised handle is not allowed.
71    */
72   StyleManager();
73
74   /**
75    * @brief Destructor
76    *
77    * This is non-virtual since derived Handle types must not contain data or virtual methods.
78    */
79   ~StyleManager();
80
81   /**
82    * @brief Get the singleton of StyleManager object.
83    *
84    * @return A handle to the StyleManager control.
85    */
86   static StyleManager Get();
87
88   /**
89    * @brief Specify the orientation value directly for the style manager
90    *
91    * @param[in] orientation The orientation in degrees
92    */
93   void SetOrientationValue( int orientation );
94
95   /**
96    * @brief Return the orientation value
97    *
98    * @return The orientation value
99    */
100   int GetOrientationValue();
101
102   /**
103    * @brief Set the orientation object. This will take precedence over setting the orientation value.
104    *
105    * @param[in] orientation Device orientation
106    */
107   void SetOrientation( Orientation orientation );
108
109   /**
110    * @brief Return the orientation object
111    *
112    * @return The orientation.
113    */
114   Orientation GetOrientation();
115
116   /**
117    * @brief Make a request to set the theme JSON file to one that exists in the Toolkit package.
118    *
119    * Multiple requests per event processing cycle can be made, but only the final one will be acted
120    * on in the event processing finished callback.
121    *
122    * @param[in] themeFile This is just the JSON theme file name and not the full path.
123    */
124   void RequestThemeChange( const std::string& themeFile );
125
126   /**
127    * @brief Request a change to the default theme
128    */
129   void RequestDefaultTheme();
130
131   /**
132    * @brief Set a constant for use when building styles
133    *
134    * A constant is used in JSON files e.g. "my-image":"{ROOT_PATH}/mypath/image.jpg"
135    * where the string "{ROOT_PATH}" is substituted with the value.
136    *
137    * @param[in] key The key of the constant
138    * @param[in] value The value of the constant
139    */
140   void SetStyleConstant( const std::string& key, const Property::Value& value );
141
142   /**
143    * @brief Return the style constant set for a specific key
144    *
145    * @param[in] key The key of the constant
146    * @param[out] valueOut The value of the constant if it exists
147    *
148    * @return If the constant for key exists then return the constant in valueOut and return true
149    */
150   bool GetStyleConstant( const std::string& key, Property::Value& valueOut );
151
152   /**
153    * @brief Apply the specified style to the control.
154    *
155    * The JSON file will be cached and subsequent calls using the same JSON file name will
156    * use the already loaded cached values instead.
157    *
158    * @param[in] control The control to apply style.
159    * @param[in] jsonFileName The name of the JSON style file to apply.
160    * @param[in] styleName The name of the style within the JSON file to apply.
161    */
162   void ApplyStyle( Toolkit::Control control, const std::string& jsonFileName, const std::string& styleName );
163
164 public: // Signals
165
166   /**
167    * @brief This signal is emitted whenever the style (e.g. theme/font change) is changed on device
168    * A callback of the following type may be connected:
169    * @code
170    *   void YourCallbackName( StyleManager styleManager, StyleChange change );
171    * @endcode
172    * @return The signal to connect to.
173    */
174   StyleChangeSignalType& StyleChangeSignal();
175
176 public:
177
178   /**
179    * @brief Creates a new handle from the implementation.
180    *
181    * @param[in] impl A pointer to the object.
182    */
183   explicit DALI_INTERNAL StyleManager( Internal::StyleManager *impl );
184
185 }; // class StyleManager
186
187 } // namespace Toolkit
188
189 } // namespace Dali
190
191
192 #endif /* __DALI_TOOLKIT_STYLE_MANAGER_H__ */