From: Artur Świgoń Date: Fri, 3 Dec 2021 15:35:25 +0000 (+0100) Subject: [AT-SPI] Split accessibility-impl.h X-Git-Tag: submit/tizen/20211221.101644~2^2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F267453%2F5;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git [AT-SPI] Split accessibility-impl.h Every AT-SPI interface now resides in a separate header file. There are no major changes besides moving code between files and making necessary adjustments to #include statements. Change-Id: If693012e7babc63518d9d314d27e534497f7014b --- diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 802f5aa32..7d2da303c 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -272,6 +272,7 @@ SET( tizenadaptordevelapidir ${INCLUDE_DIR}/dali/devel-api ) SET( tizenadaptorintegrationapidir ${INCLUDE_DIR}/dali/integration-api/adaptor-framework ) SET( tizenadaptorframeworkpublicapidir ${tizenadaptorpublicapidir}/adaptor-framework ) SET( tizenadaptorframeworkdevelapidir ${tizenadaptordevelapidir}/adaptor-framework ) +SET( tizenatspiinterfacesdevelapidir ${tizenadaptordevelapidir}/atspi-interfaces ) SET( tizentextabstractiondevelapidir ${tizenadaptordevelapidir}/text-abstraction ) SET( tizenadaptordaliheaderdir ${INCLUDE_DIR}/dali ) SET( tizenwatchpublicapidir ${tizenadaptorpublicapidir}/watch ) @@ -285,6 +286,7 @@ INSTALL( FILES ${public_api_header_files} DESTINATION ${tizenadaptorpublicapidir INSTALL( FILES ${adaptor_integration_api_header_files} DESTINATION ${tizenadaptorintegrationapidir} ) INSTALL( FILES ${public_api_adaptor_framework_header_files} DESTINATION ${tizenadaptorframeworkpublicapidir} ) INSTALL( FILES ${devel_api_adaptor_framework_header_files} DESTINATION ${tizenadaptorframeworkdevelapidir} ) +INSTALL( FILES ${devel_api_atspi_interfaces_header_files} DESTINATION ${tizenatspiinterfacesdevelapidir} ) INSTALL( FILES ${text_abstraction_header_files} DESTINATION ${tizentextabstractiondevelapidir} ) # Install Android framework headers for Android build diff --git a/dali/devel-api/adaptor-framework/accessibility-bridge.h b/dali/devel-api/adaptor-framework/accessibility-bridge.h new file mode 100644 index 000000000..90f9fb5d0 --- /dev/null +++ b/dali/devel-api/adaptor-framework/accessibility-bridge.h @@ -0,0 +1,463 @@ +#ifndef DALI_ADAPTOR_ACCESSIBILITY_BRIDGE_H +#define DALI_ADAPTOR_ACCESSIBILITY_BRIDGE_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali +{ +namespace Accessibility +{ +class Accessible; + +/** + * @brief Base class for different accessibility bridges. + * + * Bridge is resposible for initializing and managing connection on accessibility bus. + * Accessibility clients will not get any information about UI without initialized and upraised bridge. + * Concrete implementation depends on the accessibility technology available on the platform. + * + * @note This class is singleton. + */ +struct DALI_ADAPTOR_API Bridge +{ + enum class ForceUpResult + { + JUST_STARTED, + ALREADY_UP + }; + + /** + * @brief Destructor + */ + virtual ~Bridge() = default; + + /** + * @brief Gets bus name which bridge is initialized on. + * + * @return The bus name + */ + virtual const std::string& GetBusName() const = 0; + + /** + * @brief Registers top level window. + * + * Hierarchy of objects visible for accessibility clients is based on tree-like + * structure created from Actors objects. This method allows to connect chosen + * object as direct ancestor of application and therefore make it visible for + * accessibility clients. + * + * @param[in] object The accessible object + */ + virtual void AddTopLevelWindow(Accessible* object) = 0; + + /** + * @brief Removes top level window. + * + * Hierarchy of objects visible for accessibility clients is based on tree-like + * structure created from Actors objects. This method removes previously added + * window from visible accessibility objects. + * + * @param[in] object The accessible object + */ + virtual void RemoveTopLevelWindow(Accessible* object) = 0; + + /** + * @brief Adds object on the top of the stack of "default label" sourcing objects. + * + * @see GetDefaultLabel + * + * @param[in] object The accessible object + */ + virtual void RegisterDefaultLabel(Accessible* object) = 0; + + /** + * @brief Removes object from the stack of "default label" sourcing objects. + * + * @see GetDefaultLabel + * + * @param[in] object The accessible object + */ + virtual void UnregisterDefaultLabel(Accessible* object) = 0; + + /** + * @brief Gets the top-most object from the stack of "default label" sourcing objects. + * + * The "default label" is a reading material (text) derived from an accesibility object + * that could be read by screen-reader immediately after the navigation context has changed + * (window activates, popup shows up, tab changes) and before first UI element is highlighted. + * + * @return The handler to accessibility object + * @note This is a Tizen only feature not present in upstream ATSPI. + * Feature can be enabled/disabled for particular context root object + * by setting value of its accessibility attribute "default_label". + * Following strings are valid values for "default_label" attribute: "enabled", "disabled". + * Any other value will be interpreted as "enabled". + */ + virtual Accessible* GetDefaultLabel() const = 0; + + /** + * @brief Sets name of current application which will be visible on accessibility bus. + * + * @param[in] name The application name + */ + virtual void SetApplicationName(std::string name) = 0; + + /** + * @brief Gets object being root of accessibility tree. + * + * @return handler to accessibility object + */ + virtual Accessible* GetApplication() const = 0; + + /** + * @brief Finds an object in accessibility tree. + * + * @param[in] path The path to object + * + * @return The handler to accessibility object + */ + virtual Accessible* FindByPath(const std::string& path) const = 0; + + /** + * @brief Notifies accessibility dbus that window has just been shown. + * + * @param[in] window The window to be shown + */ + virtual void WindowShown(Window window) = 0; + + /** + * @brief Notifies accessibility dbus that window has just been hidden. + * + * @param[in] window The window to be hidden + */ + virtual void WindowHidden(Window window) = 0; + + /** + * @brief Notifies accessibility dbus that window has just been focused. + * + * @param[in] window The window to be focused + */ + virtual void WindowFocused(Window window) = 0; + + /** + * @brief Notifies accessibility dbus that window has just been out of focus. + * + * @param[in] window The window to be out of focus + */ + virtual void WindowUnfocused(Window window) = 0; + + /** + * @brief Initializes accessibility bus. + */ + virtual void Initialize() = 0; + + /** + * @brief Terminates accessibility bus. + */ + virtual void Terminate() = 0; + + /** + * @brief This method is called, when bridge is being activated. + */ + virtual ForceUpResult ForceUp() + { + if(mData) + { + return ForceUpResult::ALREADY_UP; + } + mData = std::make_shared(); + mData->mBridge = this; + return ForceUpResult::JUST_STARTED; + } + + /** + * @brief This method is called, when bridge is being deactivated. + */ + virtual void ForceDown() = 0; + + /** + * @brief Checks if bridge is activated or not. + * @return True if brige is activated. + */ + bool IsUp() const + { + return bool(mData); + } + + /** + * @brief Emits cursor-moved event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] cursorPosition The new cursor position + **/ + virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0; + + /** + * @brief Emits active-descendant-changed event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] child The child of the object + **/ + virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0; + + /** + * @brief Emits text-changed event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] state The changed state for text, such as Inserted or Deleted + * @param[in] position The cursor position + * @param[in] length The text length + * @param[in] content The changed text + **/ + virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0; + + /** + * @brief Emits MoveOuted event on at-spi bus. + * + * @param[in] obj Accessible object + * @param[in] type Direction type when an Accessible object moves out of screen + **/ + virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0; + + /** + * @brief Emits state-changed event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc) + * @param[in] newValue Whether the state value is changed to new value or not. + * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali) + **/ + virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0; + + /** + * @brief Emits window event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] event The enumerated window event + * @param[in] detail The additional parameter which interpretation depends on chosen event + **/ + virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0; + + /** + * @brief Emits property-changed event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] event Property changed event + **/ + virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0; + + /** + * @brief Emits bounds-changed event on at-spi bus. + * + * @param[in] obj The accessible object + * @param[in] rect The rectangle for changed bounds + **/ + virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0; + + /** + * @brief Emits key event on at-spi bus. + * + * Screen-reader might receive this event and reply, that given keycode is consumed. In that case + * further processing of the keycode should be ignored. + * + * @param[in] type Key event type + * @param[in] keyCode Key code + * @param[in] keyName Key name + * @param[in] timeStamp Time stamp + * @param[in] isText Whether it's text or not + * @return Whether this event is consumed or not + **/ + virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0; + + /** + * @brief Reads given text by screen reader + * + * @param[in] text The text to read + * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests, + * if FALSE the reading must finish before next reading request can be started + * @param[in] callback the callback function that is called on reading signals emitted + * during processing of this reading request. + * Callback can be one of the following signals: + * ReadingCancelled, ReadingStopped, ReadingSkipped + */ + virtual void Say(const std::string& text, bool discardable, std::function callback) = 0; + + /** + * @brief Force accessibility client to pause. + */ + virtual void Pause() = 0; + + /** + * @brief Force accessibility client to resume. + */ + virtual void Resume() = 0; + + /** + * @brief Cancels anything screen-reader is reading / has queued to read + * + * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well + */ + virtual void StopReading(bool alsoNonDiscardable) = 0; + + /** + * @brief Suppresses reading of screen-reader + * + * @param[in] suppress whether to suppress reading of screen-reader + */ + virtual void SuppressScreenReader(bool suppress) = 0; + + /** + * @brief Gets screen reader status. + * + * @return True if screen reader is enabled + */ + virtual bool GetScreenReaderEnabled() = 0; + + /** + * @brief Gets ATSPI status. + * + * @return True if ATSPI is enabled + */ + virtual bool IsEnabled() = 0; + + /** + * @brief Returns instance of bridge singleton object. + * + * @return The current bridge object + **/ + static Bridge* GetCurrentBridge(); + + /** + * @brief Blocks auto-initialization of AT-SPI bridge + * + * Use this only if your application starts before DBus does, and call it early in main() + * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an + * instance of DummyBridge. + * + * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still + * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an + * environment variable, or if creating the real bridge failed. + * + * @see Dali::Accessibility::DummyBridge + * @see Dali::Accessibility::Bridge::EnableAutoInit + */ + static void DisableAutoInit(); + + /** + * @brief Re-enables auto-initialization of AT-SPI bridge + * + * Normal applications do not have to call this function. GetCurrentBridge() tries to + * initialize the AT-SPI bridge when it is called for the first time. + * + * @see Dali::Accessibility::Bridge::DisableAutoInit + * @see Dali::Accessibility::Bridge::AddTopLevelWindow + * @see Dali::Accessibility::Bridge::SetApplicationName + */ + static void EnableAutoInit(); + + static Signal& EnabledSignal() + { + return mEnabledSignal; + } + + static Signal& DisabledSignal() + { + return mDisabledSignal; + } + +protected: + struct Data + { + std::unordered_set mKnownObjects; + std::string mBusName; + Bridge* mBridge = nullptr; + Actor mHighlightActor; + Actor mCurrentlyHighlightedActor; + }; + std::shared_ptr mData; + friend class Accessible; + + enum class AutoInitState + { + DISABLED, + ENABLED + }; + + inline static AutoInitState mAutoInitState = AutoInitState::ENABLED; + + inline static Signal mEnabledSignal; + inline static Signal mDisabledSignal; + + /** + * @brief Registers accessible object to be known in bridge object. + * + * Bridge must known about all currently alive accessible objects, as some requst + * might come and object will be identified by number id (it's memory address). + * To avoid memory corruption number id is checked against set of known objects. + * + * @param[in] object The accessible object + **/ + void RegisterOnBridge(Accessible* object); + + /** + * @brief Tells bridge, that given object is considered root (doesn't have any parents). + * + * All root objects will have the same parent - application object. Application object + * is controlled by bridge and private. + * + * @param[in] owner The accessible object + **/ + void SetIsOnRootLevel(Accessible* owner); +}; + +/** + * @brief Checks if ATSPI is activated or not. + * @return True if ATSPI is activated. + */ +inline bool IsUp() +{ + if(Bridge::GetCurrentBridge() == nullptr) + { + return false; + } + + if(Bridge::GetCurrentBridge()->IsEnabled() == false) + { + return false; + } + + return Bridge::GetCurrentBridge()->IsUp(); +} + +} // namespace Accessibility +} // namespace Dali + +#endif // DALI_ADAPTOR_ACCESSIBILITY_BRIDGE_H diff --git a/dali/devel-api/adaptor-framework/accessibility-impl.cpp b/dali/devel-api/adaptor-framework/accessibility-impl.cpp deleted file mode 100644 index 774915f4e..000000000 --- a/dali/devel-api/adaptor-framework/accessibility-impl.cpp +++ /dev/null @@ -1,829 +0,0 @@ -/* - * Copyright 2020 Samsung Electronics Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// CLASS HEADER - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include - -// INTERNAL INCLUDES -#include -#include -#include -#include - -using namespace Dali::Accessibility; -using namespace Dali; - -const std::string& Dali::Accessibility::Address::GetBus() const -{ - return mBus.empty() && Bridge::GetCurrentBridge() ? Bridge::GetCurrentBridge()->GetBusName() : mBus; -} - -std::string EmptyAccessibleWithAddress::GetRoleName() -{ - return ""; -} - -std::string Accessible::GetLocalizedRoleName() -{ - return GetRoleName(); -} - -std::string Accessible::GetRoleName() -{ - switch(GetRole()) - { - case Role::INVALID: - { - return "invalid"; - } - case Role::ACCELERATOR_LABEL: - { - return "accelerator label"; - } - case Role::ALERT: - { - return "alert"; - } - case Role::ANIMATION: - { - return "animation"; - } - case Role::ARROW: - { - return "arrow"; - } - case Role::CALENDAR: - { - return "calendar"; - } - case Role::CANVAS: - { - return "canvas"; - } - case Role::CHECK_BOX: - { - return "check box"; - } - case Role::CHECK_MENU_ITEM: - { - return "check menu item"; - } - case Role::COLOR_CHOOSER: - { - return "color chooser"; - } - case Role::COLUMN_HEADER: - { - return "column header"; - } - case Role::COMBO_BOX: - { - return "combo box"; - } - case Role::DATE_EDITOR: - { - return "date editor"; - } - case Role::DESKTOP_ICON: - { - return "desktop icon"; - } - case Role::DESKTOP_FRAME: - { - return "desktop frame"; - } - case Role::DIAL: - { - return "dial"; - } - case Role::DIALOG: - { - return "dialog"; - } - case Role::DIRECTORY_PANE: - { - return "directory pane"; - } - case Role::DRAWING_AREA: - { - return "drawing area"; - } - case Role::FILE_CHOOSER: - { - return "file chooser"; - } - case Role::FILLER: - { - return "filler"; - } - case Role::FOCUS_TRAVERSABLE: - { - return "focus traversable"; - } - case Role::FONT_CHOOSER: - { - return "font chooser"; - } - case Role::FRAME: - { - return "frame"; - } - case Role::GLASS_PANE: - { - return "glass pane"; - } - case Role::HTML_CONTAINER: - { - return "html container"; - } - case Role::ICON: - { - return "icon"; - } - case Role::IMAGE: - { - return "image"; - } - case Role::INTERNAL_FRAME: - { - return "internal frame"; - } - case Role::LABEL: - { - return "label"; - } - case Role::LAYERED_PANE: - { - return "layered pane"; - } - case Role::LIST: - { - return "list"; - } - case Role::LIST_ITEM: - { - return "list item"; - } - case Role::MENU: - { - return "menu"; - } - case Role::MENU_BAR: - { - return "menu bar"; - } - case Role::MENU_ITEM: - { - return "menu item"; - } - case Role::OPTION_PANE: - { - return "option pane"; - } - case Role::PAGE_TAB: - { - return "page tab"; - } - case Role::PAGE_TAB_LIST: - { - return "page tab list"; - } - case Role::PANEL: - { - return "panel"; - } - case Role::PASSWORD_TEXT: - { - return "password text"; - } - case Role::POPUP_MENU: - { - return "popup menu"; - } - case Role::PROGRESS_BAR: - { - return "progress bar"; - } - case Role::PUSH_BUTTON: - { - return "push button"; - } - case Role::RADIO_BUTTON: - { - return "radio button"; - } - case Role::RADIO_MENU_ITEM: - { - return "radio menu item"; - } - case Role::ROOT_PANE: - { - return "root pane"; - } - case Role::ROW_HEADER: - { - return "row header"; - } - case Role::SCROLL_BAR: - { - return "scroll bar"; - } - case Role::SCROLL_PANE: - { - return "scroll pane"; - } - case Role::SEPARATOR: - { - return "separator"; - } - case Role::SLIDER: - { - return "slider"; - } - case Role::SPIN_BUTTON: - { - return "spin button"; - } - case Role::SPLIT_PANE: - { - return "split pane"; - } - case Role::STATUS_BAR: - { - return "status bar"; - } - case Role::TABLE: - { - return "table"; - } - case Role::TABLE_CELL: - { - return "table cell"; - } - case Role::TABLE_COLUMN_HEADER: - { - return "table column header"; - } - case Role::TABLE_ROW_HEADER: - { - return "table row header"; - } - case Role::TEAROFF_MENU_ITEM: - { - return "tearoff menu item"; - } - case Role::TERMINAL: - { - return "terminal"; - } - case Role::TEXT: - { - return "text"; - } - case Role::TOGGLE_BUTTON: - { - return "toggle button"; - } - case Role::TOOL_BAR: - { - return "tool bar"; - } - case Role::TOOL_TIP: - { - return "tool tip"; - } - case Role::TREE: - { - return "tree"; - } - case Role::TREE_TABLE: - { - return "tree table"; - } - case Role::UNKNOWN: - { - return "unknown"; - } - case Role::VIEWPORT: - { - return "viewport"; - } - case Role::WINDOW: - { - return "window"; - } - case Role::EXTENDED: - { - return "extended"; - } - case Role::HEADER: - { - return "header"; - } - case Role::FOOTER: - { - return "footer"; - } - case Role::PARAGRAPH: - { - return "paragraph"; - } - case Role::RULER: - { - return "ruler"; - } - case Role::APPLICATION: - { - return "application"; - } - case Role::AUTOCOMPLETE: - { - return "autocomplete"; - } - case Role::EDITBAR: - { - return "edit bar"; - } - case Role::EMBEDDED: - { - return "embedded"; - } - case Role::ENTRY: - { - return "entry"; - } - case Role::CHART: - { - return "chart"; - } - case Role::CAPTION: - { - return "caution"; - } - case Role::DOCUMENT_FRAME: - { - return "document frame"; - } - case Role::HEADING: - { - return "heading"; - } - case Role::PAGE: - { - return "page"; - } - case Role::SECTION: - { - return "section"; - } - case Role::REDUNDANT_OBJECT: - { - return "redundant object"; - } - case Role::FORM: - { - return "form"; - } - case Role::LINK: - { - return "link"; - } - case Role::INPUT_METHOD_WINDOW: - { - return "input method window"; - } - case Role::TABLE_ROW: - { - return "table row"; - } - case Role::TREE_ITEM: - { - return "tree item"; - } - case Role::DOCUMENT_SPREADSHEET: - { - return "document spreadsheet"; - } - case Role::DOCUMENT_PRESENTATION: - { - return "document presentation"; - } - case Role::DOCUMENT_TEXT: - { - return "document text"; - } - case Role::DOCUMENT_WEB: - { - return "document web"; - } - case Role::DOCUMENT_EMAIL: - { - return "document email"; - } - case Role::COMMENT: - { - return "comment"; - } - case Role::LIST_BOX: - { - return "list box"; - } - case Role::GROUPING: - { - return "grouping"; - } - case Role::IMAGE_MAP: - { - return "image map"; - } - case Role::NOTIFICATION: - { - return "notification"; - } - case Role::INFO_BAR: - { - return "info bar"; - } - case Role::LEVEL_BAR: - { - return "level bar"; - } - case Role::TITLE_BAR: - { - return "title bar"; - } - case Role::BLOCK_QUOTE: - { - return "block quote"; - } - case Role::AUDIO: - { - return "audio"; - } - case Role::VIDEO: - { - return "video"; - } - case Role::DEFINITION: - { - return "definition"; - } - case Role::ARTICLE: - { - return "article"; - } - case Role::LANDMARK: - { - return "landmark"; - } - case Role::LOG: - { - return "log"; - } - case Role::MARQUEE: - { - return "marquee"; - } - case Role::MATH: - { - return "math"; - } - case Role::RATING: - { - return "rating"; - } - case Role::TIMER: - { - return "timer"; - } - case Role::STATIC: - { - return "static"; - } - case Role::MATH_FRACTION: - { - return "math fraction"; - } - case Role::MATH_ROOT: - { - return "math root"; - } - case Role::SUBSCRIPT: - { - return "subscript"; - } - case Role::SUPERSCRIPT: - { - return "superscript"; - } - case Role::MAX_COUNT: - { - break; - } - } - return ""; -} - -Dali::Actor Accessible::GetCurrentlyHighlightedActor() -{ - return IsUp() ? Bridge::GetCurrentBridge()->mData->mCurrentlyHighlightedActor : Dali::Actor{}; -} - -void Accessible::SetCurrentlyHighlightedActor(Dali::Actor actor) -{ - if(IsUp()) - { - Bridge::GetCurrentBridge()->mData->mCurrentlyHighlightedActor = actor; - } -} - -Dali::Actor Accessible::GetHighlightActor() -{ - return IsUp() ? Bridge::GetCurrentBridge()->mData->mHighlightActor : Dali::Actor{}; -} - -void Accessible::SetHighlightActor(Dali::Actor actor) -{ - if(IsUp()) - { - Bridge::GetCurrentBridge()->mData->mHighlightActor = actor; - } -} - -void Bridge::ForceDown() -{ - auto highlighted = Accessible::GetCurrentlyHighlightedActor(); - if(highlighted) - { - auto component = dynamic_cast(Accessible::Get(highlighted)); - if(component) - { - component->ClearHighlight(); - } - } - mData = {}; -} - -void Bridge::SetIsOnRootLevel(Accessible* owner) -{ - owner->mIsOnRootLevel = true; -} - -namespace -{ -class AdaptorAccessible : public virtual Accessible, public virtual Collection, public virtual Component -{ -protected: - Dali::WeakHandle mSelf; - bool mRoot = false; - - Dali::Actor Self() - { - auto handle = mSelf.GetHandle(); - - // AdaptorAccessible is deleted on ObjectDestroyedSignal - // for the respective actor (see `nonControlAccessibles`). - DALI_ASSERT_ALWAYS(handle); - - return handle; - } - -public: - AdaptorAccessible(Dali::Actor actor, bool isRoot) - : mSelf(actor), - mRoot(isRoot) - { - } - - Dali::Rect<> GetExtents(Dali::Accessibility::CoordinateType type) override - { - Dali::Actor actor = Self(); - Vector2 screenPosition = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get(); - Vector3 size = actor.GetCurrentProperty(Actor::Property::SIZE) * actor.GetCurrentProperty(Actor::Property::WORLD_SCALE); - bool positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get(); - Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); - Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y); - - if(type == Dali::Accessibility::CoordinateType::WINDOW) - { - return {position.x, position.y, size.x, size.y}; - } - else // Dali::Accessibility::CoordinateType::SCREEN - { - auto window = Dali::DevelWindow::Get(actor); - auto windowPosition = window.GetPosition(); - return {position.x + windowPosition.GetX(), position.y + windowPosition.GetY(), size.x, size.y}; - } - } - - Dali::Accessibility::ComponentLayer GetLayer() override - { - return Dali::Accessibility::ComponentLayer::WINDOW; - } - - int16_t GetMdiZOrder() override - { - return 0; - } - - double GetAlpha() override - { - return 0; - } - - bool GrabFocus() override - { - return false; - } - - bool GrabHighlight() override - { - return false; - } - - bool ClearHighlight() override - { - return false; - } - - bool IsScrollable() override - { - return false; - } - - std::string GetName() override - { - return Self().GetProperty(Dali::Actor::Property::NAME); - } - - std::string GetDescription() override - { - return ""; - } - - Accessible* GetParent() override - { - if(IsOnRootLevel()) - { - auto data = GetBridgeData(); - return data->mBridge->GetApplication(); - } - return Get(Self().GetParent()); - } - - size_t GetChildCount() override - { - return static_cast(Self().GetChildCount()); - } - - Accessible* GetChildAtIndex(size_t index) override - { - auto numberOfChildren = static_cast(Self().GetChildCount()); - if(index >= numberOfChildren) - { - throw std::domain_error{"invalid index " + std::to_string(index) + " for object with " + std::to_string(numberOfChildren) + " children"}; - } - return Get(Self().GetChildAt(static_cast(index))); - } - - size_t GetIndexInParent() override - { - auto parent = Self().GetParent(); - if(!parent) - { - return 0; - } - auto size = static_cast(parent.GetChildCount()); - for(auto i = 0u; i < size; ++i) - { - if(parent.GetChildAt(i) == Self()) - { - return i; - } - } - throw std::domain_error{"actor is not a child of it's parent"}; - } - - Role GetRole() override - { - return mRoot ? Role::WINDOW : Role::REDUNDANT_OBJECT; - } - - States GetStates() override - { - States state; - if(mRoot) - { - auto window = Dali::DevelWindow::Get(Self()); - auto visible = window.IsVisible(); - state[State::ENABLED] = true; - state[State::SENSITIVE] = true; - state[State::SHOWING] = visible; - state[State::VISIBLE] = true; - state[State::ACTIVE] = visible; - } - else - { - auto parentState = GetParent()->GetStates(); - state[State::SHOWING] = parentState[State::SHOWING]; - state[State::VISIBLE] = parentState[State::VISIBLE]; - } - return state; - } - - Attributes GetAttributes() override - { - Dali::TypeInfo type; - Self().GetTypeInfo(type); - return - { - {"class", type.GetName()}, - }; - } - - bool DoGesture(const GestureInfo& gestureInfo) override - { - return false; - } - - std::vector GetRelationSet() override - { - return {}; - } - - Dali::Actor GetInternalActor() override - { - return mSelf.GetHandle(); - } -}; // AdaptorAccessible - -using AdaptorAccessiblesType = std::unordered_map >; - -// Save RefObject from an Actor in Accessible::Get() -AdaptorAccessiblesType gAdaptorAccessibles; - -std::function convertingFunctor = [](Dali::Actor) -> Accessible* { - return nullptr; -}; - -ObjectRegistry objectRegistry; -} // namespace - -void Accessible::SetObjectRegistry(ObjectRegistry registry) -{ - objectRegistry = registry; -} - -void Accessible::RegisterExternalAccessibleGetter(std::function functor) -{ - convertingFunctor = functor; -} - -Accessible* Accessible::Get(Dali::Actor actor, bool isRoot) -{ - if(!actor) - { - return nullptr; - } - - auto accessible = convertingFunctor(actor); - if(!accessible) - { - if(gAdaptorAccessibles.empty() && objectRegistry) - { - objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) { - gAdaptorAccessibles.erase(obj); - }); - } - auto pair = gAdaptorAccessibles.emplace(&actor.GetBaseObject(), nullptr); - if(pair.second) - { - pair.first->second.reset(new AdaptorAccessible(actor, isRoot)); - } - accessible = pair.first->second.get(); - } - - return accessible; -} diff --git a/dali/devel-api/adaptor-framework/accessibility-impl.h b/dali/devel-api/adaptor-framework/accessibility-impl.h deleted file mode 100644 index 57d6fdee7..000000000 --- a/dali/devel-api/adaptor-framework/accessibility-impl.h +++ /dev/null @@ -1,1535 +0,0 @@ -#ifndef DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H -#define DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H - -/* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -// EXTERNAL INCLUDES -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//INTERNAL INCLUDES -#include -#include -#include - -namespace Dali -{ -namespace Accessibility -{ -class DALI_ADAPTOR_API Accessible; -class DALI_ADAPTOR_API Text; -class DALI_ADAPTOR_API Value; -class DALI_ADAPTOR_API Component; -class DALI_ADAPTOR_API Collection; -class DALI_ADAPTOR_API Action; -class DALI_ADAPTOR_API Application; -class DALI_ADAPTOR_API Hypertext; -class DALI_ADAPTOR_API Hyperlink; - -/** - * @brief Base class for different accessibility bridges. - * - * Bridge is resposible for initializing and managing connection on accessibility bus. - * Accessibility clients will not get any information about UI without initialized and upraised bridge. - * Concrete implementation depends on the accessibility technology available on the platform. - * - * @note This class is singleton. - */ -struct DALI_ADAPTOR_API Bridge -{ - enum class ForceUpResult - { - JUST_STARTED, - ALREADY_UP - }; - - /** - * @brief Destructor - */ - virtual ~Bridge() = default; - - /** - * @brief Gets bus name which bridge is initialized on. - * - * @return The bus name - */ - virtual const std::string& GetBusName() const = 0; - - /** - * @brief Registers top level window. - * - * Hierarchy of objects visible for accessibility clients is based on tree-like - * structure created from Actors objects. This method allows to connect chosen - * object as direct ancestor of application and therefore make it visible for - * accessibility clients. - * - * @param[in] object The accessible object - */ - virtual void AddTopLevelWindow(Accessible* object) = 0; - - /** - * @brief Removes top level window. - * - * Hierarchy of objects visible for accessibility clients is based on tree-like - * structure created from Actors objects. This method removes previously added - * window from visible accessibility objects. - * - * @param[in] object The accessible object - */ - virtual void RemoveTopLevelWindow(Accessible* object) = 0; - - /** - * @brief Adds object on the top of the stack of "default label" sourcing objects. - * - * @see GetDefaultLabel - * - * @param[in] object The accessible object - */ - virtual void RegisterDefaultLabel(Accessible* object) = 0; - - /** - * @brief Removes object from the stack of "default label" sourcing objects. - * - * @see GetDefaultLabel - * - * @param[in] object The accessible object - */ - virtual void UnregisterDefaultLabel(Accessible* object) = 0; - - /** - * @brief Gets the top-most object from the stack of "default label" sourcing objects. - * - * The "default label" is a reading material (text) derived from an accesibility object - * that could be read by screen-reader immediately after the navigation context has changed - * (window activates, popup shows up, tab changes) and before first UI element is highlighted. - * - * @return The handler to accessibility object - * @note This is a Tizen only feature not present in upstream ATSPI. - * Feature can be enabled/disabled for particular context root object - * by setting value of its accessibility attribute "default_label". - * Following strings are valid values for "default_label" attribute: "enabled", "disabled". - * Any other value will be interpreted as "enabled". - */ - virtual Accessible* GetDefaultLabel() const = 0; - - /** - * @brief Sets name of current application which will be visible on accessibility bus. - * - * @param[in] name The application name - */ - virtual void SetApplicationName(std::string name) = 0; - - /** - * @brief Gets object being root of accessibility tree. - * - * @return handler to accessibility object - */ - virtual Accessible* GetApplication() const = 0; - - /** - * @brief Finds an object in accessibility tree. - * - * @param[in] path The path to object - * - * @return The handler to accessibility object - */ - virtual Accessible* FindByPath(const std::string& path) const = 0; - - /** - * @brief Notifies accessibility dbus that window has just been shown. - * - * @param[in] window The window to be shown - */ - virtual void WindowShown(Window window) = 0; - - /** - * @brief Notifies accessibility dbus that window has just been hidden. - * - * @param[in] window The window to be hidden - */ - virtual void WindowHidden(Window window) = 0; - - /** - * @brief Notifies accessibility dbus that window has just been focused. - * - * @param[in] window The window to be focused - */ - virtual void WindowFocused(Window window) = 0; - - /** - * @brief Notifies accessibility dbus that window has just been out of focus. - * - * @param[in] window The window to be out of focus - */ - virtual void WindowUnfocused(Window window) = 0; - - /** - * @brief Initializes accessibility bus. - */ - virtual void Initialize() = 0; - - /** - * @brief Terminates accessibility bus. - */ - virtual void Terminate() = 0; - - /** - * @brief This method is called, when bridge is being activated. - */ - virtual ForceUpResult ForceUp() - { - if(mData) - { - return ForceUpResult::ALREADY_UP; - } - mData = std::make_shared(); - mData->mBridge = this; - return ForceUpResult::JUST_STARTED; - } - - /** - * @brief This method is called, when bridge is being deactivated. - */ - virtual void ForceDown() = 0; - - /** - * @brief Checks if bridge is activated or not. - * @return True if brige is activated. - */ - bool IsUp() const - { - return bool(mData); - } - - /** - * @brief Emits cursor-moved event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] cursorPosition The new cursor position - **/ - virtual void EmitCursorMoved(Accessible* obj, unsigned int cursorPosition) = 0; - - /** - * @brief Emits active-descendant-changed event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] child The child of the object - **/ - virtual void EmitActiveDescendantChanged(Accessible* obj, Accessible* child) = 0; - - /** - * @brief Emits text-changed event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] state The changed state for text, such as Inserted or Deleted - * @param[in] position The cursor position - * @param[in] length The text length - * @param[in] content The changed text - **/ - virtual void EmitTextChanged(Accessible* obj, TextChangedState state, unsigned int position, unsigned int length, const std::string& content) = 0; - - /** - * @brief Emits MoveOuted event on at-spi bus. - * - * @param[in] obj Accessible object - * @param[in] type Direction type when an Accessible object moves out of screen - **/ - virtual void EmitMovedOutOfScreen(Accessible* obj, ScreenRelativeMoveType type) = 0; - - /** - * @brief Emits state-changed event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc) - * @param[in] newValue Whether the state value is changed to new value or not. - * @param[in] reserved Reserved. (Currently, this argument is not implemented in dali) - **/ - virtual void EmitStateChanged(Accessible* obj, State state, int newValue, int reserved = 0) = 0; - - /** - * @brief Emits window event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] event The enumerated window event - * @param[in] detail The additional parameter which interpretation depends on chosen event - **/ - virtual void Emit(Accessible* obj, WindowEvent event, unsigned int detail = 0) = 0; - - /** - * @brief Emits property-changed event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] event Property changed event - **/ - virtual void Emit(Accessible* obj, ObjectPropertyChangeEvent event) = 0; - - /** - * @brief Emits bounds-changed event on at-spi bus. - * - * @param[in] obj The accessible object - * @param[in] rect The rectangle for changed bounds - **/ - virtual void EmitBoundsChanged(Accessible* obj, Rect<> rect) = 0; - - /** - * @brief Emits key event on at-spi bus. - * - * Screen-reader might receive this event and reply, that given keycode is consumed. In that case - * further processing of the keycode should be ignored. - * - * @param[in] type Key event type - * @param[in] keyCode Key code - * @param[in] keyName Key name - * @param[in] timeStamp Time stamp - * @param[in] isText Whether it's text or not - * @return Whether this event is consumed or not - **/ - virtual Consumed Emit(KeyEventType type, unsigned int keyCode, const std::string& keyName, unsigned int timeStamp, bool isText) = 0; - - /** - * @brief Reads given text by screen reader - * - * @param[in] text The text to read - * @param[in] discardable If TRUE, reading can be discarded by subsequent reading requests, - * if FALSE the reading must finish before next reading request can be started - * @param[in] callback the callback function that is called on reading signals emitted - * during processing of this reading request. - * Callback can be one of the following signals: - * ReadingCancelled, ReadingStopped, ReadingSkipped - */ - virtual void Say(const std::string& text, bool discardable, std::function callback) = 0; - - /** - * @brief Force accessibility client to pause. - */ - virtual void Pause() = 0; - - /** - * @brief Force accessibility client to resume. - */ - virtual void Resume() = 0; - - /** - * @brief Cancels anything screen-reader is reading / has queued to read - * - * @param[in] alsoNonDiscardable whether to cancel non-discardable readings as well - */ - virtual void StopReading(bool alsoNonDiscardable) = 0; - - /** - * @brief Suppresses reading of screen-reader - * - * @param[in] suppress whether to suppress reading of screen-reader - */ - virtual void SuppressScreenReader(bool suppress) = 0; - - /** - * @brief Gets screen reader status. - * - * @return True if screen reader is enabled - */ - virtual bool GetScreenReaderEnabled() = 0; - - /** - * @brief Gets ATSPI status. - * - * @return True if ATSPI is enabled - */ - virtual bool IsEnabled() = 0; - - /** - * @brief Returns instance of bridge singleton object. - * - * @return The current bridge object - **/ - static Bridge* GetCurrentBridge(); - - /** - * @brief Blocks auto-initialization of AT-SPI bridge - * - * Use this only if your application starts before DBus does, and call it early in main() - * (before GetCurrentBridge() is called by anyone). GetCurrentBridge() will then return an - * instance of DummyBridge. - * - * When DBus is ready, call EnableAutoInit(). Please note that GetCurrentBridge() may still - * return an instance of DummyBridge if AT-SPI was disabled at compile time or using an - * environment variable, or if creating the real bridge failed. - * - * @see Dali::Accessibility::DummyBridge - * @see Dali::Accessibility::Bridge::EnableAutoInit - */ - static void DisableAutoInit(); - - /** - * @brief Re-enables auto-initialization of AT-SPI bridge - * - * Normal applications do not have to call this function. GetCurrentBridge() tries to - * initialize the AT-SPI bridge when it is called for the first time. - * - * @see Dali::Accessibility::Bridge::DisableAutoInit - * @see Dali::Accessibility::Bridge::AddTopLevelWindow - * @see Dali::Accessibility::Bridge::SetApplicationName - */ - static void EnableAutoInit(); - - static Signal& EnabledSignal() - { - return mEnabledSignal; - } - - static Signal& DisabledSignal() - { - return mDisabledSignal; - } - -protected: - struct Data - { - std::unordered_set mKnownObjects; - std::string mBusName; - Bridge* mBridge = nullptr; - Actor mHighlightActor; - Actor mCurrentlyHighlightedActor; - }; - std::shared_ptr mData; - friend class Accessible; - - enum class AutoInitState - { - DISABLED, - ENABLED - }; - - inline static AutoInitState mAutoInitState = AutoInitState::ENABLED; - - inline static Signal mEnabledSignal; - inline static Signal mDisabledSignal; - - /** - * @brief Registers accessible object to be known in bridge object. - * - * Bridge must known about all currently alive accessible objects, as some requst - * might come and object will be identified by number id (it's memory address). - * To avoid memory corruption number id is checked against set of known objects. - * - * @param[in] object The accessible object - **/ - void RegisterOnBridge(Accessible* object); - - /** - * @brief Tells bridge, that given object is considered root (doesn't have any parents). - * - * All root objects will have the same parent - application object. Application object - * is controlled by bridge and private. - * - * @param[in] owner The accessible object - **/ - void SetIsOnRootLevel(Accessible* owner); -}; - -/** - * @brief Checks if ATSPI is activated or not. - * @return True if ATSPI is activated. - */ -inline bool IsUp() -{ - if(Bridge::GetCurrentBridge() == nullptr) - { - return false; - } - - if(Bridge::GetCurrentBridge()->IsEnabled() == false) - { - return false; - } - - return Bridge::GetCurrentBridge()->IsUp(); -} - -/** - * @brief Basic interface implemented by all accessibility objects. - */ -class Accessible -{ -public: - virtual ~Accessible(); - - using utf8_t = unsigned char; - - /** - * @brief Calculates and finds word boundaries in given utf8 text. - * - * @param[in] string The source text to find - * @param[in] length The length of text to find - * @param[in] language The language to use - * @param[out] breaks The word boundaries in given text - * - * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length. - */ - void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks); - - /** - * @brief Calculates and finds line boundaries in given utf8 text. - * - * @param[in] string The source text to find - * @param[in] length The length of text to find - * @param[in] language The language to use - * @param[out] breaks The line boundaries in given text - * - * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length. - */ - void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks); - - /** - * @brief Helper function for emiting active-descendant-changed event. - * - * @param[in] obj The accessible object - * @param[in] child The child of the object - */ - void EmitActiveDescendantChanged(Accessible* obj, Accessible* child); - - /** - * @brief Helper function for emiting state-changed event. - * - * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc) - * @param[in] newValue Whether the state value is changed to new value or not. - * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali) - * - * @note The second argument determines which value is depending on State. - * For instance, if the state is PRESSED, newValue means isPressed or isSelected. - * If the state is SHOWING, newValue means isShowing. - */ - void EmitStateChanged(State state, int newValue, int reserved = 0); - - /** - * @brief Helper function for emiting bounds-changed event. - * - * @param rect The rectangle for changed bounds - */ - void EmitBoundsChanged(Rect<> rect); - - /** - * @brief Emits "showing" event. - * The method informs accessibility clients about "showing" state. - * - * @param[in] isShowing The flag pointing if object is showing - */ - void EmitShowing(bool isShowing); - - /** - * @brief Emits "visible" event. - * The method informs accessibility clients about "visible" state. - * - * @param[in] isVisible The flag pointing if object is visible - */ - void EmitVisible(bool isVisible); - - /** - * @brief Emits "highlighted" event. - * The method informs accessibility clients about "highlighted" state. - * - * @param[in] isHighlighted The flag pointing if object is highlighted - */ - void EmitHighlighted(bool isHighlighted); - - /** - * @brief Emits "focused" event. - * The method informs accessibility clients about "focused" state. - * - * @param[in] isFocused The flag pointing if object is focused - */ - void EmitFocused(bool isFocused); - - /** - * @brief Emits "text inserted" event. - * - * @param[in] position The cursor position - * @param[in] length The text length - * @param[in] content The inserted text - */ - void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content); - - /** - * @brief Emits "text deleted" event. - * - * @param[in] position The cursor position - * @param[in] length The text length - * @param[in] content The deleted text - */ - void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content); - - /** - * @brief Emits "cursor moved" event. - * - * @param[in] cursorPosition The new cursor position - */ - void EmitTextCursorMoved(unsigned int cursorPosition); - - /** - * @brief Emits "MoveOuted" event. - * - * @param[in] type moved out of screen type - */ - void EmitMovedOutOfScreen(ScreenRelativeMoveType type); - - /** - * @brief Emits "highlighted" event. - * - * @param[in] event The enumerated window event - * @param[in] detail The additional parameter which interpretation depends on chosen event - */ - void Emit(WindowEvent event, unsigned int detail = 0); - - /** - * @brief Emits property-changed event. - * - * @param[in] event Property changed event - **/ - void Emit(ObjectPropertyChangeEvent event); - - /** - * @brief Gets accessibility name. - * - * @return The string with name - */ - virtual std::string GetName() = 0; - - /** - * @brief Gets accessibility description. - * - * @return The string with description - */ - virtual std::string GetDescription() = 0; - - /** - * @brief Gets parent. - * - * @return The handler to accessibility object - */ - virtual Accessible* GetParent() = 0; - - /** - * @brief Gets the number of children. - * - * @return The number of children - */ - virtual size_t GetChildCount() = 0; - - /** - * @brief Gets collection with all children. - * - * @return The collection of accessibility objects - */ - virtual std::vector GetChildren(); - - /** - * @brief Gets child of the index. - * - * @return The child object - */ - virtual Accessible* GetChildAtIndex(size_t index) = 0; - - /** - * @brief Gets index that current object has in its parent's children collection. - * - * @return The index of the current object - */ - virtual size_t GetIndexInParent() = 0; - - /** - * @brief Gets accessibility role. - * - * @return Role enumeration - * - * @see Dali::Accessibility::Role - */ - virtual Role GetRole() = 0; - - /** - * @brief Gets name of accessibility role. - * - * @return The string with human readable role converted from enumeration - * - * @see Dali::Accessibility::Role - * @see Accessibility::Accessible::GetRole - */ - virtual std::string GetRoleName(); - - /** - * @brief Gets localized name of accessibility role. - * - * @return The string with human readable role translated according to current - * translation domain - * - * @see Dali::Accessibility::Role - * @see Accessibility::Accessible::GetRole - * @see Accessibility::Accessible::GetRoleName - * - * @note translation is not supported in this version - */ - virtual std::string GetLocalizedRoleName(); - - /** - * @brief Gets accessibility states. - * - * @return The collection of states - * - * @note States class is instatation of ArrayBitset template class - * - * @see Dali::Accessibility::State - * @see Dali::Accessibility::ArrayBitset - */ - virtual States GetStates() = 0; - - /** - * @brief Gets accessibility attributes. - * - * @return The map of attributes and their values - */ - virtual Attributes GetAttributes() = 0; - - /** - * @brief Checks if this is proxy. - * - * @return True if this is proxy - */ - virtual bool IsProxy(); - - /** - * @brief Gets unique address on accessibility bus. - * - * @return The Address class containing address - * - * @see Dali::Accessibility::Address - */ - virtual Address GetAddress(); - - /** - * @brief Deputes an object to perform provided gesture. - * - * @param[in] gestureInfo The structure describing the gesture - * - * @return true on success, false otherwise - * - * @see Dali::Accessibility::GestureInfo - */ - virtual bool DoGesture(const GestureInfo& gestureInfo) = 0; - - /** - * @brief Re-emits selected states of an Accessibility Object. - * - * @param[in] states The chosen states to re-emit - * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states - */ - void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive); - - /** - * @brief Gets information about current object and all relations that connects - * it with other accessibility objects. - * - * @return The iterable collection of Relation objects - * - * @see Dali::Accessibility::Relation - */ - virtual std::vector GetRelationSet() = 0; - - /** - * @brief Gets internal Actor to be saved before. - * - * @return The internal Actor - */ - virtual Dali::Actor GetInternalActor() = 0; - - /** - * @brief Gets all implemented interfaces. - * - * @return The collection of strings with implemented interfaces - */ - std::vector GetInterfaces(); - - /** - * @brief Checks if object is on root level. - * - * @return Whether object is on root level or not - */ - bool IsOnRootLevel() const - { - return mIsOnRootLevel; - } - -protected: - Accessible(); - Accessible(const Accessible&) = delete; - Accessible(Accessible&&) = delete; - Accessible& operator=(const Accessible&) = delete; - Accessible& operator=(Accessible&&) = delete; - std::shared_ptr GetBridgeData(); - -public: - /** - * @brief Gets the highlight actor. - * - * This method is to get the highlight itself. - * @return The highlight actor - */ - static Dali::Actor GetHighlightActor(); - - /** - * @brief Sets the highlight actor. - * - * This method is to set the highlight itself. - * @param[in] actor The highlight actor - */ - static void SetHighlightActor(Dali::Actor actor); - - /** - * @brief Gets the currently highlighted actor. - * - * @return The current highlighted actor - */ - static Dali::Actor GetCurrentlyHighlightedActor(); - - /** - * @brief Sets currently highlighted actor. - * - * @param[in] actor The highlight actor - */ - static void SetCurrentlyHighlightedActor(Dali::Actor actor); - - /** - * @brief Sets ObjectRegistry. - * - * @param[in] registry ObjectRegistry instance - */ - static void SetObjectRegistry(ObjectRegistry registry); - - /** - * @brief The method registers functor resposible for converting Actor into Accessible. - * @param functor The returning Accessible handle from Actor object - */ - static void RegisterExternalAccessibleGetter(std::function functor); - - /** - * @brief Acquires Accessible object from Actor object. - * - * @param[in] actor Actor object - * @param[in] isRoot True, if it's top level object (window) - * - * @return The handle to Accessible object - */ - static Accessible* Get(Dali::Actor actor, bool isRoot = false); - -private: - friend class Bridge; - - std::weak_ptr mBridgeData; - bool mIsOnRootLevel = false; - -}; // Accessible class - -/** - * @brief Interface enabling to perform provided actions. - */ -class Action : public virtual Accessible -{ -public: - /** - * @brief Gets name of action with given index. - * - * @param[in] index The index of action - * - * @return The string with name of action - */ - virtual std::string GetActionName(size_t index) = 0; - - /** - * @brief Gets translated name of action with given index. - * - * @param[in] index The index of action - * - * @return The string with name of action translated according to current translation domain - * - * @note The translation is not supported in this version - */ - virtual std::string GetLocalizedActionName(size_t index) = 0; - - /** - * @brief Gets description of action with given index. - * - * @param[in] index The index of action - * - * @return The string with description of action - */ - virtual std::string GetActionDescription(size_t index) = 0; - - /** - * @brief Gets key code binded to action with given index. - * - * @param[in] index The index of action - * - * @return The string with key name - */ - virtual std::string GetActionKeyBinding(size_t index) = 0; - - /** - * @brief Gets number of provided actions. - * - * @return The number of actions - */ - virtual size_t GetActionCount() = 0; - - /** - * @brief Performs an action with given index. - * - * @param index The index of action - * - * @return true on success, false otherwise - */ - virtual bool DoAction(size_t index) = 0; - - /** - * @brief Performs an action with given name. - * - * @param name The name of action - * - * @return true on success, false otherwise - */ - virtual bool DoAction(const std::string& name) = 0; -}; - -/** - * @brief An interface identifying the root object - * associated with a running application. - * - * @note Provides global properties describing - * application's runtime environment. - */ -class Application : public virtual Accessible -{ -public: - /** - * @brief Gets name of graphic user interface framework used by an application. - * - * @return String with name - */ - virtual std::string GetToolkitName() = 0; - - /** - * @brief Gets version of graphic user interface framework used by an application. - * - * @return String with version - */ - virtual std::string GetVersion() = 0; -}; - -/** - * @brief Interface enabling advanced quering of accessibility objects. - * - * @note since all mathods can be implemented inside bridge, - * none methods have to be overrided - */ -class Collection : public virtual Accessible -{ -public: -}; - -/** - * @brief Interface representing objects having screen coordinates. - */ -class Component : public virtual Accessible -{ -public: - /** - * @brief Gets rectangle describing size. - * - * @param[in] type The enumeration with type of coordinate systems - * - * @return Rect<> object - * - * @see Dali::Rect - */ - virtual Rect<> GetExtents(CoordinateType type) = 0; - - /** - * @brief Gets layer current object is localized on. - * - * @return The enumeration pointing layer - * - * @see Dali::Accessibility::ComponentLayer - */ - virtual ComponentLayer GetLayer() = 0; - - /** - * @brief Gets value of z-order. - * - * @return The value of z-order - * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface) - * which in short means that many stacked windows can be displayed within a single application. - * In such model, the concept of z-order of UI element became important to deal with element overlapping. - */ - virtual int16_t GetMdiZOrder() = 0; - - /** - * @brief Sets current object as "focused". - * - * @return true on success, false otherwise - */ - virtual bool GrabFocus() = 0; - - /** - * @brief Gets value of alpha channel. - * - * @return The alpha channel value in range [0.0, 1.0] - */ - virtual double GetAlpha() = 0; - - /** - * @brief Sets current object as "highlighted". - * - * The method assings "highlighted" state, simultaneously removing it - * from currently highlighted object. - * - * @return true on success, false otherwise - */ - virtual bool GrabHighlight() = 0; - - /** - * @brief Sets current object as "unhighlighted". - * - * The method removes "highlighted" state from object. - * - * @return true on success, false otherwise - * - * @see Dali:Accessibility::State - */ - virtual bool ClearHighlight() = 0; - - /** - * @brief Checks whether object can be scrolled. - * - * @return true if object is scrollable, false otherwise - * - * @see Dali:Accessibility::State - */ - virtual bool IsScrollable(); - - /** - * @brief Gets Accessible object containing given point. - * - * @param[in] point The two-dimensional point - * @param[in] type The enumeration with type of coordinate system - * - * @return The handle to last child of current object which contains given point - * - * @see Dali::Accessibility::Point - */ - virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type); - - /** - * @brief Checks if the current object contains the given point inside. - * - * @param[in] point The two-dimensional point - * @param[in] type The enumeration with type of coordinate system - * - * @return True if accessible contains in point, otherwise false. - * - * @remarks This method is `Contains` in DBus method. - * @see Dali::Accessibility::Point - */ - virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type); -}; - -/** - * @brief Interface representing objects which can store numeric value. - */ -class Value : public virtual Accessible -{ -public: - /** - * @brief Gets the lowest possible value. - * - * @return The minimum value - */ - virtual double GetMinimum() = 0; - - /** - * @brief Gets the current value. - * - * @return The current value - */ - virtual double GetCurrent() = 0; - - /** - * @brief Gets the highest possible value. - * - * @return The highest value. - */ - virtual double GetMaximum() = 0; - - /** - * @brief Sets the current value. - * - * @param[in] value The current value to set - * - * @return true if value could have been assigned, false otherwise - */ - virtual bool SetCurrent(double value) = 0; - - /** - * @brief Gets the lowest increment that can be distinguished. - * - * @return The lowest increment - */ - virtual double GetMinimumIncrement() = 0; -}; - -/** - * @brief Interface representing objects which can store immutable texts. - * - * @see Dali::Accessibility::EditableText - */ -class DALI_ADAPTOR_API Text : public virtual Accessible -{ -public: - /** - * @brief Gets stored text in given range. - * - * @param[in] startOffset The index of first character - * @param[in] endOffset The index of first character after the last one expected - * - * @return The substring of stored text - */ - virtual std::string GetText(size_t startOffset, size_t endOffset) = 0; - - /** - * @brief Gets number of all stored characters. - * - * @return The number of characters - * @remarks This method is `CharacterCount` in DBus method. - */ - virtual size_t GetCharacterCount() = 0; - - /** - * @brief Gets the cursor offset. - * - * @return Value of cursor offset - * @remarks This method is `CaretOffset` in DBus method. - */ - virtual size_t GetCursorOffset() = 0; - - /** - * @brief Sets the cursor offset. - * - * @param[in] offset Cursor offset - * - * @return True if successful - * @remarks This method is `SetCaretOffset` in DBus method. - */ - virtual bool SetCursorOffset(size_t offset) = 0; - - /** - * @brief Gets substring of stored text truncated in concrete gradation. - * - * @param[in] offset The position in stored text - * @param[in] boundary The enumeration describing text gradation - * - * @return Range structure containing acquired text and offsets in original string - * - * @see Dali::Accessibility::Range - */ - virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0; - - /** - * @brief Gets selected text. - * - * @param[in] selectionIndex The selection index - * @note Currently only one selection (i.e. with index = 0) is supported - * - * @return Range structure containing acquired text and offsets in original string - * - * @remarks This method is `GetSelection` in DBus method. - * @see Dali::Accessibility::Range - */ - virtual Range GetRangeOfSelection(size_t selectionIndex) = 0; - - /** - * @brief Removes the whole selection. - * - * @param[in] selectionIndex The selection index - * @note Currently only one selection (i.e. with index = 0) is supported - * - * @return bool on success, false otherwise - */ - virtual bool RemoveSelection(size_t selectionIndex) = 0; - - /** - * @brief Sets selected text. - * - * @param[in] selectionIndex The selection index - * @param[in] startOffset The index of first character - * @param[in] endOffset The index of first character after the last one expected - * - * @note Currently only one selection (i.e. with index = 0) is supported - * - * @return true on success, false otherwise - * @remarks This method is `SetSelection` in DBus method. - */ - virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0; -}; - -/** - * @brief Interface representing objects which can store editable texts. - * - * @note Paste method is entirely implemented inside bridge - * - * @see Dali::Accessibility::EditableText - */ -class DALI_ADAPTOR_API EditableText : public virtual Accessible -{ -public: - /** - * @brief Copies text in range to system clipboard. - * - * @param[in] startPosition The index of first character - * @param[in] endPosition The index of first character after the last one expected - * - * @return true on success, false otherwise - */ - virtual bool CopyText(size_t startPosition, size_t endPosition) = 0; - - /** - * @brief Cuts text in range to system clipboard. - * - * @param[in] startPosition The index of first character - * @param[in] endPosition The index of first character after the last one expected - * - * @return true on success, false otherwise - */ - virtual bool CutText(size_t startPosition, size_t endPosition) = 0; - - /** - * @brief Deletes text in range. - * - * @param[in] startPosition The index of first character - * @param[in] endPosition The index of first character after the last one expected - * - * @return true on success, false otherwise - */ - virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0; - - /** - * @brief Inserts text at startPosition. - * - * @param[in] startPosition The index of first character - * @param[in] text The text content - * - * @return true on success, false otherwise - */ - virtual bool InsertText(size_t startPosition, std::string text) = 0; - - /** - * @brief Replaces text with content. - * - * @param[in] newContents The text content - * - * @return true on success, false otherwise - */ - virtual bool SetTextContents(std::string newContents) = 0; -}; - -/** - * @brief Interface representing hypertext that can store a collection of hyperlinks. - */ -class Hypertext : public virtual Accessible -{ -public: - /** - * @brief Gets the handle to hyperlink object from a specified index in hyperlink collection of this hypertext. - * - * @param[in] linkIndex The 0-based index in hyperlink collection. - * - * @return Handle to hyperlink object at a specified index in hyperlink collection of hypertext. - */ - virtual Hyperlink* GetLink(int32_t linkIndex) const = 0; - - /** - * @brief Gets the index in hyperlink collection occupied by hyperlink which spans over a specified character offset in this hypertext. - * - * @param[in] characterOffset The 0-based index of character in hypertext. - * - * @return The value of 0-based index in hyperlink collection (-1 if there is no hyperlink at the specified character offset). - */ - virtual int32_t GetLinkIndex(int32_t characterOffset) const = 0; - - /** - * @brief Gets number of hyperlinks stored in this hypertext. - * - * @return The number of hyperlinks (zero if none or -1 if the number cannot be determined) - */ - virtual int32_t GetLinkCount() const = 0; -}; - -/** - * @brief Interface representing a hyperlink in hypertext . - */ -class Hyperlink : public virtual Accessible -{ -public: - /** - * @brief Gets the index of character in originating hypertext at which this hyperlink ends. - * - * @return The 0-based index of hyperlink's last character + 1, in its originating hypertext. - */ - virtual int32_t GetEndIndex() const = 0; - - /** - * @brief Gets the index of character in originating hypertext at which this hyperlink starts. - * - * @return The 0-based index of hyperlink's first character, in its originating hypertext. - */ - virtual int32_t GetStartIndex() const = 0; - - /** - * @brief Gets the total number of anchors which this hyperlink has. Though, typical hyperlinks will have only one anchor. - * - * @return The number of anchors. - */ - virtual int32_t GetAnchorCount() const = 0; - - /** - * @brief Gets the object associated with a particular hyperlink's anchor. - * - * @param[in] anchorIndex The 0-based index in anchor collection. - * - * @return The handle to accessible object. - */ - virtual Accessible* GetAnchorAccessible(int32_t anchorIndex) const = 0; - - /** - * @brief Gets the URI associated with a particular hyperlink's anchor. - * - * @param[in] anchorIndex The 0-based index in anchor collection. - * - * @return The string containing URI. - */ - virtual std::string GetAnchorUri(int32_t anchorIndex) const = 0; - - /** - * @brief Tells whether this hyperlink object is still valid with respect to its originating hypertext object. - * - * @return True if hyperlink object is valid, false otherwise - */ - virtual bool IsValid() const = 0; -}; - -/** - * @brief Interface representing objects which can store a set of selected items. - */ -class DALI_ADAPTOR_API Selection : public virtual Accessible -{ -public: - /** - * @brief Gets the number of selected children. - * - * @return The number of selected children (zero if none) - */ - virtual int GetSelectedChildrenCount() = 0; - - /** - * @brief Gets a specific selected child. - * - * @param selectedChildIndex The index of the selected child - * - * @note @p selectedChildIndex refers to the list of selected children, - * not the list of all children - * - * @return The selected child or nullptr if index is invalid - */ - virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0; - - /** - * @brief Selects a child. - * - * @param childIndex The index of the child - * - * @return true on success, false otherwise - */ - virtual bool SelectChild(int childIndex) = 0; - - /** - * @brief Deselects a selected child. - * - * @param selectedChildIndex The index of the selected child - * - * @note @p selectedChildIndex refers to the list of selected children, - * not the list of all children - * - * @return true on success, false otherwise - * - * @see Dali::Accessibility::Selection::DeselectChild - */ - virtual bool DeselectSelectedChild(int selectedChildIndex) = 0; - - /** - * @brief Checks whether a child is selected. - * - * @param childIndex The index of the child - * - * @return true if given child is selected, false otherwise - */ - virtual bool IsChildSelected(int childIndex) = 0; - - /** - * @brief Selects all children. - * - * @return true on success, false otherwise - */ - virtual bool SelectAll() = 0; - - /** - * @brief Deselects all children. - * - * @return true on success, false otherwise - */ - virtual bool ClearSelection() = 0; - - /** - * @brief Deselects a child. - * - * @param childIndex The index of the child. - * - * @return true on success, false otherwise - * - * @see Dali::Accessibility::Selection::DeselectSelectedChild - */ - virtual bool DeselectChild(int childIndex) = 0; -}; - -/** - * @brief The minimalistic, always empty Accessible object with settable address. - * - * For those situations, where you want to return address in different bridge - * (embedding for example), but the object itself ain't planned to be used otherwise. - * This object has null parent, no children, empty name and so on - */ -class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible -{ -public: - EmptyAccessibleWithAddress() = default; - - EmptyAccessibleWithAddress(Address address) - : mAddress(std::move(address)) - { - } - - void SetAddress(Address address) - { - this->mAddress = std::move(address); - } - - std::string GetName() override - { - return ""; - } - - std::string GetDescription() override - { - return ""; - } - - Accessible* GetParent() override - { - return nullptr; - } - - size_t GetChildCount() override - { - return 0; - } - - std::vector GetChildren() override - { - return {}; - } - - Accessible* GetChildAtIndex(size_t index) override - { - throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"}; - } - - size_t GetIndexInParent() override - { - return static_cast(-1); - } - - Role GetRole() override - { - return {}; - } - - std::string GetRoleName() override; - - States GetStates() override - { - return {}; - } - - Attributes GetAttributes() override - { - return {}; - } - - Address GetAddress() override - { - return mAddress; - } - - bool DoGesture(const GestureInfo& gestureInfo) override - { - return false; - } - - std::vector GetRelationSet() override - { - return {}; - } - - Dali::Actor GetInternalActor() override - { - return Dali::Actor{}; - } - -private: - Address mAddress; -}; - -} // namespace Accessibility -} // namespace Dali - -#endif // DALI_INTERNAL_ATSPI_ACCESSIBILITY_IMPL_H diff --git a/dali/devel-api/adaptor-framework/accessibility.cpp b/dali/devel-api/adaptor-framework/accessibility.cpp new file mode 100644 index 000000000..fcf60cd5f --- /dev/null +++ b/dali/devel-api/adaptor-framework/accessibility.cpp @@ -0,0 +1,831 @@ +/* + * Copyright 2020 Samsung Electronics Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace Dali::Accessibility; +using namespace Dali; + +const std::string& Dali::Accessibility::Address::GetBus() const +{ + return mBus.empty() && Bridge::GetCurrentBridge() ? Bridge::GetCurrentBridge()->GetBusName() : mBus; +} + +std::string EmptyAccessibleWithAddress::GetRoleName() +{ + return ""; +} + +std::string Accessible::GetLocalizedRoleName() +{ + return GetRoleName(); +} + +std::string Accessible::GetRoleName() +{ + switch(GetRole()) + { + case Role::INVALID: + { + return "invalid"; + } + case Role::ACCELERATOR_LABEL: + { + return "accelerator label"; + } + case Role::ALERT: + { + return "alert"; + } + case Role::ANIMATION: + { + return "animation"; + } + case Role::ARROW: + { + return "arrow"; + } + case Role::CALENDAR: + { + return "calendar"; + } + case Role::CANVAS: + { + return "canvas"; + } + case Role::CHECK_BOX: + { + return "check box"; + } + case Role::CHECK_MENU_ITEM: + { + return "check menu item"; + } + case Role::COLOR_CHOOSER: + { + return "color chooser"; + } + case Role::COLUMN_HEADER: + { + return "column header"; + } + case Role::COMBO_BOX: + { + return "combo box"; + } + case Role::DATE_EDITOR: + { + return "date editor"; + } + case Role::DESKTOP_ICON: + { + return "desktop icon"; + } + case Role::DESKTOP_FRAME: + { + return "desktop frame"; + } + case Role::DIAL: + { + return "dial"; + } + case Role::DIALOG: + { + return "dialog"; + } + case Role::DIRECTORY_PANE: + { + return "directory pane"; + } + case Role::DRAWING_AREA: + { + return "drawing area"; + } + case Role::FILE_CHOOSER: + { + return "file chooser"; + } + case Role::FILLER: + { + return "filler"; + } + case Role::FOCUS_TRAVERSABLE: + { + return "focus traversable"; + } + case Role::FONT_CHOOSER: + { + return "font chooser"; + } + case Role::FRAME: + { + return "frame"; + } + case Role::GLASS_PANE: + { + return "glass pane"; + } + case Role::HTML_CONTAINER: + { + return "html container"; + } + case Role::ICON: + { + return "icon"; + } + case Role::IMAGE: + { + return "image"; + } + case Role::INTERNAL_FRAME: + { + return "internal frame"; + } + case Role::LABEL: + { + return "label"; + } + case Role::LAYERED_PANE: + { + return "layered pane"; + } + case Role::LIST: + { + return "list"; + } + case Role::LIST_ITEM: + { + return "list item"; + } + case Role::MENU: + { + return "menu"; + } + case Role::MENU_BAR: + { + return "menu bar"; + } + case Role::MENU_ITEM: + { + return "menu item"; + } + case Role::OPTION_PANE: + { + return "option pane"; + } + case Role::PAGE_TAB: + { + return "page tab"; + } + case Role::PAGE_TAB_LIST: + { + return "page tab list"; + } + case Role::PANEL: + { + return "panel"; + } + case Role::PASSWORD_TEXT: + { + return "password text"; + } + case Role::POPUP_MENU: + { + return "popup menu"; + } + case Role::PROGRESS_BAR: + { + return "progress bar"; + } + case Role::PUSH_BUTTON: + { + return "push button"; + } + case Role::RADIO_BUTTON: + { + return "radio button"; + } + case Role::RADIO_MENU_ITEM: + { + return "radio menu item"; + } + case Role::ROOT_PANE: + { + return "root pane"; + } + case Role::ROW_HEADER: + { + return "row header"; + } + case Role::SCROLL_BAR: + { + return "scroll bar"; + } + case Role::SCROLL_PANE: + { + return "scroll pane"; + } + case Role::SEPARATOR: + { + return "separator"; + } + case Role::SLIDER: + { + return "slider"; + } + case Role::SPIN_BUTTON: + { + return "spin button"; + } + case Role::SPLIT_PANE: + { + return "split pane"; + } + case Role::STATUS_BAR: + { + return "status bar"; + } + case Role::TABLE: + { + return "table"; + } + case Role::TABLE_CELL: + { + return "table cell"; + } + case Role::TABLE_COLUMN_HEADER: + { + return "table column header"; + } + case Role::TABLE_ROW_HEADER: + { + return "table row header"; + } + case Role::TEAROFF_MENU_ITEM: + { + return "tearoff menu item"; + } + case Role::TERMINAL: + { + return "terminal"; + } + case Role::TEXT: + { + return "text"; + } + case Role::TOGGLE_BUTTON: + { + return "toggle button"; + } + case Role::TOOL_BAR: + { + return "tool bar"; + } + case Role::TOOL_TIP: + { + return "tool tip"; + } + case Role::TREE: + { + return "tree"; + } + case Role::TREE_TABLE: + { + return "tree table"; + } + case Role::UNKNOWN: + { + return "unknown"; + } + case Role::VIEWPORT: + { + return "viewport"; + } + case Role::WINDOW: + { + return "window"; + } + case Role::EXTENDED: + { + return "extended"; + } + case Role::HEADER: + { + return "header"; + } + case Role::FOOTER: + { + return "footer"; + } + case Role::PARAGRAPH: + { + return "paragraph"; + } + case Role::RULER: + { + return "ruler"; + } + case Role::APPLICATION: + { + return "application"; + } + case Role::AUTOCOMPLETE: + { + return "autocomplete"; + } + case Role::EDITBAR: + { + return "edit bar"; + } + case Role::EMBEDDED: + { + return "embedded"; + } + case Role::ENTRY: + { + return "entry"; + } + case Role::CHART: + { + return "chart"; + } + case Role::CAPTION: + { + return "caution"; + } + case Role::DOCUMENT_FRAME: + { + return "document frame"; + } + case Role::HEADING: + { + return "heading"; + } + case Role::PAGE: + { + return "page"; + } + case Role::SECTION: + { + return "section"; + } + case Role::REDUNDANT_OBJECT: + { + return "redundant object"; + } + case Role::FORM: + { + return "form"; + } + case Role::LINK: + { + return "link"; + } + case Role::INPUT_METHOD_WINDOW: + { + return "input method window"; + } + case Role::TABLE_ROW: + { + return "table row"; + } + case Role::TREE_ITEM: + { + return "tree item"; + } + case Role::DOCUMENT_SPREADSHEET: + { + return "document spreadsheet"; + } + case Role::DOCUMENT_PRESENTATION: + { + return "document presentation"; + } + case Role::DOCUMENT_TEXT: + { + return "document text"; + } + case Role::DOCUMENT_WEB: + { + return "document web"; + } + case Role::DOCUMENT_EMAIL: + { + return "document email"; + } + case Role::COMMENT: + { + return "comment"; + } + case Role::LIST_BOX: + { + return "list box"; + } + case Role::GROUPING: + { + return "grouping"; + } + case Role::IMAGE_MAP: + { + return "image map"; + } + case Role::NOTIFICATION: + { + return "notification"; + } + case Role::INFO_BAR: + { + return "info bar"; + } + case Role::LEVEL_BAR: + { + return "level bar"; + } + case Role::TITLE_BAR: + { + return "title bar"; + } + case Role::BLOCK_QUOTE: + { + return "block quote"; + } + case Role::AUDIO: + { + return "audio"; + } + case Role::VIDEO: + { + return "video"; + } + case Role::DEFINITION: + { + return "definition"; + } + case Role::ARTICLE: + { + return "article"; + } + case Role::LANDMARK: + { + return "landmark"; + } + case Role::LOG: + { + return "log"; + } + case Role::MARQUEE: + { + return "marquee"; + } + case Role::MATH: + { + return "math"; + } + case Role::RATING: + { + return "rating"; + } + case Role::TIMER: + { + return "timer"; + } + case Role::STATIC: + { + return "static"; + } + case Role::MATH_FRACTION: + { + return "math fraction"; + } + case Role::MATH_ROOT: + { + return "math root"; + } + case Role::SUBSCRIPT: + { + return "subscript"; + } + case Role::SUPERSCRIPT: + { + return "superscript"; + } + case Role::MAX_COUNT: + { + break; + } + } + return ""; +} + +Dali::Actor Accessible::GetCurrentlyHighlightedActor() +{ + return IsUp() ? Bridge::GetCurrentBridge()->mData->mCurrentlyHighlightedActor : Dali::Actor{}; +} + +void Accessible::SetCurrentlyHighlightedActor(Dali::Actor actor) +{ + if(IsUp()) + { + Bridge::GetCurrentBridge()->mData->mCurrentlyHighlightedActor = actor; + } +} + +Dali::Actor Accessible::GetHighlightActor() +{ + return IsUp() ? Bridge::GetCurrentBridge()->mData->mHighlightActor : Dali::Actor{}; +} + +void Accessible::SetHighlightActor(Dali::Actor actor) +{ + if(IsUp()) + { + Bridge::GetCurrentBridge()->mData->mHighlightActor = actor; + } +} + +void Bridge::ForceDown() +{ + auto highlighted = Accessible::GetCurrentlyHighlightedActor(); + if(highlighted) + { + auto component = dynamic_cast(Accessible::Get(highlighted)); + if(component) + { + component->ClearHighlight(); + } + } + mData = {}; +} + +void Bridge::SetIsOnRootLevel(Accessible* owner) +{ + owner->mIsOnRootLevel = true; +} + +namespace +{ +class AdaptorAccessible : public virtual Accessible, public virtual Collection, public virtual Component +{ +protected: + Dali::WeakHandle mSelf; + bool mRoot = false; + + Dali::Actor Self() + { + auto handle = mSelf.GetHandle(); + + // AdaptorAccessible is deleted on ObjectDestroyedSignal + // for the respective actor (see `nonControlAccessibles`). + DALI_ASSERT_ALWAYS(handle); + + return handle; + } + +public: + AdaptorAccessible(Dali::Actor actor, bool isRoot) + : mSelf(actor), + mRoot(isRoot) + { + } + + Dali::Rect<> GetExtents(Dali::Accessibility::CoordinateType type) override + { + Dali::Actor actor = Self(); + Vector2 screenPosition = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get(); + Vector3 size = actor.GetCurrentProperty(Actor::Property::SIZE) * actor.GetCurrentProperty(Actor::Property::WORLD_SCALE); + bool positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get(); + Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); + Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y); + + if(type == Dali::Accessibility::CoordinateType::WINDOW) + { + return {position.x, position.y, size.x, size.y}; + } + else // Dali::Accessibility::CoordinateType::SCREEN + { + auto window = Dali::DevelWindow::Get(actor); + auto windowPosition = window.GetPosition(); + return {position.x + windowPosition.GetX(), position.y + windowPosition.GetY(), size.x, size.y}; + } + } + + Dali::Accessibility::ComponentLayer GetLayer() override + { + return Dali::Accessibility::ComponentLayer::WINDOW; + } + + int16_t GetMdiZOrder() override + { + return 0; + } + + double GetAlpha() override + { + return 0; + } + + bool GrabFocus() override + { + return false; + } + + bool GrabHighlight() override + { + return false; + } + + bool ClearHighlight() override + { + return false; + } + + bool IsScrollable() override + { + return false; + } + + std::string GetName() override + { + return Self().GetProperty(Dali::Actor::Property::NAME); + } + + std::string GetDescription() override + { + return ""; + } + + Accessible* GetParent() override + { + if(IsOnRootLevel()) + { + auto data = GetBridgeData(); + return data->mBridge->GetApplication(); + } + return Get(Self().GetParent()); + } + + size_t GetChildCount() override + { + return static_cast(Self().GetChildCount()); + } + + Accessible* GetChildAtIndex(size_t index) override + { + auto numberOfChildren = static_cast(Self().GetChildCount()); + if(index >= numberOfChildren) + { + throw std::domain_error{"invalid index " + std::to_string(index) + " for object with " + std::to_string(numberOfChildren) + " children"}; + } + return Get(Self().GetChildAt(static_cast(index))); + } + + size_t GetIndexInParent() override + { + auto parent = Self().GetParent(); + if(!parent) + { + return 0; + } + auto size = static_cast(parent.GetChildCount()); + for(auto i = 0u; i < size; ++i) + { + if(parent.GetChildAt(i) == Self()) + { + return i; + } + } + throw std::domain_error{"actor is not a child of it's parent"}; + } + + Role GetRole() override + { + return mRoot ? Role::WINDOW : Role::REDUNDANT_OBJECT; + } + + States GetStates() override + { + States state; + if(mRoot) + { + auto window = Dali::DevelWindow::Get(Self()); + auto visible = window.IsVisible(); + state[State::ENABLED] = true; + state[State::SENSITIVE] = true; + state[State::SHOWING] = visible; + state[State::VISIBLE] = true; + state[State::ACTIVE] = visible; + } + else + { + auto parentState = GetParent()->GetStates(); + state[State::SHOWING] = parentState[State::SHOWING]; + state[State::VISIBLE] = parentState[State::VISIBLE]; + } + return state; + } + + Attributes GetAttributes() override + { + Dali::TypeInfo type; + Self().GetTypeInfo(type); + return + { + {"class", type.GetName()}, + }; + } + + bool DoGesture(const GestureInfo& gestureInfo) override + { + return false; + } + + std::vector GetRelationSet() override + { + return {}; + } + + Dali::Actor GetInternalActor() override + { + return mSelf.GetHandle(); + } +}; // AdaptorAccessible + +using AdaptorAccessiblesType = std::unordered_map >; + +// Save RefObject from an Actor in Accessible::Get() +AdaptorAccessiblesType gAdaptorAccessibles; + +std::function convertingFunctor = [](Dali::Actor) -> Accessible* { + return nullptr; +}; + +ObjectRegistry objectRegistry; +} // namespace + +void Accessible::SetObjectRegistry(ObjectRegistry registry) +{ + objectRegistry = registry; +} + +void Accessible::RegisterExternalAccessibleGetter(std::function functor) +{ + convertingFunctor = functor; +} + +Accessible* Accessible::Get(Dali::Actor actor, bool isRoot) +{ + if(!actor) + { + return nullptr; + } + + auto accessible = convertingFunctor(actor); + if(!accessible) + { + if(gAdaptorAccessibles.empty() && objectRegistry) + { + objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) { + gAdaptorAccessibles.erase(obj); + }); + } + auto pair = gAdaptorAccessibles.emplace(&actor.GetBaseObject(), nullptr); + if(pair.second) + { + pair.first->second.reset(new AdaptorAccessible(actor, isRoot)); + } + accessible = pair.first->second.get(); + } + + return accessible; +} diff --git a/dali/devel-api/adaptor-framework/atspi-accessibility.cpp b/dali/devel-api/adaptor-framework/atspi-accessibility.cpp index 481aec8e2..53a230de8 100644 --- a/dali/devel-api/adaptor-framework/atspi-accessibility.cpp +++ b/dali/devel-api/adaptor-framework/atspi-accessibility.cpp @@ -15,7 +15,7 @@ * */ -#include +#include #include void Dali::AtspiAccessibility::Pause() diff --git a/dali/devel-api/adaptor-framework/proxy-accessible.h b/dali/devel-api/adaptor-framework/proxy-accessible.h new file mode 100644 index 000000000..c931039ee --- /dev/null +++ b/dali/devel-api/adaptor-framework/proxy-accessible.h @@ -0,0 +1,130 @@ +#ifndef DALI_ADAPTOR_PROXY_ACCESSIBLE_H +#define DALI_ADAPTOR_PROXY_ACCESSIBLE_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali::Accessibility +{ +/** + * @brief The minimalistic, always empty Accessible object with settable address. + * + * For those situations, where you want to return address in different bridge + * (embedding for example), but the object itself ain't planned to be used otherwise. + * This object has null parent, no children, empty name and so on + */ +class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible +{ +public: + EmptyAccessibleWithAddress() = default; + + EmptyAccessibleWithAddress(Address address) + : mAddress(std::move(address)) + { + } + + void SetAddress(Address address) + { + this->mAddress = std::move(address); + } + + std::string GetName() override + { + return ""; + } + + std::string GetDescription() override + { + return ""; + } + + Accessible* GetParent() override + { + return nullptr; + } + + size_t GetChildCount() override + { + return 0; + } + + std::vector GetChildren() override + { + return {}; + } + + Accessible* GetChildAtIndex(size_t index) override + { + throw std::domain_error{"out of bounds index (" + std::to_string(index) + ") - no children"}; + } + + size_t GetIndexInParent() override + { + return static_cast(-1); + } + + Role GetRole() override + { + return {}; + } + + std::string GetRoleName() override; + + States GetStates() override + { + return {}; + } + + Attributes GetAttributes() override + { + return {}; + } + + Address GetAddress() override + { + return mAddress; + } + + bool DoGesture(const GestureInfo& gestureInfo) override + { + return false; + } + + std::vector GetRelationSet() override + { + return {}; + } + + Dali::Actor GetInternalActor() override + { + return Dali::Actor{}; + } + +private: + Address mAddress; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_PROXY_ACCESSIBLE_H diff --git a/dali/devel-api/atspi-interfaces/accessible.h b/dali/devel-api/atspi-interfaces/accessible.h new file mode 100644 index 000000000..da7786ea3 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/accessible.h @@ -0,0 +1,416 @@ +#ifndef DALI_ADAPTOR_ATSPI_ACCESSIBLE_H +#define DALI_ADAPTOR_ATSPI_ACCESSIBLE_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include +#include +#include +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali::Accessibility +{ +/** + * @brief Basic interface implemented by all accessibility objects. + */ +class DALI_ADAPTOR_API Accessible +{ +public: + virtual ~Accessible(); + + using utf8_t = unsigned char; + + /** + * @brief Calculates and finds word boundaries in given utf8 text. + * + * @param[in] string The source text to find + * @param[in] length The length of text to find + * @param[in] language The language to use + * @param[out] breaks The word boundaries in given text + * + * @note Word boundaries are returned as non-zero values in table breaks, which must be of size at least length. + */ + void FindWordSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks); + + /** + * @brief Calculates and finds line boundaries in given utf8 text. + * + * @param[in] string The source text to find + * @param[in] length The length of text to find + * @param[in] language The language to use + * @param[out] breaks The line boundaries in given text + * + * @note Line boundaries are returned as non-zero values in table breaks, which must be of size at least length. + */ + void FindLineSeparationsUtf8(const utf8_t* string, size_t length, const char* language, char* breaks); + + /** + * @brief Helper function for emiting active-descendant-changed event. + * + * @param[in] obj The accessible object + * @param[in] child The child of the object + */ + void EmitActiveDescendantChanged(Accessible* obj, Accessible* child); + + /** + * @brief Helper function for emiting state-changed event. + * + * @param[in] state The accessibility state (SHOWING, HIGHLIGHTED, etc) + * @param[in] newValue Whether the state value is changed to new value or not. + * @param[in] reserved Reserved. (TODO : Currently, this argument is not implemented in dali) + * + * @note The second argument determines which value is depending on State. + * For instance, if the state is PRESSED, newValue means isPressed or isSelected. + * If the state is SHOWING, newValue means isShowing. + */ + void EmitStateChanged(State state, int newValue, int reserved = 0); + + /** + * @brief Helper function for emiting bounds-changed event. + * + * @param rect The rectangle for changed bounds + */ + void EmitBoundsChanged(Rect<> rect); + + /** + * @brief Emits "showing" event. + * The method informs accessibility clients about "showing" state. + * + * @param[in] isShowing The flag pointing if object is showing + */ + void EmitShowing(bool isShowing); + + /** + * @brief Emits "visible" event. + * The method informs accessibility clients about "visible" state. + * + * @param[in] isVisible The flag pointing if object is visible + */ + void EmitVisible(bool isVisible); + + /** + * @brief Emits "highlighted" event. + * The method informs accessibility clients about "highlighted" state. + * + * @param[in] isHighlighted The flag pointing if object is highlighted + */ + void EmitHighlighted(bool isHighlighted); + + /** + * @brief Emits "focused" event. + * The method informs accessibility clients about "focused" state. + * + * @param[in] isFocused The flag pointing if object is focused + */ + void EmitFocused(bool isFocused); + + /** + * @brief Emits "text inserted" event. + * + * @param[in] position The cursor position + * @param[in] length The text length + * @param[in] content The inserted text + */ + void EmitTextInserted(unsigned int position, unsigned int length, const std::string& content); + + /** + * @brief Emits "text deleted" event. + * + * @param[in] position The cursor position + * @param[in] length The text length + * @param[in] content The deleted text + */ + void EmitTextDeleted(unsigned int position, unsigned int length, const std::string& content); + + /** + * @brief Emits "cursor moved" event. + * + * @param[in] cursorPosition The new cursor position + */ + void EmitTextCursorMoved(unsigned int cursorPosition); + + /** + * @brief Emits "MoveOuted" event. + * + * @param[in] type moved out of screen type + */ + void EmitMovedOutOfScreen(ScreenRelativeMoveType type); + + /** + * @brief Emits "highlighted" event. + * + * @param[in] event The enumerated window event + * @param[in] detail The additional parameter which interpretation depends on chosen event + */ + void Emit(WindowEvent event, unsigned int detail = 0); + + /** + * @brief Emits property-changed event. + * + * @param[in] event Property changed event + **/ + void Emit(ObjectPropertyChangeEvent event); + + /** + * @brief Gets accessibility name. + * + * @return The string with name + */ + virtual std::string GetName() = 0; + + /** + * @brief Gets accessibility description. + * + * @return The string with description + */ + virtual std::string GetDescription() = 0; + + /** + * @brief Gets parent. + * + * @return The handler to accessibility object + */ + virtual Accessible* GetParent() = 0; + + /** + * @brief Gets the number of children. + * + * @return The number of children + */ + virtual size_t GetChildCount() = 0; + + /** + * @brief Gets collection with all children. + * + * @return The collection of accessibility objects + */ + virtual std::vector GetChildren(); + + /** + * @brief Gets child of the index. + * + * @return The child object + */ + virtual Accessible* GetChildAtIndex(size_t index) = 0; + + /** + * @brief Gets index that current object has in its parent's children collection. + * + * @return The index of the current object + */ + virtual size_t GetIndexInParent() = 0; + + /** + * @brief Gets accessibility role. + * + * @return Role enumeration + * + * @see Dali::Accessibility::Role + */ + virtual Role GetRole() = 0; + + /** + * @brief Gets name of accessibility role. + * + * @return The string with human readable role converted from enumeration + * + * @see Dali::Accessibility::Role + * @see Accessibility::Accessible::GetRole + */ + virtual std::string GetRoleName(); + + /** + * @brief Gets localized name of accessibility role. + * + * @return The string with human readable role translated according to current + * translation domain + * + * @see Dali::Accessibility::Role + * @see Accessibility::Accessible::GetRole + * @see Accessibility::Accessible::GetRoleName + * + * @note translation is not supported in this version + */ + virtual std::string GetLocalizedRoleName(); + + /** + * @brief Gets accessibility states. + * + * @return The collection of states + * + * @note States class is instatation of ArrayBitset template class + * + * @see Dali::Accessibility::State + * @see Dali::Accessibility::ArrayBitset + */ + virtual States GetStates() = 0; + + /** + * @brief Gets accessibility attributes. + * + * @return The map of attributes and their values + */ + virtual Attributes GetAttributes() = 0; + + /** + * @brief Checks if this is proxy. + * + * @return True if this is proxy + */ + virtual bool IsProxy(); + + /** + * @brief Gets unique address on accessibility bus. + * + * @return The Address class containing address + * + * @see Dali::Accessibility::Address + */ + virtual Address GetAddress(); + + /** + * @brief Deputes an object to perform provided gesture. + * + * @param[in] gestureInfo The structure describing the gesture + * + * @return true on success, false otherwise + * + * @see Dali::Accessibility::GestureInfo + */ + virtual bool DoGesture(const GestureInfo& gestureInfo) = 0; + + /** + * @brief Re-emits selected states of an Accessibility Object. + * + * @param[in] states The chosen states to re-emit + * @param[in] isRecursive If true, all children of the Accessibility object will also re-emit the states + */ + void NotifyAccessibilityStateChange(Dali::Accessibility::States states, bool isRecursive); + + /** + * @brief Gets information about current object and all relations that connects + * it with other accessibility objects. + * + * @return The iterable collection of Relation objects + * + * @see Dali::Accessibility::Relation + */ + virtual std::vector GetRelationSet() = 0; + + /** + * @brief Gets internal Actor to be saved before. + * + * @return The internal Actor + */ + virtual Dali::Actor GetInternalActor() = 0; + + /** + * @brief Gets all implemented interfaces. + * + * @return The collection of strings with implemented interfaces + */ + std::vector GetInterfaces(); + + /** + * @brief Checks if object is on root level. + * + * @return Whether object is on root level or not + */ + bool IsOnRootLevel() const + { + return mIsOnRootLevel; + } + +protected: + Accessible(); + Accessible(const Accessible&) = delete; + Accessible(Accessible&&) = delete; + Accessible& operator=(const Accessible&) = delete; + Accessible& operator=(Accessible&&) = delete; + std::shared_ptr GetBridgeData(); + +public: + /** + * @brief Gets the highlight actor. + * + * This method is to get the highlight itself. + * @return The highlight actor + */ + static Dali::Actor GetHighlightActor(); + + /** + * @brief Sets the highlight actor. + * + * This method is to set the highlight itself. + * @param[in] actor The highlight actor + */ + static void SetHighlightActor(Dali::Actor actor); + + /** + * @brief Gets the currently highlighted actor. + * + * @return The current highlighted actor + */ + static Dali::Actor GetCurrentlyHighlightedActor(); + + /** + * @brief Sets currently highlighted actor. + * + * @param[in] actor The highlight actor + */ + static void SetCurrentlyHighlightedActor(Dali::Actor actor); + + /** + * @brief Sets ObjectRegistry. + * + * @param[in] registry ObjectRegistry instance + */ + static void SetObjectRegistry(ObjectRegistry registry); + + /** + * @brief The method registers functor resposible for converting Actor into Accessible. + * @param functor The returning Accessible handle from Actor object + */ + static void RegisterExternalAccessibleGetter(std::function functor); + + /** + * @brief Acquires Accessible object from Actor object. + * + * @param[in] actor Actor object + * @param[in] isRoot True, if it's top level object (window) + * + * @return The handle to Accessible object + */ + static Accessible* Get(Dali::Actor actor, bool isRoot = false); + +private: + friend class Bridge; + + std::weak_ptr mBridgeData; + bool mIsOnRootLevel = false; + +}; // Accessible class + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_ACCESSIBLE_H diff --git a/dali/devel-api/atspi-interfaces/action.h b/dali/devel-api/atspi-interfaces/action.h new file mode 100644 index 000000000..0276378e6 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/action.h @@ -0,0 +1,100 @@ +#ifndef DALI_ADAPTOR_ATSPI_ACTION_H +#define DALI_ADAPTOR_ATSPI_ACTION_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface enabling to perform provided actions. + */ +class DALI_ADAPTOR_API Action : public virtual Accessible +{ +public: + /** + * @brief Gets name of action with given index. + * + * @param[in] index The index of action + * + * @return The string with name of action + */ + virtual std::string GetActionName(size_t index) = 0; + + /** + * @brief Gets translated name of action with given index. + * + * @param[in] index The index of action + * + * @return The string with name of action translated according to current translation domain + * + * @note The translation is not supported in this version + */ + virtual std::string GetLocalizedActionName(size_t index) = 0; + + /** + * @brief Gets description of action with given index. + * + * @param[in] index The index of action + * + * @return The string with description of action + */ + virtual std::string GetActionDescription(size_t index) = 0; + + /** + * @brief Gets key code binded to action with given index. + * + * @param[in] index The index of action + * + * @return The string with key name + */ + virtual std::string GetActionKeyBinding(size_t index) = 0; + + /** + * @brief Gets number of provided actions. + * + * @return The number of actions + */ + virtual size_t GetActionCount() = 0; + + /** + * @brief Performs an action with given index. + * + * @param index The index of action + * + * @return true on success, false otherwise + */ + virtual bool DoAction(size_t index) = 0; + + /** + * @brief Performs an action with given name. + * + * @param name The name of action + * + * @return true on success, false otherwise + */ + virtual bool DoAction(const std::string& name) = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_ACTION_H diff --git a/dali/devel-api/atspi-interfaces/application.h b/dali/devel-api/atspi-interfaces/application.h new file mode 100644 index 000000000..c4eb62ad7 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/application.h @@ -0,0 +1,55 @@ +#ifndef DALI_ADAPTOR_ATSPI_APPLICATION_H +#define DALI_ADAPTOR_ATSPI_APPLICATION_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief An interface identifying the root object + * associated with a running application. + * + * @note Provides global properties describing + * application's runtime environment. + */ +class DALI_ADAPTOR_API Application : public virtual Accessible +{ +public: + /** + * @brief Gets name of graphic user interface framework used by an application. + * + * @return String with name + */ + virtual std::string GetToolkitName() = 0; + + /** + * @brief Gets version of graphic user interface framework used by an application. + * + * @return String with version + */ + virtual std::string GetVersion() = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_APPLICATION_H diff --git a/dali/devel-api/atspi-interfaces/collection.h b/dali/devel-api/atspi-interfaces/collection.h new file mode 100644 index 000000000..173c9291a --- /dev/null +++ b/dali/devel-api/atspi-interfaces/collection.h @@ -0,0 +1,38 @@ +#ifndef DALI_ADAPTOR_ATSPI_COLLECTION_H +#define DALI_ADAPTOR_ATSPI_COLLECTION_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface enabling advanced quering of accessibility objects. + * + * @note since all mathods can be implemented inside bridge, + * none methods have to be overrided + */ +class DALI_ADAPTOR_API Collection : public virtual Accessible +{ +public: +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_COLLECTION_H diff --git a/dali/devel-api/atspi-interfaces/component.h b/dali/devel-api/atspi-interfaces/component.h new file mode 100644 index 000000000..b32fe026c --- /dev/null +++ b/dali/devel-api/atspi-interfaces/component.h @@ -0,0 +1,138 @@ +#ifndef DALI_ADAPTOR_ATSPI_COMPONENT_H +#define DALI_ADAPTOR_ATSPI_COMPONENT_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing objects having screen coordinates. + */ +class DALI_ADAPTOR_API Component : public virtual Accessible +{ +public: + /** + * @brief Gets rectangle describing size. + * + * @param[in] type The enumeration with type of coordinate systems + * + * @return Rect<> object + * + * @see Dali::Rect + */ + virtual Rect<> GetExtents(CoordinateType type) = 0; + + /** + * @brief Gets layer current object is localized on. + * + * @return The enumeration pointing layer + * + * @see Dali::Accessibility::ComponentLayer + */ + virtual ComponentLayer GetLayer() = 0; + + /** + * @brief Gets value of z-order. + * + * @return The value of z-order + * @remarks MDI means "Multi Document Interface" (https://en.wikipedia.org/wiki/Multiple-document_interface) + * which in short means that many stacked windows can be displayed within a single application. + * In such model, the concept of z-order of UI element became important to deal with element overlapping. + */ + virtual int16_t GetMdiZOrder() = 0; + + /** + * @brief Sets current object as "focused". + * + * @return true on success, false otherwise + */ + virtual bool GrabFocus() = 0; + + /** + * @brief Gets value of alpha channel. + * + * @return The alpha channel value in range [0.0, 1.0] + */ + virtual double GetAlpha() = 0; + + /** + * @brief Sets current object as "highlighted". + * + * The method assings "highlighted" state, simultaneously removing it + * from currently highlighted object. + * + * @return true on success, false otherwise + */ + virtual bool GrabHighlight() = 0; + + /** + * @brief Sets current object as "unhighlighted". + * + * The method removes "highlighted" state from object. + * + * @return true on success, false otherwise + * + * @see Dali:Accessibility::State + */ + virtual bool ClearHighlight() = 0; + + /** + * @brief Checks whether object can be scrolled. + * + * @return true if object is scrollable, false otherwise + * + * @see Dali:Accessibility::State + */ + virtual bool IsScrollable(); + + /** + * @brief Gets Accessible object containing given point. + * + * @param[in] point The two-dimensional point + * @param[in] type The enumeration with type of coordinate system + * + * @return The handle to last child of current object which contains given point + * + * @see Dali::Accessibility::Point + */ + virtual Accessible* GetAccessibleAtPoint(Point point, CoordinateType type); + + /** + * @brief Checks if the current object contains the given point inside. + * + * @param[in] point The two-dimensional point + * @param[in] type The enumeration with type of coordinate system + * + * @return True if accessible contains in point, otherwise false. + * + * @remarks This method is `Contains` in DBus method. + * @see Dali::Accessibility::Point + */ + virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type); +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_COMPONENT_H diff --git a/dali/devel-api/atspi-interfaces/editable-text.h b/dali/devel-api/atspi-interfaces/editable-text.h new file mode 100644 index 000000000..b710958fa --- /dev/null +++ b/dali/devel-api/atspi-interfaces/editable-text.h @@ -0,0 +1,90 @@ +#ifndef DALI_ADAPTOR_ATSPI_EDITABLE_TEXT_H +#define DALI_ADAPTOR_ATSPI_EDITABLE_TEXT_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing objects which can store editable texts. + * + * @note Paste method is entirely implemented inside bridge + * + * @see Dali::Accessibility::EditableText + */ +class DALI_ADAPTOR_API EditableText : public virtual Accessible +{ +public: + /** + * @brief Copies text in range to system clipboard. + * + * @param[in] startPosition The index of first character + * @param[in] endPosition The index of first character after the last one expected + * + * @return true on success, false otherwise + */ + virtual bool CopyText(size_t startPosition, size_t endPosition) = 0; + + /** + * @brief Cuts text in range to system clipboard. + * + * @param[in] startPosition The index of first character + * @param[in] endPosition The index of first character after the last one expected + * + * @return true on success, false otherwise + */ + virtual bool CutText(size_t startPosition, size_t endPosition) = 0; + + /** + * @brief Deletes text in range. + * + * @param[in] startPosition The index of first character + * @param[in] endPosition The index of first character after the last one expected + * + * @return true on success, false otherwise + */ + virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0; + + /** + * @brief Inserts text at startPosition. + * + * @param[in] startPosition The index of first character + * @param[in] text The text content + * + * @return true on success, false otherwise + */ + virtual bool InsertText(size_t startPosition, std::string text) = 0; + + /** + * @brief Replaces text with content. + * + * @param[in] newContents The text content + * + * @return true on success, false otherwise + */ + virtual bool SetTextContents(std::string newContents) = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_EDITABLE_TEXT_H diff --git a/dali/devel-api/atspi-interfaces/hyperlink.h b/dali/devel-api/atspi-interfaces/hyperlink.h new file mode 100644 index 000000000..dc2461562 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/hyperlink.h @@ -0,0 +1,84 @@ +#ifndef DALI_ADAPTOR_ATSPI_HYPERLINK_H +#define DALI_ADAPTOR_ATSPI_HYPERLINK_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include +#include + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing a hyperlink in hypertext . + */ +class Hyperlink : public virtual Accessible +{ +public: + /** + * @brief Gets the index of character in originating hypertext at which this hyperlink ends. + * + * @return The 0-based index of hyperlink's last character + 1, in its originating hypertext. + */ + virtual int32_t GetEndIndex() const = 0; + + /** + * @brief Gets the index of character in originating hypertext at which this hyperlink starts. + * + * @return The 0-based index of hyperlink's first character, in its originating hypertext. + */ + virtual int32_t GetStartIndex() const = 0; + + /** + * @brief Gets the total number of anchors which this hyperlink has. Though, typical hyperlinks will have only one anchor. + * + * @return The number of anchors. + */ + virtual int32_t GetAnchorCount() const = 0; + + /** + * @brief Gets the object associated with a particular hyperlink's anchor. + * + * @param[in] anchorIndex The 0-based index in anchor collection. + * + * @return The handle to accessible object. + */ + virtual Accessible* GetAnchorAccessible(int32_t anchorIndex) const = 0; + + /** + * @brief Gets the URI associated with a particular hyperlink's anchor. + * + * @param[in] anchorIndex The 0-based index in anchor collection. + * + * @return The string containing URI. + */ + virtual std::string GetAnchorUri(int32_t anchorIndex) const = 0; + + /** + * @brief Tells whether this hyperlink object is still valid with respect to its originating hypertext object. + * + * @return True if hyperlink object is valid, false otherwise + */ + virtual bool IsValid() const = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_HYPERLINK_H diff --git a/dali/devel-api/atspi-interfaces/hypertext.h b/dali/devel-api/atspi-interfaces/hypertext.h new file mode 100644 index 000000000..cc96bbbb7 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/hypertext.h @@ -0,0 +1,63 @@ +#ifndef DALI_ADAPTOR_ATSPI_HYPERTEXT_H +#define DALI_ADAPTOR_ATSPI_HYPERTEXT_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing hypertext that can store a collection of hyperlinks. + */ +class DALI_ADAPTOR_API Hypertext : public virtual Accessible +{ +public: + /** + * @brief Gets the handle to hyperlink object from a specified index in hyperlink collection of this hypertext. + * + * @param[in] linkIndex The 0-based index in hyperlink collection. + * + * @return Handle to hyperlink object at a specified index in hyperlink collection of hypertext. + */ + virtual Hyperlink* GetLink(int32_t linkIndex) const = 0; + + /** + * @brief Gets the index in hyperlink collection occupied by hyperlink which spans over a specified character offset in this hypertext. + * + * @param[in] characterOffset The 0-based index of character in hypertext. + * + * @return The value of 0-based index in hyperlink collection (-1 if there is no hyperlink at the specified character offset). + */ + virtual int32_t GetLinkIndex(int32_t characterOffset) const = 0; + + /** + * @brief Gets number of hyperlinks stored in this hypertext. + * + * @return The number of hyperlinks (zero if none or -1 if the number cannot be determined) + */ + virtual int32_t GetLinkCount() const = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_HYPERTEXT_H diff --git a/dali/devel-api/atspi-interfaces/selection.h b/dali/devel-api/atspi-interfaces/selection.h new file mode 100644 index 000000000..fb6bdf96f --- /dev/null +++ b/dali/devel-api/atspi-interfaces/selection.h @@ -0,0 +1,110 @@ +#ifndef DALI_ADAPTOR_ATSPI_SELECTION_H +#define DALI_ADAPTOR_ATSPI_SELECTION_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing objects which can store a set of selected items. + */ +class DALI_ADAPTOR_API Selection : public virtual Accessible +{ +public: + /** + * @brief Gets the number of selected children. + * + * @return The number of selected children (zero if none) + */ + virtual int GetSelectedChildrenCount() = 0; + + /** + * @brief Gets a specific selected child. + * + * @param selectedChildIndex The index of the selected child + * + * @note @p selectedChildIndex refers to the list of selected children, + * not the list of all children + * + * @return The selected child or nullptr if index is invalid + */ + virtual Accessible* GetSelectedChild(int selectedChildIndex) = 0; + + /** + * @brief Selects a child. + * + * @param childIndex The index of the child + * + * @return true on success, false otherwise + */ + virtual bool SelectChild(int childIndex) = 0; + + /** + * @brief Deselects a selected child. + * + * @param selectedChildIndex The index of the selected child + * + * @note @p selectedChildIndex refers to the list of selected children, + * not the list of all children + * + * @return true on success, false otherwise + * + * @see Dali::Accessibility::Selection::DeselectChild + */ + virtual bool DeselectSelectedChild(int selectedChildIndex) = 0; + + /** + * @brief Checks whether a child is selected. + * + * @param childIndex The index of the child + * + * @return true if given child is selected, false otherwise + */ + virtual bool IsChildSelected(int childIndex) = 0; + + /** + * @brief Selects all children. + * + * @return true on success, false otherwise + */ + virtual bool SelectAll() = 0; + + /** + * @brief Deselects all children. + * + * @return true on success, false otherwise + */ + virtual bool ClearSelection() = 0; + + /** + * @brief Deselects a child. + * + * @param childIndex The index of the child. + * + * @return true on success, false otherwise + * + * @see Dali::Accessibility::Selection::DeselectSelectedChild + */ + virtual bool DeselectChild(int childIndex) = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_SELECTION_H diff --git a/dali/devel-api/atspi-interfaces/text.h b/dali/devel-api/atspi-interfaces/text.h new file mode 100644 index 000000000..53158baf9 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/text.h @@ -0,0 +1,125 @@ +#ifndef DALI_ADAPTOR_ATSPI_TEXT_H +#define DALI_ADAPTOR_ATSPI_TEXT_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing objects which can store immutable texts. + * + * @see Dali::Accessibility::EditableText + */ +class DALI_ADAPTOR_API Text : public virtual Accessible +{ +public: + /** + * @brief Gets stored text in given range. + * + * @param[in] startOffset The index of first character + * @param[in] endOffset The index of first character after the last one expected + * + * @return The substring of stored text + */ + virtual std::string GetText(size_t startOffset, size_t endOffset) = 0; + + /** + * @brief Gets number of all stored characters. + * + * @return The number of characters + * @remarks This method is `CharacterCount` in DBus method. + */ + virtual size_t GetCharacterCount() = 0; + + /** + * @brief Gets the cursor offset. + * + * @return Value of cursor offset + * @remarks This method is `CaretOffset` in DBus method. + */ + virtual size_t GetCursorOffset() = 0; + + /** + * @brief Sets the cursor offset. + * + * @param[in] offset Cursor offset + * + * @return True if successful + * @remarks This method is `SetCaretOffset` in DBus method. + */ + virtual bool SetCursorOffset(size_t offset) = 0; + + /** + * @brief Gets substring of stored text truncated in concrete gradation. + * + * @param[in] offset The position in stored text + * @param[in] boundary The enumeration describing text gradation + * + * @return Range structure containing acquired text and offsets in original string + * + * @see Dali::Accessibility::Range + */ + virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0; + + /** + * @brief Gets selected text. + * + * @param[in] selectionIndex The selection index + * @note Currently only one selection (i.e. with index = 0) is supported + * + * @return Range structure containing acquired text and offsets in original string + * + * @remarks This method is `GetSelection` in DBus method. + * @see Dali::Accessibility::Range + */ + virtual Range GetRangeOfSelection(size_t selectionIndex) = 0; + + /** + * @brief Removes the whole selection. + * + * @param[in] selectionIndex The selection index + * @note Currently only one selection (i.e. with index = 0) is supported + * + * @return bool on success, false otherwise + */ + virtual bool RemoveSelection(size_t selectionIndex) = 0; + + /** + * @brief Sets selected text. + * + * @param[in] selectionIndex The selection index + * @param[in] startOffset The index of first character + * @param[in] endOffset The index of first character after the last one expected + * + * @note Currently only one selection (i.e. with index = 0) is supported + * + * @return true on success, false otherwise + * @remarks This method is `SetSelection` in DBus method. + */ + virtual bool SetRangeOfSelection(size_t selectionIndex, size_t startOffset, size_t endOffset) = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_TEXT_H diff --git a/dali/devel-api/atspi-interfaces/value.h b/dali/devel-api/atspi-interfaces/value.h new file mode 100644 index 000000000..69bba3223 --- /dev/null +++ b/dali/devel-api/atspi-interfaces/value.h @@ -0,0 +1,71 @@ +#ifndef DALI_ADAPTOR_ATSPI_VALUE_H +#define DALI_ADAPTOR_ATSPI_VALUE_H + +/* + * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// INTERNAL INCLUDES +#include + +namespace Dali::Accessibility +{ +/** + * @brief Interface representing objects which can store numeric value. + */ +class DALI_ADAPTOR_API Value : public virtual Accessible +{ +public: + /** + * @brief Gets the lowest possible value. + * + * @return The minimum value + */ + virtual double GetMinimum() = 0; + + /** + * @brief Gets the current value. + * + * @return The current value + */ + virtual double GetCurrent() = 0; + + /** + * @brief Gets the highest possible value. + * + * @return The highest value. + */ + virtual double GetMaximum() = 0; + + /** + * @brief Sets the current value. + * + * @param[in] value The current value to set + * + * @return true if value could have been assigned, false otherwise + */ + virtual bool SetCurrent(double value) = 0; + + /** + * @brief Gets the lowest increment that can be distinguished. + * + * @return The lowest increment + */ + virtual double GetMinimumIncrement() = 0; +}; + +} // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_ATSPI_VALUE_H diff --git a/dali/devel-api/file.list b/dali/devel-api/file.list index 4e16b3b02..b501e0cf9 100755 --- a/dali/devel-api/file.list +++ b/dali/devel-api/file.list @@ -1,7 +1,7 @@ SET( devel_api_src_files - ${adaptor_devel_api_dir}/adaptor-framework/accessibility-impl.cpp + ${adaptor_devel_api_dir}/adaptor-framework/accessibility.cpp ${adaptor_devel_api_dir}/adaptor-framework/animated-image-loading.cpp ${adaptor_devel_api_dir}/adaptor-framework/application-devel.cpp ${adaptor_devel_api_dir}/adaptor-framework/atspi-accessibility.cpp @@ -54,7 +54,7 @@ SET( devel_api_src_files SET( devel_api_adaptor_framework_header_files ${adaptor_devel_api_dir}/adaptor-framework/accessibility.h - ${adaptor_devel_api_dir}/adaptor-framework/accessibility-impl.h + ${adaptor_devel_api_dir}/adaptor-framework/accessibility-bridge.h ${adaptor_devel_api_dir}/adaptor-framework/animated-image-loading.h ${adaptor_devel_api_dir}/adaptor-framework/application-devel.h ${adaptor_devel_api_dir}/adaptor-framework/atspi-accessibility.h @@ -91,6 +91,7 @@ SET( devel_api_adaptor_framework_header_files ${adaptor_devel_api_dir}/adaptor-framework/orientation.h ${adaptor_devel_api_dir}/adaptor-framework/performance-logger.h ${adaptor_devel_api_dir}/adaptor-framework/pixel-buffer.h + ${adaptor_devel_api_dir}/adaptor-framework/proxy-accessible.h ${adaptor_devel_api_dir}/adaptor-framework/sound-player.h ${adaptor_devel_api_dir}/adaptor-framework/style-monitor.h ${adaptor_devel_api_dir}/adaptor-framework/tilt-sensor.h @@ -135,6 +136,21 @@ SET( devel_api_adaptor_framework_header_files ) +SET( devel_api_atspi_interfaces_header_files + ${adaptor_devel_api_dir}/atspi-interfaces/accessible.h + ${adaptor_devel_api_dir}/atspi-interfaces/action.h + ${adaptor_devel_api_dir}/atspi-interfaces/application.h + ${adaptor_devel_api_dir}/atspi-interfaces/collection.h + ${adaptor_devel_api_dir}/atspi-interfaces/component.h + ${adaptor_devel_api_dir}/atspi-interfaces/editable-text.h + ${adaptor_devel_api_dir}/atspi-interfaces/hyperlink.h + ${adaptor_devel_api_dir}/atspi-interfaces/hypertext.h + ${adaptor_devel_api_dir}/atspi-interfaces/selection.h + ${adaptor_devel_api_dir}/atspi-interfaces/text.h + ${adaptor_devel_api_dir}/atspi-interfaces/value.h +) + + SET( devel_api_text_abstraction_src_files ${adaptor_devel_api_dir}/text-abstraction/bidirectional-support.cpp ${adaptor_devel_api_dir}/text-abstraction/bitmap-font.cpp diff --git a/dali/internal/accessibility/bridge/accessibility-common.h b/dali/internal/accessibility/bridge/accessibility-common.h index eabad2fdb..4da5e3cf1 100644 --- a/dali/internal/accessibility/bridge/accessibility-common.h +++ b/dali/internal/accessibility/bridge/accessibility-common.h @@ -25,7 +25,7 @@ #include // INTERNAL INCLUDES -#include +#include #include #include #include diff --git a/dali/internal/accessibility/bridge/accessible.cpp b/dali/internal/accessibility/bridge/accessible.cpp index ca6bc7806..2921e60e5 100644 --- a/dali/internal/accessibility/bridge/accessible.cpp +++ b/dali/internal/accessibility/bridge/accessible.cpp @@ -18,6 +18,18 @@ // CLASS HEADER //INTERNAL INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/dali/internal/accessibility/bridge/bridge-accessible.cpp b/dali/internal/accessibility/bridge/bridge-accessible.cpp index 00a2107ae..59481d378 100644 --- a/dali/internal/accessibility/bridge/bridge-accessible.cpp +++ b/dali/internal/accessibility/bridge/bridge-accessible.cpp @@ -22,6 +22,13 @@ #include #include +// INTERNAL INCLUDES +#include +#include +#include +#include +#include + //comment out 2 lines below to get more logs #undef LOG #define LOG() _LoggerEmpty() diff --git a/dali/internal/accessibility/bridge/bridge-accessible.h b/dali/internal/accessibility/bridge/bridge-accessible.h index d5f6c95ab..3ca2223b0 100644 --- a/dali/internal/accessibility/bridge/bridge-accessible.h +++ b/dali/internal/accessibility/bridge/bridge-accessible.h @@ -25,7 +25,9 @@ #include // INTERNAL INCLUDES -#include "bridge-base.h" +#include +#include +#include /** * @brief The BridgeAccessible class is to correspond with Dali::Accessibility::Accessible. diff --git a/dali/internal/accessibility/bridge/bridge-action.h b/dali/internal/accessibility/bridge/bridge-action.h index 2d112649f..c83fe8dc6 100644 --- a/dali/internal/accessibility/bridge/bridge-action.h +++ b/dali/internal/accessibility/bridge/bridge-action.h @@ -23,6 +23,7 @@ #include // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-application.h b/dali/internal/accessibility/bridge/bridge-application.h index ca1e417c5..f4cefc4e2 100644 --- a/dali/internal/accessibility/bridge/bridge-application.h +++ b/dali/internal/accessibility/bridge/bridge-application.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-base.h b/dali/internal/accessibility/bridge/bridge-base.h index dacbfc65e..77cd826d1 100644 --- a/dali/internal/accessibility/bridge/bridge-base.h +++ b/dali/internal/accessibility/bridge/bridge-base.h @@ -25,7 +25,11 @@ #include // INTERNAL INCLUDES +#include #include +#include +#include +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-collection.h b/dali/internal/accessibility/bridge/bridge-collection.h index dc22b1f4c..88f4d02df 100644 --- a/dali/internal/accessibility/bridge/bridge-collection.h +++ b/dali/internal/accessibility/bridge/bridge-collection.h @@ -25,6 +25,7 @@ #include // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-component.h b/dali/internal/accessibility/bridge/bridge-component.h index 868868911..ec24f422a 100644 --- a/dali/internal/accessibility/bridge/bridge-component.h +++ b/dali/internal/accessibility/bridge/bridge-component.h @@ -26,6 +26,7 @@ #include // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-editable-text.h b/dali/internal/accessibility/bridge/bridge-editable-text.h index a123b72e7..742a8d7fc 100644 --- a/dali/internal/accessibility/bridge/bridge-editable-text.h +++ b/dali/internal/accessibility/bridge/bridge-editable-text.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-hyperlink.h b/dali/internal/accessibility/bridge/bridge-hyperlink.h index 0b00356e9..c32614178 100644 --- a/dali/internal/accessibility/bridge/bridge-hyperlink.h +++ b/dali/internal/accessibility/bridge/bridge-hyperlink.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include class BridgeHyperlink : public virtual BridgeBase diff --git a/dali/internal/accessibility/bridge/bridge-hypertext.h b/dali/internal/accessibility/bridge/bridge-hypertext.h index c39c5f842..d3dcb2d8e 100644 --- a/dali/internal/accessibility/bridge/bridge-hypertext.h +++ b/dali/internal/accessibility/bridge/bridge-hypertext.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include class BridgeHypertext : public virtual BridgeBase diff --git a/dali/internal/accessibility/bridge/bridge-object.h b/dali/internal/accessibility/bridge/bridge-object.h index 918c704e3..69ca828d7 100644 --- a/dali/internal/accessibility/bridge/bridge-object.h +++ b/dali/internal/accessibility/bridge/bridge-object.h @@ -25,6 +25,7 @@ #include // INTERNAL INCLUDES +#include #include #include diff --git a/dali/internal/accessibility/bridge/bridge-selection.h b/dali/internal/accessibility/bridge/bridge-selection.h index 589254451..639401d66 100644 --- a/dali/internal/accessibility/bridge/bridge-selection.h +++ b/dali/internal/accessibility/bridge/bridge-selection.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-text.h b/dali/internal/accessibility/bridge/bridge-text.h index 49e69e350..737d3183f 100644 --- a/dali/internal/accessibility/bridge/bridge-text.h +++ b/dali/internal/accessibility/bridge/bridge-text.h @@ -19,6 +19,7 @@ */ // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/bridge-value.h b/dali/internal/accessibility/bridge/bridge-value.h index e4bfec504..caa7cc12e 100644 --- a/dali/internal/accessibility/bridge/bridge-value.h +++ b/dali/internal/accessibility/bridge/bridge-value.h @@ -26,6 +26,7 @@ #include // INTERNAL INCLUDES +#include #include /** diff --git a/dali/internal/accessibility/bridge/component.cpp b/dali/internal/accessibility/bridge/component.cpp index d93789a74..7992df5c5 100644 --- a/dali/internal/accessibility/bridge/component.cpp +++ b/dali/internal/accessibility/bridge/component.cpp @@ -21,6 +21,7 @@ #include // INTERNAL INCLUDES +#include #include using namespace Dali::Accessibility; diff --git a/dali/internal/accessibility/bridge/dummy-atspi.cpp b/dali/internal/accessibility/bridge/dummy-atspi.cpp index 06d907456..a518df9ac 100644 --- a/dali/internal/accessibility/bridge/dummy-atspi.cpp +++ b/dali/internal/accessibility/bridge/dummy-atspi.cpp @@ -15,8 +15,10 @@ * */ -#include #include +#include +#include +#include #include namespace Dali diff --git a/dali/internal/accessibility/bridge/dummy-atspi.h b/dali/internal/accessibility/bridge/dummy-atspi.h index 38f6cabe4..80079c1f6 100644 --- a/dali/internal/accessibility/bridge/dummy-atspi.h +++ b/dali/internal/accessibility/bridge/dummy-atspi.h @@ -1,3 +1,6 @@ +#ifndef DALI_ADAPTOR_DUMMY_ATSPI_H +#define DALI_ADAPTOR_DUMMY_ATSPI_H + /* * Copyright (c) 2021 Samsung Electronics Co., Ltd. * @@ -15,8 +18,8 @@ * */ -#include #include +#include namespace Dali::Accessibility { @@ -172,3 +175,5 @@ struct DummyBridge : Dali::Accessibility::Bridge }; } // namespace Dali::Accessibility + +#endif // DALI_ADAPTOR_DUMMY_ATSPI_H diff --git a/dali/internal/adaptor/common/adaptor-impl.cpp b/dali/internal/adaptor/common/adaptor-impl.cpp index d880a94f1..ddc912a60 100644 --- a/dali/internal/adaptor/common/adaptor-impl.cpp +++ b/dali/internal/adaptor/common/adaptor-impl.cpp @@ -67,7 +67,7 @@ #include #include -#include +#include #include #include diff --git a/dali/internal/adaptor/common/application-impl.cpp b/dali/internal/adaptor/common/application-impl.cpp index 4e08ba12b..03138a926 100644 --- a/dali/internal/adaptor/common/application-impl.cpp +++ b/dali/internal/adaptor/common/application-impl.cpp @@ -24,8 +24,9 @@ #include // INTERNAL INCLUDES -#include +#include #include +#include #include #include #include diff --git a/dali/internal/window-system/common/window-impl.cpp b/dali/internal/window-system/common/window-impl.cpp index e3f65254e..58476e346 100644 --- a/dali/internal/window-system/common/window-impl.cpp +++ b/dali/internal/window-system/common/window-impl.cpp @@ -32,7 +32,8 @@ #include // INTERNAL HEADERS -#include +#include +#include #include #include #include