1 #ifndef DALI_TOOLKIT_CONTROL_DEVEL_H
2 #define DALI_TOOLKIT_CONTROL_DEVEL_H
5 * Copyright (c) 2019 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/input-method-context.h>
24 #include <dali-toolkit/public-api/controls/control.h>
25 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
40 namespace DevelControl
55 STYLE_NAME = Control::Property::STYLE_NAME,
56 RESERVED_PROPERTY_01 = Control::Property::RESERVED_PROPERTY_01,
57 RESERVED_PROPERTY_02 = Control::Property::RESERVED_PROPERTY_02,
58 KEY_INPUT_FOCUS = Control::Property::KEY_INPUT_FOCUS,
59 BACKGROUND = Control::Property::BACKGROUND,
60 MARGIN = Control::Property::MARGIN,
61 PADDING = Control::Property::PADDING,
64 * @brief Displays a tooltip when the control is hovered over.
65 * @details Name "tooltip", type Property::STRING, Property::ARRAY or Property::MAP.
66 * If Property::STRING, then the style specified in the stylesheet is used.
67 * If Property::ARRAY of Visuals then all are displayed in one row.
68 * If Property::MAP, then it should be a map of Tooltip properties.
69 * @note The tooltip is only activated if display content is received, i.e. a string (text) or visual to show.
70 * The rest is used to just build up the style of the tooltip (i.e. background, text color/point-size etc.)
71 * @note When retrieved, a Property::MAP is returned.
72 * @see Toolkit::Tooltip
74 TOOLTIP = PADDING + 1,
77 * @brief The current state of the control.
78 * @details Name "state", type DevelControl::State ( Property::INTEGER ) or Property::STRING
80 * @see DevelControl::State
85 * @brief The current sub state of the control.
86 * @details Name "subState", type Property::INTEGER or Property::STRING. The numeration used is dependent on the derived control.
88 * @see DevelControl::State
90 SUB_STATE = PADDING + 3,
93 * @brief The actor ID of the left focusable control.
94 * @details Name "leftFocusableActorId", type Property::INTEGER.
97 LEFT_FOCUSABLE_ACTOR_ID = PADDING + 4,
100 * @brief The actor ID of the right focusable control.
101 * @details Name "rightFocusableActorId", type Property::INTEGER.
104 RIGHT_FOCUSABLE_ACTOR_ID = PADDING + 5,
107 * @brief The actor ID of the up focusable control.
108 * @details Name "upFocusableActorId", type Property::INTEGER.
111 UP_FOCUSABLE_ACTOR_ID = PADDING + 6,
114 * @brief The actor ID of the down focusable control.
115 * @details Name "downFocusableActorId", type Property::INTEGER.
118 DOWN_FOCUSABLE_ACTOR_ID = PADDING + 7,
121 * @brief The name of object visible in accessibility tree.
122 * @details Name "accessibilityName", type Property::STRING.
127 * @brief The description of object visible in accessibility tree.
128 * @details Name "accessibilityDescription", type Property::STRING.
130 ACCESSIBILITY_DESCRIPTON,
133 * @brief Current translation domain for accessibility clients.
134 * @details Name "accessibilityTranslationDomain", type Property::STRING.
136 ACCESSIBILITY_TRANSLATION_DOMAIN,
139 * @brief Role being performed in accessibility hierarchy.
140 * @details Name "accessibilityRole", type Property::INTEGER.
141 * @note Property is stored as INTEGER, however its interpretaton
142 * depend on enumeration Dali::Accessibility::Role and should be read and written
143 * with usage of enumerated values.
144 * @see Dali::Accessibility::Role
148 * @brief Mark of able to highlight object.
149 * @details Name "accessibilityHighlightable", type Property::BOOLEAN.
151 ACCESSIBILITY_HIGHLIGHTABLE,
153 * @brief Set of accessibility attributes describing object in accessibility hierarchy
154 * @details Name "accessibilityAttributes", type Property::MAP
156 ACCESSIBILITY_ATTRIBUTES,
159 * @brief Boolean flag describing object as animated
160 * @details Name "accessibilityAnimated", type Property::BOOLEAN
161 * @note Flag set to true will prevent BoundChanged accessibility signal from emiting
163 ACCESSIBILITY_ANIMATED
166 } // namespace Property
169 * @brief Register a visual by Property Index.
171 * @param[in] control The control
172 * @param[in] index The Property index of the visual, used to reference visual
173 * @param[in] visual The visual to register
175 * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
176 * Use below API with enabled set to false if derived class wishes to control when visual is staged.
177 * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
178 * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
180 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual );
183 * @brief Register a visual by Property Index with a depth index.
185 * @param[in] control The control
186 * @param[in] index The Property index of the visual, used to reference visual
187 * @param[in] visual The visual to register
188 * @param[in] depthIndex The visual's depth-index is set to this
190 * @note Derived class should not call visual.SetOnStage(actor). It is the responsibility of the base class to connect/disconnect registered visual to stage.
191 * Use below API with enabled set to false if derived class wishes to control when visual is staged.
193 * @see Visual::Base::GetDepthIndex()
194 * @see Visual::Base::SetDepthIndex()
196 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, int depthIndex );
199 * @brief Register a visual by Property Index with the option of enabling/disabling it.
201 * @param[in] control The control
202 * @param[in] index The Property index of the visual, used to reference visual
203 * @param[in] visual The visual to register
204 * @param[in] enabled false if derived class wants to control when visual is set on stage.
206 * @note If the depth-index is not set on the visual, then it is set to be above the currently registered visuals.
207 * @note If replacing a visual, then the depth-index of the visual being replaced is used for the visual.
209 * @see EnableVisual()
211 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled );
214 * @brief Register a visual by Property Index with a depth index with the option of enabling/disabling it.
216 * @param[in] control The control
217 * @param[in] index The Property index of the visual, used to reference visual
218 * @param[in] visual The visual to register
219 * @param[in] enabled false if derived class wants to control when visual is set on stage.
220 * @param[in] depthIndex The visual's depth-index is set to this
222 * @see EnableVisual()
223 * @see Visual::Base::GetDepthIndex()
224 * @see Visual::Base::SetDepthIndex()
226 DALI_TOOLKIT_API void RegisterVisual( Internal::Control& control, Dali::Property::Index index, Toolkit::Visual::Base& visual, bool enabled, int depthIndex );
229 * @brief Erase the entry matching the given index from the list of registered visuals
231 * @param[in] control The control
232 * @param[in] index The Property index of the visual, used to reference visual
234 DALI_TOOLKIT_API void UnregisterVisual( Internal::Control& control, Dali::Property::Index index );
237 * @brief Retrieve the visual associated with the given property index.
239 * @param[in] control The control
240 * @param[in] index The Property index of the visual.
241 * @return The registered visual if exist, otherwise empty handle.
242 * @note For managing object life-cycle, do not store the returned visual as a member which increments its reference count.
244 DALI_TOOLKIT_API Toolkit::Visual::Base GetVisual( const Internal::Control& control, Dali::Property::Index index );
247 * @brief Sets the given visual to be displayed or not when parent staged.
249 * @param[in] control The control
250 * @param[in] index The Property index of the visual
251 * @param[in] enable flag to set enabled or disabled.
253 DALI_TOOLKIT_API void EnableVisual( Internal::Control& control, Dali::Property::Index index, bool enable );
256 * @brief Queries if the given visual is to be displayed when parent staged.
258 * @param[in] control The control
259 * @param[in] index The Property index of the visual
260 * @return bool whether visual is enabled or not
262 DALI_TOOLKIT_API bool IsVisualEnabled( const Internal::Control& control, Dali::Property::Index index );
266 * @brief Add a transition effect on the control to the given animation
268 * Only generates an animator if the properties described in the transition
269 * data are staged (e.g. the visual is Enabled and the control is on stage).
270 * Otherwise the target values are stored, and will get set onto the properties
271 * when the visual is next staged.
273 * @param[in] control The control
274 * @param[in] animation The Animation to add valid transitions to
275 * @param[in] transitionData The transition data describing the effect to create
277 DALI_TOOLKIT_API void AddTransitions( Internal::Control& control,
278 Dali::Animation animation,
279 const Toolkit::TransitionData& transitionData );
282 * @brief Create a transition effect on the control.
284 * Only generates an animation if the properties described in the transition
285 * data are staged (e.g. the visual is Enabled and the control is on stage).
286 * Otherwise the target values are stored, and will get set onto the properties
287 * when the visual is next staged.
289 * @param[in] control The control
290 * @param[in] transitionData The transition data describing the effect to create
291 * @return A handle to an animation defined with the given effect, or an empty
292 * handle if no properties match.
294 DALI_TOOLKIT_API Dali::Animation CreateTransition( Internal::Control& control,
295 const Toolkit::TransitionData& transitionData );
298 * @brief Perform an action on a visual registered to this control.
300 * Visuals will have actions, this API is used to perform one of these actions with the given attributes.
302 * @param[in] control The control.
303 * @param[in] visualIndex The Property index of the visual.
304 * @param[in] actionId The action to perform. See Visual to find supported actions.
305 * @param[in] attributes Optional attributes for the action.
307 DALI_TOOLKIT_API void DoAction( Control& control, Dali::Property::Index visualIndex, Dali::Property::Index actionId, const Dali::Property::Value attributes );
310 * @brief Set input method context.
312 * @param[in] control The control.
313 * @param[in] inputMethodContext The input method context.
315 DALI_TOOLKIT_API void SetInputMethodContext( Internal::Control& control, InputMethodContext& inputMethodContext );
318 * @brief Visual Event signal type
320 using VisualEventSignalType = Signal< void ( Control, Dali::Property::Index, Dali::Property::Index ) >;
323 * @brief This signal is emitted when a visual has an event to notify.
325 * A callback of the following type may be connected:
327 * void YourCallbackName( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId );
329 * @return The signal to connect to
331 DALI_TOOLKIT_API VisualEventSignalType& VisualEventSignal( Control control );
334 * @brief The signal is emmited as a succession of "activate" signal send by accessibility client.
335 * @return The signal to connect to
337 DALI_TOOLKIT_API Toolkit::Control::AccessibilityActivateSignalType &AccessibilityActivateSignal( Toolkit::Control control );
340 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
341 * was placed in TTS queue but other text with higher priority prevented it from being read.
343 * @return The signal to connect to
345 DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingSkippedSignalType &AccessibilityReadingSkippedSignal( Toolkit::Control control );
348 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
349 * was placed in TTS queue and reading was started but other text with higher priority cancelled it.
351 * @return The signal to connect to
353 DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingCancelledSignalType &AccessibilityReadingCancelledSignal( Toolkit::Control control );
356 * @brief The signal is emmited when text send via Dali::Accessibility::Bridge::Say
357 * was fully read by TTS module.
359 * @return The signal to connect to
361 DALI_TOOLKIT_API Toolkit::Control::AccessibilityReadingStoppedSignalType &AccessibilityReadingStoppedSignal( Toolkit::Control control );
364 * @brief The signal is emmited when accessibility client asks for object's name.
366 * Connected callback should assign name to std::string call parameter.
367 * Accessibility name can be stored in two ways:
369 * ACCESSIBILITY_NAME property,
370 * Priority is as above. If none is used, default implementation is provided.
371 * @return [description]
373 DALI_TOOLKIT_API Toolkit::Control::AccessibilityGetNameSignalType &AccessibilityGetNameSignal( Toolkit::Control control );
376 * @brief The signal is emmited when accessibility client asks for object's description.
378 * Connected callback should assign description to std::string call parameter.
379 * Accessibility description can be stored in two ways:
381 * ACCESSIBILITY_DESCRIPTON property,
382 * Priority is as above. If none is used, default implementation is provided.
383 * @return signal handler
385 DALI_TOOLKIT_API Toolkit::Control::AccessibilityGetDescriptionSignalType &AccessibilityGetDescriptionSignal( Toolkit::Control control );
388 * @brief The signal is emitted when accessibility client call "DoGesture" method via IPC mechanism.
390 * This signal allows developers to serve incoming gesture in specific way.
391 * @return signal handler
393 DALI_TOOLKIT_API Toolkit::Control::AccessibilityDoGestureSignalType &AccessibilityDoGestureSignal( Toolkit::Control control );
396 * @brief The method allows connection with other actor with usage of concrete accessibility relation type.
398 * @param control object to append attribute to
399 * @param destination Actor object
400 * @param relation enumerated value describing relation
402 DALI_TOOLKIT_API void AppendAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation );
405 * @brief The method allows removing relation
407 * @param control object to append attribute to
408 * @param destination Actor object
409 * @param relation enumerated value describing relation
411 DALI_TOOLKIT_API void RemoveAccessibilityRelation( Dali::Actor control, Actor destination, Dali::Accessibility::RelationType relation );
414 * @brief The method returns collection accessibility addresses representing objects connected with current object
416 * @param control object to append attribute to
417 * @return std::vector, where index is casted value of Accessibility::RelationType and value is std::vector of type Accessibility::Address
419 DALI_TOOLKIT_API std::vector<std::vector<Accessibility::Address>> GetAccessibilityRelations( Dali::Actor control );
422 * @brief The method removes all previously appended relations
424 * @param control object to append attribute to
426 DALI_TOOLKIT_API void ClearAccessibilityRelations( Dali::Actor control );
429 * @brief The method allows to add or modify value matched with given key.
430 * Modification take place if key was previously set.
432 * @param control object to append attribute to
433 * @param key std::string value
434 * @param value std::string value
436 DALI_TOOLKIT_API void AppendAccessibilityAttribute( Dali::Actor control, const std::string& key, const std::string value );
439 * @brief The method erases key with its value from accessibility attributes
440 * @param control object to append attribute to
441 * @param key std::string value
443 DALI_TOOLKIT_API void RemoveAccessibilityAttribute( Dali::Actor control, const std::string& key );
446 * @brief The method clears accessibility attributes
448 * @param control object to append attribute to
450 DALI_TOOLKIT_API void ClearAccessibilityAttributes( Dali::Actor control );
453 * @brief The method inserts reading information of an accessible object into attributes
455 * @param control object to append attribute to
456 * @param types Reading information types
458 DALI_TOOLKIT_API void SetAccessibilityReadingInfoType( Dali::Actor control, const Dali::Accessibility::ReadingInfoTypes types );
461 * @brief The method returns reading information of an accessible object
463 * @param control object to append attribute to
464 * @return Reading information types
466 DALI_TOOLKIT_API Dali::Accessibility::ReadingInfoTypes GetAccessibilityReadingInfoType( Dali::Actor control );
469 * @brief The method erases highlight.
471 * @param control object to append attribute to
472 * @return bool value, false when it is not possible or something went wrong, at the other way true.
474 DALI_TOOLKIT_API bool ClearAccessibilityHighlight( Dali::Actor control );
477 * @brief The method grabs highlight.
479 * @param control object to append attribute to
480 * @return bool value, false when it is not possible or something went wrong, at the other way true.
482 DALI_TOOLKIT_API bool GrabAccessibilityHighlight( Dali::Actor control );
485 * @brief The metod presents bitset of control's states.
487 * @param control object to append attribute to
488 * @return Dali::Accessibility::States is vector of enumerated State.
490 DALI_TOOLKIT_API Dali::Accessibility::States GetAccessibilityStates( Dali::Actor control );
493 * @brief The method force sending notifications about current states to accessibility clients
495 * @param control object to append attribute to
496 * @param states mask with states expected to broadcast
497 * @param doRecursive flag pointing if notifications of children's state would be sent
499 DALI_TOOLKIT_API void NotifyAccessibilityStateChange( Dali::Actor control, Dali::Accessibility::States states, bool doRecursive );
502 * The method allows to set specific constructor for creating accessibility structure
504 * Thank to this method hierarchy of accessibility objects can be based on internal hierarchy of Actors.
505 * It prevents from necessity of keeping two trees synchronized.
506 * The method should be called inside constructors of all classes inheriting from Control.
508 * Possible usage can be as follows:
510 * SetAccessibilityConstructor( []( Dali::Actor actor ) {
511 return std::unique_ptr< Dali::Accessibility::Accessible >(
512 new AccessibleImpl( actor, Dali::Accessibility::Role::DIALOG, true ) );
516 * param constructor callback creating Accessible object
518 DALI_TOOLKIT_API void SetAccessibilityConstructor( Dali::Actor control, std::function<std::unique_ptr<Dali::Accessibility::Accessible>(Dali::Actor)> constructor);
521 * Returns accessibility object bound to actor, if any
523 * This method won't bound new accessibility object. Use Dali::Accessibility::Accessible::Get in that case.
525 DALI_TOOLKIT_API Dali::Accessibility::Accessible *GetBoundAccessibilityObject( Dali::Actor control );
527 } // namespace DevelControl
529 } // namespace Toolkit
533 #endif // DALI_TOOLKIT_CONTROL_DEVEL_H