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