Revert "Change adding focus indicator logic" 18/114918/2
authorRichard Huang <r.huang@samsung.com>
Wed, 15 Feb 2017 14:08:54 +0000 (06:08 -0800)
committerRichard Huang <r.huang@samsung.com>
Wed, 15 Feb 2017 14:09:48 +0000 (06:09 -0800)
This reverts commit c00b54ce005b74dfbf5397468d4dca1e4dfbbf31.

Change-Id: I96a9913234c63cf7c8a33efb798717c66ec78f5b

dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp
dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h

index f67ca6f..197550f 100644 (file)
@@ -117,14 +117,17 @@ KeyboardFocusManager::KeyboardFocusManager()
   mCurrentFocusActor( 0 ),
   mFocusIndicatorActor(),
   mFocusGroupLoopEnabled( false ),
   mCurrentFocusActor( 0 ),
   mFocusIndicatorActor(),
   mFocusGroupLoopEnabled( false ),
+  mIsKeyboardFocusEnabled( false ),
   mIsFocusIndicatorEnabled( false ),
   mIsWaitingKeyboardFocusChangeCommit( false ),
   mFocusHistory(),
   mSlotDelegate( this )
 {
   mIsFocusIndicatorEnabled( false ),
   mIsWaitingKeyboardFocusChangeCommit( false ),
   mFocusHistory(),
   mSlotDelegate( this )
 {
-  // TODO: Get FocusIndicatorEnable constant from stylesheet to set mIsFocusIndicatorEnabled.
+  OnPhysicalKeyboardStatusChanged(PhysicalKeyboard::Get());
+
   Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
   Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
   Toolkit::KeyInputFocusManager::Get().UnhandledKeyEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnKeyEvent);
   Stage::GetCurrent().TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch );
+  PhysicalKeyboard::Get().StatusChangedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnPhysicalKeyboardStatusChanged);
 }
 
 KeyboardFocusManager::~KeyboardFocusManager()
 }
 
 KeyboardFocusManager::~KeyboardFocusManager()
@@ -152,8 +155,9 @@ bool KeyboardFocusManager::DoSetCurrentFocusActor( const unsigned int actorID )
   // Check whether the actor is in the stage and is keyboard focusable.
   if( actor && actor.IsKeyboardFocusable() )
   {
   // Check whether the actor is in the stage and is keyboard focusable.
   if( actor && actor.IsKeyboardFocusable() )
   {
-    // Draw the focus indicator upon the focused actor when Focus Indicator is enabled
-    if( mIsFocusIndicatorEnabled )
+    mIsFocusIndicatorEnabled = true;
+    // Draw the focus indicator upon the focused actor when PhysicalKeyboard is attached
+    if( mIsKeyboardFocusEnabled )
     {
       actor.Add( GetFocusIndicatorActor() );
     }
     {
       actor.Add( GetFocusIndicatorActor() );
     }
@@ -503,8 +507,39 @@ Actor KeyboardFocusManager::GetFocusIndicatorActor()
   return mFocusIndicatorActor;
 }
 
   return mFocusIndicatorActor;
 }
 
+void KeyboardFocusManager::OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard)
+{
+  mIsKeyboardFocusEnabled = keyboard.IsAttached();
+
+  if(mIsKeyboardFocusEnabled)
+  {
+    // Show indicator when keyboard focus turned on if there is focused actor.
+    Actor actor = GetCurrentFocusActor();
+    if(actor)
+    {
+      actor.Add( GetFocusIndicatorActor() );
+    }
+    mIsFocusIndicatorEnabled = true;
+  }
+  else
+  {
+    // Hide indicator when keyboard focus turned off
+    Actor actor = GetCurrentFocusActor();
+    if( actor && mFocusIndicatorActor )
+    {
+      actor.Remove( mFocusIndicatorActor );
+    }
+    mIsFocusIndicatorEnabled = false;
+  }
+}
+
 void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
 {
 void KeyboardFocusManager::OnKeyEvent(const KeyEvent& event)
 {
+  if(!mIsKeyboardFocusEnabled)
+  {
+    return;
+  }
+
   AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get();
   bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled();
 
   AccessibilityAdaptor accessibilityAdaptor = AccessibilityAdaptor::Get();
   bool isAccessibilityEnabled = accessibilityAdaptor.IsEnabled();
 
index fd46678..1ece0b1 100644 (file)
@@ -19,6 +19,8 @@
  */
 
 // EXTERNAL INCLUDES
  */
 
 // EXTERNAL INCLUDES
+#include <string>
+#include <dali/devel-api/adaptor-framework/physical-keyboard.h>
 #include <dali/public-api/object/base-object.h>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/object/base-object.h>
 
 // INTERNAL INCLUDES
@@ -226,6 +228,12 @@ private:
    */
   void OnTouch( const TouchData& touch );
 
    */
   void OnTouch( const TouchData& touch );
 
+  /**
+   * Change the keyboard focus status when keyboard focus feature turned on or off.
+   * @return Whether the status is changed or not.
+   */
+  void OnPhysicalKeyboardStatusChanged(PhysicalKeyboard keyboard);
+
 private:
 
   // Undefined
 private:
 
   // Undefined
@@ -246,6 +254,8 @@ private:
 
   bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
 
 
   bool mFocusGroupLoopEnabled:1; ///< Whether the focus movement is looped within the same focus group
 
+  bool mIsKeyboardFocusEnabled:1; ///< Whether keyboard focus feature turned on/off
+
   bool mIsFocusIndicatorEnabled:1; ///< Whether indicator should be shown / hidden. It could be enabled when keyboard focus feature enabled and navigation keys or 'Tab' key pressed.
 
   bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.
   bool mIsFocusIndicatorEnabled:1; ///< Whether indicator should be shown / hidden. It could be enabled when keyboard focus feature enabled and navigation keys or 'Tab' key pressed.
 
   bool mIsWaitingKeyboardFocusChangeCommit:1; /// A flag to indicate PreFocusChangeSignal emitted but the proposed focus actor is not commited by the application yet.