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 SCROLLVIEW_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define SCROLLVIEW_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
30 * @brief Event arguments that passed via SnapStarted signal
33 public class SnapStartedEventArgs : EventArgs
35 private Dali.ScrollView.SnapEvent _snapEvent;
38 * @brief SnapEvent - is the SnapEvent information like snap or flick (it tells the target position, scale, rotation for the snap or flick).
41 public Dali.ScrollView.SnapEvent SnapEventInfo
55 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
56 public delegate void SnapStartedEventHandler(object source, SnapStartedEventArgs e);
58 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
59 private delegate void SnapStartedCallbackDelegate(IntPtr data);
60 private SnapStartedEventHandler _scrollViewSnapStartedEventHandler;
61 private SnapStartedCallbackDelegate _scrollViewSnapStartedCallbackDelegate;
64 * @brief Event for SnapStarted signal which can be used to subscribe/unsubscribe the event handler
65 * (in the type of SnapStartedEventHandler) provided by the user.
66 * SnapStarted signal is emitted hen the ScrollView has started to snap or flick (it tells the target
67 * position, scale, rotation for the snap or flick).
70 public event SnapStartedEventHandler SnapStarted
76 // Restricted to only one listener
77 if (_scrollViewSnapStartedEventHandler == null)
79 _scrollViewSnapStartedEventHandler += value;
81 _scrollViewSnapStartedCallbackDelegate = new SnapStartedCallbackDelegate(OnSnapStarted);
82 this.SnapStartedSignal().Connect(_scrollViewSnapStartedCallbackDelegate);
91 if (_scrollViewSnapStartedEventHandler != null)
93 this.SnapStartedSignal().Disconnect(_scrollViewSnapStartedCallbackDelegate);
96 _scrollViewSnapStartedEventHandler -= value;
101 // Callback for ScrollView SnapStarted signal
102 private void OnSnapStarted(IntPtr data)
104 SnapStartedEventArgs e = new SnapStartedEventArgs();
106 // Populate all members of "e" (SnapStartedEventArgs) with real data
107 e.SnapEventInfo = SnapEvent.GetSnapEventFromPtr( data );
109 if (_scrollViewSnapStartedEventHandler != null)
111 //here we send all data to user event handlers
112 _scrollViewSnapStartedEventHandler(this, e);
121 %define DALI_SCROLLVIEW_EVENTHANDLER_PARAM( NameSpace, ClassName)
123 SCROLLVIEW_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
124 SCROLLVIEW_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
130 DALI_SCROLLVIEW_EVENTHANDLER_PARAM( Dali::Toolkit, ScrollView);