utc-Dali-ControlImpl.cpp
utc-Dali-DefaultControls.cpp
utc-Dali-DissolveEffect.cpp
- utc-Dali-FocusManager.cpp
+ utc-Dali-AccessibilityFocusManager.cpp
utc-Dali-IrisEffect.cpp
utc-Dali-ItemLayout.cpp
utc-Dali-ItemView.cpp
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <stdlib.h>
+
+// Need to override adaptor classes for toolkit test harness, so include
+// test harness headers before dali headers.
+#include <dali-toolkit-test-suite-utils.h>
+
+#include <dali-toolkit/dali-toolkit.h>
+
+using namespace Dali;
+using namespace Toolkit;
+
+
+void utc_dali_toolkit_accessibility_focus_manager_startup(void)
+{
+ test_return_value = TET_UNDEF;
+}
+
+void utc_dali_toolkit_accessibility_focus_manager_cleanup(void)
+{
+ test_return_value = TET_PASS;
+}
+
+
+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
+{
+public:
+ FocusChangedCallback(bool& signalReceived)
+ : mSignalVerified(signalReceived),
+ mOriginalFocusedActor(),
+ mCurrentFocusedActor()
+ {
+ }
+
+ void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
+ {
+ tet_infoline("Verifying FocusChangedCallback()");
+
+ if(originalFocusedActor == mCurrentFocusedActor)
+ {
+ mSignalVerified = true;
+ }
+
+ mOriginalFocusedActor = originalFocusedActor;
+ mCurrentFocusedActor = currentFocusedActor;
+ }
+
+ void Reset()
+ {
+ mSignalVerified = false;
+ }
+
+ bool& mSignalVerified;
+ Actor mOriginalFocusedActor;
+ Actor mCurrentFocusedActor;
+};
+
+// Functors to test whether focus overshot signal is emitted when there is no way to move focus further.
+class FocusOvershotCallback : public Dali::ConnectionTracker
+{
+public:
+ FocusOvershotCallback(bool& signalReceived)
+ : mSignalVerified(signalReceived),
+ mCurrentFocusedActor(),
+ mFocusOvershotDirection(Toolkit::AccessibilityFocusManager::OVERSHOT_NEXT)
+ {
+ }
+
+ void Callback(Actor currentFocusedActor, Toolkit::AccessibilityFocusManager::FocusOvershotDirection direction)
+ {
+ tet_infoline("Verifying FocusOvershotCallback()");
+
+ if(currentFocusedActor == mCurrentFocusedActor && direction == mFocusOvershotDirection)
+ {
+ mSignalVerified = true;
+ }
+ }
+
+ void Reset()
+ {
+ mSignalVerified = false;
+ }
+
+ bool& mSignalVerified;
+ Actor mCurrentFocusedActor;
+ Toolkit::AccessibilityFocusManager::FocusOvershotDirection mFocusOvershotDirection;
+};
+
+// Functor to test whether focused actor activated signal is emitted.
+class FocusedActorActivatedCallback : public Dali::ConnectionTracker
+{
+public:
+ FocusedActorActivatedCallback()
+ {
+ }
+
+ void Callback(Actor activatedActor)
+ {
+ tet_infoline("Verifying FocusedActorActivatedCallback()");
+ }
+};
+
+} // namespace
+
+
+int UtcDaliAccessibilityFocusManagerGet(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerGet");
+
+ AccessibilityFocusManager 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 = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+ }
+ DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
+
+ AccessibilityFocusManager newManager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(newManager);
+
+ // Check that focus manager is a singleton
+ DALI_TEST_CHECK(manager == newManager);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSetAndGetAccessibilityAttribute(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSetAndGetAccessibilityAttribute");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Actor actor = Actor::New();
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "");
+
+ manager.SetAccessibilityAttribute(actor, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "Description");
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "Description");
+
+ manager.SetAccessibilityAttribute(actor, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "New description");
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "New description");
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSetAndGetFocusOrder(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSetAndGetFocusOrder");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Actor first = Actor::New();
+ Actor second = Actor::New();
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 0);
+
+ // Set the focus order and description for the first actor
+ manager.SetFocusOrder(first, 1);
+ manager.SetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "first");
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(second, 2);
+ manager.SetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "second");
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // check that the focus order of the first actor is changed
+ manager.SetFocusOrder(first, 2);
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 2);
+ // make sure the change of focus order doesn't affect the actor's description
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // check that the focus order of the second actor is increased to 3
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 3);
+ // make sure the change of focus order doesn't affect the actor's description
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // check that the focus order of the second actor is changed to 1
+ manager.SetFocusOrder(second, 1);
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 1);
+ // make sure the change of focus order doesn't affect the actor's description
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // Set the focus order and description for the third actor
+ Actor third = Actor::New();
+ manager.SetFocusOrder(third, 1);
+ manager.SetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "third");
+ DALI_TEST_CHECK(manager.GetFocusOrder(third) == 1);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // check that the focus order of the second actor is increased to 2.
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
+ // make sure the change of focus order doesn't affect the actor's description
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // check that the focus order of the first actor is increased to 3.
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 3);
+ // make sure the change of focus order doesn't affect the actor's description
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerGenerateNewFocusOrder(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerGenerateNewFocusOrder");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder());
+ DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder());
+
+ Actor first = Actor::New();
+ Actor second = Actor::New();
+
+ // Set the focus order for the first actor
+ manager.SetFocusOrder(first, 1);
+ manager.SetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "first");
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
+
+ //Test for new focus order
+ DALI_TEST_CHECK(2 == manager.GenerateNewFocusOrder());
+
+ // Set the focus order for the first actor
+ manager.SetFocusOrder(second, 2);
+ manager.SetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "first");
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerGetActorByFocusOrder(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerGetActorByFocusOrder");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Create the actors and set their focus orders
+ Actor first = Actor::New();
+ manager.SetFocusOrder(first, 1);
+
+ Actor second = Actor::New();
+ manager.SetFocusOrder(second, 2);
+
+ Actor third = Actor::New();
+ manager.SetFocusOrder(third, 3);
+
+ // Check that we get an empty handle as no actor is added to the stage yet.
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == Actor());
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == Actor());
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == Actor());
+
+ // Add the actors to the stage
+ Stage::GetCurrent().Add(first);
+ Stage::GetCurrent().Add(second);
+ Stage::GetCurrent().Add(third);
+
+ // Check that we get an empty handle because focus order 0 means undefined.
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(0) == Actor());
+
+ // Check that we get correct actors for the specified focus orders
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == first);
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == second);
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == third);
+
+ // Change the focus order of the third actor to 1
+ manager.SetFocusOrder(third, 1);
+
+ // Check that we still get correct actors after changing their focus orders
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == third);
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == first);
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == second);
+
+ // Check that we get an empty handle because no actor has a focus order of 4
+ DALI_TEST_CHECK(manager.GetActorByFocusOrder(4) == Actor());
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSetAndGetCurrentFocusActor(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSetAndGetCurrentFocusActor");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ manager.SetFocusOrder(first, 1);
+ Stage::GetCurrent().Add(first);
+
+ // Create the second actor and add it to the stage
+ Actor second = Actor::New();
+ manager.SetFocusOrder(second, 2);
+ Stage::GetCurrent().Add(second);
+
+ // Create the third actor but don't add it to the stage
+ Actor third = Actor::New();
+ manager.SetFocusOrder(third, 3);
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Check that it will fail to set focus on an invalid actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
+
+ // Check that the focus is set on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ // Check that the focus is set on the second actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+
+ // Check that it will fail to set focus on the third actor as it's not in the stage
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
+
+ // Add the third actor to the stage
+ Stage::GetCurrent().Add(third);
+
+ // make the third actor invisible
+ third.SetVisible(false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Check that it will fail to set focus on the third actor as it's invisible
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
+
+ // Make the third actor visible
+ third.SetVisible(true);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Make the third actor not focusable
+ Property::Index propertyActorFocusable = third.GetPropertyIndex("focusable");
+ third.SetProperty(propertyActorFocusable, false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Check that it will fail to set focus on the third actor as it's not focusable
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
+
+ // Make the third actor focusable
+ third.SetProperty(propertyActorFocusable, true);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Check that the focus is successfully moved to the third actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
+
+ // Make the current focused actor to be not focusable by setting its focus order to be 0
+ manager.SetFocusOrder(third, 0);
+
+ // Check that the focus is automatically cleared
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Set the focus order of the third actor again
+ manager.SetFocusOrder(third, 3);
+
+ // Check that the third actor can be focused successfully now
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerGetCurrentFocusGroup(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerGetCurrentFocusGroup");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Create an actor with two child actors and add it to the stage
+ Actor parent = Actor::New();
+ Actor firstChild = Actor::New();
+ Actor secondChild = Actor::New();
+ parent.Add(firstChild);
+ parent.Add(secondChild);
+ Stage::GetCurrent().Add(parent);
+
+ // Create three actors and add them as the children of the first child actor
+ Actor firstGrandChild = Actor::New();
+ Actor secondGrandChild = Actor::New();
+ Actor thirdGrandChild = Actor::New();
+ firstChild.Add(firstGrandChild);
+ firstChild.Add(secondGrandChild);
+ firstChild.Add(thirdGrandChild);
+
+ // Set focus order to the actors
+ manager.SetFocusOrder(parent, 1);
+ manager.SetFocusOrder(firstChild, 2);
+ manager.SetFocusOrder(firstGrandChild, 3);
+ manager.SetFocusOrder(secondGrandChild, 4);
+ manager.SetFocusOrder(thirdGrandChild, 5);
+ manager.SetFocusOrder(secondChild, 6);
+
+ // Set the parent and the first child actor as focus groups
+ manager.SetFocusGroup(parent, true);
+ DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
+
+ // Set focus to the first grand child actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstGrandChild) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
+
+ // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
+ DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == parent);
+
+ manager.SetFocusGroup(firstChild, true);
+ DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);
+
+ // The current focus group should be the firstChild, As it is the immediate parent which is also a focus group.
+ DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);
+
+ manager.SetFocusGroup(firstGrandChild, true);
+ DALI_TEST_CHECK(manager.IsFocusGroup(firstGrandChild) == true);
+
+ // The current focus group should be itself, As it is also a focus group.
+ DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstGrandChild);
+
+ // Set focus to the second grand child actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondGrandChild) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
+
+ // The current focus group should be the firstChild, As it is the immediate parent which is also a
+ // focus group for the current focus actor.
+ DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);
+
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerGetCurrentFocusOrder(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerGetCurrentFocusOrder");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Actor first = Actor::New();
+ Stage::GetCurrent().Add(first);
+
+ Actor second = Actor::New();
+ Stage::GetCurrent().Add(second);
+
+ Actor third = Actor::New();
+ Stage::GetCurrent().Add(third);
+
+ // Set the focus order and description for the first actor
+ manager.SetFocusOrder(first, 1);
+ manager.SetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "first");
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(second, 2);
+ manager.SetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "second");
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(third, 3);
+ manager.SetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "third");
+ DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0);
+
+ // Set the focus on the first actor and test
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 1);
+
+ // Move the focus forward to the second actor and test
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 2);
+
+ // Move the focus forward to the third actor and test
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 3);
+
+ // Clear focus and test
+ manager.ClearFocus();
+ DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerMoveFocusForward(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerMoveFocusForward");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Actor first = Actor::New();
+ Stage::GetCurrent().Add(first);
+
+ Actor second = Actor::New();
+ Stage::GetCurrent().Add(second);
+
+ Actor third = Actor::New();
+ Stage::GetCurrent().Add(third);
+
+ // Set the focus order and description for the first actor
+ manager.SetFocusOrder(first, 1);
+ manager.SetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "first");
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(second, 2);
+ manager.SetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "second");
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(third, 3);
+ manager.SetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "third");
+ DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Set the focus on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Test the non-wrapped move first
+ manager.SetWrapMode(false);
+ DALI_TEST_CHECK(manager.GetWrapMode() == false);
+
+ // Move the focus forward to the second actor
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // Move the focus forward to the third actor
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Check that it will fail to move the focus forward again as the third actor is the last
+ // focusable actor in the focus chain
+ manager.MoveFocusForward();
+ // The focus should still be set on the third actor
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Now test the wrapped move
+ manager.SetWrapMode(true);
+ DALI_TEST_CHECK(manager.GetWrapMode() == true);
+
+ // Move the focus forward recursively and this time the first actor should be focused
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Make the second actor not focusable
+ Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
+ second.SetProperty(propertyActorFocusable, false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Move the focus forward and check that the second actor should be skipped and
+ // the third actor should be focused now.
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Make the first actor invisible
+ first.SetVisible(false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Move the focus forward and check that the first actor should be skipped as it's
+ // invisible and the second actor should also be skipped as it's not focusable,
+ // so the focus will still be on the third actor
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Make the third actor invisible so that no actor can be focused.
+ third.SetVisible(false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Check that the focus move is failed as all the three actors can not be focused
+ manager.MoveFocusForward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerMoveFocusBackward(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerMoveFocusBackward");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Actor first = Actor::New();
+ Stage::GetCurrent().Add(first);
+
+ Actor second = Actor::New();
+ Stage::GetCurrent().Add(second);
+
+ Actor third = Actor::New();
+ Stage::GetCurrent().Add(third);
+
+ // Set the focus order and description for the first actor
+ manager.SetFocusOrder(first, 1);
+ manager.SetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "first");
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(second, 2);
+ manager.SetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "second");
+ DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // Set the focus order and description for the second actor
+ manager.SetFocusOrder(third, 3);
+ manager.SetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL, "third");
+ DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Set the focus on the third actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Test the non-wrapped move first
+ manager.SetWrapMode(false);
+ DALI_TEST_CHECK(manager.GetWrapMode() == false);
+
+ // Move the focus backward to the second actor
+ manager.MoveFocusBackward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "second");
+
+ // Move the focus backward to the first actor
+ manager.MoveFocusBackward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Check that it will fail to move the focus backward again as the first actor is the first
+ // focusable actor in the focus chain
+ manager.MoveFocusBackward();
+ // The focus should still be set on the first actor
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Now test the wrapped move
+ manager.SetWrapMode(true);
+ DALI_TEST_CHECK(manager.GetWrapMode() == true);
+
+ // Move the focus backward recursively and this time the third actor should be focused
+ manager.MoveFocusBackward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "third");
+
+ // Make the second actor not focusable
+ Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
+ second.SetProperty(propertyActorFocusable, false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Move the focus backward and check that the second actor should be skipped and
+ // the first actor should be focused now.
+ manager.MoveFocusBackward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Make the third actor invisible
+ third.SetVisible(false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Move the focus backward and check that the third actor should be skipped as it's
+ // invisible and the second actor should also be skipped as it's not focusable,
+ // so the focus will still be on the first actor
+ manager.MoveFocusBackward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+
+ // Make the first actor invisible so that no actor can be focused.
+ first.SetVisible(false);
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ // Check that the focus move is failed as all the three actors can not be focused
+ manager.MoveFocusBackward();
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), AccessibilityFocusManager::ACCESSIBILITY_LABEL) == "first");
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerClearFocus(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerClearFocus");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ manager.SetFocusOrder(first, 1);
+ Stage::GetCurrent().Add(first);
+
+ // Create the second actor and add it to the stage
+ Actor second = Actor::New();
+ manager.SetFocusOrder(second, 2);
+ Stage::GetCurrent().Add(second);
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Check that the focus is set on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ // Check that the focus is set on the second actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+
+ // Clear the focus
+ manager.ClearFocus();
+
+ // Check that no actor is being focused now.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerReset(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerReset");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ manager.SetFocusOrder(first, 1);
+ Stage::GetCurrent().Add(first);
+
+ // Create the second actor and add it to the stage
+ Actor second = Actor::New();
+ manager.SetFocusOrder(second, 2);
+ Stage::GetCurrent().Add(second);
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Check that the focus is set on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ // Check that the focus is set on the second actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+
+ // Clear the focus
+ manager.Reset();
+
+ // Check that no actor is being focused now and the focus order of actors have been cleared
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
+ DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerFocusGroup(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerFocusGroup");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ // Create an actor with two child actors and add it to the stage
+ Actor parent = Actor::New();
+ Actor firstChild = Actor::New();
+ Actor secondChild = Actor::New();
+ parent.Add(firstChild);
+ parent.Add(secondChild);
+ Stage::GetCurrent().Add(parent);
+
+ // Create three actors and add them as the children of the first child actor
+ Actor firstGrandChild = Actor::New();
+ Actor secondGrandChild = Actor::New();
+ Actor thirdGrandChild = Actor::New();
+ firstChild.Add(firstGrandChild);
+ firstChild.Add(secondGrandChild);
+ firstChild.Add(thirdGrandChild);
+
+ // Set focus order to the actors
+ manager.SetFocusOrder(parent, 1);
+ manager.SetFocusOrder(firstChild, 2);
+ manager.SetFocusOrder(firstGrandChild, 3);
+ manager.SetFocusOrder(secondGrandChild, 4);
+ manager.SetFocusOrder(thirdGrandChild, 5);
+ manager.SetFocusOrder(secondChild, 6);
+
+ // Set the parent and the first child actor as focus groups
+ manager.SetFocusGroup(parent, true);
+ DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
+
+ // The focus group of the parent should be itself, as it is set to be a focus group.
+ DALI_TEST_CHECK(manager.GetFocusGroup(parent) == parent);
+
+ // The focus group of the firstChild should be its parent, as it is the immediate parent which is also a group.
+ DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == parent);
+
+ manager.SetFocusGroup(firstChild, true);
+ DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);
+
+ // The focus group of the firstChild should be itself, as it is set to be a focus group now.
+ DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == firstChild);
+
+ // Enable wrap mode for focus movement.
+ manager.SetWrapMode(true);
+ DALI_TEST_CHECK(manager.GetWrapMode() == true);
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Check that the focus is set on the parent actor.
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(parent) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
+
+ // Check that group mode is disabled.
+ DALI_TEST_CHECK(manager.GetGroupMode() == false);
+
+ // Check that the focus movement is wrapped as normal.
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
+
+ // Enable the group mode.
+ manager.SetGroupMode(true);
+ DALI_TEST_CHECK(manager.GetGroupMode() == true);
+
+ // Check that the focus movement is now limited to the current focus group.
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSetAndGetFocusIndicator(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSetAndGetFocusIndicator");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
+ DALI_TEST_CHECK(defaultFocusIndicatorActor);
+
+ Actor newFocusIndicatorActor = Actor::New();
+ manager.SetFocusIndicatorActor(newFocusIndicatorActor);
+ DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSignalFocusChanged(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSignalFocusChanged");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ bool signalVerified = false;
+ FocusChangedCallback callback(signalVerified);
+ manager.FocusChangedSignal().Connect( &callback, &FocusChangedCallback::Callback );
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ manager.SetFocusOrder(first, 1);
+ Stage::GetCurrent().Add(first);
+
+ // Create the second actor and add it to the stage
+ Actor second = Actor::New();
+ manager.SetFocusOrder(second, 2);
+ Stage::GetCurrent().Add(second);
+
+ // Check that no actor is being focused yet.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+
+ // Check that the focus is set on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(callback.mSignalVerified);
+ callback.Reset();
+
+ // Check that the focus is set on the second actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+ DALI_TEST_CHECK(callback.mSignalVerified);
+ callback.Reset();
+
+ // Clear the focus
+ manager.ClearFocus();
+
+ // Check that no actor is being focused now.
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
+ DALI_TEST_CHECK(callback.mSignalVerified);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSignalFocusOvershot(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSignalFocusOvershot");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ bool signalVerified = false;
+ FocusOvershotCallback callback(signalVerified);
+ manager.FocusOvershotSignal().Connect(&callback, &FocusOvershotCallback::Callback);
+
+ // Create the first actor and add it to the stage
+ Actor first = Actor::New();
+ manager.SetFocusOrder(first, 1);
+ Stage::GetCurrent().Add(first);
+
+ // Create the second actor and add it to the stage
+ Actor second = Actor::New();
+ manager.SetFocusOrder(second, 2);
+ Stage::GetCurrent().Add(second);
+
+ // Check that the wrap mode is disabled
+ DALI_TEST_CHECK(manager.GetWrapMode() == false);
+
+ // Check that the focus is set on the first actor
+ DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+
+ // Check that the focus is moved to the second actor successfully.
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+
+ // Check that the forward focus movement is overshot.
+ callback.mCurrentFocusedActor = second;
+ callback.mFocusOvershotDirection = Toolkit::AccessibilityFocusManager::OVERSHOT_NEXT;
+ DALI_TEST_CHECK(manager.MoveFocusForward() == false);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
+ DALI_TEST_CHECK(signalVerified);
+ callback.Reset();
+
+ // Enable the wrap mode
+ manager.SetWrapMode(true);
+ DALI_TEST_CHECK(manager.GetWrapMode() == true);
+
+ // Check that the forward focus movement is wrapped and no overshot happens.
+ DALI_TEST_CHECK(manager.MoveFocusForward() == true);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(signalVerified == false);
+
+ // Disable the wrap mode
+ manager.SetWrapMode(false);
+ DALI_TEST_CHECK(manager.GetWrapMode() == false);
+
+ // Check that the backward focus movement is overshot.
+ callback.mCurrentFocusedActor = first;
+ callback.mFocusOvershotDirection = Toolkit::AccessibilityFocusManager::OVERSHOT_PREVIOUS;
+ DALI_TEST_CHECK(manager.MoveFocusBackward() == false);
+ DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
+ DALI_TEST_CHECK(signalVerified);
+ END_TEST;
+}
+
+int UtcDaliAccessibilityFocusManagerSignalFocusedActorActivated(void)
+{
+ ToolkitTestApplication application;
+
+ tet_infoline(" UtcDaliAccessibilityFocusManagerSignalFocusedActorActivated");
+
+ AccessibilityFocusManager manager = AccessibilityFocusManager::Get();
+ DALI_TEST_CHECK(manager);
+
+ FocusedActorActivatedCallback callback;
+ manager.FocusedActorActivatedSignal().Connect(&callback, &FocusedActorActivatedCallback::Callback);
+ DALI_TEST_CHECK(true);
+
+ END_TEST;
+}
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <iostream>
-#include <stdlib.h>
-
-// Need to override adaptor classes for toolkit test harness, so include
-// test harness headers before dali headers.
-#include <dali-toolkit-test-suite-utils.h>
-
-#include <dali-toolkit/dali-toolkit.h>
-
-using namespace Dali;
-using namespace Toolkit;
-
-
-void utc_dali_toolkit_focus_manager_startup(void)
-{
- test_return_value = TET_UNDEF;
-}
-
-void utc_dali_toolkit_focus_manager_cleanup(void)
-{
- test_return_value = TET_PASS;
-}
-
-
-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
-{
-public:
- FocusChangedCallback(bool& signalReceived)
- : mSignalVerified(signalReceived),
- mOriginalFocusedActor(),
- mCurrentFocusedActor()
- {
- }
-
- void Callback(Actor originalFocusedActor, Actor currentFocusedActor)
- {
- tet_infoline("Verifying FocusChangedCallback()");
-
- if(originalFocusedActor == mCurrentFocusedActor)
- {
- mSignalVerified = true;
- }
-
- mOriginalFocusedActor = originalFocusedActor;
- mCurrentFocusedActor = currentFocusedActor;
- }
-
- void Reset()
- {
- mSignalVerified = false;
- }
-
- bool& mSignalVerified;
- Actor mOriginalFocusedActor;
- Actor mCurrentFocusedActor;
-};
-
-// Functors to test whether focus overshot signal is emitted when there is no way to move focus further.
-class FocusOvershotCallback : public Dali::ConnectionTracker
-{
-public:
- FocusOvershotCallback(bool& signalReceived)
- : mSignalVerified(signalReceived),
- mCurrentFocusedActor(),
- mFocusOvershotDirection(Toolkit::FocusManager::OVERSHOT_NEXT)
- {
- }
-
- void Callback(Actor currentFocusedActor, Toolkit::FocusManager::FocusOvershotDirection direction)
- {
- tet_infoline("Verifying FocusOvershotCallback()");
-
- if(currentFocusedActor == mCurrentFocusedActor && direction == mFocusOvershotDirection)
- {
- mSignalVerified = true;
- }
- }
-
- void Reset()
- {
- mSignalVerified = false;
- }
-
- bool& mSignalVerified;
- Actor mCurrentFocusedActor;
- Toolkit::FocusManager::FocusOvershotDirection mFocusOvershotDirection;
-};
-
-// Functor to test whether focused actor activated signal is emitted.
-class FocusedActorActivatedCallback : public Dali::ConnectionTracker
-{
-public:
- FocusedActorActivatedCallback()
- {
- }
-
- void Callback(Actor activatedActor)
- {
- tet_infoline("Verifying FocusedActorActivatedCallback()");
- }
-};
-
-} // namespace
-
-
-int UtcDaliFocusManagerGet(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerGet");
-
- FocusManager 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 = FocusManager::Get();
- DALI_TEST_CHECK(manager);
- }
- DALI_TEST_CHECK( gObjectCreatedCallBackCalled );
-
- FocusManager newManager = FocusManager::Get();
- DALI_TEST_CHECK(newManager);
-
- // Check that focus manager is a singleton
- DALI_TEST_CHECK(manager == newManager);
- END_TEST;
-}
-
-int UtcDaliFocusManagerSetAndGetAccessibilityAttribute(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSetAndGetAccessibilityAttribute");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- Actor actor = Actor::New();
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, FocusManager::ACCESSIBILITY_LABEL) == "");
-
- manager.SetAccessibilityAttribute(actor, FocusManager::ACCESSIBILITY_LABEL, "Description");
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, FocusManager::ACCESSIBILITY_LABEL) == "Description");
-
- manager.SetAccessibilityAttribute(actor, FocusManager::ACCESSIBILITY_LABEL, "New description");
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(actor, FocusManager::ACCESSIBILITY_LABEL) == "New description");
- END_TEST;
-}
-
-int UtcDaliFocusManagerSetAndGetFocusOrder(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSetAndGetFocusOrder");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- Actor first = Actor::New();
- Actor second = Actor::New();
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 0);
-
- // Set the focus order and description for the first actor
- manager.SetFocusOrder(first, 1);
- manager.SetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL, "first");
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(second, 2);
- manager.SetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL, "second");
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // check that the focus order of the first actor is changed
- manager.SetFocusOrder(first, 2);
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 2);
- // make sure the change of focus order doesn't affect the actor's description
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // check that the focus order of the second actor is increased to 3
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 3);
- // make sure the change of focus order doesn't affect the actor's description
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // check that the focus order of the second actor is changed to 1
- manager.SetFocusOrder(second, 1);
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 1);
- // make sure the change of focus order doesn't affect the actor's description
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // Set the focus order and description for the third actor
- Actor third = Actor::New();
- manager.SetFocusOrder(third, 1);
- manager.SetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL, "third");
- DALI_TEST_CHECK(manager.GetFocusOrder(third) == 1);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // check that the focus order of the second actor is increased to 2.
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
- // make sure the change of focus order doesn't affect the actor's description
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // check that the focus order of the first actor is increased to 3.
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 3);
- // make sure the change of focus order doesn't affect the actor's description
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");
- END_TEST;
-}
-
-int UtcDaliFocusManagerGenerateNewFocusOrder(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerGenerateNewFocusOrder");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder());
- DALI_TEST_CHECK(1 == manager.GenerateNewFocusOrder());
-
- Actor first = Actor::New();
- Actor second = Actor::New();
-
- // Set the focus order for the first actor
- manager.SetFocusOrder(first, 1);
- manager.SetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL, "first");
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
-
- //Test for new focus order
- DALI_TEST_CHECK(2 == manager.GenerateNewFocusOrder());
-
- // Set the focus order for the first actor
- manager.SetFocusOrder(second, 2);
- manager.SetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL, "first");
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
- END_TEST;
-}
-
-int UtcDaliFocusManagerGetActorByFocusOrder(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerGetActorByFocusOrder");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- // Create the actors and set their focus orders
- Actor first = Actor::New();
- manager.SetFocusOrder(first, 1);
-
- Actor second = Actor::New();
- manager.SetFocusOrder(second, 2);
-
- Actor third = Actor::New();
- manager.SetFocusOrder(third, 3);
-
- // Check that we get an empty handle as no actor is added to the stage yet.
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == Actor());
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == Actor());
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == Actor());
-
- // Add the actors to the stage
- Stage::GetCurrent().Add(first);
- Stage::GetCurrent().Add(second);
- Stage::GetCurrent().Add(third);
-
- // Check that we get an empty handle because focus order 0 means undefined.
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(0) == Actor());
-
- // Check that we get correct actors for the specified focus orders
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == first);
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == second);
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == third);
-
- // Change the focus order of the third actor to 1
- manager.SetFocusOrder(third, 1);
-
- // Check that we still get correct actors after changing their focus orders
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(1) == third);
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(2) == first);
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(3) == second);
-
- // Check that we get an empty handle because no actor has a focus order of 4
- DALI_TEST_CHECK(manager.GetActorByFocusOrder(4) == Actor());
- END_TEST;
-}
-
-int UtcDaliFocusManagerSetAndGetCurrentFocusActor(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSetAndGetCurrentFocusActor");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- // Create the first actor and add it to the stage
- Actor first = Actor::New();
- manager.SetFocusOrder(first, 1);
- Stage::GetCurrent().Add(first);
-
- // Create the second actor and add it to the stage
- Actor second = Actor::New();
- manager.SetFocusOrder(second, 2);
- Stage::GetCurrent().Add(second);
-
- // Create the third actor but don't add it to the stage
- Actor third = Actor::New();
- manager.SetFocusOrder(third, 3);
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Check that it will fail to set focus on an invalid actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(Actor()) == false);
-
- // Check that the focus is set on the first actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
-
- // Check that the focus is set on the second actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
-
- // Check that it will fail to set focus on the third actor as it's not in the stage
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
-
- // Add the third actor to the stage
- Stage::GetCurrent().Add(third);
-
- // make the third actor invisible
- third.SetVisible(false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Check that it will fail to set focus on the third actor as it's invisible
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
-
- // Make the third actor visible
- third.SetVisible(true);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Make the third actor not focusable
- Property::Index propertyActorFocusable = third.GetPropertyIndex("focusable");
- third.SetProperty(propertyActorFocusable, false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Check that it will fail to set focus on the third actor as it's not focusable
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == false);
-
- // Make the third actor focusable
- third.SetProperty(propertyActorFocusable, true);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Check that the focus is successfully moved to the third actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
-
- // Make the current focused actor to be not focusable by setting its focus order to be 0
- manager.SetFocusOrder(third, 0);
-
- // Check that the focus is automatically cleared
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Set the focus order of the third actor again
- manager.SetFocusOrder(third, 3);
-
- // Check that the third actor can be focused successfully now
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
- END_TEST;
-}
-
-int UtcDaliFocusManagerGetCurrentFocusGroup(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerGetCurrentFocusGroup");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- // Create an actor with two child actors and add it to the stage
- Actor parent = Actor::New();
- Actor firstChild = Actor::New();
- Actor secondChild = Actor::New();
- parent.Add(firstChild);
- parent.Add(secondChild);
- Stage::GetCurrent().Add(parent);
-
- // Create three actors and add them as the children of the first child actor
- Actor firstGrandChild = Actor::New();
- Actor secondGrandChild = Actor::New();
- Actor thirdGrandChild = Actor::New();
- firstChild.Add(firstGrandChild);
- firstChild.Add(secondGrandChild);
- firstChild.Add(thirdGrandChild);
-
- // Set focus order to the actors
- manager.SetFocusOrder(parent, 1);
- manager.SetFocusOrder(firstChild, 2);
- manager.SetFocusOrder(firstGrandChild, 3);
- manager.SetFocusOrder(secondGrandChild, 4);
- manager.SetFocusOrder(thirdGrandChild, 5);
- manager.SetFocusOrder(secondChild, 6);
-
- // Set the parent and the first child actor as focus groups
- manager.SetFocusGroup(parent, true);
- DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
-
- // Set focus to the first grand child actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(firstGrandChild) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
-
- // The current focus group should be the parent, As it is the immediate parent which is also a focus group.
- DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == parent);
-
- manager.SetFocusGroup(firstChild, true);
- DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);
-
- // The current focus group should be the firstChild, As it is the immediate parent which is also a focus group.
- DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);
-
- manager.SetFocusGroup(firstGrandChild, true);
- DALI_TEST_CHECK(manager.IsFocusGroup(firstGrandChild) == true);
-
- // The current focus group should be itself, As it is also a focus group.
- DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstGrandChild);
-
- // Set focus to the second grand child actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(secondGrandChild) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
-
- // The current focus group should be the firstChild, As it is the immediate parent which is also a
- // focus group for the current focus actor.
- DALI_TEST_CHECK(manager.GetCurrentFocusGroup() == firstChild);
-
- END_TEST;
-}
-
-int UtcDaliFocusManagerGetCurrentFocusOrder(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerGetCurrentFocusOrder");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- Actor first = Actor::New();
- Stage::GetCurrent().Add(first);
-
- Actor second = Actor::New();
- Stage::GetCurrent().Add(second);
-
- Actor third = Actor::New();
- Stage::GetCurrent().Add(third);
-
- // Set the focus order and description for the first actor
- manager.SetFocusOrder(first, 1);
- manager.SetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL, "first");
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(second, 2);
- manager.SetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL, "second");
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(third, 3);
- manager.SetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL, "third");
- DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0);
-
- // Set the focus on the first actor and test
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 1);
-
- // Move the focus forward to the second actor and test
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 2);
-
- // Move the focus forward to the third actor and test
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 3);
-
- // Clear focus and test
- manager.ClearFocus();
- DALI_TEST_CHECK(manager.GetCurrentFocusOrder() == 0);
- END_TEST;
-}
-
-int UtcDaliFocusManagerMoveFocusForward(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerMoveFocusForward");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- Actor first = Actor::New();
- Stage::GetCurrent().Add(first);
-
- Actor second = Actor::New();
- Stage::GetCurrent().Add(second);
-
- Actor third = Actor::New();
- Stage::GetCurrent().Add(third);
-
- // Set the focus order and description for the first actor
- manager.SetFocusOrder(first, 1);
- manager.SetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL, "first");
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(second, 2);
- manager.SetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL, "second");
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(third, 3);
- manager.SetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL, "third");
- DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Set the focus on the first actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Test the non-wrapped move first
- manager.SetWrapMode(false);
- DALI_TEST_CHECK(manager.GetWrapMode() == false);
-
- // Move the focus forward to the second actor
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // Move the focus forward to the third actor
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Check that it will fail to move the focus forward again as the third actor is the last
- // focusable actor in the focus chain
- manager.MoveFocusForward();
- // The focus should still be set on the third actor
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Now test the wrapped move
- manager.SetWrapMode(true);
- DALI_TEST_CHECK(manager.GetWrapMode() == true);
-
- // Move the focus forward recursively and this time the first actor should be focused
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Make the second actor not focusable
- Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
- second.SetProperty(propertyActorFocusable, false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Move the focus forward and check that the second actor should be skipped and
- // the third actor should be focused now.
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Make the first actor invisible
- first.SetVisible(false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Move the focus forward and check that the first actor should be skipped as it's
- // invisible and the second actor should also be skipped as it's not focusable,
- // so the focus will still be on the third actor
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Make the third actor invisible so that no actor can be focused.
- third.SetVisible(false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Check that the focus move is failed as all the three actors can not be focused
- manager.MoveFocusForward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
- END_TEST;
-}
-
-int UtcDaliFocusManagerMoveFocusBackward(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerMoveFocusBackward");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- Actor first = Actor::New();
- Stage::GetCurrent().Add(first);
-
- Actor second = Actor::New();
- Stage::GetCurrent().Add(second);
-
- Actor third = Actor::New();
- Stage::GetCurrent().Add(third);
-
- // Set the focus order and description for the first actor
- manager.SetFocusOrder(first, 1);
- manager.SetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL, "first");
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 1);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(first, FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(second, 2);
- manager.SetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL, "second");
- DALI_TEST_CHECK(manager.GetFocusOrder(second) == 2);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(second, FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // Set the focus order and description for the second actor
- manager.SetFocusOrder(third, 3);
- manager.SetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL, "third");
- DALI_TEST_CHECK(manager.GetFocusOrder(third) == 3);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(third, FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Set the focus on the third actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(third) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Test the non-wrapped move first
- manager.SetWrapMode(false);
- DALI_TEST_CHECK(manager.GetWrapMode() == false);
-
- // Move the focus backward to the second actor
- manager.MoveFocusBackward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "second");
-
- // Move the focus backward to the first actor
- manager.MoveFocusBackward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Check that it will fail to move the focus backward again as the first actor is the first
- // focusable actor in the focus chain
- manager.MoveFocusBackward();
- // The focus should still be set on the first actor
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Now test the wrapped move
- manager.SetWrapMode(true);
- DALI_TEST_CHECK(manager.GetWrapMode() == true);
-
- // Move the focus backward recursively and this time the third actor should be focused
- manager.MoveFocusBackward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == third);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "third");
-
- // Make the second actor not focusable
- Property::Index propertyActorFocusable = second.GetPropertyIndex("focusable");
- second.SetProperty(propertyActorFocusable, false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Move the focus backward and check that the second actor should be skipped and
- // the first actor should be focused now.
- manager.MoveFocusBackward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Make the third actor invisible
- third.SetVisible(false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Move the focus backward and check that the third actor should be skipped as it's
- // invisible and the second actor should also be skipped as it's not focusable,
- // so the focus will still be on the first actor
- manager.MoveFocusBackward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
-
- // Make the first actor invisible so that no actor can be focused.
- first.SetVisible(false);
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- // Check that the focus move is failed as all the three actors can not be focused
- manager.MoveFocusBackward();
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(manager.GetAccessibilityAttribute(manager.GetCurrentFocusActor(), FocusManager::ACCESSIBILITY_LABEL) == "first");
- END_TEST;
-}
-
-int UtcDaliFocusManagerClearFocus(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerClearFocus");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- // Create the first actor and add it to the stage
- Actor first = Actor::New();
- manager.SetFocusOrder(first, 1);
- Stage::GetCurrent().Add(first);
-
- // Create the second actor and add it to the stage
- Actor second = Actor::New();
- manager.SetFocusOrder(second, 2);
- Stage::GetCurrent().Add(second);
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Check that the focus is set on the first actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
-
- // Check that the focus is set on the second actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
-
- // Clear the focus
- manager.ClearFocus();
-
- // Check that no actor is being focused now.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
- END_TEST;
-}
-
-int UtcDaliFocusManagerReset(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerReset");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- // Create the first actor and add it to the stage
- Actor first = Actor::New();
- manager.SetFocusOrder(first, 1);
- Stage::GetCurrent().Add(first);
-
- // Create the second actor and add it to the stage
- Actor second = Actor::New();
- manager.SetFocusOrder(second, 2);
- Stage::GetCurrent().Add(second);
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Check that the focus is set on the first actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
-
- // Check that the focus is set on the second actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
-
- // Clear the focus
- manager.Reset();
-
- // Check that no actor is being focused now and the focus order of actors have been cleared
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
- DALI_TEST_CHECK(manager.GetFocusOrder(first) == 0);
- END_TEST;
-}
-
-int UtcDaliFocusManagerFocusGroup(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerFocusGroup");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- // Create an actor with two child actors and add it to the stage
- Actor parent = Actor::New();
- Actor firstChild = Actor::New();
- Actor secondChild = Actor::New();
- parent.Add(firstChild);
- parent.Add(secondChild);
- Stage::GetCurrent().Add(parent);
-
- // Create three actors and add them as the children of the first child actor
- Actor firstGrandChild = Actor::New();
- Actor secondGrandChild = Actor::New();
- Actor thirdGrandChild = Actor::New();
- firstChild.Add(firstGrandChild);
- firstChild.Add(secondGrandChild);
- firstChild.Add(thirdGrandChild);
-
- // Set focus order to the actors
- manager.SetFocusOrder(parent, 1);
- manager.SetFocusOrder(firstChild, 2);
- manager.SetFocusOrder(firstGrandChild, 3);
- manager.SetFocusOrder(secondGrandChild, 4);
- manager.SetFocusOrder(thirdGrandChild, 5);
- manager.SetFocusOrder(secondChild, 6);
-
- // Set the parent and the first child actor as focus groups
- manager.SetFocusGroup(parent, true);
- DALI_TEST_CHECK(manager.IsFocusGroup(parent) == true);
-
- // The focus group of the parent should be itself, as it is set to be a focus group.
- DALI_TEST_CHECK(manager.GetFocusGroup(parent) == parent);
-
- // The focus group of the firstChild should be its parent, as it is the immediate parent which is also a group.
- DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == parent);
-
- manager.SetFocusGroup(firstChild, true);
- DALI_TEST_CHECK(manager.IsFocusGroup(firstChild) == true);
-
- // The focus group of the firstChild should be itself, as it is set to be a focus group now.
- DALI_TEST_CHECK(manager.GetFocusGroup(firstChild) == firstChild);
-
- // Enable wrap mode for focus movement.
- manager.SetWrapMode(true);
- DALI_TEST_CHECK(manager.GetWrapMode() == true);
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Check that the focus is set on the parent actor.
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(parent) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
-
- // Check that group mode is disabled.
- DALI_TEST_CHECK(manager.GetGroupMode() == false);
-
- // Check that the focus movement is wrapped as normal.
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == parent);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
-
- // Enable the group mode.
- manager.SetGroupMode(true);
- DALI_TEST_CHECK(manager.GetGroupMode() == true);
-
- // Check that the focus movement is now limited to the current focus group.
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == secondGrandChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == thirdGrandChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstChild);
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == firstGrandChild);
- END_TEST;
-}
-
-int UtcDaliFocusManagerSetAndGetFocusIndicator(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSetAndGetFocusIndicator");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- Actor defaultFocusIndicatorActor = manager.GetFocusIndicatorActor();
- DALI_TEST_CHECK(defaultFocusIndicatorActor);
-
- Actor newFocusIndicatorActor = Actor::New();
- manager.SetFocusIndicatorActor(newFocusIndicatorActor);
- DALI_TEST_CHECK(manager.GetFocusIndicatorActor() == newFocusIndicatorActor);
- END_TEST;
-}
-
-int UtcDaliFocusManagerSignalFocusChanged(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSignalFocusChanged");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- bool signalVerified = false;
- FocusChangedCallback callback(signalVerified);
- manager.FocusChangedSignal().Connect( &callback, &FocusChangedCallback::Callback );
-
- // Create the first actor and add it to the stage
- Actor first = Actor::New();
- manager.SetFocusOrder(first, 1);
- Stage::GetCurrent().Add(first);
-
- // Create the second actor and add it to the stage
- Actor second = Actor::New();
- manager.SetFocusOrder(second, 2);
- Stage::GetCurrent().Add(second);
-
- // Check that no actor is being focused yet.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
-
- // Check that the focus is set on the first actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(callback.mSignalVerified);
- callback.Reset();
-
- // Check that the focus is set on the second actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(second) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
- DALI_TEST_CHECK(callback.mSignalVerified);
- callback.Reset();
-
- // Clear the focus
- manager.ClearFocus();
-
- // Check that no actor is being focused now.
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == Actor());
- DALI_TEST_CHECK(callback.mSignalVerified);
- END_TEST;
-}
-
-int UtcDaliFocusManagerSignalFocusOvershot(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSignalFocusOvershot");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- bool signalVerified = false;
- FocusOvershotCallback callback(signalVerified);
- manager.FocusOvershotSignal().Connect(&callback, &FocusOvershotCallback::Callback);
-
- // Create the first actor and add it to the stage
- Actor first = Actor::New();
- manager.SetFocusOrder(first, 1);
- Stage::GetCurrent().Add(first);
-
- // Create the second actor and add it to the stage
- Actor second = Actor::New();
- manager.SetFocusOrder(second, 2);
- Stage::GetCurrent().Add(second);
-
- // Check that the wrap mode is disabled
- DALI_TEST_CHECK(manager.GetWrapMode() == false);
-
- // Check that the focus is set on the first actor
- DALI_TEST_CHECK(manager.SetCurrentFocusActor(first) == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
-
- // Check that the focus is moved to the second actor successfully.
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
-
- // Check that the forward focus movement is overshot.
- callback.mCurrentFocusedActor = second;
- callback.mFocusOvershotDirection = Toolkit::FocusManager::OVERSHOT_NEXT;
- DALI_TEST_CHECK(manager.MoveFocusForward() == false);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == second);
- DALI_TEST_CHECK(signalVerified);
- callback.Reset();
-
- // Enable the wrap mode
- manager.SetWrapMode(true);
- DALI_TEST_CHECK(manager.GetWrapMode() == true);
-
- // Check that the forward focus movement is wrapped and no overshot happens.
- DALI_TEST_CHECK(manager.MoveFocusForward() == true);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(signalVerified == false);
-
- // Disable the wrap mode
- manager.SetWrapMode(false);
- DALI_TEST_CHECK(manager.GetWrapMode() == false);
-
- // Check that the backward focus movement is overshot.
- callback.mCurrentFocusedActor = first;
- callback.mFocusOvershotDirection = Toolkit::FocusManager::OVERSHOT_PREVIOUS;
- DALI_TEST_CHECK(manager.MoveFocusBackward() == false);
- DALI_TEST_CHECK(manager.GetCurrentFocusActor() == first);
- DALI_TEST_CHECK(signalVerified);
- END_TEST;
-}
-
-int UtcDaliFocusManagerSignalFocusedActorActivated(void)
-{
- ToolkitTestApplication application;
-
- tet_infoline(" UtcDaliFocusManagerSignalFocusedActorActivated");
-
- FocusManager manager = FocusManager::Get();
- DALI_TEST_CHECK(manager);
-
- FocusedActorActivatedCallback callback;
- manager.FocusedActorActivatedSignal().Connect(&callback, &FocusedActorActivatedCallback::Callback);
- DALI_TEST_CHECK(true);
-
- END_TEST;
-}
#include <dali-toolkit-test-suite-utils.h>
#include <dali-toolkit/dali-toolkit.h>
#include <dali/integration-api/events/key-event-integ.h>
+#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include "dummy-control.h"
develapisliderdir = $(develapicontrolsdir)/slider
develapishadowviewdir = $(develapicontrolsdir)/shadow-view
develapisuperblurviewdir = $(develapicontrolsdir)/super-blur-view
+develapifocusmanagerdir = $(develapidir)/focus-manager
develapiscriptingdir = $(develapidir)/scripting
develapibubbleeffectdir = $(develapidir)/shader-effects/bubble-effect
develapishadereffectsdir = $(develapidir)/shader-effects
develapibubbleeffect_HEADERS = $(devel_api_bubble_effect_header_files)
develapibuilder_HEADERS = $(devel_api_builder_header_files)
develapieffectsview_HEADERS = $(devel_api_effects_view_header_files)
+develapifocusmanager_HEADERS = $(devel_api_focus_manager_header_files)
develapimagnifier_HEADERS = $(devel_api_magnifier_header_files)
develapipageturnview_HEADERS = $(devel_api_page_turn_view_header_files)
develapipopup_HEADERS = $(devel_api_popup_header_files)
#include <dali-toolkit/public-api/controls/table-view/table-view.h>
#include <dali-toolkit/public-api/controls/text-controls/text-field.h>
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
-#include <dali-toolkit/public-api/focus-manager/focus-manager.h>
+#include <dali-toolkit/public-api/focus-manager/accessibility-focus-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
-#include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/public-api/text/rendering-backend.h>
#include <dali-toolkit/public-api/dali-toolkit-version.h>
#include <dali-toolkit/public-api/enums.h>
$(devel_api_src_dir)/controls/super-blur-view/super-blur-view.cpp \
$(devel_api_src_dir)/controls/text-controls/text-selection-popup.cpp \
$(devel_api_src_dir)/controls/tool-bar/tool-bar.cpp \
+ $(devel_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(devel_api_src_dir)/styling/style-manager.cpp \
$(devel_api_src_dir)/scripting/script.cpp \
$(devel_api_src_dir)/shader-effects/bubble-effect/bubble-effect.cpp \
devel_api_slider_header_files = \
$(devel_api_src_dir)/controls/slider/slider.h
+devel_api_focus_manager_header_files = \
+ $(devel_api_src_dir)/focus-manager/keyinput-focus-manager.h
+
devel_api_styling_header_files = \
$(devel_api_src_dir)/styling/style-manager.h
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "keyinput-focus-manager.h"
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/singleton-service.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+KeyInputFocusManager::KeyInputFocusManager()
+{
+}
+
+KeyInputFocusManager::~KeyInputFocusManager()
+{
+}
+
+KeyInputFocusManager KeyInputFocusManager::Get()
+{
+ KeyInputFocusManager manager;
+
+ // Check whether the focus manager is already created
+ SingletonService singletonService( SingletonService::Get() );
+ if ( singletonService )
+ {
+ Dali::BaseHandle handle = singletonService.GetSingleton(typeid(KeyInputFocusManager));
+ if(handle)
+ {
+ // If so, downcast the handle of singleton to focus manager
+ manager = KeyInputFocusManager(dynamic_cast<Internal::KeyInputFocusManager*>(handle.GetObjectPtr()));
+ }
+
+ if(!manager)
+ {
+ // If not, create the focus manager and register it as a singleton
+ manager = KeyInputFocusManager(new Internal::KeyInputFocusManager());
+ singletonService.Register(typeid(manager), manager);
+ }
+ }
+
+ return manager;
+}
+
+KeyInputFocusManager::KeyInputFocusManager(Internal::KeyInputFocusManager *impl)
+ : BaseHandle(impl)
+{
+}
+
+void KeyInputFocusManager::SetFocus(Control control)
+{
+ GetImpl(*this).SetFocus(control);
+}
+
+Control KeyInputFocusManager::GetCurrentFocusControl() const
+{
+ return GetImpl(*this).GetCurrentFocusControl();
+}
+
+void KeyInputFocusManager::RemoveFocus(Control control)
+{
+ GetImpl(*this).RemoveFocus(control);
+}
+
+bool KeyInputFocusManager::IsKeyboardListener(Control control)
+{
+ return GetImpl(*this).IsKeyboardListener(control);
+}
+
+KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
+{
+ return GetImpl(*this).KeyInputFocusChangedSignal();
+}
+
+KeyInputFocusManager::UnhandledKeyEventSignalType& KeyInputFocusManager::UnhandledKeyEventSignal()
+{
+ return GetImpl(*this).UnhandledKeyEventSignal();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
--- /dev/null
+#ifndef __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__
+#define __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class KeyInputFocusManager;
+}
+
+/**
+ * KeyInputFocusManager
+ * This class provides the functionality of registering for keyboard events for controls.
+ * The keyinput focus manager maintains a stack of controls, With the last added control receiving
+ * all the keyboard events first. And if the conrol doesn't consume the event it is passed to
+ * the next control in the stack. If none of the controls in the stack consume the key event then
+ * UnhandledKeyEventSignal() is emitted.
+ *
+ * Signals
+ * | %Signal Name | Method |
+ * |-------------------------|-----------------------------------|
+ * | key-input-focus-changed | @ref KeyInputFocusChangedSignal() |
+ * | unhandled-key-event | @ref UnhandledKeyEventSignal() |
+ */
+class DALI_IMPORT_API KeyInputFocusManager : public BaseHandle
+{
+public:
+
+ // KeyInputFocusChanged
+ typedef Signal< void (Control, Control) > KeyInputFocusChangedSignalType;
+
+ // Unhandled Key Event
+ typedef Signal< void (const KeyEvent&) > UnhandledKeyEventSignalType;
+
+public:
+
+ /**
+ * Create a KeyInputFocusManager handle; this can be initialised with KeyInputFocusManager::Get()
+ * Calling member functions with an uninitialised handle is not allowed.
+ */
+ KeyInputFocusManager();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~KeyInputFocusManager();
+
+ /**
+ * Get the singleton of KeyInputFocusManager object.
+ * @return A handle to the KeyInputFocusManager control.
+ */
+ static KeyInputFocusManager Get();
+
+ /**
+ * Sets keyboard focus for a control.
+ * Note: A control can be set to be in focus and still not receive all the key events if another control has over ridden it.
+ * As the key input focus mechanism works like a stack, the top most control receives all the key events, and passes on the
+ * unhandled events to the controls below in the stack. A control in the stack will regain key input focus when there are no more
+ * controls above it in the focus stack.
+ *
+ * @pre The Control is not in the focus stack. If it is allready present in the top of the stack it results in a no-op, If it is
+ * present in the stack but not on the top of the stack, then the control is moved to the top of the focus stack.
+ * @param[in] control The Control to receive keyboard input
+ */
+ void SetFocus(Control control);
+
+ /**
+ * Query for the control that is currently set to be on top of the fcous stack and receives all
+ * keyboard input events first.
+ * @return Pointer to the control set to receive keyboard inputs.
+ */
+ Control GetCurrentFocusControl() const;
+
+ /**
+ * Removes focus for the given control, The control will no longer receive events from keyboard.
+ * @param [in] control which should be removed from focus.
+ */
+ void RemoveFocus(Control control);
+
+ /**
+ * Queries whether a control is currently part of the focus stack.
+ * @param [in] control which should be queried.
+ * @return True if it is part of the foucus stack False otherwise.
+ */
+ bool IsKeyboardListener(Control control);
+
+public: // Signals
+
+ /**
+ * This signal is emitted when the key input focus control changes.
+ * Two control parameters are sent as part of this signal, the first being the signal that now has the focus, the second
+ * being the one that has lost focus.
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallback(Control focusGainedControl, Control focusLostActor);
+ * @endcode
+ * @return The signal to connect to.
+ */
+ KeyInputFocusChangedSignalType& KeyInputFocusChangedSignal();
+
+ /**
+ * This signal is emitted when a key event was received, and none of the focused controls on the stage have consumed it.
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(const KeyEvent& event);
+ * @endcode
+ * @return The signal to connect to.
+ */
+ UnhandledKeyEventSignalType& UnhandledKeyEventSignal();
+
+private:
+
+ explicit DALI_INTERNAL KeyInputFocusManager(Internal::KeyInputFocusManager *impl);
+
+}; // class KeyInputFocusManager
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__
#include <dali-toolkit/public-api/controls/buttons/button.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
#include <dali-toolkit/public-api/controls/default-controls/solid-color-actor.h>
-#include <dali-toolkit/public-api/focus-manager/focus-manager.h>
+#include <dali-toolkit/public-api/focus-manager/accessibility-focus-manager.h>
#include <dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h>
#include <dali-toolkit/internal/controls/buttons/button-impl.h>
$(toolkit_src_dir)/controls/text-controls/text-label-impl.cpp \
$(toolkit_src_dir)/controls/text-controls/text-selection-popup-impl.cpp \
$(toolkit_src_dir)/controls/tool-bar/tool-bar-impl.cpp \
- $(toolkit_src_dir)/focus-manager/focus-manager-impl.cpp \
+ $(toolkit_src_dir)/focus-manager/accessibility-focus-manager-impl.cpp \
$(toolkit_src_dir)/focus-manager/keyboard-focus-manager-impl.cpp \
$(toolkit_src_dir)/focus-manager/keyinput-focus-manager-impl.cpp \
$(toolkit_src_dir)/filters/blur-two-pass-filter.cpp \
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include "accessibility-focus-manager-impl.h"
+
+// EXTERNAL INCLUDES
+#include <cstring> // for strcmp
+#include <dali/public-api/actors/layer.h>
+#include <dali/devel-api/adaptor-framework/accessibility-manager.h>
+#include <dali/devel-api/adaptor-framework/sound-player.h>
+#include <dali/devel-api/adaptor-framework/tts-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/integration-api/debug.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/controls/control.h>
+#include <dali-toolkit/public-api/controls/control-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+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";
+
+#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* 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_SOUND_FILE = DALI_SOUND_DIR "Focus.ogg";
+const char* FOCUS_CHAIN_END_SOUND_FILE = DALI_SOUND_DIR "End_of_List.ogg";
+
+/**
+ * The function to be used in the hit-test algorithm to check whether the actor is hittable.
+ */
+bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
+{
+ bool hittable = false;
+
+ switch (type)
+ {
+ 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
+ {
+ // Check whether the actor is focusable
+ Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE);
+ if(propertyActorFocusable != Property::INVALID_INDEX)
+ {
+ hittable = actor.GetProperty<bool>(propertyActorFocusable);
+ }
+ }
+ break;
+ }
+ case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
+ {
+ if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
+ {
+ hittable = true;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return hittable;
+};
+
+}
+
+AccessibilityFocusManager::AccessibilityFocusManager()
+: mIsWrapped(false),
+ mIsFocusWithinGroup(false),
+ mIsEndcapFeedbackEnabled(false),
+ mIsEndcapFeedbackPlayed(false),
+ mCurrentFocusActor(FocusIDPair(0, 0)),
+ mFocusIndicatorActor(Actor()),
+ mRecursiveFocusMoveCounter(0),
+ mIsAccessibilityTtsEnabled(false),
+ mIsFocusIndicatorEnabled(false)
+{
+ CreateDefaultFocusIndicatorActor();
+
+ AccessibilityManager manager = AccessibilityManager::Get();
+ manager.SetActionHandler(*this);
+ manager.SetGestureHandler(*this);
+
+ ChangeAccessibilityStatus();
+}
+
+AccessibilityFocusManager::~AccessibilityFocusManager()
+{
+}
+
+AccessibilityFocusManager::ActorAdditionalInfo AccessibilityFocusManager::GetActorAdditionalInfo(const unsigned int actorID) const
+{
+ ActorAdditionalInfo data;
+ IDAdditionalInfoConstIter iter = mIDAdditionalInfoContainer.find(actorID);
+ if(iter != mIDAdditionalInfoContainer.end())
+ {
+ data = (*iter).second;
+ }
+
+ return data;
+}
+
+void AccessibilityFocusManager::SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order)
+{
+ ActorAdditionalInfo actorInfo = GetActorAdditionalInfo(actorID);
+ actorInfo.mFocusOrder = order;
+ mIDAdditionalInfoContainer.erase(actorID);
+ mIDAdditionalInfoContainer.insert(IDAdditionalInfoPair(actorID, actorInfo));
+}
+
+void AccessibilityFocusManager::SetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityFocusManager::AccessibilityAttribute type, const std::string& text)
+{
+ if(actor)
+ {
+ unsigned int actorID = actor.GetId();
+
+ ActorAdditionalInfo info = GetActorAdditionalInfo(actorID);
+ info.mAccessibilityAttributes[type] = text;
+
+ mIDAdditionalInfoContainer.erase(actorID);
+ mIDAdditionalInfoContainer.insert(IDAdditionalInfoPair(actorID, info));
+ }
+}
+
+std::string AccessibilityFocusManager::GetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityFocusManager::AccessibilityAttribute type) const
+{
+ std::string text;
+
+ if(actor)
+ {
+ ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId());
+ text = data.mAccessibilityAttributes[type];
+ }
+
+ return text;
+}
+
+void AccessibilityFocusManager::SetFocusOrder(Actor actor, const unsigned int order)
+{
+ // Do nothing if the focus order of the actor is not changed.
+ if(actor && GetFocusOrder(actor) != 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);
+ }
+
+ if(order == 0)
+ {
+ // The actor is not focusable without a defined focus order.
+ actor.SetProperty(propertyActorFocusable, false);
+
+ // If the actor is currently being focused, it should clear the focus
+ if(actor == GetCurrentFocusActor())
+ {
+ ClearFocus();
+ }
+ }
+ else // Insert the actor to the focus chain
+ {
+ // Check whether there is another actor in the focus chain with the same focus order already.
+ FocusIDIter focusIDIter = mFocusIDContainer.find(order);
+ if(focusIDIter != mFocusIDContainer.end())
+ {
+ // We need to increase the focus order of that actor and all the actors followed it
+ // in the focus chain.
+ FocusIDIter lastIter = mFocusIDContainer.end();
+ --lastIter;//We want forward iterator to the last element here
+ mFocusIDContainer.insert(FocusIDPair((*lastIter).first + 1, (*lastIter).second));
+
+ // Update the actor's focus order in its additional data
+ SynchronizeActorAdditionalInfo((*lastIter).second, (*lastIter).first + 1);
+
+ for(FocusIDIter iter = lastIter; iter != focusIDIter; iter--)
+ {
+ FocusIDIter previousIter = iter;
+ --previousIter;//We want forward iterator to the previous element here
+ unsigned int actorID = (*previousIter).second;
+ (*iter).second = actorID;
+
+ // Update the actor's focus order in its additional data
+ SynchronizeActorAdditionalInfo(actorID, (*iter).first);
+ }
+
+ mFocusIDContainer.erase(order);
+ }
+
+ // The actor is focusable
+ actor.SetProperty(propertyActorFocusable, true);
+
+ // Now we insert the actor into the focus chain with the specified focus order
+ mFocusIDContainer.insert(FocusIDPair(order, actor.GetId()));
+ }
+
+ // Update the actor's focus order in its additional data
+ SynchronizeActorAdditionalInfo(actor.GetId(), order);
+ }
+}
+
+unsigned int AccessibilityFocusManager::GetFocusOrder(Actor actor) const
+{
+ unsigned int focusOrder = 0;
+
+ if(actor)
+ {
+ ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId());
+ focusOrder = data.mFocusOrder;
+ }
+
+ return focusOrder;
+}
+
+unsigned int AccessibilityFocusManager::GenerateNewFocusOrder() const
+{
+ unsigned int order = 1;
+ FocusIDContainer::const_reverse_iterator iter = mFocusIDContainer.rbegin();
+
+ if(iter != mFocusIDContainer.rend())
+ {
+ order = (*iter).first + 1;
+ }
+
+ return order;
+}
+
+Actor AccessibilityFocusManager::GetActorByFocusOrder(const unsigned int order)
+{
+ Actor actor = Actor();
+
+ FocusIDIter focusIDIter = mFocusIDContainer.find(order);
+ if(focusIDIter != mFocusIDContainer.end())
+ {
+ Actor rootActor = Stage::GetCurrent().GetRootLayer();
+ actor = rootActor.FindChildById(mFocusIDContainer[order]);
+ }
+
+ return actor;
+}
+
+bool AccessibilityFocusManager::SetCurrentFocusActor(Actor actor)
+{
+ if(actor)
+ {
+ return DoSetCurrentFocusActor(actor.GetId());
+ }
+
+ return false;
+}
+
+bool AccessibilityFocusManager::DoSetCurrentFocusActor(const unsigned int actorID)
+{
+ Actor rootActor = Stage::GetCurrent().GetRootLayer();
+
+ // If the group mode is enabled, check which focus group the current focused actor belongs to
+ Actor focusGroup;
+ if(mIsFocusWithinGroup)
+ {
+ focusGroup = GetFocusGroup(GetCurrentFocusActor());
+ }
+
+ if(!focusGroup)
+ {
+ focusGroup = rootActor;
+ }
+
+ Actor actor = focusGroup.FindChildById(actorID);
+
+ // Check whether the actor is in the stage
+ if(actor)
+ {
+ // Check whether the actor is focusable
+ bool actorFocusable = false;
+ Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE);
+ if(propertyActorFocusable != Property::INVALID_INDEX)
+ {
+ actorFocusable = actor.GetProperty<bool>(propertyActorFocusable);
+ }
+
+ // Go through the actor's hierarchy to check whether the actor is visible
+ bool actorVisible = actor.IsVisible();
+ Actor parent = actor.GetParent();
+ while (actorVisible && parent && parent != rootActor)
+ {
+ actorVisible = parent.IsVisible();
+ parent = parent.GetParent();
+ }
+
+ // Check whether the actor is fully transparent
+ bool actorOpaque = actor.GetCurrentWorldColor().a > 0.01f;
+
+ // Set the focus only when the actor is focusable and visible and not fully transparent
+ if(actorVisible && actorFocusable && actorOpaque)
+ {
+ // Draw the focus indicator upon the focused actor
+ if(mIsFocusIndicatorEnabled && mFocusIndicatorActor)
+ {
+ actor.Add(mFocusIndicatorActor);
+ }
+
+ // Send notification for the change of focus actor
+ mFocusChangedSignal.Emit( GetCurrentFocusActor(), actor );
+
+ // Save the current focused actor
+ mCurrentFocusActor = FocusIDPair(GetFocusOrder(actor), actorID);
+
+ if(mIsAccessibilityTtsEnabled)
+ {
+ Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get();
+ if(soundPlayer)
+ {
+ soundPlayer.PlaySound(FOCUS_SOUND_FILE);
+ }
+
+ // Play the accessibility attributes with the TTS player.
+ Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER);
+
+ // Combine attribute texts to one text
+ std::string informationText;
+ for(int i = 0; i < Toolkit::AccessibilityFocusManager::ACCESSIBILITY_ATTRIBUTE_NUM; i++)
+ {
+ if(!GetActorAdditionalInfo(actorID).mAccessibilityAttributes[i].empty())
+ {
+ if( i > 0 )
+ {
+ informationText += ", "; // for space time between each information
+ }
+ informationText += GetActorAdditionalInfo(actorID).mAccessibilityAttributes[i];
+ }
+ }
+ player.Play(informationText);
+ }
+
+ return true;
+ }
+ }
+
+ DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__);
+ return false;
+}
+
+Actor AccessibilityFocusManager::GetCurrentFocusActor()
+{
+ Actor rootActor = Stage::GetCurrent().GetRootLayer();
+ return rootActor.FindChildById(mCurrentFocusActor.second);
+}
+
+Actor AccessibilityFocusManager::GetCurrentFocusGroup()
+{
+ return GetFocusGroup(GetCurrentFocusActor());
+}
+
+unsigned int AccessibilityFocusManager::GetCurrentFocusOrder()
+{
+ return mCurrentFocusActor.first;
+}
+
+bool AccessibilityFocusManager::MoveFocusForward()
+{
+ bool ret = false;
+ mRecursiveFocusMoveCounter = 0;
+
+ FocusIDIter focusIDIter = mFocusIDContainer.find(mCurrentFocusActor.first);
+ if(focusIDIter != mFocusIDContainer.end())
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
+ ret = DoMoveFocus(focusIDIter, true, mIsWrapped);
+ }
+ else
+ {
+ // TODO: if there is not focused actor, move first actor
+ if(!mFocusIDContainer.empty())
+ {
+ //if there is not focused actor, move 1st actor
+ focusIDIter = mFocusIDContainer.begin(); // TODO: I'm not sure it was sorted.
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
+ ret = DoSetCurrentFocusActor((*focusIDIter).second);
+ }
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s] %s\n", __FUNCTION__, ret?"SUCCEED!!!":"FAILED!!!");
+
+ return ret;
+}
+
+bool AccessibilityFocusManager::MoveFocusBackward()
+{
+ bool ret = false;
+ mRecursiveFocusMoveCounter = 0;
+
+ FocusIDIter focusIDIter = mFocusIDContainer.find(mCurrentFocusActor.first);
+ if(focusIDIter != mFocusIDContainer.end())
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
+ ret = DoMoveFocus(focusIDIter, false, mIsWrapped);
+ }
+ else
+ {
+ // TODO: if there is not focused actor, move last actor
+ if(!mFocusIDContainer.empty())
+ {
+ //if there is not focused actor, move last actor
+ focusIDIter = mFocusIDContainer.end();
+ --focusIDIter;//We want forward iterator to the last element here
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
+ ret = DoSetCurrentFocusActor((*focusIDIter).second);
+ }
+ }
+
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s] %s\n", __FUNCTION__, ret?"SUCCEED!!!":"FAILED!!!");
+
+ return ret;
+}
+
+void AccessibilityFocusManager::DoActivate(Actor actor)
+{
+ if(actor)
+ {
+ Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
+ if(control)
+ {
+ // Notify the control that it is activated
+ GetImplementation( control ).AccessibilityActivate();
+ }
+
+ // Send notification for the activation of focused actor
+ mFocusedActorActivatedSignal.Emit(actor);
+ }
+}
+
+void AccessibilityFocusManager::ClearFocus()
+{
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ actor.Remove(mFocusIndicatorActor);
+ }
+
+ mCurrentFocusActor = FocusIDPair(0, 0);
+
+ // Send notification for the change of focus actor
+ mFocusChangedSignal.Emit(actor, Actor());
+
+ if(mIsAccessibilityTtsEnabled)
+ {
+ // Stop the TTS playing if any
+ Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER);
+ player.Stop();
+ }
+}
+
+void AccessibilityFocusManager::Reset()
+{
+ ClearFocus();
+ mFocusIDContainer.clear();
+ mIDAdditionalInfoContainer.clear();
+}
+
+void AccessibilityFocusManager::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);
+ }
+ else
+ {
+ actor.SetProperty(propertyIsFocusGroup, isFocusGroup);
+ }
+ }
+}
+
+bool AccessibilityFocusManager::IsFocusGroup(Actor actor) const
+{
+ // Check whether the actor is a focus group
+ bool isFocusGroup = false;
+
+ if(actor)
+ {
+ Property::Index propertyIsFocusGroup = actor.GetPropertyIndex(IS_FOCUS_GROUP);
+ if(propertyIsFocusGroup != Property::INVALID_INDEX)
+ {
+ isFocusGroup = actor.GetProperty<bool>(propertyIsFocusGroup);
+ }
+ }
+
+ return isFocusGroup;
+}
+
+Actor AccessibilityFocusManager::GetFocusGroup(Actor actor)
+{
+ // Go through the actor's hierarchy to check which focus group the actor belongs to
+ while (actor && !IsFocusGroup(actor))
+ {
+ actor = actor.GetParent();
+ }
+
+ return actor;
+}
+
+void AccessibilityFocusManager::SetGroupMode(bool enabled)
+{
+ mIsFocusWithinGroup = enabled;
+}
+
+bool AccessibilityFocusManager::GetGroupMode() const
+{
+ return mIsFocusWithinGroup;
+}
+
+void AccessibilityFocusManager::SetWrapMode(bool wrapped)
+{
+ mIsWrapped = wrapped;
+}
+
+bool AccessibilityFocusManager::GetWrapMode() const
+{
+ return mIsWrapped;
+}
+
+void AccessibilityFocusManager::SetFocusIndicatorActor(Actor indicator)
+{
+ mFocusIndicatorActor = indicator;
+}
+
+Actor AccessibilityFocusManager::GetFocusIndicatorActor()
+{
+ return mFocusIndicatorActor;
+}
+
+bool AccessibilityFocusManager::DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped)
+{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] %d focusable actors\n", __FUNCTION__, __LINE__, mFocusIDContainer.size());
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
+
+ if( (forward && ++focusIDIter == mFocusIDContainer.end())
+ || (!forward && focusIDIter-- == mFocusIDContainer.begin()) )
+ {
+ if(mIsEndcapFeedbackEnabled)
+ {
+ if(mIsEndcapFeedbackPlayed == false)
+ {
+ // play sound & skip moving once
+ Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get();
+ if(soundPlayer)
+ {
+ soundPlayer.PlaySound(FOCUS_CHAIN_END_SOUND_FILE);
+ }
+
+ mIsEndcapFeedbackPlayed = true;
+ return true;
+ }
+ mIsEndcapFeedbackPlayed = false;
+ }
+
+ if(wrapped)
+ {
+ if(forward)
+ {
+ focusIDIter = mFocusIDContainer.begin();
+ }
+ else
+ {
+ focusIDIter = mFocusIDContainer.end();
+ --focusIDIter;//We want forward iterator to the last element here
+ }
+ }
+ else
+ {
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Overshot\n", __FUNCTION__, __LINE__);
+ // Send notification for handling overshooted situation
+ mFocusOvershotSignal.Emit(GetCurrentFocusActor(), forward ? Toolkit::AccessibilityFocusManager::OVERSHOT_NEXT : Toolkit::AccessibilityFocusManager::OVERSHOT_PREVIOUS);
+
+ return false; // Try to move the focus out of the scope
+ }
+ }
+
+ if((focusIDIter != mFocusIDContainer.end()) && !DoSetCurrentFocusActor((*focusIDIter).second))
+ {
+ mRecursiveFocusMoveCounter++;
+ if(mRecursiveFocusMoveCounter > mFocusIDContainer.size())
+ {
+ // We've attempted to focus all the actors in the whole focus chain and no actor
+ // can be focused successfully.
+
+ DALI_LOG_WARNING("[%s] There is no more focusable actor in %d focus chains\n", __FUNCTION__, mRecursiveFocusMoveCounter);
+
+ return false;
+ }
+ else
+ {
+ return DoMoveFocus(focusIDIter, forward, wrapped);
+ }
+ }
+
+ return true;
+}
+
+void AccessibilityFocusManager::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);
+ }
+ else
+ {
+ actor.SetProperty(propertyActorFocusable, focusable);
+ }
+ }
+}
+
+void AccessibilityFocusManager::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 AccessibilityFocusManager::ChangeAccessibilityStatus()
+{
+ AccessibilityManager manager = AccessibilityManager::Get();
+ mIsAccessibilityTtsEnabled = manager.IsEnabled();
+
+ if(mIsAccessibilityTtsEnabled)
+ {
+ // Show indicator when tts turned on if there is focused actor.
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ if(mFocusIndicatorActor)
+ {
+ actor.Add(mFocusIndicatorActor);
+ }
+ }
+ mIsFocusIndicatorEnabled = true;
+ }
+ else
+ {
+ // Hide indicator when tts turned off
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ actor.Remove(mFocusIndicatorActor);
+ }
+ mIsFocusIndicatorEnabled = false;
+ }
+
+ return true;
+}
+
+bool AccessibilityFocusManager::AccessibilityActionNext(bool allowEndFeedback)
+{
+ if(mIsAccessibilityTtsEnabled)
+ {
+ mIsEndcapFeedbackEnabled = allowEndFeedback;
+ return MoveFocusForward();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool AccessibilityFocusManager::AccessibilityActionPrevious(bool allowEndFeedback)
+{
+ if(mIsAccessibilityTtsEnabled)
+ {
+ mIsEndcapFeedbackEnabled = allowEndFeedback;
+ return MoveFocusBackward();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool AccessibilityFocusManager::AccessibilityActionActivate()
+{
+ bool ret = false;
+
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ DoActivate(actor);
+ ret = true;
+ }
+
+ return ret;
+}
+
+bool AccessibilityFocusManager::AccessibilityActionRead(bool allowReadAgain)
+{
+ bool ret = false;
+
+ if(mIsAccessibilityTtsEnabled)
+ {
+ // Find the focusable actor at the read position
+ AccessibilityManager manager = AccessibilityManager::Get();
+ Dali::HitTestAlgorithm::Results results;
+ Dali::HitTestAlgorithm::HitTest( Stage::GetCurrent(), manager.GetReadPosition(), results, IsActorFocusableFunction );
+
+ FocusIDIter focusIDIter = mFocusIDContainer.find(GetFocusOrder(results.actor));
+ if(focusIDIter != mFocusIDContainer.end())
+ {
+ if( allowReadAgain || (results.actor != GetCurrentFocusActor()) )
+ {
+ // Move the focus to the actor
+ ret = SetCurrentFocusActor(results.actor);
+ DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SetCurrentFocusActor returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
+ }
+ }
+ }
+
+ return ret;
+}
+
+bool AccessibilityFocusManager::AccessibilityActionReadNext(bool allowEndFeedback)
+{
+ if(mIsAccessibilityTtsEnabled)
+ {
+ return MoveFocusForward();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool AccessibilityFocusManager::AccessibilityActionReadPrevious(bool allowEndFeedback)
+{
+ if(mIsAccessibilityTtsEnabled)
+ {
+ return MoveFocusBackward();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool AccessibilityFocusManager::AccessibilityActionUp()
+{
+ bool ret = false;
+
+ if(mIsAccessibilityTtsEnabled)
+ {
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
+ if(control)
+ {
+ // Notify the control that it is activated
+ ret = GetImplementation( control ).OnAccessibilityValueChange(true);
+ }
+ }
+ }
+
+ return ret;
+}
+
+bool AccessibilityFocusManager::AccessibilityActionDown()
+{
+ bool ret = false;
+
+ if(mIsAccessibilityTtsEnabled)
+ {
+ Actor actor = GetCurrentFocusActor();
+ if(actor)
+ {
+ Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
+ if(control)
+ {
+ // Notify the control that it is activated
+ ret = GetImplementation( control ).OnAccessibilityValueChange(false);
+ }
+ }
+ }
+
+ return ret;
+}
+
+bool AccessibilityFocusManager::ClearAccessibilityFocus()
+{
+ if(mIsAccessibilityTtsEnabled)
+ {
+ ClearFocus();
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+bool AccessibilityFocusManager::AccessibilityActionBack()
+{
+ // TODO: Back to previous view
+
+ return mIsAccessibilityTtsEnabled;
+}
+
+bool AccessibilityFocusManager::AccessibilityActionTouch(const TouchEvent& touchEvent)
+{
+ bool handled = false;
+
+ // TODO: Need to convert the touchevent for the focused actor?
+
+ Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(GetCurrentFocusActor());
+ if(control)
+ {
+ handled = GetImplementation( control ).OnAccessibilityTouch(touchEvent);
+ }
+
+ return handled;
+}
+
+bool AccessibilityFocusManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent)
+{
+ bool handled = false;
+
+ if( panEvent.state == Gesture::Started )
+ {
+ // Find the focusable actor at the event position
+ Dali::HitTestAlgorithm::Results results;
+ AccessibilityManager manager = AccessibilityManager::Get();
+
+ Dali::HitTestAlgorithm::HitTest( Stage::GetCurrent(), panEvent.currentPosition, results, IsActorFocusableFunction );
+ mCurrentGesturedActor = results.actor;
+
+ if(!mCurrentGesturedActor)
+ {
+ DALI_LOG_ERROR("Gesture detected, but no hit actor");
+ }
+ }
+
+ // Gesture::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 )
+ {
+ // Store the previous position for next Gesture::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;
+
+ // Only handle the pan gesture when the current focused actor is scrollable or within a scrollable actor
+ while(mCurrentGesturedActor && mCurrentGesturedActor != rootActor && !handled)
+ {
+ Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(mCurrentGesturedActor);
+ if(control)
+ {
+ Vector2 localCurrent;
+ control.ScreenToLocal( localCurrent.x, localCurrent.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
+ pan.position = 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;
+
+ handled = GetImplementation( control ).OnAccessibilityPan(pan);
+ }
+
+ // If the gesture is not handled by the control, check its parent
+ if(!handled)
+ {
+ mCurrentGesturedActor = mCurrentGesturedActor.GetParent();
+
+ if(!mCurrentGesturedActor)
+ {
+ DALI_LOG_ERROR("no more gestured actor");
+ }
+ }
+ else
+ {
+ // If handled, then update the pan gesture properties
+ PanGestureDetector::SetPanGestureProperties( pan );
+ }
+ }
+
+ return handled;
+}
+
+Toolkit::AccessibilityFocusManager::FocusChangedSignalType& AccessibilityFocusManager::FocusChangedSignal()
+{
+ return mFocusChangedSignal;
+}
+
+Toolkit::AccessibilityFocusManager::FocusOvershotSignalType& AccessibilityFocusManager::FocusOvershotSignal()
+{
+ return mFocusOvershotSignal;
+}
+
+Toolkit::AccessibilityFocusManager::FocusedActorActivatedSignalType& AccessibilityFocusManager::FocusedActorActivatedSignal()
+{
+ return mFocusedActorActivatedSignal;
+}
+
+bool AccessibilityFocusManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
+{
+ Dali::BaseHandle handle( object );
+
+ bool connected( true );
+ AccessibilityFocusManager* manager = dynamic_cast<AccessibilityFocusManager*>( 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
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_FOCUS_MANAGER_H__
+#define __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_FOCUS_MANAGER_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <dali/devel-api/common/map-wrapper.h>
+#include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
+#include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
+#include <dali/public-api/object/base-object.h>
+#include <dali/integration-api/events/pan-gesture-event.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/focus-manager/accessibility-focus-manager.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal
+{
+
+class AccessibilityFocusManager;
+
+/**
+ * @copydoc Toolkit::AccessibilityFocusManager
+ */
+class AccessibilityFocusManager : public Dali::BaseObject, Dali::AccessibilityActionHandler, Dali::AccessibilityGestureHandler
+{
+public:
+
+ struct ActorAdditionalInfo
+ {
+ ActorAdditionalInfo()
+ : mFocusOrder(0)
+ {
+ }
+
+ unsigned int mFocusOrder; ///< The focus order of the actor. It is undefined by default.
+
+ std::string mAccessibilityAttributes[Toolkit::AccessibilityFocusManager::ACCESSIBILITY_ATTRIBUTE_NUM]; ///< The array of attribute texts
+ };
+
+ typedef std::pair<unsigned int, unsigned int> FocusIDPair;
+ typedef std::map<unsigned int, unsigned int> FocusIDContainer;
+ typedef FocusIDContainer::iterator FocusIDIter;
+ typedef FocusIDContainer::const_iterator FocusIDConstIter;
+
+ typedef std::pair<unsigned int, ActorAdditionalInfo> IDAdditionalInfoPair;
+ typedef std::map<unsigned int, ActorAdditionalInfo> IDAdditionalInfoContainer;
+ typedef IDAdditionalInfoContainer::iterator IDAdditionalInfoIter;
+ typedef IDAdditionalInfoContainer::const_iterator IDAdditionalInfoConstIter;
+
+ /**
+ * Construct a new AccessibilityFocusManager.
+ */
+ AccessibilityFocusManager();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetAccessibilityAttribute
+ */
+ void SetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityFocusManager::AccessibilityAttribute type, const std::string& text);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetAccessibilityAttribute
+ */
+ std::string GetAccessibilityAttribute(Actor actor, Toolkit::AccessibilityFocusManager::AccessibilityAttribute type) const;
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetFocusOrder
+ */
+ void SetFocusOrder(Actor actor, const unsigned int order);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetFocusOrder
+ */
+ unsigned int GetFocusOrder(Actor actor) const;
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GenerateNewFocusOrder
+ */
+ unsigned int GenerateNewFocusOrder() const;
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetActorByFocusOrder
+ */
+ Actor GetActorByFocusOrder(const unsigned int order);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetCurrentFocusActor
+ */
+ bool SetCurrentFocusActor(Actor actor);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetCurrentFocusActor
+ */
+ Actor GetCurrentFocusActor();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetCurrentFocusGroup
+ */
+ Actor GetCurrentFocusGroup();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetCurrentFocusOrder
+ */
+ unsigned int GetCurrentFocusOrder();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::MoveFocusForward
+ */
+ bool MoveFocusForward();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::MoveFocusBackward
+ */
+ bool MoveFocusBackward();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::ClearFocus
+ */
+ void ClearFocus();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::Reset
+ */
+ void Reset();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetFocusGroup
+ */
+ void SetFocusGroup(Actor actor, bool isFocusGroup);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::IsFocusGroup
+ */
+ bool IsFocusGroup(Actor actor) const;
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetGroupMode
+ */
+ void SetGroupMode(bool enabled);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetGroupMode
+ */
+ bool GetGroupMode() const;
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetWrapMode
+ */
+ void SetWrapMode(bool wrapped);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetWrapMode
+ */
+ bool GetWrapMode() const;
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::SetFocusIndicatorActor
+ */
+ void SetFocusIndicatorActor(Actor indicator);
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetFocusIndicatorActor
+ */
+ Actor GetFocusIndicatorActor();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::GetFocusGroup
+ */
+ Actor GetFocusGroup(Actor actor);
+
+public:
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::FocusChangedSignal()
+ */
+ Toolkit::AccessibilityFocusManager::FocusChangedSignalType& FocusChangedSignal();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::FocusOvershotSignal()
+ */
+ Toolkit::AccessibilityFocusManager::FocusOvershotSignalType& FocusOvershotSignal();
+
+ /**
+ * @copydoc Toolkit::AccessibilityFocusManager::FocusedActorActivatedSignal()
+ */
+ Toolkit::AccessibilityFocusManager::FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
+
+ /**
+ * Connects a callback function with the object's signals.
+ * @param[in] object The object providing the signal.
+ * @param[in] tracker Used to disconnect the signal.
+ * @param[in] signalName The signal to connect to.
+ * @param[in] functor A newly allocated FunctorDelegate.
+ * @return True if the signal was connected.
+ * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
+ */
+ static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
+
+protected:
+
+ /**
+ * Destructor
+ */
+ virtual ~AccessibilityFocusManager();
+
+private:
+
+ /**
+ * Get the additional information (e.g. focus order and description) of the given actor.
+ * @param actorID The ID of the actor to be queried
+ * @return The additional information of the actor
+ */
+ ActorAdditionalInfo GetActorAdditionalInfo(const unsigned int actorID) const;
+
+ /**
+ * Synchronize the actor's additional information to reflect its latest focus order
+ * @param actorID The ID of the actor
+ * @param order The focus order of the actor
+ * @return The additional information of the actor
+ */
+ void SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order);
+
+ /**
+ * Move the focus to the specified actor and send notification for the focus change.
+ * @param actorID The ID of the actor to be queried
+ * @return Whether the focus is successful or not
+ */
+ bool DoSetCurrentFocusActor(const unsigned int actorID);
+
+ /**
+ * Move the focus to the next actor in the focus chain towards the specified direction.
+ * @param focusIDIter The iterator pointing to the current focused actor
+ * @param forward Whether the focus movement is forward or not. The focus movement will be backward if this is false.
+ * @param wrapped Whether the focus shoule be moved wrapped around or not
+ * @return Whether the focus is successful or not
+ */
+ bool DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped);
+
+ /**
+ * Activate the actor. If the actor is control, call OnActivated virtual function.
+ * This function will emit FocusedActorActivatedSignal.
+ * @param actor The actor to activate
+ */
+ 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
+ * @param focusable Whether the actor is focusable or not
+ */
+ void SetFocusable(Actor actor, bool focusable);
+
+ /**
+ * Handle the accessibility pan gesture.
+ * @param[in] panEvent The pan event to be handled.
+ * @return whether the gesture is handled successfully or not.
+ */
+ virtual bool HandlePanGesture(const Integration::PanGestureEvent& panEvent);
+
+ /**
+ * Change the accessibility status when Accessibility feature(screen-reader) turned on or off.
+ * @return whether the status is changed or not.
+ */
+ virtual bool ChangeAccessibilityStatus();
+
+ /**
+ * Clear the accessibility focus from the current focused actor.
+ * @return whether the focus is cleared or not.
+ */
+ virtual bool ClearAccessibilityFocus();
+
+ /**
+ * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick up).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionPrevious(bool allowEndFeedback);
+
+ /**
+ * Perform the accessibility action to move focus to the next focusable actor (by one finger flick down).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionNext(bool allowEndFeedback);
+
+ /**
+ * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick left).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionReadPrevious(bool allowEndFeedback);
+
+ /**
+ * Perform the accessibility action to move focus to the next focusable actor (by one finger flick right).
+ * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionReadNext(bool allowEndFeedback);
+
+ /**
+ * Perform the accessibility action to focus and read the actor (by one finger tap or move).
+ * @param allowReadAgain true if the action read again the same object (i.e. read action)
+ * false if the action just read when the focus object is changed (i.e. over action)
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionRead(bool allowReadAgain);
+
+ /**
+ * Perform the accessibility action to activate the current focused actor (by one finger double tap).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionActivate();
+
+ /**
+ * Perform the accessibility action to change the value when the current focused actor is a slider
+ * (by double finger down and move up and right).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionUp();
+
+ /**
+ * Perform the accessibility action to change the value when the current focused actor is a slider
+ * (by double finger down and move down and left).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionDown();
+
+ /**
+ * Perform the accessibility action to navigate back (by two fingers circle draw).
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionBack();
+
+ /**
+ * Perform the accessibility action to mouse move (by one finger tap & hold and move).
+ * @param touchEvent touch event structure
+ * @return whether the accessibility action is performed or not.
+ */
+ virtual bool AccessibilityActionTouch(const TouchEvent& touchEvent);
+
+private:
+
+ // Undefined
+ AccessibilityFocusManager(const AccessibilityFocusManager&);
+
+ AccessibilityFocusManager& operator=(const AccessibilityFocusManager& rhs);
+
+private:
+
+ Toolkit::AccessibilityFocusManager::FocusChangedSignalType mFocusChangedSignal; ///< The signal to notify the focus change
+ Toolkit::AccessibilityFocusManager::FocusOvershotSignalType mFocusOvershotSignal; ///< The signal to notify the focus overshooted
+ Toolkit::AccessibilityFocusManager::FocusedActorActivatedSignalType mFocusedActorActivatedSignal; ///< The signal to notify the activation of focused actor
+
+ bool mIsWrapped; ///< Whether the focus movement is wrapped around or not
+ bool mIsFocusWithinGroup; ///< Whether the focus movement is limited to the current focus group or not
+
+ bool mIsEndcapFeedbackEnabled; ///< Whether the endcap feedback need to be played when the focus leaves the end or vice versa
+ bool mIsEndcapFeedbackPlayed; ///< Whether the endcap feedback was played or not
+
+ FocusIDContainer mFocusIDContainer; ///< The container to look up actor ID by focus order
+ IDAdditionalInfoContainer mIDAdditionalInfoContainer; ///< The container to look up additional information by actor ID
+
+ FocusIDPair mCurrentFocusActor; ///< The focus order and actor ID of current focused actor
+ Actor mCurrentGesturedActor; ///< The actor that will handle the gesture
+
+ Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the focusable actors for highlight
+
+ Vector2 mPreviousPosition; ///< The previous pan position; useful for calculating velocity for Gesture::Finished events
+
+ unsigned int mRecursiveFocusMoveCounter; ///< The counter to count the number of recursive focus movement attempted before the focus movement is successful.
+
+ bool mIsAccessibilityTtsEnabled; ///< Whether accessibility feature(screen-reader) turned on/off
+
+ bool mIsFocusIndicatorEnabled; ///< Whether indicator should be shown / hidden. It could be enabled when TTS enabled or 'Tab' key operated.
+};
+
+} // namespace Internal
+
+inline Internal::AccessibilityFocusManager& GetImpl(Dali::Toolkit::AccessibilityFocusManager& obj)
+{
+ DALI_ASSERT_ALWAYS(obj);
+
+ Dali::BaseObject& handle = obj.GetBaseObject();
+
+ return static_cast<Internal::AccessibilityFocusManager&>(handle);
+}
+
+inline const Internal::AccessibilityFocusManager& GetImpl(const Dali::Toolkit::AccessibilityFocusManager& obj)
+{
+ DALI_ASSERT_ALWAYS(obj);
+
+ const Dali::BaseObject& handle = obj.GetBaseObject();
+
+ return static_cast<const Internal::AccessibilityFocusManager&>(handle);
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_INTERNAL_ACCESSIBILITY_FOCUS_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "focus-manager-impl.h"
-
-// EXTERNAL INCLUDES
-#include <cstring> // for strcmp
-#include <dali/public-api/actors/layer.h>
-#include <dali/devel-api/adaptor-framework/accessibility-manager.h>
-#include <dali/devel-api/adaptor-framework/sound-player.h>
-#include <dali/devel-api/adaptor-framework/tts-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/integration-api/debug.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control.h>
-#include <dali-toolkit/public-api/controls/control-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-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";
-
-#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* 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_SOUND_FILE = DALI_SOUND_DIR "Focus.ogg";
-const char* FOCUS_CHAIN_END_SOUND_FILE = DALI_SOUND_DIR "End_of_List.ogg";
-
-/**
- * The function to be used in the hit-test algorithm to check whether the actor is hittable.
- */
-bool IsActorFocusableFunction(Actor actor, Dali::HitTestAlgorithm::TraverseType type)
-{
- bool hittable = false;
-
- switch (type)
- {
- 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
- {
- // Check whether the actor is focusable
- Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE);
- if(propertyActorFocusable != Property::INVALID_INDEX)
- {
- hittable = actor.GetProperty<bool>(propertyActorFocusable);
- }
- }
- break;
- }
- case Dali::HitTestAlgorithm::DESCEND_ACTOR_TREE:
- {
- if( actor.IsVisible() ) // Actor is visible, if not visible then none of its children are visible.
- {
- hittable = true;
- }
- break;
- }
- default:
- {
- break;
- }
- }
-
- return hittable;
-};
-
-}
-
-FocusManager::FocusManager()
-: mIsWrapped(false),
- mIsFocusWithinGroup(false),
- mIsEndcapFeedbackEnabled(false),
- mIsEndcapFeedbackPlayed(false),
- mCurrentFocusActor(FocusIDPair(0, 0)),
- mFocusIndicatorActor(Actor()),
- mRecursiveFocusMoveCounter(0),
- mIsAccessibilityTtsEnabled(false),
- mIsFocusIndicatorEnabled(false)
-{
- CreateDefaultFocusIndicatorActor();
-
- AccessibilityManager manager = AccessibilityManager::Get();
- manager.SetActionHandler(*this);
- manager.SetGestureHandler(*this);
-
- ChangeAccessibilityStatus();
-}
-
-FocusManager::~FocusManager()
-{
-}
-
-FocusManager::ActorAdditionalInfo FocusManager::GetActorAdditionalInfo(const unsigned int actorID) const
-{
- ActorAdditionalInfo data;
- IDAdditionalInfoConstIter iter = mIDAdditionalInfoContainer.find(actorID);
- if(iter != mIDAdditionalInfoContainer.end())
- {
- data = (*iter).second;
- }
-
- return data;
-}
-
-void FocusManager::SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order)
-{
- ActorAdditionalInfo actorInfo = GetActorAdditionalInfo(actorID);
- actorInfo.mFocusOrder = order;
- mIDAdditionalInfoContainer.erase(actorID);
- mIDAdditionalInfoContainer.insert(IDAdditionalInfoPair(actorID, actorInfo));
-}
-
-void FocusManager::SetAccessibilityAttribute(Actor actor, Toolkit::FocusManager::AccessibilityAttribute type, const std::string& text)
-{
- if(actor)
- {
- unsigned int actorID = actor.GetId();
-
- ActorAdditionalInfo info = GetActorAdditionalInfo(actorID);
- info.mAccessibilityAttributes[type] = text;
-
- mIDAdditionalInfoContainer.erase(actorID);
- mIDAdditionalInfoContainer.insert(IDAdditionalInfoPair(actorID, info));
- }
-}
-
-std::string FocusManager::GetAccessibilityAttribute(Actor actor, Toolkit::FocusManager::AccessibilityAttribute type) const
-{
- std::string text;
-
- if(actor)
- {
- ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId());
- text = data.mAccessibilityAttributes[type];
- }
-
- return text;
-}
-
-void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
-{
- // Do nothing if the focus order of the actor is not changed.
- if(actor && GetFocusOrder(actor) != 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);
- }
-
- if(order == 0)
- {
- // The actor is not focusable without a defined focus order.
- actor.SetProperty(propertyActorFocusable, false);
-
- // If the actor is currently being focused, it should clear the focus
- if(actor == GetCurrentFocusActor())
- {
- ClearFocus();
- }
- }
- else // Insert the actor to the focus chain
- {
- // Check whether there is another actor in the focus chain with the same focus order already.
- FocusIDIter focusIDIter = mFocusIDContainer.find(order);
- if(focusIDIter != mFocusIDContainer.end())
- {
- // We need to increase the focus order of that actor and all the actors followed it
- // in the focus chain.
- FocusIDIter lastIter = mFocusIDContainer.end();
- --lastIter;//We want forward iterator to the last element here
- mFocusIDContainer.insert(FocusIDPair((*lastIter).first + 1, (*lastIter).second));
-
- // Update the actor's focus order in its additional data
- SynchronizeActorAdditionalInfo((*lastIter).second, (*lastIter).first + 1);
-
- for(FocusIDIter iter = lastIter; iter != focusIDIter; iter--)
- {
- FocusIDIter previousIter = iter;
- --previousIter;//We want forward iterator to the previous element here
- unsigned int actorID = (*previousIter).second;
- (*iter).second = actorID;
-
- // Update the actor's focus order in its additional data
- SynchronizeActorAdditionalInfo(actorID, (*iter).first);
- }
-
- mFocusIDContainer.erase(order);
- }
-
- // The actor is focusable
- actor.SetProperty(propertyActorFocusable, true);
-
- // Now we insert the actor into the focus chain with the specified focus order
- mFocusIDContainer.insert(FocusIDPair(order, actor.GetId()));
- }
-
- // Update the actor's focus order in its additional data
- SynchronizeActorAdditionalInfo(actor.GetId(), order);
- }
-}
-
-unsigned int FocusManager::GetFocusOrder(Actor actor) const
-{
- unsigned int focusOrder = 0;
-
- if(actor)
- {
- ActorAdditionalInfo data = GetActorAdditionalInfo(actor.GetId());
- focusOrder = data.mFocusOrder;
- }
-
- return focusOrder;
-}
-
-unsigned int FocusManager::GenerateNewFocusOrder() const
-{
- unsigned int order = 1;
- FocusIDContainer::const_reverse_iterator iter = mFocusIDContainer.rbegin();
-
- if(iter != mFocusIDContainer.rend())
- {
- order = (*iter).first + 1;
- }
-
- return order;
-}
-
-Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
-{
- Actor actor = Actor();
-
- FocusIDIter focusIDIter = mFocusIDContainer.find(order);
- if(focusIDIter != mFocusIDContainer.end())
- {
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
- actor = rootActor.FindChildById(mFocusIDContainer[order]);
- }
-
- return actor;
-}
-
-bool FocusManager::SetCurrentFocusActor(Actor actor)
-{
- if(actor)
- {
- return DoSetCurrentFocusActor(actor.GetId());
- }
-
- return false;
-}
-
-bool FocusManager::DoSetCurrentFocusActor(const unsigned int actorID)
-{
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
-
- // If the group mode is enabled, check which focus group the current focused actor belongs to
- Actor focusGroup;
- if(mIsFocusWithinGroup)
- {
- focusGroup = GetFocusGroup(GetCurrentFocusActor());
- }
-
- if(!focusGroup)
- {
- focusGroup = rootActor;
- }
-
- Actor actor = focusGroup.FindChildById(actorID);
-
- // Check whether the actor is in the stage
- if(actor)
- {
- // Check whether the actor is focusable
- bool actorFocusable = false;
- Property::Index propertyActorFocusable = actor.GetPropertyIndex(ACTOR_FOCUSABLE);
- if(propertyActorFocusable != Property::INVALID_INDEX)
- {
- actorFocusable = actor.GetProperty<bool>(propertyActorFocusable);
- }
-
- // Go through the actor's hierarchy to check whether the actor is visible
- bool actorVisible = actor.IsVisible();
- Actor parent = actor.GetParent();
- while (actorVisible && parent && parent != rootActor)
- {
- actorVisible = parent.IsVisible();
- parent = parent.GetParent();
- }
-
- // Check whether the actor is fully transparent
- bool actorOpaque = actor.GetCurrentWorldColor().a > 0.01f;
-
- // Set the focus only when the actor is focusable and visible and not fully transparent
- if(actorVisible && actorFocusable && actorOpaque)
- {
- // Draw the focus indicator upon the focused actor
- if(mIsFocusIndicatorEnabled && mFocusIndicatorActor)
- {
- actor.Add(mFocusIndicatorActor);
- }
-
- // Send notification for the change of focus actor
- mFocusChangedSignal.Emit( GetCurrentFocusActor(), actor );
-
- // Save the current focused actor
- mCurrentFocusActor = FocusIDPair(GetFocusOrder(actor), actorID);
-
- if(mIsAccessibilityTtsEnabled)
- {
- Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get();
- if(soundPlayer)
- {
- soundPlayer.PlaySound(FOCUS_SOUND_FILE);
- }
-
- // Play the accessibility attributes with the TTS player.
- Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER);
-
- // Combine attribute texts to one text
- std::string informationText;
- for(int i = 0; i < Toolkit::FocusManager::ACCESSIBILITY_ATTRIBUTE_NUM; i++)
- {
- if(!GetActorAdditionalInfo(actorID).mAccessibilityAttributes[i].empty())
- {
- if( i > 0 )
- {
- informationText += ", "; // for space time between each information
- }
- informationText += GetActorAdditionalInfo(actorID).mAccessibilityAttributes[i];
- }
- }
- player.Play(informationText);
- }
-
- return true;
- }
- }
-
- DALI_LOG_WARNING("[%s:%d] FAILED\n", __FUNCTION__, __LINE__);
- return false;
-}
-
-Actor FocusManager::GetCurrentFocusActor()
-{
- Actor rootActor = Stage::GetCurrent().GetRootLayer();
- return rootActor.FindChildById(mCurrentFocusActor.second);
-}
-
-Actor FocusManager::GetCurrentFocusGroup()
-{
- return GetFocusGroup(GetCurrentFocusActor());
-}
-
-unsigned int FocusManager::GetCurrentFocusOrder()
-{
- return mCurrentFocusActor.first;
-}
-
-bool FocusManager::MoveFocusForward()
-{
- bool ret = false;
- mRecursiveFocusMoveCounter = 0;
-
- FocusIDIter focusIDIter = mFocusIDContainer.find(mCurrentFocusActor.first);
- if(focusIDIter != mFocusIDContainer.end())
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
- ret = DoMoveFocus(focusIDIter, true, mIsWrapped);
- }
- else
- {
- // TODO: if there is not focused actor, move first actor
- if(!mFocusIDContainer.empty())
- {
- //if there is not focused actor, move 1st actor
- focusIDIter = mFocusIDContainer.begin(); // TODO: I'm not sure it was sorted.
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
- ret = DoSetCurrentFocusActor((*focusIDIter).second);
- }
- }
-
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s] %s\n", __FUNCTION__, ret?"SUCCEED!!!":"FAILED!!!");
-
- return ret;
-}
-
-bool FocusManager::MoveFocusBackward()
-{
- bool ret = false;
- mRecursiveFocusMoveCounter = 0;
-
- FocusIDIter focusIDIter = mFocusIDContainer.find(mCurrentFocusActor.first);
- if(focusIDIter != mFocusIDContainer.end())
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
- ret = DoMoveFocus(focusIDIter, false, mIsWrapped);
- }
- else
- {
- // TODO: if there is not focused actor, move last actor
- if(!mFocusIDContainer.empty())
- {
- //if there is not focused actor, move last actor
- focusIDIter = mFocusIDContainer.end();
- --focusIDIter;//We want forward iterator to the last element here
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
- ret = DoSetCurrentFocusActor((*focusIDIter).second);
- }
- }
-
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s] %s\n", __FUNCTION__, ret?"SUCCEED!!!":"FAILED!!!");
-
- return ret;
-}
-
-void FocusManager::DoActivate(Actor actor)
-{
- if(actor)
- {
- Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
- if(control)
- {
- // Notify the control that it is activated
- GetImplementation( control ).AccessibilityActivate();
- }
-
- // Send notification for the activation of focused actor
- mFocusedActorActivatedSignal.Emit(actor);
- }
-}
-
-void FocusManager::ClearFocus()
-{
- Actor actor = GetCurrentFocusActor();
- if(actor)
- {
- actor.Remove(mFocusIndicatorActor);
- }
-
- mCurrentFocusActor = FocusIDPair(0, 0);
-
- // Send notification for the change of focus actor
- mFocusChangedSignal.Emit(actor, Actor());
-
- if(mIsAccessibilityTtsEnabled)
- {
- // Stop the TTS playing if any
- Dali::TtsPlayer player = Dali::TtsPlayer::Get(Dali::TtsPlayer::SCREEN_READER);
- player.Stop();
- }
-}
-
-void FocusManager::Reset()
-{
- ClearFocus();
- mFocusIDContainer.clear();
- mIDAdditionalInfoContainer.clear();
-}
-
-void FocusManager::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);
- }
- else
- {
- actor.SetProperty(propertyIsFocusGroup, isFocusGroup);
- }
- }
-}
-
-bool FocusManager::IsFocusGroup(Actor actor) const
-{
- // Check whether the actor is a focus group
- bool isFocusGroup = false;
-
- if(actor)
- {
- Property::Index propertyIsFocusGroup = actor.GetPropertyIndex(IS_FOCUS_GROUP);
- if(propertyIsFocusGroup != Property::INVALID_INDEX)
- {
- isFocusGroup = actor.GetProperty<bool>(propertyIsFocusGroup);
- }
- }
-
- return isFocusGroup;
-}
-
-Actor FocusManager::GetFocusGroup(Actor actor)
-{
- // Go through the actor's hierarchy to check which focus group the actor belongs to
- while (actor && !IsFocusGroup(actor))
- {
- actor = actor.GetParent();
- }
-
- return actor;
-}
-
-void FocusManager::SetGroupMode(bool enabled)
-{
- mIsFocusWithinGroup = enabled;
-}
-
-bool FocusManager::GetGroupMode() const
-{
- return mIsFocusWithinGroup;
-}
-
-void FocusManager::SetWrapMode(bool wrapped)
-{
- mIsWrapped = wrapped;
-}
-
-bool FocusManager::GetWrapMode() const
-{
- return mIsWrapped;
-}
-
-void FocusManager::SetFocusIndicatorActor(Actor indicator)
-{
- mFocusIndicatorActor = indicator;
-}
-
-Actor FocusManager::GetFocusIndicatorActor()
-{
- return mFocusIndicatorActor;
-}
-
-bool FocusManager::DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped)
-{
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] %d focusable actors\n", __FUNCTION__, __LINE__, mFocusIDContainer.size());
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] focus order : %d\n", __FUNCTION__, __LINE__, (*focusIDIter).first);
-
- if( (forward && ++focusIDIter == mFocusIDContainer.end())
- || (!forward && focusIDIter-- == mFocusIDContainer.begin()) )
- {
- if(mIsEndcapFeedbackEnabled)
- {
- if(mIsEndcapFeedbackPlayed == false)
- {
- // play sound & skip moving once
- Dali::SoundPlayer soundPlayer = Dali::SoundPlayer::Get();
- if(soundPlayer)
- {
- soundPlayer.PlaySound(FOCUS_CHAIN_END_SOUND_FILE);
- }
-
- mIsEndcapFeedbackPlayed = true;
- return true;
- }
- mIsEndcapFeedbackPlayed = false;
- }
-
- if(wrapped)
- {
- if(forward)
- {
- focusIDIter = mFocusIDContainer.begin();
- }
- else
- {
- focusIDIter = mFocusIDContainer.end();
- --focusIDIter;//We want forward iterator to the last element here
- }
- }
- else
- {
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] Overshot\n", __FUNCTION__, __LINE__);
- // Send notification for handling overshooted situation
- mFocusOvershotSignal.Emit(GetCurrentFocusActor(), forward ? Toolkit::FocusManager::OVERSHOT_NEXT : Toolkit::FocusManager::OVERSHOT_PREVIOUS);
-
- return false; // Try to move the focus out of the scope
- }
- }
-
- if((focusIDIter != mFocusIDContainer.end()) && !DoSetCurrentFocusActor((*focusIDIter).second))
- {
- mRecursiveFocusMoveCounter++;
- if(mRecursiveFocusMoveCounter > mFocusIDContainer.size())
- {
- // We've attempted to focus all the actors in the whole focus chain and no actor
- // can be focused successfully.
-
- DALI_LOG_WARNING("[%s] There is no more focusable actor in %d focus chains\n", __FUNCTION__, mRecursiveFocusMoveCounter);
-
- return false;
- }
- else
- {
- return DoMoveFocus(focusIDIter, forward, wrapped);
- }
- }
-
- return true;
-}
-
-void FocusManager::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);
- }
- else
- {
- actor.SetProperty(propertyActorFocusable, focusable);
- }
- }
-}
-
-void FocusManager::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 FocusManager::ChangeAccessibilityStatus()
-{
- AccessibilityManager manager = AccessibilityManager::Get();
- mIsAccessibilityTtsEnabled = manager.IsEnabled();
-
- if(mIsAccessibilityTtsEnabled)
- {
- // Show indicator when tts turned on if there is focused actor.
- Actor actor = GetCurrentFocusActor();
- if(actor)
- {
- if(mFocusIndicatorActor)
- {
- actor.Add(mFocusIndicatorActor);
- }
- }
- mIsFocusIndicatorEnabled = true;
- }
- else
- {
- // Hide indicator when tts turned off
- Actor actor = GetCurrentFocusActor();
- if(actor)
- {
- actor.Remove(mFocusIndicatorActor);
- }
- mIsFocusIndicatorEnabled = false;
- }
-
- return true;
-}
-
-bool FocusManager::AccessibilityActionNext(bool allowEndFeedback)
-{
- if(mIsAccessibilityTtsEnabled)
- {
- mIsEndcapFeedbackEnabled = allowEndFeedback;
- return MoveFocusForward();
- }
- else
- {
- return false;
- }
-}
-
-bool FocusManager::AccessibilityActionPrevious(bool allowEndFeedback)
-{
- if(mIsAccessibilityTtsEnabled)
- {
- mIsEndcapFeedbackEnabled = allowEndFeedback;
- return MoveFocusBackward();
- }
- else
- {
- return false;
- }
-}
-
-bool FocusManager::AccessibilityActionActivate()
-{
- bool ret = false;
-
- Actor actor = GetCurrentFocusActor();
- if(actor)
- {
- DoActivate(actor);
- ret = true;
- }
-
- return ret;
-}
-
-bool FocusManager::AccessibilityActionRead(bool allowReadAgain)
-{
- bool ret = false;
-
- if(mIsAccessibilityTtsEnabled)
- {
- // Find the focusable actor at the read position
- AccessibilityManager manager = AccessibilityManager::Get();
- Dali::HitTestAlgorithm::Results results;
- Dali::HitTestAlgorithm::HitTest( Stage::GetCurrent(), manager.GetReadPosition(), results, IsActorFocusableFunction );
-
- FocusIDIter focusIDIter = mFocusIDContainer.find(GetFocusOrder(results.actor));
- if(focusIDIter != mFocusIDContainer.end())
- {
- if( allowReadAgain || (results.actor != GetCurrentFocusActor()) )
- {
- // Move the focus to the actor
- ret = SetCurrentFocusActor(results.actor);
- DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SetCurrentFocusActor returns %s\n", __FUNCTION__, __LINE__, ret?"TRUE":"FALSE");
- }
- }
- }
-
- return ret;
-}
-
-bool FocusManager::AccessibilityActionReadNext(bool allowEndFeedback)
-{
- if(mIsAccessibilityTtsEnabled)
- {
- return MoveFocusForward();
- }
- else
- {
- return false;
- }
-}
-
-bool FocusManager::AccessibilityActionReadPrevious(bool allowEndFeedback)
-{
- if(mIsAccessibilityTtsEnabled)
- {
- return MoveFocusBackward();
- }
- else
- {
- return false;
- }
-}
-
-bool FocusManager::AccessibilityActionUp()
-{
- bool ret = false;
-
- if(mIsAccessibilityTtsEnabled)
- {
- Actor actor = GetCurrentFocusActor();
- if(actor)
- {
- Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
- if(control)
- {
- // Notify the control that it is activated
- ret = GetImplementation( control ).OnAccessibilityValueChange(true);
- }
- }
- }
-
- return ret;
-}
-
-bool FocusManager::AccessibilityActionDown()
-{
- bool ret = false;
-
- if(mIsAccessibilityTtsEnabled)
- {
- Actor actor = GetCurrentFocusActor();
- if(actor)
- {
- Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(actor);
- if(control)
- {
- // Notify the control that it is activated
- ret = GetImplementation( control ).OnAccessibilityValueChange(false);
- }
- }
- }
-
- return ret;
-}
-
-bool FocusManager::ClearAccessibilityFocus()
-{
- if(mIsAccessibilityTtsEnabled)
- {
- ClearFocus();
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool FocusManager::AccessibilityActionBack()
-{
- // TODO: Back to previous view
-
- return mIsAccessibilityTtsEnabled;
-}
-
-bool FocusManager::AccessibilityActionTouch(const TouchEvent& touchEvent)
-{
- bool handled = false;
-
- // TODO: Need to convert the touchevent for the focused actor?
-
- Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(GetCurrentFocusActor());
- if(control)
- {
- handled = GetImplementation( control ).OnAccessibilityTouch(touchEvent);
- }
-
- return handled;
-}
-
-bool FocusManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent)
-{
- bool handled = false;
-
- if( panEvent.state == Gesture::Started )
- {
- // Find the focusable actor at the event position
- Dali::HitTestAlgorithm::Results results;
- AccessibilityManager manager = AccessibilityManager::Get();
-
- Dali::HitTestAlgorithm::HitTest( Stage::GetCurrent(), panEvent.currentPosition, results, IsActorFocusableFunction );
- mCurrentGesturedActor = results.actor;
-
- if(!mCurrentGesturedActor)
- {
- DALI_LOG_ERROR("Gesture detected, but no hit actor");
- }
- }
-
- // Gesture::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 )
- {
- // Store the previous position for next Gesture::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;
-
- // Only handle the pan gesture when the current focused actor is scrollable or within a scrollable actor
- while(mCurrentGesturedActor && mCurrentGesturedActor != rootActor && !handled)
- {
- Dali::Toolkit::Control control = Dali::Toolkit::Control::DownCast(mCurrentGesturedActor);
- if(control)
- {
- Vector2 localCurrent;
- control.ScreenToLocal( localCurrent.x, localCurrent.y, panEvent.currentPosition.x, panEvent.currentPosition.y );
- pan.position = 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;
-
- handled = GetImplementation( control ).OnAccessibilityPan(pan);
- }
-
- // If the gesture is not handled by the control, check its parent
- if(!handled)
- {
- mCurrentGesturedActor = mCurrentGesturedActor.GetParent();
-
- if(!mCurrentGesturedActor)
- {
- DALI_LOG_ERROR("no more gestured actor");
- }
- }
- else
- {
- // If handled, then update the pan gesture properties
- PanGestureDetector::SetPanGestureProperties( pan );
- }
- }
-
- return handled;
-}
-
-Toolkit::FocusManager::FocusChangedSignalType& FocusManager::FocusChangedSignal()
-{
- return mFocusChangedSignal;
-}
-
-Toolkit::FocusManager::FocusOvershotSignalType& FocusManager::FocusOvershotSignal()
-{
- return mFocusOvershotSignal;
-}
-
-Toolkit::FocusManager::FocusedActorActivatedSignalType& FocusManager::FocusedActorActivatedSignal()
-{
- return mFocusedActorActivatedSignal;
-}
-
-bool FocusManager::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
-{
- Dali::BaseHandle handle( object );
-
- bool connected( true );
- FocusManager* manager = dynamic_cast<FocusManager*>( 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
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_INTERNAL_FOCUS_MANAGER_H__
-#define __DALI_TOOLKIT_INTERNAL_FOCUS_MANAGER_H__
-
-/*
- * Copyright (c) 2014 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <string>
-#include <dali/devel-api/common/map-wrapper.h>
-#include <dali/devel-api/adaptor-framework/accessibility-action-handler.h>
-#include <dali/devel-api/adaptor-framework/accessibility-gesture-handler.h>
-#include <dali/public-api/object/base-object.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/focus-manager/focus-manager.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal
-{
-
-class FocusManager;
-
-/**
- * @copydoc Toolkit::FocusManager
- */
-class FocusManager : public Dali::BaseObject, Dali::AccessibilityActionHandler, Dali::AccessibilityGestureHandler
-{
-public:
-
- struct ActorAdditionalInfo
- {
- ActorAdditionalInfo()
- : mFocusOrder(0)
- {
- }
-
- unsigned int mFocusOrder; ///< The focus order of the actor. It is undefined by default.
-
- std::string mAccessibilityAttributes[Toolkit::FocusManager::ACCESSIBILITY_ATTRIBUTE_NUM]; ///< The array of attribute texts
- };
-
- typedef std::pair<unsigned int, unsigned int> FocusIDPair;
- typedef std::map<unsigned int, unsigned int> FocusIDContainer;
- typedef FocusIDContainer::iterator FocusIDIter;
- typedef FocusIDContainer::const_iterator FocusIDConstIter;
-
- typedef std::pair<unsigned int, ActorAdditionalInfo> IDAdditionalInfoPair;
- typedef std::map<unsigned int, ActorAdditionalInfo> IDAdditionalInfoContainer;
- typedef IDAdditionalInfoContainer::iterator IDAdditionalInfoIter;
- typedef IDAdditionalInfoContainer::const_iterator IDAdditionalInfoConstIter;
-
- /**
- * Construct a new FocusManager.
- */
- FocusManager();
-
- /**
- * @copydoc Toolkit::FocusManager::SetAccessibilityAttribute
- */
- void SetAccessibilityAttribute(Actor actor, Toolkit::FocusManager::AccessibilityAttribute type, const std::string& text);
-
- /**
- * @copydoc Toolkit::FocusManager::GetAccessibilityAttribute
- */
- std::string GetAccessibilityAttribute(Actor actor, Toolkit::FocusManager::AccessibilityAttribute type) const;
-
- /**
- * @copydoc Toolkit::FocusManager::SetFocusOrder
- */
- void SetFocusOrder(Actor actor, const unsigned int order);
-
- /**
- * @copydoc Toolkit::FocusManager::GetFocusOrder
- */
- unsigned int GetFocusOrder(Actor actor) const;
-
- /**
- * @copydoc Toolkit::FocusManager::GenerateNewFocusOrder
- */
- unsigned int GenerateNewFocusOrder() const;
-
- /**
- * @copydoc Toolkit::FocusManager::GetActorByFocusOrder
- */
- Actor GetActorByFocusOrder(const unsigned int order);
-
- /**
- * @copydoc Toolkit::FocusManager::SetCurrentFocusActor
- */
- bool SetCurrentFocusActor(Actor actor);
-
- /**
- * @copydoc Toolkit::FocusManager::GetCurrentFocusActor
- */
- Actor GetCurrentFocusActor();
-
- /**
- * @copydoc Toolkit::FocusManager::GetCurrentFocusGroup
- */
- Actor GetCurrentFocusGroup();
-
- /**
- * @copydoc Toolkit::FocusManager::GetCurrentFocusOrder
- */
- unsigned int GetCurrentFocusOrder();
-
- /**
- * @copydoc Toolkit::FocusManager::MoveFocusForward
- */
- bool MoveFocusForward();
-
- /**
- * @copydoc Toolkit::FocusManager::MoveFocusBackward
- */
- bool MoveFocusBackward();
-
- /**
- * @copydoc Toolkit::FocusManager::ClearFocus
- */
- void ClearFocus();
-
- /**
- * @copydoc Toolkit::FocusManager::Reset
- */
- void Reset();
-
- /**
- * @copydoc Toolkit::FocusManager::SetFocusGroup
- */
- void SetFocusGroup(Actor actor, bool isFocusGroup);
-
- /**
- * @copydoc Toolkit::FocusManager::IsFocusGroup
- */
- bool IsFocusGroup(Actor actor) const;
-
- /**
- * @copydoc Toolkit::FocusManager::SetGroupMode
- */
- void SetGroupMode(bool enabled);
-
- /**
- * @copydoc Toolkit::FocusManager::GetGroupMode
- */
- bool GetGroupMode() const;
-
- /**
- * @copydoc Toolkit::FocusManager::SetWrapMode
- */
- void SetWrapMode(bool wrapped);
-
- /**
- * @copydoc Toolkit::FocusManager::GetWrapMode
- */
- bool GetWrapMode() const;
-
- /**
- * @copydoc Toolkit::FocusManager::SetFocusIndicatorActor
- */
- void SetFocusIndicatorActor(Actor indicator);
-
- /**
- * @copydoc Toolkit::FocusManager::GetFocusIndicatorActor
- */
- Actor GetFocusIndicatorActor();
-
- /**
- * @copydoc Toolkit::FocusManager::GetFocusGroup
- */
- Actor GetFocusGroup(Actor actor);
-
-public:
-
- /**
- * @copydoc Toolkit::FocusManager::FocusChangedSignal()
- */
- Toolkit::FocusManager::FocusChangedSignalType& FocusChangedSignal();
-
- /**
- * @copydoc Toolkit::FocusManager::FocusOvershotSignal()
- */
- Toolkit::FocusManager::FocusOvershotSignalType& FocusOvershotSignal();
-
- /**
- * @copydoc Toolkit::FocusManager::FocusedActorActivatedSignal()
- */
- Toolkit::FocusManager::FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
-
- /**
- * Connects a callback function with the object's signals.
- * @param[in] object The object providing the signal.
- * @param[in] tracker Used to disconnect the signal.
- * @param[in] signalName The signal to connect to.
- * @param[in] functor A newly allocated FunctorDelegate.
- * @return True if the signal was connected.
- * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
- */
- static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
-
-protected:
-
- /**
- * Destructor
- */
- virtual ~FocusManager();
-
-private:
-
- /**
- * Get the additional information (e.g. focus order and description) of the given actor.
- * @param actorID The ID of the actor to be queried
- * @return The additional information of the actor
- */
- ActorAdditionalInfo GetActorAdditionalInfo(const unsigned int actorID) const;
-
- /**
- * Synchronize the actor's additional information to reflect its latest focus order
- * @param actorID The ID of the actor
- * @param order The focus order of the actor
- * @return The additional information of the actor
- */
- void SynchronizeActorAdditionalInfo(const unsigned int actorID, const unsigned int order);
-
- /**
- * Move the focus to the specified actor and send notification for the focus change.
- * @param actorID The ID of the actor to be queried
- * @return Whether the focus is successful or not
- */
- bool DoSetCurrentFocusActor(const unsigned int actorID);
-
- /**
- * Move the focus to the next actor in the focus chain towards the specified direction.
- * @param focusIDIter The iterator pointing to the current focused actor
- * @param forward Whether the focus movement is forward or not. The focus movement will be backward if this is false.
- * @param wrapped Whether the focus shoule be moved wrapped around or not
- * @return Whether the focus is successful or not
- */
- bool DoMoveFocus(FocusIDIter focusIDIter, bool forward, bool wrapped);
-
- /**
- * Activate the actor. If the actor is control, call OnActivated virtual function.
- * This function will emit FocusedActorActivatedSignal.
- * @param actor The actor to activate
- */
- 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
- * @param focusable Whether the actor is focusable or not
- */
- void SetFocusable(Actor actor, bool focusable);
-
- /**
- * Handle the accessibility pan gesture.
- * @param[in] panEvent The pan event to be handled.
- * @return whether the gesture is handled successfully or not.
- */
- virtual bool HandlePanGesture(const Integration::PanGestureEvent& panEvent);
-
- /**
- * Change the accessibility status when Accessibility feature(screen-reader) turned on or off.
- * @return whether the status is changed or not.
- */
- virtual bool ChangeAccessibilityStatus();
-
- /**
- * Clear the accessibility focus from the current focused actor.
- * @return whether the focus is cleared or not.
- */
- virtual bool ClearAccessibilityFocus();
-
- /**
- * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick up).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionPrevious(bool allowEndFeedback);
-
- /**
- * Perform the accessibility action to move focus to the next focusable actor (by one finger flick down).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionNext(bool allowEndFeedback);
-
- /**
- * Perform the accessibility action to move focus to the previous focusable actor (by one finger flick left).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionReadPrevious(bool allowEndFeedback);
-
- /**
- * Perform the accessibility action to move focus to the next focusable actor (by one finger flick right).
- * @param allowEndFeedback true if end of list feedback should be played when the focus is alread reached to the end
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionReadNext(bool allowEndFeedback);
-
- /**
- * Perform the accessibility action to focus and read the actor (by one finger tap or move).
- * @param allowReadAgain true if the action read again the same object (i.e. read action)
- * false if the action just read when the focus object is changed (i.e. over action)
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionRead(bool allowReadAgain);
-
- /**
- * Perform the accessibility action to activate the current focused actor (by one finger double tap).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionActivate();
-
- /**
- * Perform the accessibility action to change the value when the current focused actor is a slider
- * (by double finger down and move up and right).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionUp();
-
- /**
- * Perform the accessibility action to change the value when the current focused actor is a slider
- * (by double finger down and move down and left).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionDown();
-
- /**
- * Perform the accessibility action to navigate back (by two fingers circle draw).
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionBack();
-
- /**
- * Perform the accessibility action to mouse move (by one finger tap & hold and move).
- * @param touchEvent touch event structure
- * @return whether the accessibility action is performed or not.
- */
- virtual bool AccessibilityActionTouch(const TouchEvent& touchEvent);
-
-private:
-
- // Undefined
- FocusManager(const FocusManager&);
-
- FocusManager& operator=(const FocusManager& rhs);
-
-private:
-
- Toolkit::FocusManager::FocusChangedSignalType mFocusChangedSignal; ///< The signal to notify the focus change
- Toolkit::FocusManager::FocusOvershotSignalType mFocusOvershotSignal; ///< The signal to notify the focus overshooted
- Toolkit::FocusManager::FocusedActorActivatedSignalType mFocusedActorActivatedSignal; ///< The signal to notify the activation of focused actor
-
- bool mIsWrapped; ///< Whether the focus movement is wrapped around or not
- bool mIsFocusWithinGroup; ///< Whether the focus movement is limited to the current focus group or not
-
- bool mIsEndcapFeedbackEnabled; ///< Whether the endcap feedback need to be played when the focus leaves the end or vice versa
- bool mIsEndcapFeedbackPlayed; ///< Whether the endcap feedback was played or not
-
- FocusIDContainer mFocusIDContainer; ///< The container to look up actor ID by focus order
- IDAdditionalInfoContainer mIDAdditionalInfoContainer; ///< The container to look up additional information by actor ID
-
- FocusIDPair mCurrentFocusActor; ///< The focus order and actor ID of current focused actor
- Actor mCurrentGesturedActor; ///< The actor that will handle the gesture
-
- Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the focusable actors for highlight
-
- Vector2 mPreviousPosition; ///< The previous pan position; useful for calculating velocity for Gesture::Finished events
-
- unsigned int mRecursiveFocusMoveCounter; ///< The counter to count the number of recursive focus movement attempted before the focus movement is successful.
-
- bool mIsAccessibilityTtsEnabled; ///< Whether accessibility feature(screen-reader) turned on/off
-
- bool mIsFocusIndicatorEnabled; ///< Whether indicator should be shown / hidden. It could be enabled when TTS enabled or 'Tab' key operated.
-};
-
-} // namespace Internal
-
-inline Internal::FocusManager& GetImpl(Dali::Toolkit::FocusManager& obj)
-{
- DALI_ASSERT_ALWAYS(obj);
-
- Dali::BaseObject& handle = obj.GetBaseObject();
-
- return static_cast<Internal::FocusManager&>(handle);
-}
-
-inline const Internal::FocusManager& GetImpl(const Dali::Toolkit::FocusManager& obj)
-{
- DALI_ASSERT_ALWAYS(obj);
-
- const Dali::BaseObject& handle = obj.GetBaseObject();
-
- return static_cast<const Internal::FocusManager&>(handle);
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_INTERNAL_FOCUS_MANAGER_H__
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/public-api/focus-manager/focus-manager.h>
-#include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/public-api/focus-manager/accessibility-focus-manager.h>
+#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
namespace Dali
{
// Save the current focused actor
mCurrentFocusActor = actorID;
- // Move the accessibility focus to the same actor
-// Toolkit::FocusManager focusManager = Toolkit::FocusManager::Get();
-// focusManager.SetCurrentFocusActor(actor);
-
DALI_LOG_INFO( gLogFilter, Debug::General, "[%s:%d] SUCCEED\n", __FUNCTION__, __LINE__);
return true;
}
AccessibilityManager accessibilityManager = AccessibilityManager::Get();
bool isAccessibilityEnabled = accessibilityManager.IsEnabled();
- Toolkit::FocusManager accessibilityFocusManager = Toolkit::FocusManager::Get();
+ Toolkit::AccessibilityFocusManager accessibilityFocusManager = Toolkit::AccessibilityFocusManager::Get();
std::string keyName = event.keyPressedName;
#include <dali/public-api/object/object-registry.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
namespace Dali
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/focus-manager/keyinput-focus-manager.h>
+#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
#include <dali-toolkit/public-api/focus-manager/keyboard-focus-manager.h>
#include <dali-toolkit/public-api/controls/control.h>
#include <dali-toolkit/devel-api/styling/style-manager.h>
namespace Internal
{
-class FocusManager;
-class KeyboardFocusManager;
-class KeyInputFocusManager;
/**
* @brief This is the internal base class for all controls.
// Called by Focus Manager
/**
- * @brief Called by the focus manager and keyboard focus manager to Activate the Control
+ * @brief Called by the accessibility focus manager and keyboard focus manager to activate the Control
*/
DALI_INTERNAL void AccessibilityActivate();
$(public_api_src_dir)/controls/text-controls/text-label.cpp \
$(public_api_src_dir)/controls/text-controls/text-field.cpp \
$(public_api_src_dir)/controls/gaussian-blur-view/gaussian-blur-view.cpp \
- $(public_api_src_dir)/focus-manager/focus-manager.cpp \
+ $(public_api_src_dir)/focus-manager/accessibility-focus-manager.cpp \
$(public_api_src_dir)/focus-manager/keyboard-focus-manager.cpp \
- $(public_api_src_dir)/focus-manager/keyinput-focus-manager.cpp \
$(public_api_src_dir)/dali-toolkit-version.cpp \
$(public_api_src_dir)/enums.cpp
public_api_text_controls_header_files = \
$(public_api_src_dir)/controls/text-controls/text-label.h \
- $(public_api_src_dir)/controls/text-controls/text-field.h
+ $(public_api_src_dir)/controls/text-controls/text-field.h
public_api_focus_manager_header_files = \
- $(public_api_src_dir)/focus-manager/focus-manager.h \
- $(public_api_src_dir)/focus-manager/keyboard-focus-manager.h \
- $(public_api_src_dir)/focus-manager/keyinput-focus-manager.h
+ $(public_api_src_dir)/focus-manager/accessibility-focus-manager.h \
+ $(public_api_src_dir)/focus-manager/keyboard-focus-manager.h
public_api_rendering_backend_header_files = \
$(public_api_src_dir)/text/rendering-backend.h
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// CLASS HEADER
+#include <dali-toolkit/public-api/focus-manager/accessibility-focus-manager.h>
+
+// EXTERNAL INCLUDES
+#include <dali/devel-api/adaptor-framework/singleton-service.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/focus-manager/accessibility-focus-manager-impl.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+AccessibilityFocusManager::AccessibilityFocusManager()
+{
+}
+
+AccessibilityFocusManager::~AccessibilityFocusManager()
+{
+}
+
+AccessibilityFocusManager AccessibilityFocusManager::Get()
+{
+ AccessibilityFocusManager manager;
+
+ // Check whether the accessibility focus manager is already created
+ SingletonService singletonService( SingletonService::Get() );
+ if ( singletonService )
+ {
+ Dali::BaseHandle handle = singletonService.GetSingleton(typeid(AccessibilityFocusManager));
+ if(handle)
+ {
+ // If so, downcast the handle of singleton to focus manager
+ manager = AccessibilityFocusManager(dynamic_cast<Internal::AccessibilityFocusManager*>(handle.GetObjectPtr()));
+ }
+
+ if(!manager)
+ {
+ // If not, create the accessibility focus manager and register it as a singleton
+ manager = AccessibilityFocusManager(new Internal::AccessibilityFocusManager());
+ singletonService.Register(typeid(manager), manager);
+ }
+ }
+
+ return manager;
+}
+
+AccessibilityFocusManager::AccessibilityFocusManager(Internal::AccessibilityFocusManager *impl)
+ : BaseHandle(impl)
+{
+}
+
+void AccessibilityFocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
+{
+ GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
+}
+
+std::string AccessibilityFocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
+{
+ return GetImpl(*this).GetAccessibilityAttribute(actor, type);
+}
+
+void AccessibilityFocusManager::SetFocusOrder(Actor actor, const unsigned int order)
+{
+ GetImpl(*this).SetFocusOrder(actor, order);
+}
+
+unsigned int AccessibilityFocusManager::GetFocusOrder(Actor actor) const
+{
+ return GetImpl(*this).GetFocusOrder(actor);
+}
+
+unsigned int AccessibilityFocusManager::GenerateNewFocusOrder() const
+{
+ return GetImpl(*this).GenerateNewFocusOrder();
+}
+
+Actor AccessibilityFocusManager::GetActorByFocusOrder(const unsigned int order)
+{
+ return GetImpl(*this).GetActorByFocusOrder(order);
+}
+
+bool AccessibilityFocusManager::SetCurrentFocusActor(Actor actor)
+{
+ return GetImpl(*this).SetCurrentFocusActor(actor);
+}
+
+Actor AccessibilityFocusManager::GetCurrentFocusActor()
+{
+ return GetImpl(*this).GetCurrentFocusActor();
+}
+
+Actor AccessibilityFocusManager::GetCurrentFocusGroup()
+{
+ return GetImpl(*this).GetCurrentFocusGroup();
+}
+
+unsigned int AccessibilityFocusManager::GetCurrentFocusOrder()
+{
+ return GetImpl(*this).GetCurrentFocusOrder();
+}
+
+bool AccessibilityFocusManager::MoveFocusForward()
+{
+ return GetImpl(*this).MoveFocusForward();
+}
+
+bool AccessibilityFocusManager::MoveFocusBackward()
+{
+ return GetImpl(*this).MoveFocusBackward();
+}
+
+void AccessibilityFocusManager::ClearFocus()
+{
+ GetImpl(*this).ClearFocus();
+}
+
+void AccessibilityFocusManager::Reset()
+{
+ GetImpl(*this).Reset();
+}
+
+void AccessibilityFocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
+{
+ GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
+}
+
+bool AccessibilityFocusManager::IsFocusGroup(Actor actor) const
+{
+ return GetImpl(*this).IsFocusGroup(actor);
+}
+
+void AccessibilityFocusManager::SetGroupMode(bool enabled)
+{
+ GetImpl(*this).SetGroupMode(enabled);
+}
+
+bool AccessibilityFocusManager::GetGroupMode() const
+{
+ return GetImpl(*this).GetGroupMode();
+}
+
+void AccessibilityFocusManager::SetWrapMode(bool wrapped)
+{
+ GetImpl(*this).SetWrapMode(wrapped);
+}
+
+bool AccessibilityFocusManager::GetWrapMode() const
+{
+ return GetImpl(*this).GetWrapMode();
+}
+
+void AccessibilityFocusManager::SetFocusIndicatorActor(Actor indicator)
+{
+ GetImpl(*this).SetFocusIndicatorActor(indicator);
+}
+
+Actor AccessibilityFocusManager::GetFocusIndicatorActor()
+{
+ return GetImpl(*this).GetFocusIndicatorActor();
+}
+
+Actor AccessibilityFocusManager::GetFocusGroup(Actor actor)
+{
+ return GetImpl(*this).GetFocusGroup(actor);
+}
+
+AccessibilityFocusManager::FocusChangedSignalType& AccessibilityFocusManager::FocusChangedSignal()
+{
+ return GetImpl(*this).FocusChangedSignal();
+}
+
+AccessibilityFocusManager::FocusOvershotSignalType& AccessibilityFocusManager::FocusOvershotSignal()
+{
+ return GetImpl(*this).FocusOvershotSignal();
+}
+
+AccessibilityFocusManager::FocusedActorActivatedSignalType& AccessibilityFocusManager::FocusedActorActivatedSignal()
+{
+ return GetImpl(*this).FocusedActorActivatedSignal();
+}
+
+} // namespace Toolkit
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_TOOLKIT_ACCESSIBILITY_FOCUS_MANAGER_H__
+#define __DALI_TOOLKIT_ACCESSIBILITY_FOCUS_MANAGER_H__
+
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/actors/actor.h>
+#include <dali/public-api/actors/image-actor.h>
+
+namespace Dali
+{
+
+namespace Toolkit
+{
+
+namespace Internal DALI_INTERNAL
+{
+class AccessibilityFocusManager;
+}
+
+/**
+ * @brief Manages registration of actors in a accessibility focus chain and changing the
+ * focused actor within that chain.
+ *
+ * This class provides the functionality of registering the focus order and description
+ * of actors and maintaining the focus chain.
+ *
+ * It provides functionality of setting the
+ * focus and moving the focus forward and backward. It also draws a highlight for the
+ * focused actor and emits a signal when the focus is changed.
+ *
+ * Signals
+ * | %Signal Name | Method |
+ * |-------------------------|------------------------------------|
+ * | focus-changed | @ref FocusChangedSignal() |
+ * | focus-overshot | @ref FocusOvershotSignal() |
+ * | focused-actor-activated | @ref FocusedActorActivatedSignal() |
+ */
+class DALI_IMPORT_API AccessibilityFocusManager : public BaseHandle
+{
+public:
+
+ /**
+ * @brief Accessibility needs four information which will be read by screen-reader.
+ *
+ * Reading order : Label -> Trait -> Optional (Value and Hint)
+ */
+ enum AccessibilityAttribute
+ {
+ ACCESSIBILITY_LABEL = 0, ///< Simple text which contained in ui-control
+ ACCESSIBILITY_TRAIT, ///< Description of ui-control trait
+ ACCESSIBILITY_VALUE, ///< Current value of ui-control (Optional)
+ ACCESSIBILITY_HINT, ///< Hint for action (Optional)
+ ACCESSIBILITY_ATTRIBUTE_NUM ///< Number of attributes
+ };
+
+ /**
+ * @brief Overshoot direction.
+ */
+ enum FocusOvershotDirection
+ {
+ OVERSHOT_PREVIOUS = -1, ///< Try to move previous of the first actor
+ OVERSHOT_NEXT = 1, ///< Try to move next of the last actor
+ };
+
+ public:
+
+ /// @brief Focus changed signal
+ typedef Signal< void ( Actor, Actor ) > FocusChangedSignalType;
+
+ /// @brief Focus overshooted signal
+ typedef Signal< void ( Actor, FocusOvershotDirection ) > FocusOvershotSignalType;
+
+ /// @brief Focused actor activated signal
+ typedef Signal< void ( Actor ) > FocusedActorActivatedSignalType;
+
+ /**
+ * @brief Create a AccessibilityFocusManager handle; this can be initialised with AccessibilityFocusManager::New().
+ *
+ * Calling member functions with an uninitialised handle is not allowed.
+ */
+ AccessibilityFocusManager();
+
+ /**
+ * @brief Destructor
+ *
+ * This is non-virtual since derived Handle types must not contain data or virtual methods.
+ */
+ ~AccessibilityFocusManager();
+
+ /**
+ * @brief Get the singleton of AccessibilityFocusManager object.
+ *
+ * @return A handle to the AccessibilityFocusManager control.
+ */
+ static AccessibilityFocusManager Get();
+
+ /**
+ * @brief Set the information of the specified actor's accessibility attribute.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor the text to be set with
+ * @param type The attribute type the text to be set with
+ * @param text The text for the actor's accessibility information
+ */
+ void SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text);
+
+ /**
+ * @brief Get the text of the specified actor's accessibility attribute.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor to be queried
+ * @param type The attribute type to be queried
+ * @return The text of the actor's accessibility information
+ */
+ std::string GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const;
+
+ /**
+ * @brief Set the focus order of the actor.
+ *
+ * The focus order of each actor in the focus chain is unique. If
+ * there is another actor assigned with the same focus order
+ * already, the new actor will be inserted to the focus chain with
+ * that focus order, and the focus order of the original actor and
+ * all the actors followed in the focus chain will be increased
+ * accordingly. If the focus order assigned to the actor is 0, it
+ * means that actor's focus order is undefined (e.g. the actor has a
+ * description but with no focus order being set yet) and therefore
+ * that actor is not focusable.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor the focus order to be set with
+ * @param order The focus order of the actor
+ */
+ void SetFocusOrder(Actor actor, const unsigned int order);
+
+ /**
+ * @brief Get the focus order of the actor.
+ *
+ * When the focus order is 0, it means the focus order of the actor
+ * is undefined.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor to be queried
+ * @return The focus order of the actor
+ */
+ unsigned int GetFocusOrder(Actor actor) const;
+
+ /**
+ * @brief Generates a new focus order number which can be used to
+ * assign to actors which need to be appended to the end of the
+ * current focus order chain.
+ *
+ * The new number will be an increment over the very last focus
+ * order number in the focus chain. If the focus chain is empty then
+ * the function returns 1, else the number returned will be FOLast +
+ * 1 where FOLast is the focus order of the very last control in the
+ * focus chain.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return The focus order of the actor
+ */
+ unsigned int GenerateNewFocusOrder() const;
+
+ /**
+ * @brief Get the actor that has the specified focus order.
+ *
+ * It will return an empty handle if the actor is not in the stage
+ * or has a focus order of 0.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @param order The focus order of the actor
+ *
+ * @return The actor that has the specified focus order or an empty
+ * handle if no actor in the stage has the specified focus order.
+ */
+ Actor GetActorByFocusOrder(const unsigned int order);
+
+ /**
+ * @brief Move the focus to the specified actor.
+ *
+ * Only one actor can be focused at the same time. The actor must
+ * have a defined focus order and must be focusable, visible and in
+ * the stage.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor to be focused
+ * @return Whether the focus is successful or not
+ */
+ bool SetCurrentFocusActor(Actor actor);
+
+ /**
+ * @brief Get the current focused actor.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return A handle to the current focused actor or an empty handle if no actor is focused.
+ */
+ Actor GetCurrentFocusActor();
+
+ /**
+ * @brief Get the focus group of current focused actor.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ *
+ * @return A handle to the immediate parent of the current focused
+ * actor which is also a focus group, or an empty handle if no actor
+ * is focused.
+ */
+ Actor GetCurrentFocusGroup();
+
+ /**
+ * @brief Get the focus order of currently focused actor.
+ * @pre The AccessibilityFocusManager has been initialized.
+ *
+ * @return The focus order of the currently focused actor or 0 if no
+ * actor is in focus.
+ */
+ unsigned int GetCurrentFocusOrder();
+
+ /**
+ * @brief Move the focus to the next focusable actor in the focus
+ * chain (according to the focus traversal order).
+ *
+ * When the focus movement is wrapped around, the focus will be moved
+ * to the first focusable actor when it reaches the end of the focus chain.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return true if the moving was successful
+ */
+ bool MoveFocusForward();
+
+ /**
+ * @brief Move the focus to the previous focusable actor in the
+ * focus chain (according to the focus traversal order).
+ *
+ * When the focus movement is wrapped around, the focus will be
+ * moved to the last focusable actor when it reaches the beginning
+ * of the focus chain.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return true if the moving was successful
+ */
+ bool MoveFocusBackward();
+
+ /**
+ * @brief Clear the focus from the current focused actor if any, so
+ * that no actor is focused in the focus chain.
+ *
+ * It will emit focus changed signal without current focused actor
+ * @pre The AccessibilityFocusManager has been initialized.
+ */
+ void ClearFocus();
+
+ /**
+ * @brief Clear the every registered focusable actor from focus-manager.
+ * @pre The AccessibilityFocusManager has been initialized.
+ */
+ void Reset();
+
+ /**
+ * @brief Set whether an actor is a focus group that can limit the
+ * scope of focus movement to its child actors in the focus chain.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor to be set as a focus group.
+ * @param isFocusGroup Whether to set the actor to be a focus group or not.
+ */
+ void SetFocusGroup(Actor actor, bool isFocusGroup);
+
+ /**
+ * @brief Check whether the actor is set as a focus group or not.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The Actor has been initialized.
+ * @param actor The actor to be checked.
+ * @return Whether the actor is set as a focus group.
+ */
+ bool IsFocusGroup(Actor actor) const;
+
+ /**
+ * @brief Set whether the group mode is enabled or not.
+ *
+ * When the group mode is enabled, the focus movement will be limited to the child actors
+ * of the current focus group including the current focus group itself. The current focus
+ * group is the closest ancestor of the current focused actor that set as a focus group.
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @param enabled Whether the group mode is enabled or not
+ */
+ void SetGroupMode(bool enabled);
+
+ /**
+ * @brief Get whether the group mode is enabled or not.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return Whether the group mode is enabled or not.
+ */
+ bool GetGroupMode() const;
+
+ /**
+ * @brief Set whether focus will be moved to the beginning of the
+ * focus chain when it reaches the end or vice versa.
+ *
+ * When both the wrap mode and the group mode are enabled, focus will be
+ * wrapped within the current focus group. Focus will not be wrapped in default.
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @param wrapped Whether the focus movement is wrapped around or not
+ */
+ void SetWrapMode(bool wrapped);
+
+ /**
+ * @brief Get whether the wrap mode is enabled or not.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return Whether the wrap mode is enabled or not.
+ */
+ bool GetWrapMode() const;
+
+ /**
+ * @brief Set the focus indicator actor.
+ *
+ * This will replace the default focus indicator actor in
+ * AccessibilityFocusManager and will be added to the focused actor as a
+ * highlight.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @pre The indicator actor has been initialized.
+ * @param indicator The indicator actor to be added
+ */
+ void SetFocusIndicatorActor(Actor indicator);
+
+ /**
+ * @brief Get the focus indicator actor.
+ *
+ * @pre The AccessibilityFocusManager has been initialized.
+ * @return A handle to the focus indicator actor
+ */
+ Actor GetFocusIndicatorActor();
+
+ /**
+ * @brief Returns the closest ancestor of the given actor that is a focus group.
+ *
+ * @param actor The actor to be checked for its focus group
+ * @return The focus group the given actor belongs to or an empty handle if the given actor doesn't belong to any focus group
+ */
+ Actor GetFocusGroup(Actor actor);
+
+ public: // Signals
+
+ /**
+ * @brief This signal is emitted when the current focused actor is changed.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Actor originalFocusedActor, Actor currentFocusedActor);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ FocusChangedSignalType& FocusChangedSignal();
+
+ /**
+ * @brief This signal is emitted when there is no way to move focus further.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Actor currentFocusedActor, FocusOvershotDirection direction);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ FocusOvershotSignalType& FocusOvershotSignal();
+
+ /**
+ * @brief This signal is emitted when the current focused actor is activated.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ * void YourCallbackName(Actor activatedActor);
+ * @endcode
+ * @pre The Object has been initialized.
+ * @return The signal to connect to.
+ */
+ FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
+
+private:
+
+ explicit DALI_INTERNAL AccessibilityFocusManager(Internal::AccessibilityFocusManager *impl);
+
+}; // class AccessibilityFocusManager
+
+} // namespace Toolkit
+
+} // namespace Dali
+
+#endif // __DALI_TOOLKIT_FOCUS_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include <dali-toolkit/public-api/focus-manager/focus-manager.h>
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/singleton-service.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/focus-manager/focus-manager-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-FocusManager::FocusManager()
-{
-}
-
-FocusManager::~FocusManager()
-{
-}
-
-FocusManager FocusManager::Get()
-{
- FocusManager manager;
-
- // Check whether the focus manager is already created
- SingletonService singletonService( SingletonService::Get() );
- if ( singletonService )
- {
- Dali::BaseHandle handle = singletonService.GetSingleton(typeid(FocusManager));
- if(handle)
- {
- // If so, downcast the handle of singleton to focus manager
- manager = FocusManager(dynamic_cast<Internal::FocusManager*>(handle.GetObjectPtr()));
- }
-
- if(!manager)
- {
- // If not, create the focus manager and register it as a singleton
- manager = FocusManager(new Internal::FocusManager());
- singletonService.Register(typeid(manager), manager);
- }
- }
-
- return manager;
-}
-
-FocusManager::FocusManager(Internal::FocusManager *impl)
- : BaseHandle(impl)
-{
-}
-
-void FocusManager::SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text)
-{
- GetImpl(*this).SetAccessibilityAttribute(actor, type, text);
-}
-
-std::string FocusManager::GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const
-{
- return GetImpl(*this).GetAccessibilityAttribute(actor, type);
-}
-
-void FocusManager::SetFocusOrder(Actor actor, const unsigned int order)
-{
- GetImpl(*this).SetFocusOrder(actor, order);
-}
-
-unsigned int FocusManager::GetFocusOrder(Actor actor) const
-{
- return GetImpl(*this).GetFocusOrder(actor);
-}
-
-unsigned int FocusManager::GenerateNewFocusOrder() const
-{
- return GetImpl(*this).GenerateNewFocusOrder();
-}
-
-Actor FocusManager::GetActorByFocusOrder(const unsigned int order)
-{
- return GetImpl(*this).GetActorByFocusOrder(order);
-}
-
-bool FocusManager::SetCurrentFocusActor(Actor actor)
-{
- return GetImpl(*this).SetCurrentFocusActor(actor);
-}
-
-Actor FocusManager::GetCurrentFocusActor()
-{
- return GetImpl(*this).GetCurrentFocusActor();
-}
-
-Actor FocusManager::GetCurrentFocusGroup()
-{
- return GetImpl(*this).GetCurrentFocusGroup();
-}
-
-unsigned int FocusManager::GetCurrentFocusOrder()
-{
- return GetImpl(*this).GetCurrentFocusOrder();
-}
-
-bool FocusManager::MoveFocusForward()
-{
- return GetImpl(*this).MoveFocusForward();
-}
-
-bool FocusManager::MoveFocusBackward()
-{
- return GetImpl(*this).MoveFocusBackward();
-}
-
-void FocusManager::ClearFocus()
-{
- GetImpl(*this).ClearFocus();
-}
-
-void FocusManager::Reset()
-{
- GetImpl(*this).Reset();
-}
-
-void FocusManager::SetFocusGroup(Actor actor, bool isFocusGroup)
-{
- GetImpl(*this).SetFocusGroup(actor, isFocusGroup);
-}
-
-bool FocusManager::IsFocusGroup(Actor actor) const
-{
- return GetImpl(*this).IsFocusGroup(actor);
-}
-
-void FocusManager::SetGroupMode(bool enabled)
-{
- GetImpl(*this).SetGroupMode(enabled);
-}
-
-bool FocusManager::GetGroupMode() const
-{
- return GetImpl(*this).GetGroupMode();
-}
-
-void FocusManager::SetWrapMode(bool wrapped)
-{
- GetImpl(*this).SetWrapMode(wrapped);
-}
-
-bool FocusManager::GetWrapMode() const
-{
- return GetImpl(*this).GetWrapMode();
-}
-
-void FocusManager::SetFocusIndicatorActor(Actor indicator)
-{
- GetImpl(*this).SetFocusIndicatorActor(indicator);
-}
-
-Actor FocusManager::GetFocusIndicatorActor()
-{
- return GetImpl(*this).GetFocusIndicatorActor();
-}
-
-Actor FocusManager::GetFocusGroup(Actor actor)
-{
- return GetImpl(*this).GetFocusGroup(actor);
-}
-
-FocusManager::FocusChangedSignalType& FocusManager::FocusChangedSignal()
-{
- return GetImpl(*this).FocusChangedSignal();
-}
-
-FocusManager::FocusOvershotSignalType& FocusManager::FocusOvershotSignal()
-{
- return GetImpl(*this).FocusOvershotSignal();
-}
-
-FocusManager::FocusedActorActivatedSignalType& FocusManager::FocusedActorActivatedSignal()
-{
- return GetImpl(*this).FocusedActorActivatedSignal();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_TOOLKIT_FOCUS_MANAGER_H__
-#define __DALI_TOOLKIT_FOCUS_MANAGER_H__
-
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/actors/actor.h>
-#include <dali/public-api/actors/image-actor.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal DALI_INTERNAL
-{
-class FocusManager;
-}
-
-/**
- * @brief Manages registration of actors in a focus chain and changing the focused
- * actor within that chain.
- *
- * This class provides the functionality of registering the focus order and description
- * of actors and maintaining the focus chain.
- *
- * It provides functionality of setting the
- * focus and moving the focus forward and backward. It also draws a highlight for the
- * focused actor and emits a signal when the focus is changed.
- *
- * Signals
- * | %Signal Name | Method |
- * |-------------------------|------------------------------------|
- * | focus-changed | @ref FocusChangedSignal() |
- * | focus-overshot | @ref FocusOvershotSignal() |
- * | focused-actor-activated | @ref FocusedActorActivatedSignal() |
- */
-class DALI_IMPORT_API FocusManager : public BaseHandle
-{
-public:
-
- /**
- * @brief Accessibility needs four information which will be read by screen-reader.
- *
- * Reading order : Label -> Trait -> Optional (Value and Hint)
- */
- enum AccessibilityAttribute
- {
- ACCESSIBILITY_LABEL = 0, ///< Simple text which contained in ui-control
- ACCESSIBILITY_TRAIT, ///< Description of ui-control trait
- ACCESSIBILITY_VALUE, ///< Current value of ui-control (Optional)
- ACCESSIBILITY_HINT, ///< Hint for action (Optional)
- ACCESSIBILITY_ATTRIBUTE_NUM ///< Number of attributes
- };
-
- /**
- * @brief Overshoot direction.
- */
- enum FocusOvershotDirection
- {
- OVERSHOT_PREVIOUS = -1, ///< Try to move previous of the first actor
- OVERSHOT_NEXT = 1, ///< Try to move next of the last actor
- };
-
- public:
-
- /// @brief Focus changed signal
- typedef Signal< void ( Actor, Actor ) > FocusChangedSignalType;
-
- /// @brief Focus overshooted signal
- typedef Signal< void ( Actor, FocusOvershotDirection ) > FocusOvershotSignalType;
-
- /// @brief Focused actor activated signal
- typedef Signal< void ( Actor ) > FocusedActorActivatedSignalType;
-
- /**
- * @brief Create a FocusManager handle; this can be initialised with FocusManager::New().
- *
- * Calling member functions with an uninitialised handle is not allowed.
- */
- FocusManager();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~FocusManager();
-
- /**
- * @brief Get the singleton of FocusManager object.
- *
- * @return A handle to the FocusManager control.
- */
- static FocusManager Get();
-
- /**
- * @brief Set the information of the specified actor's accessibility attribute.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor the text to be set with
- * @param type The attribute type the text to be set with
- * @param text The text for the actor's accessibility information
- */
- void SetAccessibilityAttribute(Actor actor, AccessibilityAttribute type, const std::string& text);
-
- /**
- * @brief Get the text of the specified actor's accessibility attribute.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor to be queried
- * @param type The attribute type to be queried
- * @return The text of the actor's accessibility information
- */
- std::string GetAccessibilityAttribute(Actor actor, AccessibilityAttribute type) const;
-
- /**
- * @brief Set the focus order of the actor.
- *
- * The focus order of each actor in the focus chain is unique. If
- * there is another actor assigned with the same focus order
- * already, the new actor will be inserted to the focus chain with
- * that focus order, and the focus order of the original actor and
- * all the actors followed in the focus chain will be increased
- * accordingly. If the focus order assigned to the actor is 0, it
- * means that actor's focus order is undefined (e.g. the actor has a
- * description but with no focus order being set yet) and therefore
- * that actor is not focusable.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor the focus order to be set with
- * @param order The focus order of the actor
- */
- void SetFocusOrder(Actor actor, const unsigned int order);
-
- /**
- * @brief Get the focus order of the actor.
- *
- * When the focus order is 0, it means the focus order of the actor
- * is undefined.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor to be queried
- * @return The focus order of the actor
- */
- unsigned int GetFocusOrder(Actor actor) const;
-
- /**
- * @brief Generates a new focus order number which can be used to
- * assign to actors which need to be appended to the end of the
- * current focus order chain.
- *
- * The new number will be an increment over the very last focus
- * order number in the focus chain. If the focus chain is empty then
- * the function returns 1, else the number returned will be FOLast +
- * 1 where FOLast is the focus order of the very last control in the
- * focus chain.
- *
- * @pre The FocusManager has been initialized.
- * @return The focus order of the actor
- */
- unsigned int GenerateNewFocusOrder() const;
-
- /**
- * @brief Get the actor that has the specified focus order.
- *
- * It will return an empty handle if the actor is not in the stage
- * or has a focus order of 0.
- *
- * @pre The FocusManager has been initialized.
- * @param order The focus order of the actor
- *
- * @return The actor that has the specified focus order or an empty
- * handle if no actor in the stage has the specified focus order.
- */
- Actor GetActorByFocusOrder(const unsigned int order);
-
- /**
- * @brief Move the focus to the specified actor.
- *
- * Only one actor can be focused at the same time. The actor must
- * have a defined focus order and must be focusable, visible and in
- * the stage.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor to be focused
- * @return Whether the focus is successful or not
- */
- bool SetCurrentFocusActor(Actor actor);
-
- /**
- * @brief Get the current focused actor.
- *
- * @pre The FocusManager has been initialized.
- * @return A handle to the current focused actor or an empty handle if no actor is focused.
- */
- Actor GetCurrentFocusActor();
-
- /**
- * @brief Get the focus group of current focused actor.
- *
- * @pre The FocusManager has been initialized.
- *
- * @return A handle to the immediate parent of the current focused
- * actor which is also a focus group, or an empty handle if no actor
- * is focused.
- */
- Actor GetCurrentFocusGroup();
-
- /**
- * @brief Get the focus order of currently focused actor.
- * @pre The FocusManager has been initialized.
- *
- * @return The focus order of the currently focused actor or 0 if no
- * actor is in focus.
- */
- unsigned int GetCurrentFocusOrder();
-
- /**
- * @brief Move the focus to the next focusable actor in the focus
- * chain (according to the focus traversal order).
- *
- * When the focus movement is wrapped around, the focus will be moved
- * to the first focusable actor when it reaches the end of the focus chain.
- *
- * @pre The FocusManager has been initialized.
- * @return true if the moving was successful
- */
- bool MoveFocusForward();
-
- /**
- * @brief Move the focus to the previous focusable actor in the
- * focus chain (according to the focus traversal order).
- *
- * When the focus movement is wrapped around, the focus will be
- * moved to the last focusable actor when it reaches the beginning
- * of the focus chain.
- *
- * @pre The FocusManager has been initialized.
- * @return true if the moving was successful
- */
- bool MoveFocusBackward();
-
- /**
- * @brief Clear the focus from the current focused actor if any, so
- * that no actor is focused in the focus chain.
- *
- * It will emit focus changed signal without current focused actor
- * @pre The FocusManager has been initialized.
- */
- void ClearFocus();
-
- /**
- * @brief Clear the every registered focusable actor from focus-manager.
- * @pre The FocusManager has been initialized.
- */
- void Reset();
-
- /**
- * @brief Set whether an actor is a focus group that can limit the
- * scope of focus movement to its child actors in the focus chain.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor to be set as a focus group.
- * @param isFocusGroup Whether to set the actor to be a focus group or not.
- */
- void SetFocusGroup(Actor actor, bool isFocusGroup);
-
- /**
- * @brief Check whether the actor is set as a focus group or not.
- *
- * @pre The FocusManager has been initialized.
- * @pre The Actor has been initialized.
- * @param actor The actor to be checked.
- * @return Whether the actor is set as a focus group.
- */
- bool IsFocusGroup(Actor actor) const;
-
- /**
- * @brief Set whether the group mode is enabled or not.
- *
- * When the group mode is enabled, the focus movement will be limited to the child actors
- * of the current focus group including the current focus group itself. The current focus
- * group is the closest ancestor of the current focused actor that set as a focus group.
- * @pre The FocusManager has been initialized.
- * @param enabled Whether the group mode is enabled or not
- */
- void SetGroupMode(bool enabled);
-
- /**
- * @brief Get whether the group mode is enabled or not.
- *
- * @pre The FocusManager has been initialized.
- * @return Whether the group mode is enabled or not.
- */
- bool GetGroupMode() const;
-
- /**
- * @brief Set whether focus will be moved to the beginning of the
- * focus chain when it reaches the end or vice versa.
- *
- * When both the wrap mode and the group mode are enabled, focus will be
- * wrapped within the current focus group. Focus will not be wrapped in default.
- * @pre The FocusManager has been initialized.
- * @param wrapped Whether the focus movement is wrapped around or not
- */
- void SetWrapMode(bool wrapped);
-
- /**
- * @brief Get whether the wrap mode is enabled or not.
- *
- * @pre The FocusManager has been initialized.
- * @return Whether the wrap mode is enabled or not.
- */
- bool GetWrapMode() const;
-
- /**
- * @brief Set the focus indicator actor.
- *
- * This will replace the default focus indicator actor in
- * FocusManager and will be added to the focused actor as a
- * highlight.
- *
- * @pre The FocusManager has been initialized.
- * @pre The indicator actor has been initialized.
- * @param indicator The indicator actor to be added
- */
- void SetFocusIndicatorActor(Actor indicator);
-
- /**
- * @brief Get the focus indicator actor.
- *
- * @pre The FocusManager has been initialized.
- * @return A handle to the focus indicator actor
- */
- Actor GetFocusIndicatorActor();
-
- /**
- * @brief Returns the closest ancestor of the given actor that is a focus group.
- *
- * @param actor The actor to be checked for its focus group
- * @return The focus group the given actor belongs to or an empty handle if the given actor doesn't belong to any focus group
- */
- Actor GetFocusGroup(Actor actor);
-
- public: // Signals
-
- /**
- * @brief This signal is emitted when the current focused actor is changed.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(Actor originalFocusedActor, Actor currentFocusedActor);
- * @endcode
- * @pre The Object has been initialized.
- * @return The signal to connect to.
- */
- FocusChangedSignalType& FocusChangedSignal();
-
- /**
- * @brief This signal is emitted when there is no way to move focus further.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(Actor currentFocusedActor, FocusOvershotDirection direction);
- * @endcode
- * @pre The Object has been initialized.
- * @return The signal to connect to.
- */
- FocusOvershotSignalType& FocusOvershotSignal();
-
- /**
- * @brief This signal is emitted when the current focused actor is activated.
- *
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(Actor activatedActor);
- * @endcode
- * @pre The Object has been initialized.
- * @return The signal to connect to.
- */
- FocusedActorActivatedSignalType& FocusedActorActivatedSignal();
-
-private:
-
- explicit DALI_INTERNAL FocusManager(Internal::FocusManager *impl);
-
-}; // class FocusManager
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_FOCUS_MANAGER_H__
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// CLASS HEADER
-#include "keyinput-focus-manager.h"
-
-// EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/singleton-service.h>
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-KeyInputFocusManager::KeyInputFocusManager()
-{
-}
-
-KeyInputFocusManager::~KeyInputFocusManager()
-{
-}
-
-KeyInputFocusManager KeyInputFocusManager::Get()
-{
- KeyInputFocusManager manager;
-
- // Check whether the focus manager is already created
- SingletonService singletonService( SingletonService::Get() );
- if ( singletonService )
- {
- Dali::BaseHandle handle = singletonService.GetSingleton(typeid(KeyInputFocusManager));
- if(handle)
- {
- // If so, downcast the handle of singleton to focus manager
- manager = KeyInputFocusManager(dynamic_cast<Internal::KeyInputFocusManager*>(handle.GetObjectPtr()));
- }
-
- if(!manager)
- {
- // If not, create the focus manager and register it as a singleton
- manager = KeyInputFocusManager(new Internal::KeyInputFocusManager());
- singletonService.Register(typeid(manager), manager);
- }
- }
-
- return manager;
-}
-
-KeyInputFocusManager::KeyInputFocusManager(Internal::KeyInputFocusManager *impl)
- : BaseHandle(impl)
-{
-}
-
-void KeyInputFocusManager::SetFocus(Control control)
-{
- GetImpl(*this).SetFocus(control);
-}
-
-Control KeyInputFocusManager::GetCurrentFocusControl() const
-{
- return GetImpl(*this).GetCurrentFocusControl();
-}
-
-void KeyInputFocusManager::RemoveFocus(Control control)
-{
- GetImpl(*this).RemoveFocus(control);
-}
-
-bool KeyInputFocusManager::IsKeyboardListener(Control control)
-{
- return GetImpl(*this).IsKeyboardListener(control);
-}
-
-KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusManager::KeyInputFocusChangedSignal()
-{
- return GetImpl(*this).KeyInputFocusChangedSignal();
-}
-
-KeyInputFocusManager::UnhandledKeyEventSignalType& KeyInputFocusManager::UnhandledKeyEventSignal()
-{
- return GetImpl(*this).UnhandledKeyEventSignal();
-}
-
-} // namespace Toolkit
-
-} // namespace Dali
-
+++ /dev/null
-#ifndef __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__
-#define __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__
-
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control.h>
-
-namespace Dali
-{
-
-namespace Toolkit
-{
-
-namespace Internal DALI_INTERNAL
-{
-class KeyInputFocusManager;
-}
-
-/**
- * KeyInputFocusManager
- * This class provides the functionality of registering for keyboard events for controls.
- * The keyinput focus manager maintains a stack of controls, With the last added control receiving
- * all the keyboard events first. And if the conrol doesn't consume the event it is passed to
- * the next control in the stack. If none of the controls in the stack consume the key event then
- * UnhandledKeyEventSignal() is emitted.
- *
- * Signals
- * | %Signal Name | Method |
- * |-------------------------|-----------------------------------|
- * | key-input-focus-changed | @ref KeyInputFocusChangedSignal() |
- * | unhandled-key-event | @ref UnhandledKeyEventSignal() |
- */
-class DALI_IMPORT_API KeyInputFocusManager : public BaseHandle
-{
-public:
-
- // KeyInputFocusChanged
- typedef Signal< void (Control, Control) > KeyInputFocusChangedSignalType;
-
- // Unhandled Key Event
- typedef Signal< void (const KeyEvent&) > UnhandledKeyEventSignalType;
-
-public:
-
- /**
- * Create a KeyInputFocusManager handle; this can be initialised with KeyInputFocusManager::Get()
- * Calling member functions with an uninitialised handle is not allowed.
- */
- KeyInputFocusManager();
-
- /**
- * @brief Destructor
- *
- * This is non-virtual since derived Handle types must not contain data or virtual methods.
- */
- ~KeyInputFocusManager();
-
- /**
- * Get the singleton of KeyInputFocusManager object.
- * @return A handle to the KeyInputFocusManager control.
- */
- static KeyInputFocusManager Get();
-
- /**
- * Sets keyboard focus for a control.
- * Note: A control can be set to be in focus and still not receive all the key events if another control has over ridden it.
- * As the key input focus mechanism works like a stack, the top most control receives all the key events, and passes on the
- * unhandled events to the controls below in the stack. A control in the stack will regain key input focus when there are no more
- * controls above it in the focus stack.
- *
- * @pre The Control is not in the focus stack. If it is allready present in the top of the stack it results in a no-op, If it is
- * present in the stack but not on the top of the stack, then the control is moved to the top of the focus stack.
- * @param[in] control The Control to receive keyboard input
- */
- void SetFocus(Control control);
-
- /**
- * Query for the control that is currently set to be on top of the fcous stack and receives all
- * keyboard input events first.
- * @return Pointer to the control set to receive keyboard inputs.
- */
- Control GetCurrentFocusControl() const;
-
- /**
- * Removes focus for the given control, The control will no longer receive events from keyboard.
- * @param [in] control which should be removed from focus.
- */
- void RemoveFocus(Control control);
-
- /**
- * Queries whether a control is currently part of the focus stack.
- * @param [in] control which should be queried.
- * @return True if it is part of the foucus stack False otherwise.
- */
- bool IsKeyboardListener(Control control);
-
-public: // Signals
-
- /**
- * This signal is emitted when the key input focus control changes.
- * Two control parameters are sent as part of this signal, the first being the signal that now has the focus, the second
- * being the one that has lost focus.
- * A callback of the following type may be connected:
- * @code
- * void YourCallback(Control focusGainedControl, Control focusLostActor);
- * @endcode
- * @return The signal to connect to.
- */
- KeyInputFocusChangedSignalType& KeyInputFocusChangedSignal();
-
- /**
- * This signal is emitted when a key event was received, and none of the focused controls on the stage have consumed it.
- * A callback of the following type may be connected:
- * @code
- * void YourCallbackName(const KeyEvent& event);
- * @endcode
- * @return The signal to connect to.
- */
- UnhandledKeyEventSignalType& UnhandledKeyEventSignal();
-
-private:
-
- explicit DALI_INTERNAL KeyInputFocusManager(Internal::KeyInputFocusManager *impl);
-
-}; // class KeyInputFocusManager
-
-} // namespace Toolkit
-
-} // namespace Dali
-
-#endif // __DALI_TOOLKIT_KEYINPUT_FOCUS_MANAGER_H__