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 STAGE_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define STAGE_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
30 * @brief Event arguments that passed via Touch signal
33 public class TouchEventArgs : EventArgs
35 private TouchData _touchData;
38 * @brief TouchData - contains the information of touch points
41 public TouchData TouchData
56 * @brief Event arguments that passed via Wheel signal
59 public class WheelEventArgs : EventArgs
61 private WheelEvent _wheelEvent;
64 * @brief WheelEvent - store a wheel rolling type MOUSE_WHEEL or CUSTOM_WHEEL
67 public WheelEvent WheelEvent
81 * @brief Event arguments that passed via KeyEvent signal
84 public class KeyEventArgs : EventArgs
86 private KeyEvent _keyEvent;
89 * @brief KeyEvent - is the keyevent sent to Stage.
92 public KeyEvent KeyEvent
106 * @brief Event arguments that passed via EventProcessingFinished signal
109 public class EventProcessingFinishedEventArgs : EventArgs
114 * @brief Event arguments that passed via ContextLost signal
117 public class ContextLostEventArgs : EventArgs
122 * @brief Event arguments that passed via ContextRegained signal
125 public class ContextRegainedEventArgs : EventArgs
130 * @brief Event arguments that passed via SceneCreated signal
133 public class SceneCreatedEventArgs : EventArgs
137 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
138 public delegate void TouchEventHandler(object source, TouchEventArgs e);
140 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
141 public delegate void WheelEventHandler(object source, WheelEventArgs e);
143 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
144 public delegate void KeyEventHandler(object source, KeyEventArgs e);
146 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
147 public delegate void EventProcessingFinishedEventHandler(object source, EventProcessingFinishedEventArgs e);
149 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
150 public delegate void ContextLostEventHandler(object source, ContextLostEventArgs e);
152 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
153 public delegate void ContextRegainedEventHandler(object source, ContextRegainedEventArgs e);
155 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
156 public delegate void SceneCreatedEventHandler(object source, SceneCreatedEventArgs e);
158 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
159 private delegate void StageTouchCallbackDelegate(IntPtr data);
160 private TouchEventHandler _stageTouchEventHandler;
161 private StageTouchCallbackDelegate _stageTouchCallbackDelegate;
163 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
164 private delegate void WheelCallbackDelegate(IntPtr data);
165 private WheelEventHandler _stageWheelEventHandler;
166 private WheelCallbackDelegate _stageWheelCallbackDelegate;
168 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
169 private delegate void KeyCallbackDelegate(IntPtr data);
170 private KeyEventHandler _stageKeyEventHandler;
171 private KeyCallbackDelegate _stageKeyCallbackDelegate;
173 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
174 private delegate void EventProcessingFinishedEventCallbackDelegate();
175 private EventProcessingFinishedEventHandler _stageEventProcessingFinishedEventHandler;
176 private EventProcessingFinishedEventCallbackDelegate _stageEventProcessingFinishedEventCallbackDelegate;
178 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
179 private delegate void ContextLostEventCallbackDelegate();
180 private ContextLostEventHandler _stageContextLostEventHandler;
181 private ContextLostEventCallbackDelegate _stageContextLostEventCallbackDelegate;
183 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
184 private delegate void ContextRegainedEventCallbackDelegate();
185 private ContextRegainedEventHandler _stageContextRegainedEventHandler;
186 private ContextRegainedEventCallbackDelegate _stageContextRegainedEventCallbackDelegate;
188 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
189 private delegate void SceneCreatedEventCallbackDelegate();
190 private SceneCreatedEventHandler _stageSceneCreatedEventHandler;
191 private SceneCreatedEventCallbackDelegate _stageSceneCreatedEventCallbackDelegate;
194 * @brief Event for Touched signal which can be used to subscribe/unsubscribe the event handler
195 * (in the type of TouchEventHandler) provided by the user.
196 * Touched signal is emitted when the screen is touched and when the touch ends
197 * (i.e. the down & up touch events only).
200 public event TouchEventHandler Touched
206 // Restricted to only one listener
207 if (_stageTouchEventHandler == null)
209 _stageTouchEventHandler += value;
211 _stageTouchCallbackDelegate = new StageTouchCallbackDelegate(OnStageTouch);
212 this.TouchSignal().Connect(_stageTouchCallbackDelegate);
221 if (_stageTouchEventHandler != null)
223 this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
226 _stageTouchEventHandler -= value;
231 // Callback for Stage Touch signal
232 private void OnStageTouch(IntPtr data)
234 TouchEventArgs e = new TouchEventArgs();
236 // Populate all members of "e" (TouchEventArgs) with real data
237 e.TouchData = TouchData.GetTouchDataFromPtr( data );
239 if (_stageTouchEventHandler != null)
241 //here we send all data to user event handlers
242 _stageTouchEventHandler(this, e);
247 * @brief Event for WheelMoved signal which can be used to subscribe/unsubscribe the event handler
248 * (in the type of WheelEventHandler) provided by the user.
249 * WheelMoved signal is emitted is emitted when wheel event is received.
252 public event WheelEventHandler WheelMoved
258 // Restricted to only one listener
259 if (_stageWheelEventHandler == null)
261 _stageWheelEventHandler += value;
263 _stageWheelCallbackDelegate = new WheelCallbackDelegate(OnStageWheel);
264 this.WheelEventSignal().Connect(_stageWheelCallbackDelegate);
273 if (_stageWheelEventHandler != null)
275 this.WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
278 _stageWheelEventHandler -= value;
283 // Callback for Stage WheelEventsignal
284 private void OnStageWheel(IntPtr data)
286 WheelEventArgs e = new WheelEventArgs();
288 // Populate all members of "e" (WheelEventArgs) with real data
289 e.WheelEvent = Dali.WheelEvent.GetWheelEventFromPtr( data );
291 if (_stageWheelEventHandler != null)
293 //here we send all data to user event handlers
294 _stageWheelEventHandler(this, e);
299 * @brief Event for KeyPressed signal which can be used to subscribe/unsubscribe the event handler
300 * (in the type of KeyEventHandler) provided by the user.
301 * KeyPressed signal is emitted is emitted when key event is received.
304 public event KeyEventHandler KeyPressed
310 // Restricted to only one listener
311 if (_stageKeyEventHandler == null)
313 _stageKeyEventHandler += value;
315 _stageKeyCallbackDelegate = new KeyCallbackDelegate(OnStageKey);
316 this.KeyEventSignal().Connect(_stageKeyCallbackDelegate);
325 if (_stageKeyEventHandler != null)
327 this.KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
330 _stageKeyEventHandler -= value;
335 // Callback for Stage KeyEventsignal
336 private void OnStageKey(IntPtr keyEvent)
338 KeyEventArgs e = new KeyEventArgs();
340 // Populate all members of "e" (KeyEventArgs) with real data
341 e.KeyEvent = Dali.KeyEvent.GetKeyEventFromPtr( keyEvent );
343 if (_stageKeyEventHandler != null)
345 //here we send all data to user event handlers
346 _stageKeyEventHandler(this, e);
351 * @brief Event for EventProcessingFinished signal which can be used to subscribe/unsubscribe the event handler
352 * (in the type of EventProcessingFinishedEventHandler) provided by the user.
353 * EventProcessingFinished signal is emitted just after the event processing is finished.
356 public event EventProcessingFinishedEventHandler EventProcessingFinished
362 // Restricted to only one listener
363 if (_stageEventProcessingFinishedEventHandler == null)
365 _stageEventProcessingFinishedEventHandler += value;
367 _stageEventProcessingFinishedEventCallbackDelegate = new EventProcessingFinishedEventCallbackDelegate(OnEventProcessingFinished);
368 this.EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
377 if (_stageEventProcessingFinishedEventHandler != null)
379 this.EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
382 _stageEventProcessingFinishedEventHandler -= value;
387 // Callback for Stage EventProcessingFinishedSignal
388 private void OnEventProcessingFinished()
390 EventProcessingFinishedEventArgs e = new EventProcessingFinishedEventArgs();
392 if (_stageEventProcessingFinishedEventHandler != null)
394 //here we send all data to user event handlers
395 _stageEventProcessingFinishedEventHandler(this, e);
400 * @brief Event for ContextLost signal which can be used to subscribe/unsubscribe the event handler
401 * (in the type of ContextLostEventHandler) provided by the user.
402 * ContextLost signal is emitted when the GL context is lost (Platform specific behaviour).
405 public event ContextLostEventHandler ContextLost
411 // Restricted to only one listener
412 if (_stageContextLostEventHandler == null)
414 _stageContextLostEventHandler += value;
416 _stageContextLostEventCallbackDelegate = new ContextLostEventCallbackDelegate(OnContextLost);
417 this.ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
426 if (_stageContextLostEventHandler != null)
428 this.ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
431 _stageContextLostEventHandler -= value;
436 // Callback for Stage ContextLostSignal
437 private void OnContextLost()
439 ContextLostEventArgs e = new ContextLostEventArgs();
441 if (_stageContextLostEventHandler != null)
443 //here we send all data to user event handlers
444 _stageContextLostEventHandler(this, e);
449 * @brief Event for ContextRegained signal which can be used to subscribe/unsubscribe the event handler
450 * (in the type of ContextRegainedEventHandler) provided by the user.
451 * ContextRegained signal is emitted when the GL context is regained (Platform specific
455 public event ContextRegainedEventHandler ContextRegained
461 // Restricted to only one listener
462 if (_stageContextRegainedEventHandler == null)
464 _stageContextRegainedEventHandler += value;
466 _stageContextRegainedEventCallbackDelegate = new ContextRegainedEventCallbackDelegate(OnContextRegained);
467 this.ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
476 if (_stageContextRegainedEventHandler != null)
478 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
481 _stageContextRegainedEventHandler -= value;
486 // Callback for Stage ContextRegainedSignal
487 private void OnContextRegained()
489 ContextRegainedEventArgs e = new ContextRegainedEventArgs();
491 if (_stageContextRegainedEventHandler != null)
493 //here we send all data to user event handlers
494 _stageContextRegainedEventHandler(this, e);
499 * @brief Event for SceneCreated signal which can be used to subscribe/unsubscribe the event handler
500 * (in the type of SceneCreatedEventHandler) provided by the user.
501 * SceneCreated signal is emitted after the initial scene is created.
504 public event SceneCreatedEventHandler SceneCreated
510 // Restricted to only one listener
511 if (_stageSceneCreatedEventHandler == null)
513 _stageSceneCreatedEventHandler += value;
515 _stageSceneCreatedEventCallbackDelegate = new SceneCreatedEventCallbackDelegate(OnSceneCreated);
516 this.SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
525 if (_stageSceneCreatedEventHandler != null)
527 this.SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
530 _stageSceneCreatedEventHandler -= value;
535 // Callback for Stage SceneCreatedSignal
536 private void OnSceneCreated()
538 SceneCreatedEventArgs e = new SceneCreatedEventArgs();
540 if (_stageSceneCreatedEventHandler != null)
542 //here we send all data to user event handlers
543 _stageSceneCreatedEventHandler(this, e);
551 Vector2 ret = GetSize();
556 public Vector4 BackgroundColor
560 SetBackgroundColor(value);
564 Vector4 ret = GetBackgroundColor();
574 %define DALI_STAGE_EVENTHANDLER_PARAM( NameSpace, ClassName)
576 STAGE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
577 STAGE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
583 DALI_STAGE_EVENTHANDLER_PARAM( Dali, Stage);