2 * Copyright(c) 2021 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.
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
25 /// ScrollView contains views that can be scrolled manually (via touch).
27 public partial class ScrollView
29 private DaliEventHandler<object, SnapStartedEventArgs> scrollViewSnapStartedEventHandler;
30 private SnapStartedCallbackDelegate scrollViewSnapStartedCallbackDelegate;
32 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
33 private delegate void SnapStartedCallbackDelegate(IntPtr data);
36 /// SnapStarted can be used to subscribe or unsubscribe the event handler
37 /// The SnapStarted signal is emitted when the ScrollView has started to snap or flick (it tells the target
38 /// position, scale, rotation for the snap or flick).
40 [EditorBrowsable(EditorBrowsableState.Never)]
41 public event DaliEventHandler<object, SnapStartedEventArgs> SnapStarted
45 // Restricted to only one listener
46 if (scrollViewSnapStartedEventHandler == null)
48 scrollViewSnapStartedEventHandler += value;
50 scrollViewSnapStartedCallbackDelegate = new SnapStartedCallbackDelegate(OnSnapStarted);
51 ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal();
52 snapStarted?.Connect(scrollViewSnapStartedCallbackDelegate);
53 snapStarted?.Dispose();
59 if (scrollViewSnapStartedEventHandler != null)
61 ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal();
62 snapStarted?.Disconnect(scrollViewSnapStartedCallbackDelegate);
63 snapStarted?.Dispose();
66 scrollViewSnapStartedEventHandler -= value;
70 internal ScrollViewSnapStartedSignal SnapStartedSignal()
72 ScrollViewSnapStartedSignal ret = new ScrollViewSnapStartedSignal(Interop.ScrollView.SnapStartedSignal(SwigCPtr), false);
73 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77 // Callback for ScrollView SnapStarted signal
78 private void OnSnapStarted(IntPtr data)
80 SnapStartedEventArgs e = new SnapStartedEventArgs();
82 // Populate all members of "e" (SnapStartedEventArgs) with real data
83 e.SnapEventInfo = SnapEvent.GetSnapEventFromPtr(data);
85 if (scrollViewSnapStartedEventHandler != null)
87 //here we send all data to user event handlers
88 scrollViewSnapStartedEventHandler(this, e);
93 /// Snaps signal event's data.
95 [EditorBrowsable(EditorBrowsableState.Never)]
96 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
97 public class SnapEvent : Disposable
102 [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
103 [EditorBrowsable(EditorBrowsableState.Never)]
104 protected bool swigCMemOwn;
105 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
108 /// Create an instance of SnapEvent.
110 [EditorBrowsable(EditorBrowsableState.Never)]
111 public SnapEvent() : this(Interop.ScrollView.NewScrollViewSnapEvent(), true)
113 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116 internal SnapEvent(global::System.IntPtr cPtr, bool cMemoryOwn)
118 swigCMemOwn = cMemoryOwn;
119 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
125 [EditorBrowsable(EditorBrowsableState.Never)]
126 public Vector2 position
130 Interop.ScrollView.SnapEventPositionSet(swigCPtr, Vector2.getCPtr(value));
131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135 global::System.IntPtr cPtr = Interop.ScrollView.SnapEventPositionGet(swigCPtr);
136 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
145 [EditorBrowsable(EditorBrowsableState.Never)]
146 public float duration
150 Interop.ScrollView.SnapEventDurationSet(swigCPtr, value);
151 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155 float ret = Interop.ScrollView.SnapEventDurationGet(swigCPtr);
156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
161 internal SnapType type
165 Interop.ScrollView.SnapEventTypeSet(swigCPtr, (int)value);
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 SnapType ret = (SnapType)Interop.ScrollView.SnapEventTypeGet(swigCPtr);
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
177 /// Get SnapEvent From Ptr
179 [EditorBrowsable(EditorBrowsableState.Never)]
180 public static SnapEvent GetSnapEventFromPtr(global::System.IntPtr cPtr)
182 SnapEvent ret = new SnapEvent(cPtr, false);
183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 /// <param name="type">the dispose type</param>
191 [EditorBrowsable(EditorBrowsableState.Never)]
192 protected override void Dispose(DisposeTypes type)
199 //Release your own unmanaged resources here.
200 //You should not access any managed member here except static instance.
201 //because the execution order of Finalizes is non-deterministic.
203 if (swigCPtr.Handle != global::System.IntPtr.Zero)
208 Interop.ScrollView.DeleteScrollViewSnapEvent(swigCPtr);
210 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
219 /// Event arguments that passed via the SnapStarted signal.
221 [EditorBrowsable(EditorBrowsableState.Never)]
222 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
223 public class SnapStartedEventArgs : EventArgs
225 private Tizen.NUI.ScrollView.SnapEvent snapEvent;
228 /// SnapEventInfo is the SnapEvent information like snap or flick (it tells the target position, scale, rotation for the snap or flick).
230 [EditorBrowsable(EditorBrowsableState.Never)]
231 public Tizen.NUI.ScrollView.SnapEvent SnapEventInfo