2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 namespace ElmSharp.Wearable
22 /// Circle slider is circular designed widget to select a value in a range by rotary event.
24 public class CircleSlider : EvasObject
26 public event EventHandler Changed;
28 SmartEvent _changedEvent;
31 /// Creates and initializes a new instance of the CircleSlider class.
33 /// <param name="parent">The EvasObject to which the new CircleSlider will be attached as a child.</param>
34 public CircleSlider(EvasObject parent) : base(parent)
36 _changedEvent = new SmartEvent(this, "value,changed");
38 _changedEvent.On += (s, e) => Changed?.Invoke(this, EventArgs.Empty);
42 /// Sets or gets the step by which the circle slider bar moves.
45 /// This value is used when circle slider value is changed by an drag or rotary event
46 /// The value of the slider is increased/decreased by the step value.
52 return Interop.Eext.eext_circle_object_slider_step_get(RealHandle);
56 Interop.Eext.eext_circle_object_slider_step_set(RealHandle, (double)value);
61 /// Sets or gets disabled state of the circle slider object.
67 return Interop.Eext.eext_circle_object_disabled_get(RealHandle); ;
71 Interop.Eext.eext_circle_object_disabled_set(RealHandle, value);
76 /// Sets or gets color of the circle slider bar.
86 Interop.Eext.eext_circle_object_color_get(RealHandle, out r, out g, out b, out a);
87 return Color.FromRgba(r, g, b, a);
91 Interop.Eext.eext_circle_object_color_set(RealHandle, value.R, value.G, value.B, value.A);
96 /// Sets or gets color of the circle slider background.
98 public Color BackgroundColor
106 Interop.Eext.eext_circle_object_item_color_get(RealHandle, "bg", out r, out g, out b, out a);
107 return Color.FromRgba(r, g, b, a);
111 Interop.Eext.eext_circle_object_item_color_set(RealHandle, "bg", value.R, value.G, value.B, value.A);
116 /// Sets or gets the line with of the circle slider bar.
118 public int BarLineWidth
122 return Interop.Eext.eext_circle_object_line_width_get(RealHandle); ;
126 Interop.Eext.eext_circle_object_line_width_set(RealHandle, value);
131 /// Sets or gets the line with of the circle slider background.
133 public int BackgroundLineWidth
137 return Interop.Eext.eext_circle_object_item_line_width_get(RealHandle, "bg");
141 Interop.Eext.eext_circle_object_item_line_width_set(RealHandle, "bg", value);
146 /// Sets or gets the angle in degree of the circle slider bar.
148 public double BarAngle
152 return Interop.Eext.eext_circle_object_angle_get(RealHandle); ;
156 Interop.Eext.eext_circle_object_angle_set(RealHandle, value);
161 /// Sets or gets the angle in degree of the circle slider background.
163 public double BackgroundAngle
167 return Interop.Eext.eext_circle_object_item_angle_get(RealHandle, "bg");
171 Interop.Eext.eext_circle_object_item_angle_set(RealHandle, "bg", value);
176 /// Sets or gets the angle offset for the slider bar.
177 /// offset value means start position of the slider bar.
179 public double BarAngleOffset
183 return Interop.Eext.eext_circle_object_angle_offset_get(RealHandle); ;
187 Interop.Eext.eext_circle_object_angle_offset_set(RealHandle, value);
192 /// Sets or gets the angle offset for the circle slider background.
193 /// offset value means start position of the slider background.
195 public double BackgroundAngleOffset
199 return Interop.Eext.eext_circle_object_item_angle_offset_get(RealHandle, "bg");
203 Interop.Eext.eext_circle_object_item_angle_offset_set(RealHandle, "bg", value);
208 /// Sets or gets the minimum angle of the circle slider bar.
210 public double BarAngleMinimum
216 Interop.Eext.eext_circle_object_angle_min_max_get(RealHandle, out min, out max);
221 double max = BarAngleMaximum;
222 Interop.Eext.eext_circle_object_angle_min_max_set(RealHandle, (double)value, max);
227 /// Sets or gets the maximum angle of the circle slider bar.
229 public double BarAngleMaximum
235 Interop.Eext.eext_circle_object_angle_min_max_get(RealHandle, out min, out max);
240 double min = BarAngleMinimum;
241 Interop.Eext.eext_circle_object_angle_min_max_set(RealHandle, min, (double)value);
246 /// Sets or gets the minimum values for the circle slider.
249 /// This defines the allowed minimum values to be selected by the user.
250 /// If the actual value is less than min, it is updated to min.
251 /// Actual value can be obtained with Value.By default, min is equal to 0.0.
253 public double Minimum
259 Interop.Eext.eext_circle_object_value_min_max_get(RealHandle, out min, out max);
264 double max = Maximum;
265 Interop.Eext.eext_circle_object_value_min_max_set(RealHandle, (double)value, max);
270 /// Sets or gets the maximum values for the circle slider.
273 /// This defines the allowed maximum values to be selected by the user.
274 /// If the actual value is bigger then max, it is updated to max.
275 /// Actual value can be obtained with Value.By default, min is equal to 0.0, and max is equal to 1.0.
276 /// Maximum must be greater than minimum, otherwise the behavior is undefined.
278 public double Maximum
284 Interop.Eext.eext_circle_object_value_min_max_get(RealHandle, out min, out max);
289 double min = Minimum;
290 Interop.Eext.eext_circle_object_value_min_max_set(RealHandle, min, (double)value);
295 /// Gets or sets the value displayed by the circle slider.
298 /// The value must to be between Minimum and Maximum values.
304 return Interop.Eext.eext_circle_object_value_get(RealHandle);
308 Interop.Eext.eext_circle_object_value_set(RealHandle, (double)value);
313 /// Gets or sets the radius value for the circle slider bar.
315 public double BarRadius
319 return Interop.Eext.eext_circle_object_radius_get(RealHandle); ;
323 Interop.Eext.eext_circle_object_radius_set(RealHandle, value);
328 /// Gets or sets the radius value for the circle slider background.
330 public double BackgroundRadius
334 return Interop.Eext.eext_circle_object_item_radius_get(RealHandle, "bg"); ;
338 Interop.Eext.eext_circle_object_item_radius_set(RealHandle, "bg", value);
342 protected override IntPtr CreateHandle(EvasObject parent)
344 IntPtr surface = IntPtr.Zero;
345 if (parent is Conformant)
347 surface = Interop.Eext.eext_circle_surface_conformant_add(parent);
349 else if (parent is Layout)
351 surface = Interop.Eext.eext_circle_surface_layout_add(parent);
353 else if (parent is Naviframe)
355 surface = Interop.Eext.eext_circle_surface_naviframe_add(parent.RealHandle);
358 IntPtr handle = Interop.Eext.eext_circle_object_slider_add(parent, surface);
359 if (surface == IntPtr.Zero)
361 EvasObject p = parent;
362 while (!(p is Window))
366 var w = (p as Window).ScreenSize.Width;
367 var h = (p as Window).ScreenSize.Height;
368 Interop.Evas.evas_object_resize(handle, w, h);
371 Interop.Eext.eext_rotary_object_event_activated_set(handle, true);