enum class ForceUpResult
{
JUST_STARTED,
- ALREADY_UP
+ ALREADY_UP,
+ FAILED
};
/**
protected:
struct Data
{
- std::unordered_set<Accessible*> mKnownObjects;
- std::string mBusName;
- Bridge* mBridge = nullptr;
- Actor mHighlightActor;
- Actor mCurrentlyHighlightedActor;
+ std::unordered_set<const Accessible*> mKnownObjects;
+ std::string mBusName;
+ Bridge* mBridge = nullptr;
+ Actor mHighlightActor;
+ Actor mCurrentlyHighlightedActor;
};
std::shared_ptr<Data> mData;
friend class Accessible;
*
* @param[in] object The accessible object
**/
- void RegisterOnBridge(Accessible* object);
+ void RegisterOnBridge(const Accessible* object);
/**
* @brief Tells bridge, that given object is considered root (doesn't have any parents).
#include <dali/public-api/object/object-registry.h>
#include <dali/public-api/object/type-info.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/public-api/object/weak-handle.h>
+#include <string_view>
+#include <unordered_map>
// INTERNAL INCLUDES
#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/actor-accessible.h>
#include <dali/devel-api/adaptor-framework/proxy-accessible.h>
#include <dali/devel-api/adaptor-framework/window-devel.h>
#include <dali/devel-api/atspi-interfaces/accessible.h>
return mBus.empty() && Bridge::GetCurrentBridge() ? Bridge::GetCurrentBridge()->GetBusName() : mBus;
}
-std::string EmptyAccessibleWithAddress::GetRoleName()
-{
- return "";
-}
-
-std::string Accessible::GetLocalizedRoleName()
+std::string Accessible::GetLocalizedRoleName() const
{
return GetRoleName();
}
-std::string Accessible::GetRoleName()
+std::string Accessible::GetRoleName() const
{
- switch(GetRole())
+ static const std::unordered_map<Role, std::string_view> roleMap{
+ {Role::INVALID, "invalid"},
+ {Role::ACCELERATOR_LABEL, "accelerator label"},
+ {Role::ALERT, "alert"},
+ {Role::ANIMATION, "animation"},
+ {Role::ARROW, "arrow"},
+ {Role::CALENDAR, "calendar"},
+ {Role::CANVAS, "canvas"},
+ {Role::CHECK_BOX, "check box"},
+ {Role::CHECK_MENU_ITEM, "check menu item"},
+ {Role::COLOR_CHOOSER, "color chooser"},
+ {Role::COLUMN_HEADER, "column header"},
+ {Role::COMBO_BOX, "combo box"},
+ {Role::DATE_EDITOR, "date editor"},
+ {Role::DESKTOP_ICON, "desktop icon"},
+ {Role::DESKTOP_FRAME, "desktop frame"},
+ {Role::DIAL, "dial"},
+ {Role::DIALOG, "dialog"},
+ {Role::DIRECTORY_PANE, "directory pane"},
+ {Role::DRAWING_AREA, "drawing area"},
+ {Role::FILE_CHOOSER, "file chooser"},
+ {Role::FILLER, "filler"},
+ {Role::FOCUS_TRAVERSABLE, "focus traversable"},
+ {Role::FONT_CHOOSER, "font chooser"},
+ {Role::FRAME, "frame"},
+ {Role::GLASS_PANE, "glass pane"},
+ {Role::HTML_CONTAINER, "html container"},
+ {Role::ICON, "icon"},
+ {Role::IMAGE, "image"},
+ {Role::INTERNAL_FRAME, "internal frame"},
+ {Role::LABEL, "label"},
+ {Role::LAYERED_PANE, "layered pane"},
+ {Role::LIST, "list"},
+ {Role::LIST_ITEM, "list item"},
+ {Role::MENU, "menu"},
+ {Role::MENU_BAR, "menu bar"},
+ {Role::MENU_ITEM, "menu item"},
+ {Role::OPTION_PANE, "option pane"},
+ {Role::PAGE_TAB, "page tab"},
+ {Role::PAGE_TAB_LIST, "page tab list"},
+ {Role::PANEL, "panel"},
+ {Role::PASSWORD_TEXT, "password text"},
+ {Role::POPUP_MENU, "popup menu"},
+ {Role::PROGRESS_BAR, "progress bar"},
+ {Role::PUSH_BUTTON, "push button"},
+ {Role::RADIO_BUTTON, "radio button"},
+ {Role::RADIO_MENU_ITEM, "radio menu item"},
+ {Role::ROOT_PANE, "root pane"},
+ {Role::ROW_HEADER, "row header"},
+ {Role::SCROLL_BAR, "scroll bar"},
+ {Role::SCROLL_PANE, "scroll pane"},
+ {Role::SEPARATOR, "separator"},
+ {Role::SLIDER, "slider"},
+ {Role::SPIN_BUTTON, "spin button"},
+ {Role::SPLIT_PANE, "split pane"},
+ {Role::STATUS_BAR, "status bar"},
+ {Role::TABLE, "table"},
+ {Role::TABLE_CELL, "table cell"},
+ {Role::TABLE_COLUMN_HEADER, "table column header"},
+ {Role::TABLE_ROW_HEADER, "table row header"},
+ {Role::TEAROFF_MENU_ITEM, "tearoff menu item"},
+ {Role::TERMINAL, "terminal"},
+ {Role::TEXT, "text"},
+ {Role::TOGGLE_BUTTON, "toggle button"},
+ {Role::TOOL_BAR, "tool bar"},
+ {Role::TOOL_TIP, "tool tip"},
+ {Role::TREE, "tree"},
+ {Role::TREE_TABLE, "tree table"},
+ {Role::UNKNOWN, "unknown"},
+ {Role::VIEWPORT, "viewport"},
+ {Role::WINDOW, "window"},
+ {Role::EXTENDED, "extended"},
+ {Role::HEADER, "header"},
+ {Role::FOOTER, "footer"},
+ {Role::PARAGRAPH, "paragraph"},
+ {Role::RULER, "ruler"},
+ {Role::APPLICATION, "application"},
+ {Role::AUTOCOMPLETE, "autocomplete"},
+ {Role::EDITBAR, "edit bar"},
+ {Role::EMBEDDED, "embedded"},
+ {Role::ENTRY, "entry"},
+ {Role::CHART, "chart"},
+ {Role::CAPTION, "caution"},
+ {Role::DOCUMENT_FRAME, "document frame"},
+ {Role::HEADING, "heading"},
+ {Role::PAGE, "page"},
+ {Role::SECTION, "section"},
+ {Role::REDUNDANT_OBJECT, "redundant object"},
+ {Role::FORM, "form"},
+ {Role::LINK, "link"},
+ {Role::INPUT_METHOD_WINDOW, "input method window"},
+ {Role::TABLE_ROW, "table row"},
+ {Role::TREE_ITEM, "tree item"},
+ {Role::DOCUMENT_SPREADSHEET, "document spreadsheet"},
+ {Role::DOCUMENT_PRESENTATION, "document presentation"},
+ {Role::DOCUMENT_TEXT, "document text"},
+ {Role::DOCUMENT_WEB, "document web"},
+ {Role::DOCUMENT_EMAIL, "document email"},
+ {Role::COMMENT, "comment"},
+ {Role::LIST_BOX, "list box"},
+ {Role::GROUPING, "grouping"},
+ {Role::IMAGE_MAP, "image map"},
+ {Role::NOTIFICATION, "notification"},
+ {Role::INFO_BAR, "info bar"},
+ {Role::LEVEL_BAR, "level bar"},
+ {Role::TITLE_BAR, "title bar"},
+ {Role::BLOCK_QUOTE, "block quote"},
+ {Role::AUDIO, "audio"},
+ {Role::VIDEO, "video"},
+ {Role::DEFINITION, "definition"},
+ {Role::ARTICLE, "article"},
+ {Role::LANDMARK, "landmark"},
+ {Role::LOG, "log"},
+ {Role::MARQUEE, "marquee"},
+ {Role::MATH, "math"},
+ {Role::RATING, "rating"},
+ {Role::TIMER, "timer"},
+ {Role::STATIC, "static"},
+ {Role::MATH_FRACTION, "math fraction"},
+ {Role::MATH_ROOT, "math root"},
+ {Role::SUBSCRIPT, "subscript"},
+ {Role::SUPERSCRIPT, "superscript"},
+ };
+
+ auto it = roleMap.find(GetRole());
+
+ if(it == roleMap.end())
{
- 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 {};
}
- return "";
+
+ return std::string{it->second};
}
Dali::Actor Accessible::GetCurrentlyHighlightedActor()
namespace
{
-class AdaptorAccessible : public virtual Accessible, public virtual Collection, public virtual Component
+class AdaptorAccessible : public ActorAccessible
{
protected:
- Dali::WeakHandle<Dali::Actor> 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;
- }
+ bool mRoot = false;
public:
AdaptorAccessible(Dali::Actor actor, bool isRoot)
- : mSelf(actor),
+ : ActorAccessible(actor),
mRoot(isRoot)
{
}
- Dali::Rect<> GetExtents(Dali::Accessibility::CoordinateType type) override
- {
- Dali::Actor actor = Self();
- Vector2 screenPosition = actor.GetProperty(Actor::Property::SCREEN_POSITION).Get<Vector2>();
- Vector3 size = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
- bool positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT).Get<bool>();
- Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty<Vector3>(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;
return false;
}
- bool IsScrollable() override
- {
- return false;
- }
-
- std::string GetName() override
- {
- return Self().GetProperty<std::string>(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<size_t>(Self().GetChildCount());
- }
-
- Accessible* GetChildAtIndex(size_t index) override
- {
- auto numberOfChildren = static_cast<size_t>(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<unsigned int>(index)));
- }
-
- size_t GetIndexInParent() override
- {
- auto parent = Self().GetParent();
- if(!parent)
- {
- return 0;
- }
- auto size = static_cast<size_t>(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
+ Role GetRole() const override
{
return mRoot ? Role::WINDOW : Role::REDUNDANT_OBJECT;
}
States state;
if(mRoot)
{
- auto window = Dali::DevelWindow::Get(Self());
- auto visible = window.IsVisible();
+ auto window = Dali::DevelWindow::Get(Self());
+ auto visible = window.IsVisible();
state[State::ENABLED] = true;
state[State::SENSITIVE] = true;
state[State::SHOWING] = visible;
}
else
{
- auto parentState = GetParent()->GetStates();
+ auto parentState = GetParent()->GetStates();
state[State::SHOWING] = parentState[State::SHOWING];
state[State::VISIBLE] = parentState[State::VISIBLE];
}
return state;
}
- Attributes GetAttributes() override
+ Attributes GetAttributes() const override
{
Dali::TypeInfo type;
Self().GetTypeInfo(type);
- return
- {
+ return {
{"class", type.GetName()},
};
}
{
return {};
}
-
- Dali::Actor GetInternalActor() override
- {
- return mSelf.GetHandle();
- }
}; // AdaptorAccessible
using AdaptorAccessiblesType = std::unordered_map<const Dali::RefObject*, std::unique_ptr<AdaptorAccessible> >;
void Accessible::SetObjectRegistry(ObjectRegistry registry)
{
objectRegistry = registry;
+ objectRegistry.ObjectDestroyedSignal().Connect([](const Dali::RefObject* obj) {
+ gAdaptorAccessibles.erase(obj);
+ });
}
void Accessible::RegisterExternalAccessibleGetter(std::function<Accessible*(Dali::Actor)> functor)
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)
{
--- /dev/null
+/*
+ * 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/devel-api/adaptor-framework/actor-accessible.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/window-devel.h>
+
+namespace Dali::Accessibility
+{
+ActorAccessible::ActorAccessible(Actor actor)
+: mSelf(actor)
+{
+}
+
+std::string ActorAccessible::GetName() const
+{
+ return Self().GetProperty<std::string>(Dali::Actor::Property::NAME);
+}
+
+std::string ActorAccessible::GetDescription() const
+{
+ return {};
+}
+
+Accessible* ActorAccessible::GetParent()
+{
+ if(IsOnRootLevel())
+ {
+ auto data = GetBridgeData();
+ return data->mBridge->GetApplication();
+ }
+
+ return Get(Self().GetParent());
+}
+
+std::size_t ActorAccessible::GetChildCount() const
+{
+ return static_cast<std::size_t>(Self().GetChildCount());
+}
+
+std::vector<Accessible*> ActorAccessible::GetChildren()
+{
+ std::vector<Accessible*> tmp(GetChildCount());
+ for(auto i = 0u; i < tmp.size(); ++i)
+ {
+ tmp[i] = GetChildAtIndex(i);
+ }
+
+ return tmp;
+}
+
+Accessible* ActorAccessible::GetChildAtIndex(std::size_t index)
+{
+ auto numberOfChildren = GetChildCount();
+ if(DALI_UNLIKELY(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<std::uint32_t>(index)));
+}
+
+std::size_t ActorAccessible::GetIndexInParent()
+{
+ auto self = Self();
+ auto parent = self.GetParent();
+
+ if(DALI_UNLIKELY(!parent))
+ {
+ throw std::domain_error{"can't call GetIndexInParent on object without parent"};
+ }
+
+ auto size = static_cast<std::size_t>(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 its parent"};
+}
+
+Dali::Actor ActorAccessible::GetInternalActor()
+{
+ return Self();
+}
+
+ComponentLayer ActorAccessible::GetLayer() const
+{
+ return ComponentLayer::WINDOW;
+}
+
+std::int16_t ActorAccessible::GetMdiZOrder() const
+{
+ return 0;
+}
+
+double ActorAccessible::GetAlpha() const
+{
+ return 0;
+}
+
+bool ActorAccessible::IsScrollable() const
+{
+ return false;
+}
+
+Dali::Rect<> ActorAccessible::GetExtents(CoordinateType type) const
+{
+ Dali::Actor actor = Self();
+ Vector2 screenPosition = actor.GetProperty<Vector2>(Actor::Property::SCREEN_POSITION);
+ Vector3 size = actor.GetCurrentProperty<Vector3>(Actor::Property::SIZE) * actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_SCALE);
+ bool positionUsesAnchorPoint = actor.GetProperty<bool>(Actor::Property::POSITION_USES_ANCHOR_POINT);
+ Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty<Vector3>(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT);
+ Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
+
+ if(type == CoordinateType::WINDOW)
+ {
+ return {position.x, position.y, size.x, size.y};
+ }
+ else // 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};
+ }
+}
+
+} // namespace Dali::Accessibility
--- /dev/null
+#ifndef DALI_ADAPTOR_ACTOR_ACCESSIBLE_H
+#define DALI_ADAPTOR_ACTOR_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 <dali/public-api/actors/actor.h>
+#include <dali/public-api/object/weak-handle.h>
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/atspi-interfaces/accessible.h>
+#include <dali/devel-api/atspi-interfaces/collection.h>
+#include <dali/devel-api/atspi-interfaces/component.h>
+
+namespace Dali::Accessibility
+{
+class DALI_ADAPTOR_API ActorAccessible : public virtual Accessible, public virtual Collection, public virtual Component
+{
+public:
+ ActorAccessible() = delete;
+
+ ActorAccessible(Actor actor);
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetName()
+ */
+ std::string GetName() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetDescription()
+ */
+ std::string GetDescription() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetParent()
+ */
+ Accessible* GetParent() override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetChildCount()
+ */
+ std::size_t GetChildCount() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetChildren()
+ */
+ std::vector<Accessible*> GetChildren() override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetChildAtIndex()
+ */
+ Accessible* GetChildAtIndex(std::size_t index) override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetIndexInParent()
+ */
+ std::size_t GetIndexInParent() override;
+
+ /**
+ * @copydoc Dali::Accessibility::Accessible::GetInternalActor()
+ */
+ Dali::Actor GetInternalActor() override;
+
+ /**
+ * @copydoc Dali::Accessibility::Component::GetLayer()
+ */
+ ComponentLayer GetLayer() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Component::GetMdiZOrder()
+ */
+ std::int16_t GetMdiZOrder() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Component::GetAlpha()
+ */
+ double GetAlpha() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Component::IsScrollable()
+ */
+ bool IsScrollable() const override;
+
+ /**
+ * @copydoc Dali::Accessibility::Component::GetExtents()
+ */
+ Dali::Rect<> GetExtents(CoordinateType type) const override;
+
+protected:
+ Dali::Actor Self() const
+ {
+ auto handle = mSelf.GetHandle();
+
+ // It is a bug if the Accessible outlives its Actor
+ DALI_ASSERT_ALWAYS(handle);
+
+ return handle;
+ }
+
+private:
+ Dali::WeakHandle<Dali::Actor> mSelf;
+};
+
+} // namespace Dali::Accessibility
+
+#endif // DALI_ADAPTOR_ACTOR_ACCESSIBLE_H
/**
* @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
+ * To be used as a proxy object, in those situations where you want to return an address in
+ * a different bridge (embedding for example), but the object itself isn't planned to be used
+ * otherwise. This object has no parent, no children, an empty name and so on.
*/
-class DALI_ADAPTOR_API EmptyAccessibleWithAddress : public virtual Accessible
+class DALI_ADAPTOR_API ProxyAccessible : public virtual Accessible
{
public:
- EmptyAccessibleWithAddress() = default;
+ ProxyAccessible() = default;
- EmptyAccessibleWithAddress(Address address)
+ ProxyAccessible(Address address)
: mAddress(std::move(address))
{
}
this->mAddress = std::move(address);
}
- std::string GetName() override
+ std::string GetName() const override
{
return "";
}
- std::string GetDescription() override
+ std::string GetDescription() const override
{
return "";
}
return nullptr;
}
- size_t GetChildCount() override
+ size_t GetChildCount() const override
{
return 0;
}
return static_cast<size_t>(-1);
}
- Role GetRole() override
+ Role GetRole() const override
{
return {};
}
- std::string GetRoleName() override;
+ std::string GetRoleName() const override
+ {
+ return {};
+ }
States GetStates() override
{
return {};
}
- Attributes GetAttributes() override
+ Attributes GetAttributes() const override
{
return {};
}
- Address GetAddress() override
+ Address GetAddress() const override
{
return mAddress;
}
#include <dali/public-api/actors/actor.h>
#include <dali/public-api/math/rect.h>
#include <dali/public-api/object/object-registry.h>
+#include <cstdint>
#include <string>
#include <vector>
class DALI_ADAPTOR_API Accessible
{
public:
- virtual ~Accessible();
+ virtual ~Accessible() noexcept;
using utf8_t = unsigned char;
*
* @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);
+ static void FindWordSeparationsUtf8(const utf8_t* string, std::size_t length, const char* language, char* breaks);
/**
* @brief Calculates and finds line boundaries in given utf8 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);
+ static void FindLineSeparationsUtf8(const utf8_t* string, std::size_t length, const char* language, char* breaks);
/**
* @brief Helper function for emiting active-descendant-changed event.
*
* @return The string with name
*/
- virtual std::string GetName() = 0;
+ virtual std::string GetName() const = 0;
/**
* @brief Gets accessibility description.
*
* @return The string with description
*/
- virtual std::string GetDescription() = 0;
+ virtual std::string GetDescription() const = 0;
/**
* @brief Gets parent.
*
* @return The number of children
*/
- virtual size_t GetChildCount() = 0;
+ virtual std::size_t GetChildCount() const = 0;
/**
* @brief Gets collection with all children.
*
* @return The collection of accessibility objects
*/
- virtual std::vector<Accessible*> GetChildren();
+ virtual std::vector<Accessible*> GetChildren() = 0;
/**
* @brief Gets child of the index.
*
* @return The child object
*/
- virtual Accessible* GetChildAtIndex(size_t index) = 0;
+ virtual Accessible* GetChildAtIndex(std::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;
+ virtual std::size_t GetIndexInParent() = 0;
/**
* @brief Gets accessibility role.
*
* @see Dali::Accessibility::Role
*/
- virtual Role GetRole() = 0;
+ virtual Role GetRole() const = 0;
/**
* @brief Gets name of accessibility role.
* @see Dali::Accessibility::Role
* @see Accessibility::Accessible::GetRole
*/
- virtual std::string GetRoleName();
+ virtual std::string GetRoleName() const;
/**
* @brief Gets localized name of accessibility role.
*
* @note translation is not supported in this version
*/
- virtual std::string GetLocalizedRoleName();
+ virtual std::string GetLocalizedRoleName() const;
/**
* @brief Gets accessibility states.
*
* @return The map of attributes and their values
*/
- virtual Attributes GetAttributes() = 0;
+ virtual Attributes GetAttributes() const = 0;
+
+ /**
+ * @brief Checks if this is hidden.
+ *
+ * @return True if this is hidden
+ *
+ * @note Hidden means not present in the AT-SPI tree.
+ */
+ virtual bool IsHidden() const;
/**
* @brief Checks if this is proxy.
*
* @return True if this is proxy
*/
- virtual bool IsProxy();
+ virtual bool IsProxy() const;
/**
* @brief Gets unique address on accessibility bus.
*
* @see Dali::Accessibility::Address
*/
- virtual Address GetAddress();
+ virtual Address GetAddress() const;
/**
* @brief Deputes an object to perform provided gesture.
*
* @return The collection of strings with implemented interfaces
*/
- std::vector<std::string> GetInterfaces();
+ std::vector<std::string> GetInterfaces() const;
/**
* @brief Checks if object is on root level.
Accessible(Accessible&&) = delete;
Accessible& operator=(const Accessible&) = delete;
Accessible& operator=(Accessible&&) = delete;
- std::shared_ptr<Bridge::Data> GetBridgeData();
+ std::shared_ptr<Bridge::Data> GetBridgeData() const;
public:
/**
private:
friend class Bridge;
- std::weak_ptr<Bridge::Data> mBridgeData;
- bool mIsOnRootLevel = false;
+ mutable std::weak_ptr<Bridge::Data> mBridgeData;
+ bool mIsOnRootLevel = false;
}; // Accessible class
*
* @return The string with name of action
*/
- virtual std::string GetActionName(size_t index) = 0;
+ virtual std::string GetActionName(std::size_t index) const = 0;
/**
* @brief Gets translated name of action with given index.
*
* @note The translation is not supported in this version
*/
- virtual std::string GetLocalizedActionName(size_t index) = 0;
+ virtual std::string GetLocalizedActionName(std::size_t index) const = 0;
/**
* @brief Gets description of action with given index.
*
* @return The string with description of action
*/
- virtual std::string GetActionDescription(size_t index) = 0;
+ virtual std::string GetActionDescription(std::size_t index) const = 0;
/**
* @brief Gets key code binded to action with given index.
*
* @return The string with key name
*/
- virtual std::string GetActionKeyBinding(size_t index) = 0;
+ virtual std::string GetActionKeyBinding(std::size_t index) const = 0;
/**
* @brief Gets number of provided actions.
*
* @return The number of actions
*/
- virtual size_t GetActionCount() = 0;
+ virtual std::size_t GetActionCount() const = 0;
/**
* @brief Performs an action with given index.
*
* @return true on success, false otherwise
*/
- virtual bool DoAction(size_t index) = 0;
+ virtual bool DoAction(std::size_t index) = 0;
/**
* @brief Performs an action with given name.
*
* @return String with name
*/
- virtual std::string GetToolkitName() = 0;
+ virtual std::string GetToolkitName() const = 0;
/**
* @brief Gets version of graphic user interface framework used by an application.
*
* @return String with version
*/
- virtual std::string GetVersion() = 0;
+ virtual std::string GetVersion() const = 0;
};
} // namespace Dali::Accessibility
*/
class DALI_ADAPTOR_API Collection : public virtual Accessible
{
-public:
};
} // namespace Dali::Accessibility
*
* @see Dali::Rect
*/
- virtual Rect<> GetExtents(CoordinateType type) = 0;
+ virtual Rect<> GetExtents(CoordinateType type) const = 0;
/**
* @brief Gets layer current object is localized on.
*
* @see Dali::Accessibility::ComponentLayer
*/
- virtual ComponentLayer GetLayer() = 0;
+ virtual ComponentLayer GetLayer() const = 0;
/**
* @brief Gets value of z-order.
* 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;
+ virtual int16_t GetMdiZOrder() const = 0;
/**
* @brief Sets current object as "focused".
*
* @return The alpha channel value in range [0.0, 1.0]
*/
- virtual double GetAlpha() = 0;
+ virtual double GetAlpha() const = 0;
/**
* @brief Sets current object as "highlighted".
*
* @see Dali:Accessibility::State
*/
- virtual bool IsScrollable();
+ virtual bool IsScrollable() const = 0;
/**
* @brief Gets Accessible object containing given point.
* @remarks This method is `Contains` in DBus method.
* @see Dali::Accessibility::Point
*/
- virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type);
+ virtual bool IsAccessibleContainingPoint(Point point, CoordinateType type) const;
};
} // namespace Dali::Accessibility
// INTERNAL INCLUDES
#include <dali/devel-api/atspi-interfaces/accessible.h>
+#include <dali/devel-api/atspi-interfaces/text.h>
namespace Dali::Accessibility
{
*
* @see Dali::Accessibility::EditableText
*/
-class DALI_ADAPTOR_API EditableText : public virtual Accessible
+class DALI_ADAPTOR_API EditableText : public virtual Accessible, public virtual Text
{
public:
/**
*
* @return true on success, false otherwise
*/
- virtual bool CopyText(size_t startPosition, size_t endPosition) = 0;
+ virtual bool CopyText(std::size_t startPosition, std::size_t endPosition) = 0;
/**
* @brief Cuts text in range to system clipboard.
*
* @return true on success, false otherwise
*/
- virtual bool CutText(size_t startPosition, size_t endPosition) = 0;
+ virtual bool CutText(std::size_t startPosition, std::size_t endPosition) = 0;
/**
* @brief Deletes text in range.
*
* @return true on success, false otherwise
*/
- virtual bool DeleteText(size_t startPosition, size_t endPosition) = 0;
+ virtual bool DeleteText(std::size_t startPosition, std::size_t endPosition) = 0;
/**
* @brief Inserts text at startPosition.
*
* @return true on success, false otherwise
*/
- virtual bool InsertText(size_t startPosition, std::string text) = 0;
+ virtual bool InsertText(std::size_t startPosition, std::string text) = 0;
/**
* @brief Replaces text with content.
*
* @return The 0-based index of hyperlink's last character + 1, in its originating hypertext.
*/
- virtual int32_t GetEndIndex() const = 0;
+ virtual std::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;
+ virtual std::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;
+ virtual std::int32_t GetAnchorCount() const = 0;
/**
* @brief Gets the object associated with a particular hyperlink's anchor.
*
* @return The handle to accessible object.
*/
- virtual Accessible* GetAnchorAccessible(int32_t anchorIndex) const = 0;
+ virtual Accessible* GetAnchorAccessible(std::int32_t anchorIndex) const = 0;
/**
* @brief Gets the URI associated with a particular hyperlink's anchor.
*
* @return The string containing URI.
*/
- virtual std::string GetAnchorUri(int32_t anchorIndex) const = 0;
+ virtual std::string GetAnchorUri(std::int32_t anchorIndex) const = 0;
/**
* @brief Tells whether this hyperlink object is still valid with respect to its originating hypertext object.
*
* @return Handle to hyperlink object at a specified index in hyperlink collection of hypertext.
*/
- virtual Hyperlink* GetLink(int32_t linkIndex) const = 0;
+ virtual Hyperlink* GetLink(std::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.
*
* @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;
+ virtual std::int32_t GetLinkIndex(std::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;
+ virtual std::int32_t GetLinkCount() const = 0;
};
} // namespace Dali::Accessibility
*
* @return The number of selected children (zero if none)
*/
- virtual int GetSelectedChildrenCount() = 0;
+ virtual int GetSelectedChildrenCount() const = 0;
/**
* @brief Gets a specific selected child.
*
* @return true if given child is selected, false otherwise
*/
- virtual bool IsChildSelected(int childIndex) = 0;
+ virtual bool IsChildSelected(int childIndex) const = 0;
/**
* @brief Selects all children.
*
* @return The substring of stored text
*/
- virtual std::string GetText(size_t startOffset, size_t endOffset) = 0;
+ virtual std::string GetText(std::size_t startOffset, std::size_t endOffset) const = 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;
+ virtual std::size_t GetCharacterCount() const = 0;
/**
* @brief Gets the cursor offset.
* @return Value of cursor offset
* @remarks This method is `CaretOffset` in DBus method.
*/
- virtual size_t GetCursorOffset() = 0;
+ virtual std::size_t GetCursorOffset() const = 0;
/**
* @brief Sets the cursor offset.
* @return True if successful
* @remarks This method is `SetCaretOffset` in DBus method.
*/
- virtual bool SetCursorOffset(size_t offset) = 0;
+ virtual bool SetCursorOffset(std::size_t offset) = 0;
/**
* @brief Gets substring of stored text truncated in concrete gradation.
*
* @see Dali::Accessibility::Range
*/
- virtual Range GetTextAtOffset(size_t offset, TextBoundary boundary) = 0;
+ virtual Range GetTextAtOffset(std::size_t offset, TextBoundary boundary) const = 0;
/**
* @brief Gets selected text.
* @remarks This method is `GetSelection` in DBus method.
* @see Dali::Accessibility::Range
*/
- virtual Range GetRangeOfSelection(size_t selectionIndex) = 0;
+ virtual Range GetRangeOfSelection(std::size_t selectionIndex) const = 0;
/**
* @brief Removes the whole selection.
*
* @return bool on success, false otherwise
*/
- virtual bool RemoveSelection(size_t selectionIndex) = 0;
+ virtual bool RemoveSelection(std::size_t selectionIndex) = 0;
/**
* @brief Sets selected text.
* @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;
+ virtual bool SetRangeOfSelection(std::size_t selectionIndex, std::size_t startOffset, std::size_t endOffset) = 0;
};
} // namespace Dali::Accessibility
*
* @return The minimum value
*/
- virtual double GetMinimum() = 0;
+ virtual double GetMinimum() const = 0;
/**
* @brief Gets the current value.
*
* @return The current value
*/
- virtual double GetCurrent() = 0;
+ virtual double GetCurrent() const = 0;
/**
* @brief Gets the highest possible value.
*
* @return The highest value.
*/
- virtual double GetMaximum() = 0;
+ virtual double GetMaximum() const = 0;
/**
* @brief Sets the current value.
*
* @return The lowest increment
*/
- virtual double GetMinimumIncrement() = 0;
+ virtual double GetMinimumIncrement() const = 0;
};
} // namespace Dali::Accessibility
SET( devel_api_src_files
${adaptor_devel_api_dir}/adaptor-framework/accessibility.cpp
+ ${adaptor_devel_api_dir}/adaptor-framework/actor-accessible.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
SET( devel_api_adaptor_framework_header_files
${adaptor_devel_api_dir}/adaptor-framework/accessibility.h
${adaptor_devel_api_dir}/adaptor-framework/accessibility-bridge.h
+ ${adaptor_devel_api_dir}/adaptor-framework/actor-accessible.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
using namespace Dali::Accessibility;
-std::vector<std::string> Accessible::GetInterfaces()
+std::vector<std::string> Accessible::GetInterfaces() const
{
std::vector<std::string> tmp;
tmp.push_back(AtspiDbusInterfaceAccessible);
- if(dynamic_cast<Collection*>(this))
+ if(dynamic_cast<const Collection*>(this))
{
tmp.push_back(AtspiDbusInterfaceCollection);
}
- if(dynamic_cast<Text*>(this))
+ if(dynamic_cast<const Text*>(this))
{
tmp.push_back(AtspiDbusInterfaceText);
}
- if(dynamic_cast<EditableText*>(this))
+ if(dynamic_cast<const EditableText*>(this))
{
tmp.push_back(AtspiDbusInterfaceEditableText);
}
- if(dynamic_cast<Value*>(this))
+ if(dynamic_cast<const Value*>(this))
{
tmp.push_back(AtspiDbusInterfaceValue);
}
- if(dynamic_cast<Component*>(this))
+ if(dynamic_cast<const Component*>(this))
{
tmp.push_back(AtspiDbusInterfaceComponent);
}
- if(auto action = dynamic_cast<Action*>(this))
+ if(auto action = dynamic_cast<const Action*>(this))
{
if(action->GetActionCount() > 0)
{
tmp.push_back(AtspiDbusInterfaceAction);
}
}
- if(dynamic_cast<Selection*>(this))
+ if(dynamic_cast<const Selection*>(this))
{
tmp.push_back(AtspiDbusInterfaceSelection);
}
- if(dynamic_cast<Hypertext*>(this))
+ if(dynamic_cast<const Hypertext*>(this))
{
tmp.push_back(AtspiDbusInterfaceHypertext);
}
- if(dynamic_cast<Hyperlink*>(this))
+ if(dynamic_cast<const Hyperlink*>(this))
{
tmp.push_back(AtspiDbusInterfaceHyperlink);
}
{
}
-Accessible::~Accessible()
+Accessible::~Accessible() noexcept
{
auto handle = mBridgeData.lock();
if(handle)
}
}
-std::vector<Accessible*> Accessible::GetChildren()
-{
- std::vector<Accessible*> tmp(GetChildCount());
- for(auto i = 0u; i < tmp.size(); ++i)
- {
- tmp[i] = GetChildAtIndex(i);
- }
- return tmp;
-}
-
-std::shared_ptr<Bridge::Data> Accessible::GetBridgeData()
+std::shared_ptr<Bridge::Data> Accessible::GetBridgeData() const
{
auto handle = mBridgeData.lock();
if(!handle)
return handle;
}
-Address Accessible::GetAddress()
+Address Accessible::GetAddress() const
{
auto handle = mBridgeData.lock();
if(!handle)
return {handle ? handle->mBusName : "", tmp.str()};
}
-void Bridge::RegisterOnBridge(Accessible* object)
+void Bridge::RegisterOnBridge(const Accessible* object)
{
assert(!object->mBridgeData.lock() || object->mBridgeData.lock() == mData);
if(!object->mBridgeData.lock())
}
}
-bool Accessible::IsProxy()
+bool Accessible::IsHidden() const
+{
+ return false;
+}
+
+bool Accessible::IsProxy() const
{
return false;
}
BridgeBase::ForceUpResult BridgeBase::ForceUp()
{
- if(Bridge::ForceUp() == ForceUpResult::ALREADY_UP)
+ //TODO: checking mBusName is enough? or a new variable to check bridge state?
+ if(Bridge::ForceUp() == ForceUpResult::ALREADY_UP && !GetBusName().empty())
{
return ForceUpResult::ALREADY_UP;
}
if(!addr)
{
- throw std::domain_error{std::string("failed at call '") + dbusLocators::atspi::GET_ADDRESS + "': " + addr.getError().message};
+ DALI_LOG_ERROR("failed at call '%s': %s\n", dbusLocators::atspi::GET_ADDRESS, addr.getError().message.c_str());
+ return ForceUpResult::FAILED;
}
mConnectionPtr = DBusWrapper::Installed()->eldbus_address_connection_get_impl(std::get<0>(addr));
{
if(windowAccessible->GetInternalActor() == mApplication.mWindows[i].GetRootLayer())
{
- Dali::Accessibility::Bridge::GetCurrentBridge()->WindowHidden(mApplication.mWindows[i]);
Dali::DevelWindow::VisibilityChangedSignal(mApplication.mWindows[i]).Disconnect(this, &BridgeBase::OnWindowVisibilityChanged);
mApplication.mWindows[i].FocusChangeSignal().Disconnect(this, &BridgeBase::OnWindowFocusChanged);
mApplication.mWindows.erase(mApplication.mWindows.begin() + i);
#include <dali/internal/accessibility/bridge/accessibility-common.h>
/**
- * @brief The AppAccessible class is to define Accessibility Application.
+ * @brief The ApplicationAccessible class is to define Accessibility Application.
*/
-class AppAccessible : public virtual Dali::Accessibility::Accessible, public virtual Dali::Accessibility::Collection, public virtual Dali::Accessibility::Application
+class ApplicationAccessible : public virtual Dali::Accessibility::Accessible, public virtual Dali::Accessibility::Collection, public virtual Dali::Accessibility::Application
{
public:
- Dali::Accessibility::EmptyAccessibleWithAddress mParent;
- std::vector<Dali::Accessibility::Accessible*> mChildren;
- std::vector<Dali::Window> mWindows;
- std::string mName;
+ Dali::Accessibility::ProxyAccessible mParent;
+ std::vector<Dali::Accessibility::Accessible*> mChildren;
+ std::vector<Dali::Window> mWindows;
+ std::string mName;
- std::string GetName() override
+ std::string GetName() const override
{
return mName;
}
- std::string GetDescription() override
+ std::string GetDescription() const override
{
return "";
}
return &mParent;
}
- size_t GetChildCount() override
+ size_t GetChildCount() const override
{
return mChildren.size();
}
+ std::vector<Dali::Accessibility::Accessible*> GetChildren() override
+ {
+ return mChildren;
+ }
+
Dali::Accessibility::Accessible* GetChildAtIndex(size_t index) override
{
auto size = mChildren.size();
throw std::domain_error{"can't call GetIndexInParent on application object"};
}
- Dali::Accessibility::Role GetRole() override
+ Dali::Accessibility::Role GetRole() const override
{
return Dali::Accessibility::Role::APPLICATION;
}
return {};
}
- Dali::Accessibility::Attributes GetAttributes() override
+ Dali::Accessibility::Attributes GetAttributes() const override
{
return {};
}
return Dali::Actor{};
}
- Dali::Accessibility::Address GetAddress() override
+ Dali::Accessibility::Address GetAddress() const override
{
return {"", "root"};
}
- std::string GetToolkitName() override
+ std::string GetToolkitName() const override
{
return {"dali"};
}
- std::string GetVersion() override
+ std::string GetVersion() const override
{
return std::to_string(Dali::ADAPTOR_MAJOR_VERSION) + "." + std::to_string(Dali::ADAPTOR_MINOR_VERSION);
}
}
protected:
- mutable AppAccessible mApplication;
+ mutable ApplicationAccessible mApplication;
std::vector<Dali::Accessibility::Accessible*> mDefaultLabels;
bool mIsScreenReaderSuppressed = false;
Dali::Timer mInitializeTimer;
Dali::Timer mReadIsEnabledTimer;
Dali::Timer mReadScreenReaderEnabledTimer;
+ Dali::Timer mForceUpTimer;
public:
BridgeImpl()
mDirectReadingCallbacks.clear();
mApplication.mChildren.clear();
mApplication.mWindows.clear();
+ ClearTimer();
}
- void StopTimer()
+ void ClearTimer()
{
if(mInitializeTimer)
{
mInitializeTimer.Stop();
+ mInitializeTimer.Reset();
}
if(mReadIsEnabledTimer)
{
mReadIsEnabledTimer.Stop();
+ mReadIsEnabledTimer.Reset();
}
if(mReadScreenReaderEnabledTimer)
{
mReadScreenReaderEnabledTimer.Stop();
+ mReadScreenReaderEnabledTimer.Reset();
+ }
+
+ if(mForceUpTimer)
+ {
+ mForceUpTimer.Stop();
+ mForceUpTimer.Reset();
}
}
mData->mHighlightActor = {};
}
ForceDown();
- StopTimer();
if((NULL != mIdleCallback) && Dali::Adaptor::IsAvailable())
{
Dali::Adaptor::Get().RemoveIdle(mIdleCallback);
mConnectionPtr = {};
}
+ bool ForceUpTimerCallback()
+ {
+ if(ForceUp() != ForceUpResult::FAILED)
+ {
+ return false;
+ }
+ return true;
+ }
+
/**
* @copydoc Dali::Accessibility::Bridge::ForceUp()
*/
ForceUpResult ForceUp() override
{
- if(BridgeAccessible::ForceUp() == ForceUpResult::ALREADY_UP)
+ auto forceUpResult = BridgeAccessible::ForceUp();
+ if(forceUpResult == ForceUpResult::ALREADY_UP)
{
- return ForceUpResult::ALREADY_UP;
+ return forceUpResult;
+ }
+ else if(forceUpResult == ForceUpResult::FAILED)
+ {
+ if(!mForceUpTimer)
+ {
+ mForceUpTimer = Dali::Timer::New(RETRY_INTERVAL);
+ mForceUpTimer.TickSignal().Connect(this, &BridgeImpl::ForceUpTimerCallback);
+ mForceUpTimer.Start();
+ }
+ return forceUpResult;
}
BridgeObject::RegisterInterfaces();
ReadScreenReaderEnabledProperty();
}
+ void SwitchBridge()
+ {
+ if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
+ {
+ ForceUp();
+ }
+ else
+ {
+ ForceDown();
+ }
+ }
+
bool ReadIsEnabledTimerCallback()
{
ReadIsEnabledProperty();
}
return;
}
- mIsEnabled = std::get<0>(msg);
- if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
- {
- ForceUp();
- }
- else
+
+ if(mReadIsEnabledTimer)
{
- ForceDown();
+ mReadIsEnabledTimer.Stop();
+ mReadIsEnabledTimer.Reset();
}
+
+ mIsEnabled = std::get<0>(msg);
+ SwitchBridge();
});
}
{
mAccessibilityStatusClient.addPropertyChangedEvent<bool>("IsEnabled", [this](bool res) {
mIsEnabled = res;
- if(mIsScreenReaderEnabled || mIsEnabled)
- {
- ForceUp();
- }
- else
- {
- ForceDown();
- }
+ SwitchBridge();
});
}
}
return;
}
- mIsScreenReaderEnabled = std::get<0>(msg);
- if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
- {
- ForceUp();
- }
- else
+
+ if(mReadScreenReaderEnabledTimer)
{
- ForceDown();
+ mReadScreenReaderEnabledTimer.Stop();
+ mReadScreenReaderEnabledTimer.Reset();
}
+
+ mIsScreenReaderEnabled = std::get<0>(msg);
+ SwitchBridge();
});
}
{
mAccessibilityStatusClient.addPropertyChangedEvent<bool>("ScreenReaderEnabled", [this](bool res) {
mIsScreenReaderEnabled = res;
- if((!mIsScreenReaderSuppressed && mIsScreenReaderEnabled) || mIsEnabled)
- {
- ForceUp();
- }
- else
- {
- ForceDown();
- }
+ SwitchBridge();
});
}
using namespace Dali::Accessibility;
-bool Component::IsAccessibleContainingPoint(Point point, Dali::Accessibility::CoordinateType type)
+bool Component::IsAccessibleContainingPoint(Point point, Dali::Accessibility::CoordinateType type) const
{
auto extents = GetExtents(type);
return point.x >= extents.x && point.y >= extents.y && point.x <= extents.x + extents.width && point.y <= extents.y + extents.height;
}
return nullptr;
}
-
-bool Component::IsScrollable()
-{
- return false;
-}
{
}
-Accessibility::Accessible::~Accessible()
+Accessibility::Accessible::~Accessible() noexcept
{
}
return {};
}
-Accessibility::Address Accessibility::Accessible::GetAddress()
+Accessibility::Address Accessibility::Accessible::GetAddress() const
{
return {};
}
-std::shared_ptr<Accessibility::Bridge::Data> Accessibility::Accessible::GetBridgeData()
+std::shared_ptr<Accessibility::Bridge::Data> Accessibility::Accessible::GetBridgeData() const
{
return {};
}
-bool Accessibility::Accessible::IsProxy()
+bool Accessibility::Accessible::IsHidden() const
{
return false;
}
-bool Accessibility::Component::IsScrollable()
+bool Accessibility::Accessible::IsProxy() const
{
return false;
}
-bool Accessibility::Component::IsAccessibleContainingPoint(Point point, CoordinateType type)
+bool Accessibility::Component::IsScrollable() const
+{
+ return false;
+}
+
+bool Accessibility::Component::IsAccessibleContainingPoint(Point point, CoordinateType type) const
{
return false;
}
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
{
class CommandPool
{
- static const uint32_t COMMAND_POOL_DEFAULT_INCREMENT = 1024 * 32; // 32kb banks
- static const uint32_t MEMORY_POOL_DEFAULT_INCREMENT = 1024; // 4kb memory pool increment
- static const uint32_t MEMORY_POOL_DEFAULT_ALIGNMENT = 64; // 64bytes alignment
+ static constexpr uint32_t COMMAND_POOL_DEFAULT_INCREMENT = 1024 * 32 / sizeof(Command); // 32kb banks
+ static const uint32_t MEMORY_POOL_DEFAULT_INCREMENT = 1024; // 1kb memory pool increment
+ static const uint32_t MEMORY_POOL_DEFAULT_ALIGNMENT = 64; // 64bytes alignment
template<class T>
struct Block
IndirectPtr<T> Allocate(uint32_t count)
{
- // set fixed capacity
- if(fixedCapacity && data.size() != fixedCapacity)
+ // Set fixed capacity
+ if(fixedCapacity)
{
- data.resize(fixedCapacity);
- totalCapacity = data.size();
+ // resize data size when capacity is not setuped.
+ // Note if totalCapacity is bigger than fixedCapacity,
+ // just skip here and resize dynamically
+ if(DALI_UNLIKELY(totalCapacity < fixedCapacity))
+ {
+ data.resize(fixedCapacity);
+ totalCapacity = data.size();
+ }
}
- // or resize dynamically
- else if(data.size() <= offset + count)
+ // Resize dynamically
+ if(DALI_UNLIKELY(totalCapacity < offset + count))
{
- data.resize(data.size() + Increment);
+ // Resize the memory size as ceil((offset + count - totalCapacity)) / Increment) * Increment
+ // So the incremented size of data is always multiplied of the value Increment.
+ data.resize(data.size() + ((offset + count - totalCapacity - 1) / Increment + 1) * Increment);
// update base pointer, required for address translation
totalCapacity = data.size();
{
const unsigned int ADAPTOR_MAJOR_VERSION = 2;
const unsigned int ADAPTOR_MINOR_VERSION = 1;
-const unsigned int ADAPTOR_MICRO_VERSION = 3;
+const unsigned int ADAPTOR_MICRO_VERSION = 4;
const char* const ADAPTOR_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2-adaptor
Summary: The DALi Tizen Adaptor
-Version: 2.1.3
+Version: 2.1.4
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT