#define DALI_ADAPTOR_ATSPI_ACCESSIBLE_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
#include <vector>
// INTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/accessibility.h>
#include <dali/devel-api/adaptor-framework/accessibility-bridge.h>
+#include <dali/devel-api/adaptor-framework/accessibility.h>
namespace Dali::Accessibility
{
public:
virtual ~Accessible() noexcept;
- 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.
- */
- 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.
- *
- * @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.
- */
- 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.
*
void EmitMovedOutOfScreen(ScreenRelativeMoveType type);
/**
+ * @brief Emits "org.a11y.atspi.Socket.Available" signal.
+ */
+ // This belongs to Dali::Accessibility::Socket. However, all Emit*() helpers
+ // are here in Accessible, regardless of what interface they belong to (perhaps
+ // to spare a dynamic_cast if used like this: Accessible::Get()->Emit*(...)).
+ void EmitSocketAvailable();
+
+ /**
* @brief Emits "highlighted" event.
*
* @param[in] event The enumerated window event
/**
* @brief Gets accessibility attributes.
*
+ * Attributes are key-value string pairs which can be used to transfer arbitrary
+ * information from the application to a client such as a screen reader or an
+ * automation framework.
+ *
+ * Typically, attributes are used when the data does not fit any other category
+ * with a dedicated API (name, description, states etc.).
+ *
+ * @see Accessible::SetAttribute()
+ * @see Accessible::UnsetAttribute()
+ * @see Accessible::ClearAttributes()
+ * @see Accessible::UpdateAttributes()
+ *
* @return The map of attributes and their values
*/
- virtual Attributes GetAttributes() const = 0;
+ const Attributes& GetAttributes() const;
+
+ /**
+ * @brief Sets an attribute
+ *
+ * The key will be created if necessary and the old attribute value (if any) will be replaced.
+ *
+ * @param[in] key Attribute key
+ * @param[in] value Attribute value
+ *
+ * @return True if the key was created, false otherwise (only value was updated)
+ */
+ bool SetAttribute(const std::string& key, const std::string& value);
+
+ /**
+ * @brief Unsets an attribute
+ *
+ * The key-value pair is removed from the attribute collection.
+ *
+ * @param[in] key Attribute key
+ *
+ * @return True if there was such a key, false otherwise
+ */
+ bool UnsetAttribute(const std::string& key);
+
+ /**
+ * @brief Unsets all attributes
+ *
+ * @see Accessible::UnsetAttribute()
+ */
+ void ClearAttributes();
+
+ /**
+ * @brief Gets the reading info types
+ *
+ * @return Reading info types bitmask
+ * @see Accessible::SetReadingInfoTypes()
+ */
+ ReadingInfoTypes GetReadingInfoTypes() const;
+
+ /**
+ * @brief Sets the reading info types
+ *
+ * The reading info types are individual pieces of information (name, role etc.)
+ * that can be read by the screen reader. This method can be used to enable and
+ * disable reading specific pieces.
+ *
+ * @param[in] types Reading info types bitmask
+ *
+ * @note The types will appear in GetAttributes() under the "reading_info_type" key.
+ * @see Accessible::GetAttributes()
+ */
+ void SetReadingInfoTypes(ReadingInfoTypes types);
/**
* @brief Checks if this is hidden.
virtual std::vector<Relation> GetRelationSet() = 0;
/**
- * @brief Gets internal Actor to be saved before.
+ * @brief Gets the Actor associated with this Accessible (if there is one).
*
* @return The internal Actor
*/
virtual Dali::Actor GetInternalActor() = 0;
/**
+ * @brief Sets whether to listen for post render callback.
+ *
+ * @param[in] enabled If ture, registration post render callback, false otherwise
+ */
+ virtual void SetListenPostRender(bool enabled);
+
+ /**
* @brief Gets all implemented interfaces.
*
* Override DoGetInterfaces() to customize the return value of this method.
return mIsOnRootLevel;
}
+ /**
+ * @brief Gets all suppressed events.
+ *
+ * @return All suppressed events
+ */
+ AtspiEvents GetSuppressedEvents() const
+ {
+ return mSuppressedEvents;
+ }
+
+ /**
+ * @brief Gets all suppressed events.
+ *
+ * @return All suppressed events
+ */
+ AtspiEvents& GetSuppressedEvents()
+ {
+ return mSuppressedEvents;
+ }
+
protected:
Accessible();
Accessible(const Accessible&) = delete;
*/
virtual AtspiInterfaces DoGetInterfaces() const;
+ /**
+ * @brief Updates the attribute collection
+ *
+ * This method, which is always called by GetAttributes(), can be overriden to
+ * provide lazily-calculated or dynamically-calculated (i.e. non-constant)
+ * attributes. When overriding, make sure to call the base class implementation
+ * first.
+ *
+ * @note The attribute collection is non-empty on entry
+ * @see Accessible::GetAttributes()
+ *
+ * @param[inout] attributes The attribute collection to update
+ */
+ virtual void UpdateAttributes(Attributes& attributes) const;
+
public:
/**
* @brief Gets the highlight actor.
* @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);
+ static Accessible* Get(Dali::Actor actor);
/**
* @brief Obtains the DBus interface name for the specified AT-SPI interface.
mutable std::weak_ptr<Bridge::Data> mBridgeData;
mutable AtspiInterfaces mInterfaces;
+ mutable Attributes mAttributes;
+ ReadingInfoTypes mReadingInfoTypes = ~ReadingInfoTypes(); // all set
+ AtspiEvents mSuppressedEvents;
bool mIsOnRootLevel = false;
-
}; // Accessible class
namespace Internal