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 SLIDER_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
26 %define SLIDER_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
27 %typemap(cscode) NameSpace::ClassName %{
29 public class ValueChangedEventArgs : EventArgs
31 private Slider _slider;
32 private float _slideValue;
46 public float SlideValue
59 public class SlidingFinishedEventArgs : EventArgs
61 private Slider _slider;
62 private float _slideValue;
76 public float SlideValue
89 public class MarkReachedEventArgs : EventArgs
91 private Slider _slider;
92 private int _slideValue;
106 public int SlideValue
120 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
121 private delegate bool ValueChangedCallbackDelegate(IntPtr slider, float slideValue);
122 private DaliEventHandlerWithReturnType<object,ValueChangedEventArgs,bool> _sliderValueChangedEventHandler;
123 private ValueChangedCallbackDelegate _sliderValueChangedCallbackDelegate;
125 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
126 private delegate bool SlidingFinishedCallbackDelegate(IntPtr slider, float slideValue);
127 private DaliEventHandlerWithReturnType<object,SlidingFinishedEventArgs,bool> _sliderSlidingFinishedEventHandler;
128 private SlidingFinishedCallbackDelegate _sliderSlidingFinishedCallbackDelegate;
130 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
131 private delegate bool MarkReachedCallbackDelegate(IntPtr slider, int slideValue);
132 private DaliEventHandlerWithReturnType<object,MarkReachedEventArgs,bool> _sliderMarkReachedEventHandler;
133 private MarkReachedCallbackDelegate _sliderMarkReachedCallbackDelegate;
135 public event DaliEventHandlerWithReturnType<object,ValueChangedEventArgs,bool> ValueChanged
141 // Restricted to only one listener
142 if (_sliderValueChangedEventHandler == null)
144 _sliderValueChangedEventHandler += value;
146 _sliderValueChangedCallbackDelegate = new ValueChangedCallbackDelegate(OnValueChanged);
147 this.ValueChangedSignal().Connect(_sliderValueChangedCallbackDelegate);
156 if (_sliderValueChangedEventHandler != null)
158 this.ValueChangedSignal().Disconnect(_sliderValueChangedCallbackDelegate);
161 _sliderValueChangedEventHandler -= value;
166 // Callback for Slider ValueChanged signal
167 private bool OnValueChanged(IntPtr slider, float slideValue)
169 ValueChangedEventArgs e = new ValueChangedEventArgs();
171 // Populate all members of "e" (ValueChangedEventArgs) with real page
172 e.Slider = Slider.GetSliderFromPtr( slider );
173 e.SlideValue = slideValue;
175 if (_sliderValueChangedEventHandler != null)
177 //here we send all page to user event handlers
178 return _sliderValueChangedEventHandler(this, e);
183 public event DaliEventHandlerWithReturnType<object,SlidingFinishedEventArgs,bool> SlidingFinished
189 // Restricted to only one listener
190 if (_sliderSlidingFinishedEventHandler == null)
192 _sliderSlidingFinishedEventHandler += value;
194 _sliderSlidingFinishedCallbackDelegate = new SlidingFinishedCallbackDelegate(OnSlidingFinished);
195 this.SlidingFinishedSignal().Connect(_sliderSlidingFinishedCallbackDelegate);
204 if (_sliderSlidingFinishedEventHandler != null)
206 this.SlidingFinishedSignal().Disconnect(_sliderSlidingFinishedCallbackDelegate);
209 _sliderSlidingFinishedEventHandler -= value;
214 // Callback for Slider SlidingFinished signal
215 private bool OnSlidingFinished(IntPtr slider, float slideValue)
217 SlidingFinishedEventArgs e = new SlidingFinishedEventArgs();
219 // Populate all members of "e" (SlidingFinishedEventArgs) with real page
220 e.Slider = Slider.GetSliderFromPtr( slider );
221 e.SlideValue = slideValue;
223 if (_sliderSlidingFinishedEventHandler != null)
225 //here we send all page to user event handlers
226 return _sliderSlidingFinishedEventHandler(this, e);
231 public event DaliEventHandlerWithReturnType<object,MarkReachedEventArgs,bool> MarkReached
237 // Restricted to only one listener
238 if (_sliderMarkReachedEventHandler == null)
240 _sliderMarkReachedEventHandler += value;
242 _sliderMarkReachedCallbackDelegate = new MarkReachedCallbackDelegate(OnMarkReached);
243 this.MarkReachedSignal().Connect(_sliderMarkReachedCallbackDelegate);
252 if (_sliderMarkReachedEventHandler != null)
254 this.MarkReachedSignal().Disconnect(_sliderMarkReachedCallbackDelegate);
257 _sliderMarkReachedEventHandler -= value;
262 // Callback for Slider MarkReached signal
263 private bool OnMarkReached(IntPtr slider, int slideValue)
265 MarkReachedEventArgs e = new MarkReachedEventArgs();
267 // Populate all members of "e" (MarkReachedEventArgs) with real page
268 e.Slider = Slider.GetSliderFromPtr( slider );
269 e.SlideValue = slideValue;
271 if (_sliderMarkReachedEventHandler != null)
273 //here we send all page to user event handlers
274 return _sliderMarkReachedEventHandler(this, e);
279 public static ClassName Get ## ClassName ## FromPtr(global::System.IntPtr cPtr) {
280 ClassName ret = new ClassName(cPtr, false);
281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
285 /* Properties earlier added by Ruby Script */
287 public float LowerBound
292 GetProperty( Slider.Property.LOWER_BOUND).Get( ref temp );
297 SetProperty( Slider.Property.LOWER_BOUND, new Dali.Property.Value( value ) );
300 public float UpperBound
305 GetProperty( Slider.Property.UPPER_BOUND).Get( ref temp );
310 SetProperty( Slider.Property.UPPER_BOUND, new Dali.Property.Value( value ) );
318 GetProperty( Slider.Property.VALUE).Get( ref temp );
323 SetProperty( Slider.Property.VALUE, new Dali.Property.Value( value ) );
326 public Dali.Property.Map TrackVisual
330 Dali.Property.Map temp = new Dali.Property.Map();
331 GetProperty( Slider.Property.TRACK_VISUAL).Get( temp );
336 SetProperty( Slider.Property.TRACK_VISUAL, new Dali.Property.Value( value ) );
339 public Dali.Property.Map HandleVisual
343 Dali.Property.Map temp = new Dali.Property.Map();
344 GetProperty( Slider.Property.HANDLE_VISUAL).Get( temp );
349 SetProperty( Slider.Property.HANDLE_VISUAL, new Dali.Property.Value( value ) );
352 public Dali.Property.Map ProgressVisual
356 Dali.Property.Map temp = new Dali.Property.Map();
357 GetProperty( Slider.Property.PROGRESS_VISUAL).Get( temp );
362 SetProperty( Slider.Property.PROGRESS_VISUAL, new Dali.Property.Value( value ) );
365 public Dali.Property.Map PopupVisual
369 Dali.Property.Map temp = new Dali.Property.Map();
370 GetProperty( Slider.Property.POPUP_VISUAL).Get( temp );
375 SetProperty( Slider.Property.POPUP_VISUAL, new Dali.Property.Value( value ) );
378 public Dali.Property.Map PopupArrowVisual
382 Dali.Property.Map temp = new Dali.Property.Map();
383 GetProperty( Slider.Property.POPUP_ARROW_VISUAL).Get( temp );
388 SetProperty( Slider.Property.POPUP_ARROW_VISUAL, new Dali.Property.Value( value ) );
391 public Dali.CSharp.Color DisabledColor
395 Vector4 temp = new Vector4(0.0f,0.0f,0.0f,0.0f);
396 GetProperty( Slider.Property.DISABLED_COLOR).Get( temp );
397 Dali.CSharp.Color ret = new Dali.CSharp.Color(temp.r, temp.g, temp.b, temp.a);
402 SetProperty( Slider.Property.DISABLED_COLOR, new Dali.Property.Value( value ) );
405 public int ValuePrecision
410 GetProperty( Slider.Property.VALUE_PRECISION).Get( ref temp );
415 SetProperty( Slider.Property.VALUE_PRECISION, new Dali.Property.Value( value ) );
418 public bool ShowPopup
423 GetProperty( Slider.Property.SHOW_POPUP).Get( ref temp );
428 SetProperty( Slider.Property.SHOW_POPUP, new Dali.Property.Value( value ) );
431 public bool ShowValue
436 GetProperty( Slider.Property.SHOW_VALUE).Get( ref temp );
441 SetProperty( Slider.Property.SHOW_VALUE, new Dali.Property.Value( value ) );
444 public Dali.Property.Array Marks
448 Dali.Property.Array temp = new Dali.Property.Array();
449 GetProperty( Slider.Property.MARKS).Get( temp );
454 SetProperty( Slider.Property.MARKS, new Dali.Property.Value( value ) );
457 public bool SnapToMarks
462 GetProperty( Slider.Property.SNAP_TO_MARKS).Get( ref temp );
467 SetProperty( Slider.Property.SNAP_TO_MARKS, new Dali.Property.Value( value ) );
470 public float MarkTolerance
475 GetProperty( Slider.Property.MARK_TOLERANCE).Get( ref temp );
480 SetProperty( Slider.Property.MARK_TOLERANCE, new Dali.Property.Value( value ) );
484 /* Properties ends */
491 %define DALI_SLIDER_EVENTHANDLER_PARAM( NameSpace, ClassName)
493 SLIDER_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
494 SLIDER_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
500 DALI_SLIDER_EVENTHANDLER_PARAM( Dali::Toolkit, Slider);