2 * Copyright(c) 2019 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 /// <since_tizen> 3 </since_tizen>
28 public partial class ScrollView
30 private DaliEventHandler<object, SnapStartedEventArgs> _scrollViewSnapStartedEventHandler;
31 private SnapStartedCallbackDelegate _scrollViewSnapStartedCallbackDelegate;
33 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
34 private delegate void SnapStartedCallbackDelegate(IntPtr data);
37 /// SnapStarted can be used to subscribe or unsubscribe the event handler
38 /// The SnapStarted signal is emitted when the ScrollView has started to snap or flick (it tells the target
39 /// position, scale, rotation for the snap or flick).
41 /// <since_tizen> 3 </since_tizen>
42 /// This will be deprecated
43 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
44 [EditorBrowsable(EditorBrowsableState.Never)]
45 public event DaliEventHandler<object, SnapStartedEventArgs> SnapStarted
49 // Restricted to only one listener
50 if (_scrollViewSnapStartedEventHandler == null)
52 _scrollViewSnapStartedEventHandler += value;
54 _scrollViewSnapStartedCallbackDelegate = new SnapStartedCallbackDelegate(OnSnapStarted);
55 ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal();
56 snapStarted?.Connect(_scrollViewSnapStartedCallbackDelegate);
57 snapStarted?.Dispose();
63 if (_scrollViewSnapStartedEventHandler != null)
65 ScrollViewSnapStartedSignal snapStarted = this.SnapStartedSignal();
66 snapStarted?.Disconnect(_scrollViewSnapStartedCallbackDelegate);
67 snapStarted?.Dispose();
70 _scrollViewSnapStartedEventHandler -= value;
74 internal ScrollViewSnapStartedSignal SnapStartedSignal()
76 ScrollViewSnapStartedSignal ret = new ScrollViewSnapStartedSignal(Interop.ScrollView.SnapStartedSignal(SwigCPtr), false);
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 // Callback for ScrollView SnapStarted signal
82 private void OnSnapStarted(IntPtr data)
84 SnapStartedEventArgs e = new SnapStartedEventArgs();
86 // Populate all members of "e" (SnapStartedEventArgs) with real data
87 e.SnapEventInfo = SnapEvent.GetSnapEventFromPtr(data);
89 if (_scrollViewSnapStartedEventHandler != null)
91 //here we send all data to user event handlers
92 _scrollViewSnapStartedEventHandler(this, e);
97 /// Snaps signal event's data.
99 /// <since_tizen> 3 </since_tizen>
100 /// This will be deprecated
101 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
102 [EditorBrowsable(EditorBrowsableState.Never)]
103 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
104 public class SnapEvent : Disposable
109 /// <since_tizen> 3 </since_tizen>
110 /// It will be removed in API9
111 // ToDo : will proceed ACR as private bool swigCMemOwn;
112 [global::System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1051:Do not declare visible instance fields")]
113 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
114 [EditorBrowsable(EditorBrowsableState.Never)]
115 protected bool swigCMemOwn;
116 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
119 /// Create an instance of SnapEvent.
121 /// <since_tizen> 3 </since_tizen>
122 /// This will be deprecated
123 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public SnapEvent() : this(Interop.ScrollView.NewScrollViewSnapEvent(), true)
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 internal SnapEvent(global::System.IntPtr cPtr, bool cMemoryOwn)
132 swigCMemOwn = cMemoryOwn;
133 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
139 /// <since_tizen> 3 </since_tizen>
140 /// This will be deprecated
141 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
142 [EditorBrowsable(EditorBrowsableState.Never)]
143 public Vector2 position
147 Interop.ScrollView.SnapEventPositionSet(swigCPtr, Vector2.getCPtr(value));
148 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152 global::System.IntPtr cPtr = Interop.ScrollView.SnapEventPositionGet(swigCPtr);
153 Vector2 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector2(cPtr, false);
154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
162 /// <since_tizen> 3 </since_tizen>
163 /// This will be deprecated
164 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
165 [EditorBrowsable(EditorBrowsableState.Never)]
166 public float duration
170 Interop.ScrollView.SnapEventDurationSet(swigCPtr, value);
171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
175 float ret = Interop.ScrollView.SnapEventDurationGet(swigCPtr);
176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
181 internal SnapType type
185 Interop.ScrollView.SnapEventTypeSet(swigCPtr, (int)value);
186 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 SnapType ret = (SnapType)Interop.ScrollView.SnapEventTypeGet(swigCPtr);
191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 /// Get SnapEvent From Ptr
199 /// <since_tizen> 3 </since_tizen>
200 /// This will be deprecated
201 [Obsolete("Deprecated in API6, Will be removed in API9, " +
202 "Please use SnapStarted event instead!" +
203 "IntPtr(native integer pointer) is supposed to be not used in Application!")]
204 [EditorBrowsable(EditorBrowsableState.Never)]
205 public static SnapEvent GetSnapEventFromPtr(global::System.IntPtr cPtr)
207 SnapEvent ret = new SnapEvent(cPtr, false);
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
212 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SnapEvent obj)
214 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
220 /// <param name="type">the dispose type</param>
221 /// <since_tizen> 3 </since_tizen>
222 /// This will be deprecated
223 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
224 [EditorBrowsable(EditorBrowsableState.Never)]
225 protected override void Dispose(DisposeTypes type)
232 //Release your own unmanaged resources here.
233 //You should not access any managed member here except static instance.
234 //because the execution order of Finalizes is non-deterministic.
236 if (swigCPtr.Handle != global::System.IntPtr.Zero)
241 Interop.ScrollView.DeleteScrollViewSnapEvent(swigCPtr);
243 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
252 /// Event arguments that passed via the SnapStarted signal.
254 /// <since_tizen> 3 </since_tizen>
255 /// This will be deprecated
256 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
257 [EditorBrowsable(EditorBrowsableState.Never)]
258 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
259 public class SnapStartedEventArgs : EventArgs
261 private Tizen.NUI.ScrollView.SnapEvent _snapEvent;
264 /// SnapEventInfo is the SnapEvent information like snap or flick (it tells the target position, scale, rotation for the snap or flick).
266 /// <since_tizen> 3 </since_tizen>
267 /// This will be deprecated
268 [Obsolete("Deprecated in API6; Will be removed in API9. Please use Tizen.NUI.Components")]
269 [EditorBrowsable(EditorBrowsableState.Never)]
270 public Tizen.NUI.ScrollView.SnapEvent SnapEventInfo