DALi Version 2.1.5
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyinput-focus-manager-impl.h
index 8b03970..5974b88 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__
-#define __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H
+#define DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  */
 
 // EXTERNAL INCLUDES
-#include <string>
 #include <dali/public-api/object/base-object.h>
 #include <dali/public-api/object/object-registry.h>
+#include <string>
 
 // 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
 {
+namespace Integration
+{
+class SceneHolder;
+
+} // namespace Integration
 
 namespace Toolkit
 {
-
 namespace Internal
 {
-
 class KeyInputFocusManager;
 
 /**
@@ -44,9 +47,6 @@ class KeyInputFocusManager;
 class KeyInputFocusManager : public Dali::BaseObject, public Dali::ConnectionTracker
 {
 public:
-  typedef Dali::Vector< Dali::BaseObject* > FocusStack;
-  typedef FocusStack::Iterator FocusStackIterator;
-
   /**
    * Construct a new KeyInputFocusManager.
    */
@@ -67,24 +67,13 @@ public:
    */
   Toolkit::Control GetCurrentFocusControl() const;
 
-  /**
-   * @copydoc Toolkit::IsKeyboardListener
-   */
-  bool IsKeyboardListener(Toolkit::Control control) const;
-
 public:
-
   /**
    * @copydoc Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignal()
    */
   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusChangedSignal();
 
   /**
-   * @copydoc Toolkit::KeyInputFocusManager::UnhandledKeyEventSignal()
-   */
-  Toolkit::KeyInputFocusManager::UnhandledKeyEventSignalType& UnhandledKeyEventSignal();
-
-  /**
    * 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.
@@ -93,61 +82,54 @@ public:
    * @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 );
+  static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
 
 protected:
-
   /**
    * Destructor
    */
   virtual ~KeyInputFocusManager();
 
 private:
-
   /**
-   * Search for a control in the focus stack.
-   * @param[in] control The control for which to search
-   * @return An iterator to the control. If not found, this will equate to the
-   * mFocusStack.End() iterator.
+   * This will be called when a new scene holder is created
+   * @param sceneHolder The new scene holder
    */
-  FocusStackIterator FindFocusControlInStack( Toolkit::Control control ) const;
+  void OnSceneHolderCreated(Dali::Integration::SceneHolder& sceneHolder);
 
   /**
    * Callback for the key event when no actor in the stage has gained the key input focus
    * @param[in] event The KeyEvent event.
    */
-  void OnKeyEvent(const KeyEvent& event);
+  bool OnKeyEvent(const KeyEvent& event);
 
   /**
-   * Signal handler called when a focused Control is removed from Stage.
-   * @param[in]  control  The control removed from stage.
+   * Signal handler called when a focused Control is removed from Scene.
+   * @param[in]  control  The control removed from the scene.
    */
-  void OnFocusControlStageDisconnection( Dali::Actor control );
+  void OnFocusControlSceneDisconnection(Dali::Actor control);
 
   /**
-   * Signal handler called when an actor is destroyed.
-   */
-  void OnObjectDestroyed(const Dali::RefObject* object);
+    *  Recursively deliver events to the control and its parents, until the event is consumed or the stage is reached.
+   * @param[in]  control  The control got KeyEvent.
+   * @param[in]  event    The KeyEvent.
+   * @return True if KeyEvent is consumed.
+    */
+  bool EmitKeyEventSignal(Toolkit::Control control, const KeyEvent& event);
 
 private:
-
   // Undefined
   KeyInputFocusManager(const KeyInputFocusManager&);
 
   KeyInputFocusManager& operator=(const KeyInputFocusManager& rhs);
 
 private:
-
   // The key input focus change signal
   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType mKeyInputFocusChangedSignal;
 
-  // The un-handled key event signal
-  Toolkit::KeyInputFocusManager::UnhandledKeyEventSignalType mUnhandledKeyEventSignal;
+  SlotDelegate<KeyInputFocusManager> mSlotDelegate;
 
-  // Keyboard events are sent to the current focus actor, which will be the actor on the top of the focus actors stack.
-  FocusStack mFocusStack;
-  SlotDelegate< KeyInputFocusManager > mSlotDelegate;
-  ObjectRegistry mObjectRegistry;
+  Toolkit::Control mCurrentFocusControl; ///< The current focused control
 };
 
 } // namespace Internal
@@ -174,4 +156,4 @@ inline const Internal::KeyInputFocusManager& GetImpl(const Dali::Toolkit::KeyInp
 
 } // namespace Dali
 
-#endif // __DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H__
+#endif // DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H