Merge "ImageView ResourceReady logic update" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / controls / control-devel.h
1 #ifndef DALI_TOOLKIT_CONTROL_DEVEL_H
2 #define DALI_TOOLKIT_CONTROL_DEVEL_H
3
4 /*
5  * Copyright (c) 2017 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
21 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control.h>
23
24 namespace Dali
25 {
26
27 namespace Toolkit
28 {
29
30 class TransitionData;
31
32 namespace Visual
33 {
34 class Base;
35 }
36
37 namespace DevelControl
38 {
39
40 enum State
41 {
42   NORMAL,
43   FOCUSED,
44   DISABLED
45 };
46
47 namespace Property
48 {
49
50 enum
51 {
52   STYLE_NAME        = Control::Property::STYLE_NAME,
53   BACKGROUND_COLOR  = Control::Property::BACKGROUND_COLOR,
54   BACKGROUND_IMAGE  = Control::Property::BACKGROUND_IMAGE,
55   KEY_INPUT_FOCUS   = Control::Property::KEY_INPUT_FOCUS,
56   BACKGROUND        = Control::Property::BACKGROUND,
57
58   /**
59    * @brief Displays a tooltip when the control is hovered over.
60    * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP.
61    *          If Property::STRING, then the style specified in the stylesheet is used.
62    *          If Property::ARRAY of Visuals then all are displayed in one row.
63    *          If Property::MAP, then it should be a map of Tooltip properties.
64    * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show.
65    *       The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.)
66    * @note When retrieved, a Property::MAP is returned.
67    * @see Toolkit::Tooltip
68    */
69   TOOLTIP = BACKGROUND + 1,
70
71   /**
72    * @brief The current state of the control.
73    * @details Name "state", type DevelControl::State ( Property::INTEGER ) or Property::STRING
74    *
75    * @see DevelControl::State
76    */
77   STATE = BACKGROUND + 2,
78
79   /**
80    * @brief The current sub state of the control.
81    * @details Name "subState", type Property::INTEGER or Property::STRING. The enumeration used is dependent on the derived control.
82    *
83    * @see DevelControl::State
84    */
85   SUB_STATE = BACKGROUND + 3,
86
87   /**
88    * @brief The actor ID of the left focusable control.
89    * @details Name "leftFocusableActorId", type Property::INTEGER.
90    *
91    */
92   LEFT_FOCUSABLE_ACTOR_ID = BACKGROUND + 4,
93
94   /**
95    * @brief The actor ID of the right focusable control.
96    * @details Name "rightFocusableActorId", type Property::INTEGER.
97    *
98    */
99   RIGHT_FOCUSABLE_ACTOR_ID = BACKGROUND + 5,
100
101   /**
102    * @brief The actor ID of the up focusable control.
103    * @details Name "upFocusableActorId", type Property::INTEGER.
104    *
105    */
106   UP_FOCUSABLE_ACTOR_ID = BACKGROUND + 6,
107
108   /**
109    * @brief The actor ID of the down focusable control.
110    * @details Name "downFocusableActorId", type Property::INTEGER.
111    *
112    */
113   DOWN_FOCUSABLE_ACTOR_ID = BACKGROUND + 7
114 };
115
116 } // namespace Property
117
118 /// @brief ResourceReady signal type;
119 typedef Signal<void ( Control ) > ResourceReadySignalType;
120
121 /**
122  * @brief This signal is emitted after all resources required
123  * by a control are loaded and ready.
124  * Most resources are only loaded when the control is placed on stage.
125  *
126  * @note A RelayoutRequest is queued by Control before this signal is emitted
127  *
128  * A callback of the following type may be connected:
129  * @code
130  *   void YourCallbackName( Control control );
131  * @endcode
132  */
133 DALI_IMPORT_API ResourceReadySignalType& ResourceReadySignal( Control& control );
134
135 /**
136  * @brief Query if all resources required by a control are loaded and ready.
137  * Most resources are only loaded when the control is placed on stage.
138  * @return true if the resources are loaded and ready, false otherwise
139  *
140  */
141 DALI_IMPORT_API bool IsResourceReady( const Control& control );
142
143 /**
144  * @brief Register a visual by Property Index.
145  *
146  * @param[in] control The control
147  * @param[in] index The Property index of the visual, used to reference visual
148  * @param[in] visual The visual to register
149  *
150  * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
151  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
152  * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
153  * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
154  */
155 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
156
157 /**
158  * @brief Register a visual by Property Index with a depth index.
159  *
160  * @param[in] control The control
161  * @param[in] index The Property index of the visual, used to reference visual
162  * @param[in] visual The visual to register
163  * @param[in] depthIndex The visual's depth-index is set to this
164  *
165  * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
166  *       Use below API with enabled set to false if derived class wishes to control when visual is staged.
167  *
168  * @see Visual::Base::GetDepthIndex()
169  * @see Visual::Base::SetDepthIndex()
170  */
171 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex );
172
173 /**
174  * @brief Register a visual by Property Index with the option of enabling/disabling it.
175  *
176  * @param[in] control The control
177  * @param[in] index The Property index of the visual, used to reference visual
178  * @param[in] visual The visual to register
179  * @param[in] enabled false if derived class wants to control when visual is set on stage.
180  *
181  * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
182  * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
183  *
184  * @see EnableVisual()
185  */
186 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
187
188 /**
189  * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
190  *
191  * @param[in] control The control
192  * @param[in] index The Property index of the visual, used to reference visual
193  * @param[in] visual The visual to register
194  * @param[in] enabled false if derived class wants to control when visual is set on stage.
195  * @param[in] depthIndex The visual's depth-index is set to this
196  *
197  * @see EnableVisual()
198  * @see Visual::Base::GetDepthIndex()
199  * @see Visual::Base::SetDepthIndex()
200  */
201 DALI_IMPORT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex );
202
203 /**
204  * @brief Erase the entry matching the given index from the list of registered visuals
205  *
206  * @param[in] control The control
207  * @param[in] index The Property index of the visual, used to reference visual
208  */
209 DALI_IMPORT_API void UnregisterVisual( Internal::Control& control, Dali::Property::Index index );
210
211 /**
212  * @brief Retrieve the visual associated with the given property index.
213  *
214  * @param[in] control The control
215  * @param[in] index The Property index of the visual.
216  * @return The registered visual if exist, otherwise empty handle.
217  * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
218  */
219 DALI_IMPORT_API Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index );
220
221 /**
222  * @brief Sets the given visual to be displayed or not when parent staged.
223  *
224  * @param[in] control The control
225  * @param[in] index The Property index of the visual
226  * @param[in] enable flag to set enabled or disabled.
227  */
228 DALI_IMPORT_API void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable );
229
230 /**
231  * @brief Queries if the given visual is to be displayed when parent staged.
232  *
233  * @param[in] control The control
234  * @param[in] index The Property index of the visual
235  * @return bool whether visual is enabled or not
236  */
237 DALI_IMPORT_API bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index );
238
239 /**
240  * @brief Create a transition effect on the control.
241  *
242  * Only generates an animation if the properties described in the transition
243  * data are staged (e.g. the visual is Enabled and the control is on stage).
244  * Otherwise the target values are stored, and will get set onto the properties
245  * when the visual is next staged.
246  *
247  * @param[in] control The control
248  * @param[in] transitionData The transition data describing the effect to create
249  * @return A handle to an animation defined with the given effect, or an empty
250  * handle if no properties match.
251  */
252 DALI_IMPORT_API Dali::Animation CreateTransition( Internal::Control& control, const Toolkit::TransitionData& transitionData );
253
254 } // namespace DevelControl
255
256 } // namespace Toolkit
257
258 } // namespace Dali
259
260 #endif // DALI_TOOLKIT_CONTROL_DEVEL_H