1 #ifndef __DALI_ACCESSIBILITY_H__
2 #define __DALI_ACCESSIBILITY_H__
4 #include <dali/public-api/actors/actor.h>
12 #include <unordered_map>
19 namespace Accessibility
21 enum class RelationType
27 enum class MatchType : int32_t
36 enum class SortOrder : uint32_t
54 enum class NeighborSearchDirection
60 enum class ComponentLayer
73 enum class Role : uint32_t
168 DocumentPresentation,
199 enum class State : uint32_t
238 SupportsAutocompletion,
250 enum class WindowEvent
273 enum class TextBoundary : uint32_t
285 template < size_t I, typename S >
288 std::array< uint32_t, I > data;
293 for( auto& u : data )
296 explicit BitStates( std::array< uint32_t, I > d )
298 for( auto i = 0u; i < I; ++i )
301 explicit BitStates( std::array< int32_t, I > d )
303 for( auto i = 0u; i < I; ++i )
304 data[i] = static_cast< uint32_t >( d[i] );
309 std::array< uint32_t, I >& data;
311 bool operator=( reference r )
313 return ( *this ) = static_cast< bool >( r );
315 bool operator=( bool v )
318 data[pos / 32] |= 1 << ( pos & 31 );
320 data[pos / 32] &= ~( 1 << ( pos & 31 ) );
323 operator bool() const
325 auto i = static_cast< size_t >( pos );
326 return ( data[i / 32] & ( 1 << ( i & 31 ) ) ) != 0;
329 reference operator[]( S index ) { return {data, static_cast< size_t >( index )}; }
330 bool operator[]( S index ) const
332 auto i = static_cast< size_t >( index );
333 return ( data[i / 32] & ( 1 << ( i & 31 ) ) ) != 0;
335 std::array< uint32_t, I > GetRawData() const { return data; }
337 BitStates operator|( BitStates b ) const
340 for( auto i = 0u; i < I; ++i )
341 r.data[i] = data[i] | b.data[i];
344 BitStates operator&( BitStates b ) const
347 for( auto i = 0u; i < I; ++i )
348 r.data[i] = data[i] & b.data[i];
351 bool operator==( BitStates b ) const
353 for( auto i = 0u; i < I; ++i )
354 if( data[i] != b.data[i] )
358 explicit operator bool() const
360 for( auto& u : data )
367 using States = BitStates< 2, State >;
368 using Attributes = std::unordered_map< std::string, std::string >;
370 class DALI_IMPORT_API Address
374 Address( std::string bus, std::string path ) : bus( std::move( bus ) ), path( std::move( path ) ) {}
376 explicit operator bool() const { return !path.empty(); }
377 std::string ToString() const
379 return *this ? bus + ":" + path : "::null";
381 const std::string& GetBus() const { return bus; }
382 const std::string& GetPath() const { return path; }
385 std::string bus, path;
388 enum class KeyEventType
398 struct DALI_IMPORT_API Point
404 Point( int x, int y ) : x( x ), y( y ) {}
406 bool operator==( Point p ) const
408 return x == p.x && y == p.y;
410 bool operator!=( Point p ) const
412 return !( *this == p );
416 struct DALI_IMPORT_API Size
422 Size( int w, int h ) : width( w ), height( h ) {}
424 bool operator==( Size p ) const
426 return width == p.width && height == p.height;
428 bool operator!=( Size p ) const
430 return !( *this == p );
434 struct DALI_IMPORT_API Rectangle
439 bool operator==( Rectangle p ) const
441 return position == p.position && size == p.size;
443 bool operator!=( Rectangle p ) const
445 return !( *this == p );
448 struct DALI_IMPORT_API Range
455 Range( size_t start, size_t end ) : startOffset( start ), endOffset( end )
458 Range( size_t start, size_t end, std::string content ) : startOffset( start ), endOffset( end ), content( content )
463 class DALI_IMPORT_API AccessibleError : public std::exception
466 AccessibleError( std::string msg ) : msg( std::move( msg ) ) {}
467 const char* what() const noexcept override { return msg.c_str(); }
478 struct hash< Dali::Accessibility::Point >
480 size_t operator()( Dali::Accessibility::Point p )
482 return static_cast< size_t >( p.x ) ^ ( static_cast< size_t >( p.y ) * 11 );
486 struct hash< Dali::Accessibility::Size >
488 size_t operator()( Dali::Accessibility::Size p )
490 return static_cast< size_t >( p.width ) ^ ( static_cast< size_t >( p.height ) * 11 );
494 struct hash< Dali::Accessibility::Rectangle >
496 size_t operator()( Dali::Accessibility::Rectangle p )
498 return hash< Dali::Accessibility::Point >()( p.position ) ^ ( hash< Dali::Accessibility::Size >()( p.size ) * 11 );