Add null check for mTextureSet.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / focus-manager / keyinput-focus-manager-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H
2 #define DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <dali/public-api/object/base-object.h>
24 #include <dali/public-api/object/object-registry.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
28 #include <dali-toolkit/public-api/controls/control.h>
29
30 namespace Dali
31 {
32
33 namespace Integration
34 {
35
36 class SceneHolder;
37
38 } // namespace Integration
39
40 namespace Toolkit
41 {
42
43 namespace Internal
44 {
45
46 class KeyInputFocusManager;
47
48 /**
49  * @copydoc Toolkit::KeyInputFocusManager
50  */
51 class KeyInputFocusManager : public Dali::BaseObject, public Dali::ConnectionTracker
52 {
53 public:
54   /**
55    * Construct a new KeyInputFocusManager.
56    */
57   KeyInputFocusManager();
58
59   /**
60    * @copydoc Toolkit::SetFocus
61    */
62   void SetFocus(Toolkit::Control control);
63
64   /**
65    * @copydoc Toolkit::RemoveFocus
66    */
67   void RemoveFocus(Toolkit::Control control);
68
69   /**
70    * @copydoc Toolkit::GetCurrentFocusControl
71    */
72   Toolkit::Control GetCurrentFocusControl() const;
73
74 public:
75
76   /**
77    * @copydoc Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignal()
78    */
79   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType& KeyInputFocusChangedSignal();
80
81   /**
82    * Connects a callback function with the object's signals.
83    * @param[in] object The object providing the signal.
84    * @param[in] tracker Used to disconnect the signal.
85    * @param[in] signalName The signal to connect to.
86    * @param[in] functor A newly allocated FunctorDelegate.
87    * @return True if the signal was connected.
88    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
89    */
90   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
91
92 protected:
93
94   /**
95    * Destructor
96    */
97   virtual ~KeyInputFocusManager();
98
99 private:
100   /**
101    * This will be called when a new scene holder is created
102    * @param sceneHolder The new scene holder
103    */
104   void OnSceneHolderCreated( Dali::Integration::SceneHolder& sceneHolder );
105
106   /**
107    * Callback for the key event when no actor in the stage has gained the key input focus
108    * @param[in] event The KeyEvent event.
109    */
110   bool OnKeyEvent(const KeyEvent& event);
111
112   /**
113    * Signal handler called when a focused Control is removed from Scene.
114    * @param[in]  control  The control removed from the scene.
115    */
116   void OnFocusControlSceneDisconnection( Dali::Actor control );
117
118   /**
119     *  Recursively deliver events to the control and its parents, until the event is consumed or the stage is reached.
120    * @param[in]  control  The control got KeyEvent.
121    * @param[in]  event    The KeyEvent.
122    * @return True if KeyEvent is consumed.
123     */
124   bool EmitKeyEventSignal( Toolkit::Control control, const KeyEvent& event );
125
126 private:
127
128   // Undefined
129   KeyInputFocusManager(const KeyInputFocusManager&);
130
131   KeyInputFocusManager& operator=(const KeyInputFocusManager& rhs);
132
133 private:
134
135   // The key input focus change signal
136   Toolkit::KeyInputFocusManager::KeyInputFocusChangedSignalType mKeyInputFocusChangedSignal;
137
138   SlotDelegate< KeyInputFocusManager > mSlotDelegate;
139
140   Toolkit::Control mCurrentFocusControl; ///< The current focused control
141 };
142
143 } // namespace Internal
144
145 inline Internal::KeyInputFocusManager& GetImpl(Dali::Toolkit::KeyInputFocusManager& obj)
146 {
147   DALI_ASSERT_ALWAYS(obj);
148
149   Dali::BaseObject& handle = obj.GetBaseObject();
150
151   return static_cast<Internal::KeyInputFocusManager&>(handle);
152 }
153
154 inline const Internal::KeyInputFocusManager& GetImpl(const Dali::Toolkit::KeyInputFocusManager& obj)
155 {
156   DALI_ASSERT_ALWAYS(obj);
157
158   const Dali::BaseObject& handle = obj.GetBaseObject();
159
160   return static_cast<const Internal::KeyInputFocusManager&>(handle);
161 }
162
163 } // namespace Toolkit
164
165 } // namespace Dali
166
167 #endif // DALI_TOOLKIT_INTERNAL_KEYINPUT_FOCUS_MANAGER_H