2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 %define KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
27 %define KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
28 %typemap(cscode) NameSpace::ClassName %{
31 * @brief Event arguments that passed via FocusChanged signal
34 public class FocusChangedEventArgs : EventArgs
36 private Actor _actorCurrent;
37 private Actor _actorNext;
40 * @brief Actor - is the original focused Actor
43 public Actor ActorCurrent
51 _actorCurrent = value;
56 * @brief Actor - is the current focused Actor
59 public Actor ActorNext
73 * @brief Event arguments that passed via FocusGroupChanged signal
76 public class FocusGroupChangedEventArgs : EventArgs
78 private Actor _currentFocusedActor;
79 private bool _forwardDirection;
82 * @brief Actor - is the current focused Actor
85 public Actor CurrentFocusedActor
89 return _currentFocusedActor;
93 _currentFocusedActor = value;
98 * @brief ForwardDirection - is the direction (forward or backward) in which to move the focus next
101 public bool ForwardDirection
105 return _forwardDirection;
109 _forwardDirection = value;
115 * @brief Event arguments that passed via FocusedActorEnterKey signal
118 public class FocusedActorEnterKeyEventArgs : EventArgs
120 private Actor _actor;
123 * @brief Actor - is the current focused Actor which has the enter key pressed on it.
139 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
140 private delegate void FocusChangedEventCallbackDelegate(IntPtr actorCurrent, IntPtr actorNext);
141 private DaliEventHandler<object,FocusChangedEventArgs> _keyboardFocusManagerFocusChangedEventHandler;
142 private FocusChangedEventCallbackDelegate _keyboardFocusManagerFocusChangedEventCallbackDelegate;
144 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
145 private delegate void FocusGroupChangedEventCallbackDelegate(IntPtr currentFocusedActor, bool forwardDirection);
146 private DaliEventHandler<object,FocusGroupChangedEventArgs> _keyboardFocusManagerFocusGroupChangedEventHandler;
147 private FocusGroupChangedEventCallbackDelegate _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate;
149 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
150 private delegate void FocusedActorEnterKeyEventCallbackDelegate(IntPtr actor);
151 private DaliEventHandler<object,FocusedActorEnterKeyEventArgs> _keyboardFocusManagerFocusedActorEnterKeyEventHandler;
152 private FocusedActorEnterKeyEventCallbackDelegate _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate;
155 * @brief Event for FocusChanged signal which can be used to subscribe/unsubscribe the event handler
156 * (in the type of FocusChangedEventHandler-DaliEventHandler<object,FocusChangedEventArgs>) provided by the user.
157 * FocusChanged signal is emitted after the current focused actor has been changed.
159 public event DaliEventHandler<object,FocusChangedEventArgs> FocusChanged
165 // Restricted to only one listener
166 if (_keyboardFocusManagerFocusChangedEventHandler == null)
168 _keyboardFocusManagerFocusChangedEventHandler += value;
170 _keyboardFocusManagerFocusChangedEventCallbackDelegate = new FocusChangedEventCallbackDelegate(OnFocusChanged);
171 this.FocusChangedSignal().Connect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
180 if (_keyboardFocusManagerFocusChangedEventHandler != null)
182 this.FocusChangedSignal().Disconnect(_keyboardFocusManagerFocusChangedEventCallbackDelegate);
185 _keyboardFocusManagerFocusChangedEventHandler -= value;
190 // Callback for KeyboardFocusManager FocusChangedSignal
191 private void OnFocusChanged(IntPtr actorCurrent, IntPtr actorNext)
193 FocusChangedEventArgs e = new FocusChangedEventArgs();
195 // Populate all members of "e" (FocusChangedEventArgs) with real data
196 e.ActorCurrent = Actor.GetActorFromPtr(actorCurrent);
197 e.ActorNext = Actor.GetActorFromPtr(actorNext);
199 if (_keyboardFocusManagerFocusChangedEventHandler != null)
201 //here we send all data to user event handlers
202 _keyboardFocusManagerFocusChangedEventHandler(this, e);
207 * @brief Event for FocusGroupChanged signal which can be used to subscribe/unsubscribe the event handler
208 * (in the type of FocusGroupChangedEventHandler-DaliEventHandler<object,FocusGroupChangedEventArgs>)
209 * provided by the user. FocusGroupChanged signal is emitted when the focus group has been changed.
211 public event DaliEventHandler<object,FocusGroupChangedEventArgs> FocusGroupChanged
217 // Restricted to only one listener
218 if (_keyboardFocusManagerFocusGroupChangedEventHandler == null)
220 _keyboardFocusManagerFocusGroupChangedEventHandler += value;
222 _keyboardFocusManagerFocusGroupChangedEventCallbackDelegate = new FocusGroupChangedEventCallbackDelegate(OnFocusGroupChanged);
223 this.FocusGroupChangedSignal().Connect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
232 if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
234 this.FocusGroupChangedSignal().Disconnect(_keyboardFocusManagerFocusGroupChangedEventCallbackDelegate);
237 _keyboardFocusManagerFocusGroupChangedEventHandler -= value;
242 // Callback for KeyboardFocusManager FocusGroupChangedSignal
243 private void OnFocusGroupChanged(IntPtr currentFocusedActor, bool forwardDirection)
245 FocusGroupChangedEventArgs e = new FocusGroupChangedEventArgs();
247 // Populate all members of "e" (FocusGroupChangedEventArgs) with real data
248 e.CurrentFocusedActor = Actor.GetActorFromPtr(currentFocusedActor);
249 e.ForwardDirection = forwardDirection;
251 if (_keyboardFocusManagerFocusGroupChangedEventHandler != null)
253 //here we send all data to user event handlers
254 _keyboardFocusManagerFocusGroupChangedEventHandler(this, e);
259 * @brief Event for FocusedActorEnterKeyPressed signal which can be used to subscribe/unsubscribe the event handler
260 * (in the type of FocusedActorEnterKeyEventHandler-DaliEventHandler<object,FocusedActorEnterKeyEventArgs>) provided by the user.
261 * FocusedActorEnterKeyPressed signal is emitted when the current focused actor has the enter key pressed on it.
263 public event DaliEventHandler<object,FocusedActorEnterKeyEventArgs> FocusedActorEnterKeyPressed
269 // Restricted to only one listener
270 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler == null)
272 _keyboardFocusManagerFocusedActorEnterKeyEventHandler += value;
274 _keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate = new FocusedActorEnterKeyEventCallbackDelegate(OnFocusedActorEnterKey);
275 this.FocusedActorEnterKeySignal().Connect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
284 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
286 this.FocusedActorEnterKeySignal().Disconnect(_keyboardFocusManagerFocusedActorEnterKeyEventCallbackDelegate);
289 _keyboardFocusManagerFocusedActorEnterKeyEventHandler -= value;
294 // Callback for KeyboardFocusManager FocusedActorEnterKeySignal
295 private void OnFocusedActorEnterKey(IntPtr actor)
297 FocusedActorEnterKeyEventArgs e = new FocusedActorEnterKeyEventArgs();
299 // Populate all members of "e" (FocusedActorEnterKeyEventArgs) with real data
300 e.Actor = Actor.GetActorFromPtr(actor);
302 if (_keyboardFocusManagerFocusedActorEnterKeyEventHandler != null)
304 //here we send all data to user event handlers
305 _keyboardFocusManagerFocusedActorEnterKeyEventHandler(this, e);
312 %define DALI_KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_PARAM( NameSpace, ClassName)
313 KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
314 KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
319 DALI_KEYBOARD_FOCUS_MANAGER_EVENTHANDLER_PARAM( Dali::Toolkit, KeyboardFocusManager);