/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 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.
#include <dali/devel-api/adaptor-framework/sound-player.h>
#include <dali/public-api/animation/constraints.h>
#include <dali/devel-api/events/hit-test-algorithm.h>
-#include <dali/public-api/images/resource-image.h>
+#include <dali/devel-api/events/pan-gesture-devel.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/asset-manager/asset-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/image-view/image-view.h>
const char* const ACTOR_FOCUSABLE("focusable");
const char* const IS_FOCUS_GROUP("isFocusGroup");
-const char* FOCUS_BORDER_IMAGE_PATH = DALI_IMAGE_DIR "B16-8_TTS_focus.9.png";
+const char* FOCUS_BORDER_IMAGE_FILE_NAME = "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";
+const char* FOCUS_SOUND_FILE_NAME = "Focus.ogg";
+const char* FOCUS_CHAIN_END_SOUND_FILE_NAME = "End_of_List.ogg";
/**
* The function to be used in the hit-test algorithm to check whether the actor is hittable.
case Dali::HitTestAlgorithm::CHECK_ACTOR:
{
// Check whether the actor is visible and not fully transparent.
- if( actor.IsVisible()
- && actor.GetCurrentWorldColor().a > 0.01f) // not FULLY_TRANSPARENT
+ if( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE )
+ && actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ).a > 0.01f) // not FULLY_TRANSPARENT
{
// Check whether the actor is focusable
Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE);
}
case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
{
- if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
+ if( actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) ) // Actor is visible, if not visible then none of its children are visible.
{
hittable = true;
}
mFocusIndicatorActor(),
mPreviousPosition( 0.0f, 0.0f ),
mRecursiveFocusMoveCounter(0),
+ mFocusSoundFilePath(),
+ mFocusChainEndSoundFilePath(),
mIsWrapped(false),
mIsFocusWithinGroup(false),
mIsEndcapFeedbackEnabled(false),
mIsAccessibilityTtsEnabled(false),
mTtsCreated(false),
mIsFocusIndicatorEnabled(false),
- mContinuousPlayMode(false)
+ mContinuousPlayMode(false),
+ mIsFocusSoundFilePathSet(false),
+ mIsFocusChainEndSoundFilePathSet(false)
{
}
{
if(actor)
{
- unsigned int actorID = actor.GetId();
+ unsigned int actorID = actor.GetProperty< int >( Actor::Property::ID );
ActorAdditionalInfo info = GetActorAdditionalInfo(actorID);
info.mAccessibilityAttributes[type] = text;
}
}
+void AccessibilityManager::DeleteAccessibilityAttribute(Actor actor)
+{
+ if(actor)
+ {
+ unsigned int actorID = actor.GetProperty< int >( Actor::Property::ID );
+ mIDAdditionalInfoContainer.erase(actorID);
+ }
+}
+
std::string AccessibilityManager::GetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityManager::AccessibilityAttribute type) const
{
std::string text;
if(actor)
{
- ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId());
+ ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetProperty< int >( Actor::Property::ID ));
text = data.mAccessibilityAttributes[type];
}
actor.SetProperty(propertyActorFocusable, true);
// Now we insert the actor into the focus chain with the specified focus order
- mFocusIDContainer.insert(FocusIDPair(order, actor.GetId()));
+ mFocusIDContainer.insert(FocusIDPair(order, actor.GetProperty< int >( Actor::Property::ID )));
}
// Update the actor's focus order in its additional data
- SynchronizeActorAdditionalInfo(actor.GetId(), order);
+ SynchronizeActorAdditionalInfo(actor.GetProperty< int >( Actor::Property::ID ), order);
}
}
if(actor)
{
- ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId());
+ ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetProperty< int >( Actor::Property::ID ));
focusOrder = data.mFocusOrder;
}
{
if(actor)
{
- return DoSetCurrentFocusActor(actor.GetId());
+ return DoSetCurrentFocusActor(actor.GetProperty< int >( Actor::Property::ID ));
}
return false;
}
// Go through the actor's hierarchy to check whether the actor is visible
- bool actorVisible = actor.IsVisible();
+ bool actorVisible = actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE );
Actor parent = actor.GetParent();
while (actorVisible && parent && parent != rootActor)
{
- actorVisible = parent.IsVisible();
+ actorVisible = parent.GetCurrentProperty< bool >( Actor::Property::VISIBLE );
parent = parent.GetParent();
}
// Check whether the actor is fully transparent
- bool actorOpaque = actor.GetCurrentWorldColor().a > 0.01f;
+ bool actorOpaque = actor.GetCurrentProperty< Vector4 >( Actor::Property::WORLD_COLOR ).a > 0.01f;
// Set the focus only when the actor is focusable and visible and not fully transparent
if(actorVisible && actorFocusable && actorOpaque)
actor.Add( GetFocusIndicatorActor() );
}
+ // Send Focused actor information
+ Vector2 windowSize = rootActor.GetCurrentProperty<Vector2>(Actor::Property::SIZE);
+ AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get();
+ adaptor.SetFocusedActorPosition( Vector2((actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).x + (windowSize.width / 2)),
+ (actor.GetCurrentProperty<Vector3>(Actor::Property::WORLD_POSITION).y + (windowSize.height / 2))) );
+
// Send notification for the change of focus actor
mFocusChangedSignal.Emit( GetCurrentFocusActor(), actor );
Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get();
if(soundPlayer)
{
- soundPlayer.PlaySound(FOCUS_SOUND_FILE);
+ if (!mIsFocusSoundFilePathSet)
+ {
+ const std::string soundDirPath = AssetManager::GetDaliSoundPath();
+ mFocusSoundFilePath = soundDirPath + FOCUS_SOUND_FILE_NAME;
+ mIsFocusSoundFilePathSet = true;
+ }
+ soundPlayer.PlaySound(mFocusSoundFilePath);
}
// Play the accessibility attributes with the TTS player.
return adaptor.GetReadPosition();
}
+void AccessibilityManager::EnableAccessibility(bool enabled)
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Set Enabled Forcibly : %d \n", __FUNCTION__, __LINE__, enabled );
+ AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get();
+ adaptor.EnableAccessibility(enabled);
+}
+
+bool AccessibilityManager::IsEnabled() const
+{
+ AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get();
+ return adaptor.IsEnabled();
+}
+
void AccessibilityManager::SetGroupMode(bool enabled)
{
mIsFocusWithinGroup = enabled;
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 );
+ const std::string imageDirPath = AssetManager::GetDaliImagePath();
+ const std::string focusBorderImagePath = imageDirPath + FOCUS_BORDER_IMAGE_FILE_NAME;
+
+ mFocusIndicatorActor = Toolkit::ImageView::New(focusBorderImagePath);
+ mFocusIndicatorActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+ mFocusIndicatorActor.SetProperty( Actor::Property::POSITION_Z, 1.0f );
// Apply size constraint to the focus indicator
mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get();
if(soundPlayer)
{
- soundPlayer.PlaySound(FOCUS_CHAIN_END_SOUND_FILE);
+ if (!mIsFocusChainEndSoundFilePathSet)
+ {
+ const std::string soundDirPath = AssetManager::GetDaliSoundPath();
+ mFocusChainEndSoundFilePath = soundDirPath + FOCUS_CHAIN_END_SOUND_FILE_NAME;
+ mIsFocusChainEndSoundFilePathSet = true;
+ }
+ soundPlayer.PlaySound(mFocusChainEndSoundFilePath);
}
mIsEndcapFeedbackPlayed = true;
mIsAccessibilityTtsEnabled = adaptor.IsEnabled();
Dali::Toolkit::AccessibilityManager handle( this );
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] TtsEnabled : %d \n", __FUNCTION__, __LINE__, mIsAccessibilityTtsEnabled );
+
if(mIsAccessibilityTtsEnabled)
{
// Show indicator when tts turned on if there is focused actor.
}
}
-bool AccessibilityManager::AccessibilityActionScroll( Dali::TouchEvent& touchEvent )
+bool AccessibilityManager::AccessibilityActionScroll( Dali::TouchEvent& touch )
{
Dali::Toolkit::AccessibilityManager handle( this );
if( !mActionScrollSignal.Empty() )
{
- mActionScrollSignal.Emit( handle, touchEvent );
+ mActionScrollSignal.Emit( handle, touch );
}
return true;
return mIsAccessibilityTtsEnabled;
}
-bool AccessibilityManager::AccessibilityActionTouch(const TouchEvent& touchEvent)
+bool AccessibilityManager::AccessibilityActionForwardToApp()
{
- bool handled = false;
-
- // TODO: Need to convert the touchevent for the focused actor?
-
- Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(GetCurrentFocusActor());
- if(control)
+ Dali::Toolkit::AccessibilityManager handle( this );
+ if( !mActionForwardSignal.Empty() )
{
- handled = GetImplementation( control ).OnAccessibilityTouch(touchEvent);
+ mActionForwardSignal.Emit( handle );
}
- return handled;
+ return mIsAccessibilityTtsEnabled;
}
-bool AccessibilityManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent)
+bool AccessibilityManager::HandlePanGesture(const AccessibilityGestureEvent& panEvent)
{
bool handled = false;
- if( panEvent.state == Gesture::Started )
+ if( panEvent.state == AccessibilityGestureEvent::STARTED )
{
// Find the focusable actor at the event position
Dali::HitTestAlgorithm::Results results;
}
}
- // Gesture::Finished (Up) events are delivered with previous (Motion) event position
+ // GestureState::FINISHED (Up) events are delivered with previous (Motion) event position
// Use the real previous position; otherwise we may incorrectly get a ZERO velocity
- if ( Gesture::Finished != panEvent.state )
+ if ( AccessibilityGestureEvent::FINISHED != panEvent.state )
{
- // Store the previous position for next Gesture::Finished iteration.
+ // Store the previous position for next GestureState::FINISHED iteration.
mPreviousPosition = panEvent.previousPosition;
}
Actor rootActor = Stage::GetCurrent().GetRootLayer();
- Dali::PanGesture pan(panEvent.state);
- pan.time = panEvent.time;
- pan.numberOfTouches = panEvent.numberOfTouches;
- pan.screenPosition = panEvent.currentPosition;
- pan.screenDisplacement = mPreviousPosition - panEvent.currentPosition;
- pan.screenVelocity.x = pan.screenDisplacement.x / panEvent.timeDelta;
- pan.screenVelocity.y = pan.screenDisplacement.y / panEvent.timeDelta;
+ Dali::PanGesture pan = DevelPanGesture::New( static_cast<Dali::GestureState>(panEvent.state) );
+ DevelPanGesture::SetTime( pan, panEvent.time );
+ DevelPanGesture::SetNumberOfTouches( pan, panEvent.numberOfTouches );
+ DevelPanGesture::SetScreenPosition( pan, panEvent.currentPosition );
+ DevelPanGesture::SetScreenDisplacement( pan, mPreviousPosition - panEvent.currentPosition );
+ DevelPanGesture::SetScreenVelocity( pan, Vector2( pan.GetScreenDisplacement().x / panEvent.timeDelta, pan.GetScreenDisplacement().y / panEvent.timeDelta ) );
// Only handle the pan gesture when the current focused actor is scrollable or within a scrollable actor
while(mCurrentGesturedActor && mCurrentGesturedActor != rootActor && !handled)
{
Vector2 localCurrent;
control.ScreenToLocal( localCurrent.x, localCurrent.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
- pan.position = localCurrent;
+ DevelPanGesture::SetPosition( pan, localCurrent );
Vector2 localPrevious;
control.ScreenToLocal( localPrevious.x, localPrevious.y, mPreviousPosition.x, mPreviousPosition.y );
- pan.displacement = localCurrent - localPrevious;
- pan.velocity.x = pan.displacement.x / panEvent.timeDelta;
- pan.velocity.y = pan.displacement.y / panEvent.timeDelta;
+ DevelPanGesture::SetDisplacement( pan, localCurrent - localPrevious );
+ DevelPanGesture::SetVelocity( pan, Vector2( pan.GetDisplacement().x / panEvent.timeDelta, pan.GetDisplacement().y / panEvent.timeDelta ));
handled = GetImplementation( control ).OnAccessibilityPan(pan);
}