X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Faccessibility-manager%2Faccessibility-manager-impl.cpp;h=aee1bc0ff176bd0e7f902c97f14a669f7c0ebdd8;hp=16e0c6484b354d0d602dc2d7b37fd06dc125f278;hb=0070e9ca4e08996ac60bf9637e695b32ee72e713;hpb=94517504b052e71c97105d13625d7f2ce5933889 diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp index 16e0c64..aee1bc0 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -31,6 +31,7 @@ // INTERNAL INCLUDES #include #include +#include namespace Dali { @@ -46,19 +47,18 @@ namespace // unnamed namespace // Signals -const char* const SIGNAL_FOCUS_CHANGED = "focus-changed"; -const char* const SIGNAL_FOCUS_OVERSHOT = "focus-overshot"; -const char* const SIGNAL_FOCUSED_ACTOR_ACTIVATED = "focused-actor-activated"; +const char* const SIGNAL_FOCUS_CHANGED = "focusChanged"; +const char* const SIGNAL_FOCUS_OVERSHOT = "focusOvershot"; +const char* const SIGNAL_FOCUSED_ACTOR_ACTIVATED = "focusedActorActivated"; #if defined(DEBUG_ENABLED) Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_FOCUS_MANAGER"); #endif const char* const ACTOR_FOCUSABLE("focusable"); -const char* const IS_FOCUS_GROUP("is-focus-group"); +const char* const IS_FOCUS_GROUP("isFocusGroup"); -const char* FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "B16-8_TTS_focus.png"; -const Vector4 FOCUS_BORDER_IMAGE_BORDER = Vector4(7.0f, 7.0f, 7.0f, 7.0f); +const char* FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "B16-8_TTS_focus.9.png"; const char* FOCUS_SOUND_FILE = DALI_SOUND_DIR "Focus.ogg"; const char* FOCUS_CHAIN_END_SOUND_FILE = DALI_SOUND_DIR "End_of_List.ogg"; @@ -108,7 +108,9 @@ bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType AccessibilityManager::AccessibilityManager() : mCurrentFocusActor(FocusIDPair(0, 0)), - mFocusIndicatorActor(Actor()), + mCurrentGesturedActor(), + mFocusIndicatorActor(), + mPreviousPosition( 0.0f, 0.0f ), mRecursiveFocusMoveCounter(0), mIsWrapped(false), mIsFocusWithinGroup(false), @@ -127,8 +129,6 @@ AccessibilityManager::~AccessibilityManager() void AccessibilityManager::Initialise() { - CreateDefaultFocusIndicatorActor(); - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); adaptor.SetActionHandler(*this); adaptor.SetGestureHandler(*this); @@ -191,12 +191,8 @@ void AccessibilityManager::SetFocusOrder(Actor actor, const unsigned int order) // Firstly delete the actor from the focus chain if it's already there with a different focus order. mFocusIDContainer.erase(GetFocusOrder(actor)); - // Create actor focusable property if not already created. - Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE); - if(propertyActorFocusable == Property::INVALID_INDEX) - { - propertyActorFocusable = actor.RegisterProperty( ACTOR_FOCUSABLE, true, Property::READ_WRITE ); - } + // Create/retrieve actor focusable property + Property::Index propertyActorFocusable = actor.RegisterProperty( ACTOR_FOCUSABLE, true, Property::READ_WRITE ); if(order == 0) { @@ -345,9 +341,9 @@ bool AccessibilityManager::DoSetCurrentFocusActor(const unsigned int actorID) if(actorVisible && actorFocusable && actorOpaque) { // Draw the focus indicator upon the focused actor - if(mIsFocusIndicatorEnabled && mFocusIndicatorActor) + if( mIsFocusIndicatorEnabled ) { - actor.Add(mFocusIndicatorActor); + actor.Add( GetFocusIndicatorActor() ); } // Send notification for the change of focus actor @@ -483,9 +479,9 @@ void AccessibilityManager::DoActivate(Actor actor) void AccessibilityManager::ClearFocus() { Actor actor = GetCurrentFocusActor(); - if(actor) + if( actor && mFocusIndicatorActor ) { - actor.Remove(mFocusIndicatorActor); + actor.Remove( mFocusIndicatorActor ); } mCurrentFocusActor = FocusIDPair(0, 0); @@ -512,16 +508,8 @@ void AccessibilityManager::SetFocusGroup(Actor actor, bool isFocusGroup) { if(actor) { - // Create focus group property if not already created. - Property::Index propertyIsFocusGroup = actor.GetPropertyIndex(IS_FOCUS_GROUP); - if(propertyIsFocusGroup == Property::INVALID_INDEX) - { - actor.RegisterProperty( IS_FOCUS_GROUP, isFocusGroup, Property::READ_WRITE ); - } - else - { - actor.SetProperty(propertyIsFocusGroup, isFocusGroup); - } + // Create/Set focus group property. + actor.RegisterProperty( IS_FOCUS_GROUP, isFocusGroup, Property::READ_WRITE ); } } @@ -553,6 +541,12 @@ Actor AccessibilityManager::GetFocusGroup(Actor actor) return actor; } +Vector2 AccessibilityManager::GetReadPosition() const +{ + AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); + return adaptor.GetReadPosition(); +} + void AccessibilityManager::SetGroupMode(bool enabled) { mIsFocusWithinGroup = enabled; @@ -575,11 +569,40 @@ bool AccessibilityManager::GetWrapMode() const void AccessibilityManager::SetFocusIndicatorActor(Actor indicator) { - mFocusIndicatorActor = indicator; + if( mFocusIndicatorActor != indicator ) + { + Actor currentFocusActor = GetCurrentFocusActor(); + if( currentFocusActor ) + { + // The new focus indicator should be added to the current focused actor immediately + if( mFocusIndicatorActor ) + { + currentFocusActor.Remove( mFocusIndicatorActor ); + } + + if( indicator ) + { + currentFocusActor.Add( indicator ); + } + } + + mFocusIndicatorActor = indicator; + } } Actor AccessibilityManager::GetFocusIndicatorActor() { + if( ! mFocusIndicatorActor ) + { + // Create the default if it hasn't been set and one that's shared by all the keyboard focusable actors + mFocusIndicatorActor = Toolkit::ImageView::New( FOCUS_BORDER_IMAGE_PATH ); + mFocusIndicatorActor.SetParentOrigin( ParentOrigin::CENTER ); + mFocusIndicatorActor.SetZ( 1.0f ); + + // Apply size constraint to the focus indicator + mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + } + return mFocusIndicatorActor; } @@ -661,36 +684,11 @@ void AccessibilityManager::SetFocusable(Actor actor, bool focusable) { if(actor) { - // Create actor focusable property if not already created. - Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE); - if(propertyActorFocusable == Property::INVALID_INDEX) - { - actor.RegisterProperty( ACTOR_FOCUSABLE, focusable, Property::READ_WRITE ); - } - else - { - actor.SetProperty(propertyActorFocusable, focusable); - } + // Create/Set actor focusable property. + actor.RegisterProperty( ACTOR_FOCUSABLE, focusable, Property::READ_WRITE ); } } -void AccessibilityManager::CreateDefaultFocusIndicatorActor() -{ - // Create a focus indicator actor shared by all the focusable actors - Image borderImage = ResourceImage::New(FOCUS_BORDER_IMAGE_PATH); - - ImageActor focusIndicator = ImageActor::New(borderImage); - focusIndicator.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION_PLUS_LOCAL_POSITION ); - focusIndicator.SetStyle( ImageActor::STYLE_NINE_PATCH ); - focusIndicator.SetNinePatchBorder(FOCUS_BORDER_IMAGE_BORDER); - focusIndicator.SetPosition(Vector3(0.0f, 0.0f, 1.0f)); - - // Apply size constraint to the focus indicator - focusIndicator.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - SetFocusIndicatorActor(focusIndicator); -} - bool AccessibilityManager::ChangeAccessibilityStatus() { AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); @@ -703,10 +701,7 @@ bool AccessibilityManager::ChangeAccessibilityStatus() Actor actor = GetCurrentFocusActor(); if(actor) { - if(mFocusIndicatorActor) - { - actor.Add(mFocusIndicatorActor); - } + actor.Add( GetFocusIndicatorActor() ); } mIsFocusIndicatorEnabled = true; @@ -719,9 +714,9 @@ bool AccessibilityManager::ChangeAccessibilityStatus() { // Hide indicator when tts turned off Actor actor = GetCurrentFocusActor(); - if(actor) + if( actor && mFocusIndicatorActor ) { - actor.Remove(mFocusIndicatorActor); + actor.Remove( mFocusIndicatorActor ); } mIsFocusIndicatorEnabled = false; @@ -1245,19 +1240,6 @@ bool AccessibilityManager::AccessibilityActionZoom() return ret; } -bool AccessibilityManager::AccessibilityActionReadIndicatorInformation() -{ - Dali::Toolkit::AccessibilityManager handle( this ); - if( !mActionReadIndicatorInformationSignal.Empty() ) - { - mActionReadIndicatorInformationSignal.Emit( handle ); - } - - // TODO: Read the information in the indicator - - return mIsAccessibilityTtsEnabled; -} - bool AccessibilityManager::AccessibilityActionReadPauseResume() { Dali::Toolkit::AccessibilityManager handle( this ); @@ -1331,7 +1313,7 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& if(!mCurrentGesturedActor) { - DALI_LOG_ERROR("Gesture detected, but no hit actor"); + DALI_LOG_ERROR("Gesture detected, but no hit actor\n"); } } @@ -1380,7 +1362,7 @@ bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& if(!mCurrentGesturedActor) { - DALI_LOG_ERROR("no more gestured actor"); + DALI_LOG_ERROR("no more gestured actor\n"); } } else @@ -1408,34 +1390,6 @@ Toolkit::AccessibilityManager::FocusedActorActivatedSignalType& AccessibilityMan return mFocusedActorActivatedSignal; } -bool AccessibilityManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ) -{ - Dali::BaseHandle handle( object ); - - bool connected( true ); - AccessibilityManager* manager = dynamic_cast( object ); - - if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_CHANGED ) ) - { - manager->FocusChangedSignal().Connect( tracker, functor ); - } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUS_OVERSHOT ) ) - { - manager->FocusOvershotSignal().Connect( tracker, functor ); - } - else if( 0 == strcmp( signalName.c_str(), SIGNAL_FOCUSED_ACTOR_ACTIVATED ) ) - { - manager->FocusedActorActivatedSignal().Connect( tracker, functor ); - } - else - { - // signalName does not match any signal - connected = false; - } - - return connected; -} - } // namespace Internal } // namespace Toolkit