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 %{
31 * @brief Event arguments that passed via Touch signal
34 public class TouchEventArgs : EventArgs
39 * @brief Touch - contains the information of touch points
55 private event EventHandler<TouchEventArgs> _stageTouchHandler;
56 private EventCallbackDelegateType1<IntPtr> _stageTouchCallbackDelegate;
59 * @brief Event for TouchEvent signal which can be used to subscribe/unsubscribe the event handler
60 * TouchEvent signal is emitted when the screen is touched and when the touch ends
61 * (i.e. the down & up touch events only).
64 public event EventHandler<TouchEventArgs> Touch
70 _stageTouchHandler += value;
71 _stageTouchCallbackDelegate = OnStageTouch;
72 this.TouchSignal().Connect(_stageTouchCallbackDelegate);
79 if (_stageTouchHandler != null)
81 this.TouchSignal().Disconnect(_stageTouchCallbackDelegate);
83 _stageTouchHandler -= value;
88 private void OnStageTouch(IntPtr data)
90 TouchEventArgs e = new TouchEventArgs();
94 e.Touch = Dali.Touch.GetTouchFromPtr( data );
97 if (_stageTouchHandler != null)
99 _stageTouchHandler(this, e);
104 * @brief Wheel arguments that passed via Wheel signal
107 public class WheelEventArgs : EventArgs
109 private Wheel _wheel;
112 * @brief Wheel - store a wheel rolling type MOUSE_WHEEL or CUSTOM_WHEEL
128 private event EventHandler<WheelEventArgs> _stageWheelHandler;
129 private EventCallbackDelegateType1<IntPtr> _stageWheelCallbackDelegate;
132 * @brief Event for Wheel signal which can be used to subscribe/unsubscribe the event handler
133 * Wheel signal is emitted is emitted when wheel event is received.
136 public event EventHandler<WheelEventArgs> Wheel
142 _stageWheelHandler += value;
143 _stageWheelCallbackDelegate = OnStageWheel;
144 this.WheelEventSignal().Connect(_stageWheelCallbackDelegate);
151 if (_stageWheelHandler != null)
153 this.WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
155 _stageWheelHandler -= value;
160 private void OnStageWheel(IntPtr data)
162 WheelEventArgs e = new WheelEventArgs();
166 e.Wheel = Dali.Wheel.GetWheelFromPtr( data );
169 if (_stageWheelHandler != null)
171 _stageWheelHandler(this, e);
176 * @brief Event arguments that passed via Key signal
179 public class KeyEventArgs : EventArgs
184 * @brief Key - is the keyevent sent to Stage.
200 private event EventHandler<KeyEventArgs> _stageKeyHandler;
201 private EventCallbackDelegateType1<IntPtr> _stageKeyCallbackDelegate;
204 * @brief Event for Key signal which can be used to subscribe/unsubscribe the event handler
205 * Key signal is emitted is emitted when key event is received.
208 public event EventHandler<KeyEventArgs> Key
214 _stageKeyHandler += value;
215 _stageKeyCallbackDelegate = OnStageKey;
216 this.KeyEventSignal().Connect(_stageKeyCallbackDelegate);
223 if (_stageKeyHandler != null)
225 this.KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
227 _stageKeyHandler -= value;
232 // Callback for Stage KeyEventsignal
233 private void OnStageKey(IntPtr data)
235 KeyEventArgs e = new KeyEventArgs();
239 e.Key = Dali.Key.GetKeyFromPtr( data );
242 if (_stageKeyHandler != null)
244 //here we send all data to user event handlers
245 _stageKeyHandler(this, e);
250 private event EventHandler _stageEventProcessingFinishedEventHandler;
251 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
254 * @brief Event for EventProcessingFinished signal which can be used to subscribe/unsubscribe the event handler
255 * provided by the user. EventProcessingFinished signal is emitted just after the event processing is finished.
258 public event EventHandler EventProcessingFinished
264 _stageEventProcessingFinishedEventHandler += value;
265 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
266 this.EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
273 if (_stageEventProcessingFinishedEventHandler != null)
275 this.EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
277 _stageEventProcessingFinishedEventHandler -= value;
282 // Callback for Stage EventProcessingFinishedSignal
283 private void OnEventProcessingFinished()
285 if (_stageEventProcessingFinishedEventHandler != null)
287 _stageEventProcessingFinishedEventHandler(this, null);
292 private EventHandler _stageContextLostEventHandler;
293 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
296 * @brief Event for ContextLost signal which can be used to subscribe/unsubscribe the event handler
297 * ContextLost signal is emitted when the GL context is lost (Platform specific behaviour).
300 public event EventHandler ContextLost
306 _stageContextLostEventHandler += value;
307 _stageContextLostEventCallbackDelegate = OnContextLost;
308 this.ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
315 if (_stageContextLostEventHandler != null)
317 this.ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
320 _stageContextLostEventHandler -= value;
325 // Callback for Stage ContextLostSignal
326 private void OnContextLost()
328 if (_stageContextLostEventHandler != null)
330 _stageContextLostEventHandler(this, null);
335 private EventHandler _stageContextRegainedEventHandler;
336 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
339 * @brief Event for ContextRegained signal which can be used to subscribe/unsubscribe the event handler
340 * provided by the user. ContextRegained signal is emitted when the GL context is regained (Platform specific
344 public event EventHandler ContextRegained
350 _stageContextRegainedEventHandler += value;
351 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
352 this.ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
359 if (_stageContextRegainedEventHandler != null)
361 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
364 _stageContextRegainedEventHandler -= value;
369 // Callback for Stage ContextRegainedSignal
370 private void OnContextRegained()
372 if (_stageContextRegainedEventHandler != null)
374 _stageContextRegainedEventHandler(this, null);
379 private EventHandler _stageSceneCreatedEventHandler;
380 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
383 * @brief Event for SceneCreated signal which can be used to subscribe/unsubscribe the event handler
384 * SceneCreated signal is emitted after the initial scene is created.
387 public event EventHandler SceneCreated
393 _stageSceneCreatedEventHandler += value;
394 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
395 this.SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
402 if (_stageSceneCreatedEventHandler != null)
404 this.SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
407 _stageSceneCreatedEventHandler -= value;
412 // Callback for Stage SceneCreatedSignal
413 private void OnSceneCreated()
415 if (_stageSceneCreatedEventHandler != null)
417 _stageSceneCreatedEventHandler(this, null);
426 Vector2 ret = GetSize();
431 public Vector4 BackgroundColor
435 SetBackgroundColor(value);
439 Vector4 ret = GetBackgroundColor();
444 private static readonly Stage instance = Stage.GetCurrent();
446 public static Stage Instance
454 public Layer GetDefaultLayer()
456 return this.GetRootLayer();
459 public void AddLayer(Layer layer)
461 this.Add( (Actor)layer );
464 public void RemoveLayer(Layer layer)
466 this.Remove( (Actor)layer );
475 %define DALI_STAGE_EVENTHANDLER_PARAM( NameSpace, ClassName)
477 STAGE_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
478 STAGE_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
484 DALI_STAGE_EVENTHANDLER_PARAM( Dali, Stage);