- Both these managers created ImageViews at startup even if not required.
Change-Id: I40b6df684adac8acb6883175f8fe298558112d01
/*
- * 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.
namespace
{
-static bool gObjectCreatedCallBackCalled;
-
-static void TestCallback(BaseHandle handle)
-{
- gObjectCreatedCallBackCalled = true;
-}
-
// Functors to test whether focus changed signal is emitted when the focus is changed
class FocusChangedCallback : public Dali::ConnectionTracker
{
tet_infoline(" UtcDaliAccessibilityManagerGet");
- AccessibilityManager manager;
-
- //Ensure object is created by checking if it's registered
- ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
- DALI_TEST_CHECK(registry);
-
- gObjectCreatedCallBackCalled = false;
- registry.ObjectCreatedSignal().Connect( &TestCallback );
- {
- manager = AccessibilityManager::Get();
- DALI_TEST_CHECK(manager);
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK(manager);
AccessibilityManager newManager = AccessibilityManager::Get();
DALI_TEST_CHECK(newManager);
END_TEST;
}
+int UtcDaliAccessibilityManagerSetAndGetFocusIndicatorWithFocusedActor(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityManagerSetAndGetFocusIndicatorWithFocusedActor");
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Dali::AccessibilityAdaptor accAdaptor = Dali::AccessibilityAdaptor::Get();
+ Test::AccessibilityAdaptor::SetEnabled( accAdaptor, true );
+ accAdaptor.HandleActionEnableEvent();
+
+ Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
+ DALI_TEST_CHECK(defaultFocusIndicatorActor);
+
+ Actor focusedActor = Actor::New();
+ Stage::GetCurrent().Add( focusedActor );
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( focusedActor.GetChildCount(), 0u, TEST_LOCATION );
+
+ manager.SetFocusOrder( focusedActor, 1 );
+ manager.SetCurrentFocusActor( focusedActor );
+
+ DALI_TEST_EQUALS( focusedActor.GetChildCount(), 1u, TEST_LOCATION );
+ DALI_TEST_CHECK( focusedActor.GetChildAt(0) == defaultFocusIndicatorActor );
+
+ Actor newFocusIndicatorActor = Actor::New();
+ manager.SetFocusIndicatorActor( newFocusIndicatorActor );
+ DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
+ DALI_TEST_EQUALS( focusedActor.GetChildCount(), 1u, TEST_LOCATION );
+ DALI_TEST_CHECK( focusedActor.GetChildAt(0) == newFocusIndicatorActor );
+
+ // Disable Accessibility
+ Test::AccessibilityAdaptor::SetEnabled( accAdaptor, false );
+ accAdaptor.HandleActionEnableEvent();
+
+ DALI_TEST_EQUALS( focusedActor.GetChildCount(), 0u, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliAccessibilityManagerSignalFocusChanged(void)
{
ToolkitTestApplication application;
/*
- * 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.
AccessibilityManager::AccessibilityManager()
: mCurrentFocusActor(FocusIDPair(0, 0)),
- mFocusIndicatorActor(Actor()),
+ mFocusIndicatorActor(),
mRecursiveFocusMoveCounter(0),
mIsWrapped(false),
mIsFocusWithinGroup(false),
void AccessibilityManager::Initialise()
{
- CreateDefaultFocusIndicatorActor();
-
AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get();
adaptor.SetActionHandler(*this);
adaptor.SetGestureHandler(*this);
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
void AccessibilityManager::ClearFocus()
{
Actor actor = GetCurrentFocusActor();
- if(actor)
+ if( actor && mFocusIndicatorActor )
{
- actor.Remove(mFocusIndicatorActor);
+ actor.Remove( mFocusIndicatorActor );
}
mCurrentFocusActor = FocusIDPair(0, 0);
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;
}
}
}
-void AccessibilityManager::CreateDefaultFocusIndicatorActor()
-{
- // Create a focus indicator actor shared by all the focusable actors
- Toolkit::ImageView focusIndicator = Toolkit::ImageView::New(FOCUS_BORDER_IMAGE_PATH);
- focusIndicator.SetParentOrigin( ParentOrigin::CENTER );
- 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();
Actor actor = GetCurrentFocusActor();
if(actor)
{
- if(mFocusIndicatorActor)
- {
- actor.Add(mFocusIndicatorActor);
- }
+ actor.Add( GetFocusIndicatorActor() );
}
mIsFocusIndicatorEnabled = true;
{
// Hide indicator when tts turned off
Actor actor = GetCurrentFocusActor();
- if(actor)
+ if( actor && mFocusIndicatorActor )
{
- actor.Remove(mFocusIndicatorActor);
+ actor.Remove( mFocusIndicatorActor );
}
mIsFocusIndicatorEnabled = false;
#define __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_MANAGER_H__
/*
- * 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.
void DoActivate(Actor actor);
/**
- * Create the default indicator actor to highlight the focused actor.
- */
- void CreateDefaultFocusIndicatorActor();
-
- /**
* Set whether the actor is focusable or not. A focusable property will be registered for
* the actor if not yet.
* @param actor The actor to be focused
/*
- * Copyright (c) 2014 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.
KeyboardFocusManager::KeyboardFocusManager()
: mCurrentFocusActor(0),
- mFocusIndicatorActor(Actor()),
+ mFocusIndicatorActor(),
mFocusGroupLoopEnabled(false),
mIsKeyboardFocusEnabled(false),
mIsFocusIndicatorEnabled(false),
mIsWaitingKeyboardFocusChangeCommit(false),
mSlotDelegate(this)
{
- CreateDefaultFocusIndicatorActor();
-
OnPhysicalKeyboardStatusChanged(PhysicalKeyboard::Get());
Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
{
mIsFocusIndicatorEnabled = true;
// Draw the focus indicator upon the focused actor
- if( mFocusIndicatorActor )
- {
- actor.Add( mFocusIndicatorActor );
- }
+ actor.Add( GetFocusIndicatorActor() );
// Send notification for the change of focus actor
if( !mFocusChangedSignal.Empty() )
Actor KeyboardFocusManager::GetFocusIndicatorActor()
{
- return mFocusIndicatorActor;
-}
-
-void KeyboardFocusManager::CreateDefaultFocusIndicatorActor()
-{
- // Create a focus indicator actor shared by all the keyboard focusable actors
- Toolkit::ImageView focusIndicator = Toolkit::ImageView::New(FOCUS_BORDER_IMAGE_PATH);
- focusIndicator.SetParentOrigin( ParentOrigin::CENTER );
+ 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 );
- // Apply size constraint to the focus indicator
- focusIndicator.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ // Apply size constraint to the focus indicator
+ mFocusIndicatorActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ }
- SetFocusIndicatorActor(focusIndicator);
+ return mFocusIndicatorActor;
}
void KeyboardFocusManager::OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard)
Actor actor = GetCurrentFocusActor();
if(actor)
{
- if(mFocusIndicatorActor)
- {
- actor.Add(mFocusIndicatorActor);
- }
+ actor.Add( GetFocusIndicatorActor() );
}
mIsFocusIndicatorEnabled = true;
}
{
// Hide indicator when keyboard focus turned off
Actor actor = GetCurrentFocusActor();
- if(actor)
+ if( actor && mFocusIndicatorActor )
{
- actor.Remove(mFocusIndicatorActor);
+ actor.Remove( mFocusIndicatorActor );
}
mIsFocusIndicatorEnabled = false;
}
if(isFocusStartableKey && mIsFocusIndicatorEnabled && !isAccessibilityEnabled)
{
Actor actor = GetCurrentFocusActor();
- if( !actor )
+ if( actor )
+ {
+ // Make sure the focused actor is highlighted
+ actor.Add( GetFocusIndicatorActor() );
+ }
+ else
{
// No actor is focused but keyboard focus is activated by the key press
// Let's try to move the initial focus
MoveFocus(Toolkit::Control::KeyboardFocus::RIGHT);
}
- else if(mFocusIndicatorActor)
- {
- // Make sure the focused actor is highlighted
- actor.Add(mFocusIndicatorActor);
- }
}
}
#define __DALI_TOOLKIT_INTERNAL_KEYBOARD_FOCUS_MANAGER_H__
/*
- * Copyright (c) 2014 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.
void DoKeyboardEnter( Actor actor );
/**
- * Create the default indicator actor to highlight the focused actor.
- */
- void CreateDefaultFocusIndicatorActor();
-
- /**
* Check whether the actor is a layout control that supports two dimensional keyboard navigation.
* The layout control needs to internally set the focus order for the child actor and be able to
* tell KeyboardFocusmanager the next focusable actor in the given direction.