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
27 /// Changed will be triggered when the circle slider value changes.
29 public event EventHandler Changed;
31 SmartEvent _changedEvent;
34 /// Creates and initializes a new instance of the CircleSlider class.
36 /// <param name="parent">The EvasObject to which the new CircleSlider will be attached as a child.</param>
37 public CircleSlider(EvasObject parent) : base(parent)
39 _changedEvent = new SmartEvent(this, "value,changed");
41 _changedEvent.On += (s, e) => Changed?.Invoke(this, EventArgs.Empty);
45 /// Sets or gets the step by which the circle slider bar moves.
48 /// This value is used when circle slider value is changed by an drag or rotary event
49 /// The value of the slider is increased/decreased by the step value.
55 return Interop.Eext.eext_circle_object_slider_step_get(RealHandle);
59 Interop.Eext.eext_circle_object_slider_step_set(RealHandle, (double)value);
64 /// Sets or gets disabled state of the circle slider object.
70 return Interop.Eext.eext_circle_object_disabled_get(RealHandle); ;
74 Interop.Eext.eext_circle_object_disabled_set(RealHandle, value);
79 /// Sets or gets color of the circle slider bar.
89 Interop.Eext.eext_circle_object_color_get(RealHandle, out r, out g, out b, out a);
90 return Color.FromRgba(r, g, b, a);
94 Interop.Eext.eext_circle_object_color_set(RealHandle, value.R, value.G, value.B, value.A);
99 /// Sets or gets color of the circle slider background.
101 public Color BackgroundColor
109 Interop.Eext.eext_circle_object_item_color_get(RealHandle, "bg", out r, out g, out b, out a);
110 return Color.FromRgba(r, g, b, a);
114 Interop.Eext.eext_circle_object_item_color_set(RealHandle, "bg", value.R, value.G, value.B, value.A);
119 /// Sets or gets the line with of the circle slider bar.
121 public int BarLineWidth
125 return Interop.Eext.eext_circle_object_line_width_get(RealHandle); ;
129 Interop.Eext.eext_circle_object_line_width_set(RealHandle, value);
134 /// Sets or gets the line with of the circle slider background.
136 public int BackgroundLineWidth
140 return Interop.Eext.eext_circle_object_item_line_width_get(RealHandle, "bg");
144 Interop.Eext.eext_circle_object_item_line_width_set(RealHandle, "bg", value);
149 /// Sets or gets the angle in degree of the circle slider bar.
151 public double BarAngle
155 return Interop.Eext.eext_circle_object_angle_get(RealHandle); ;
159 Interop.Eext.eext_circle_object_angle_set(RealHandle, value);
164 /// Sets or gets the angle in degree of the circle slider background.
166 public double BackgroundAngle
170 return Interop.Eext.eext_circle_object_item_angle_get(RealHandle, "bg");
174 Interop.Eext.eext_circle_object_item_angle_set(RealHandle, "bg", value);
179 /// Sets or gets the angle offset for the slider bar.
180 /// offset value means start position of the slider bar.
182 public double BarAngleOffset
186 return Interop.Eext.eext_circle_object_angle_offset_get(RealHandle); ;
190 Interop.Eext.eext_circle_object_angle_offset_set(RealHandle, value);
195 /// Sets or gets the angle offset for the circle slider background.
196 /// offset value means start position of the slider background.
198 public double BackgroundAngleOffset
202 return Interop.Eext.eext_circle_object_item_angle_offset_get(RealHandle, "bg");
206 Interop.Eext.eext_circle_object_item_angle_offset_set(RealHandle, "bg", value);
211 /// Sets or gets the minimum angle of the circle slider bar.
213 public double BarAngleMinimum
219 Interop.Eext.eext_circle_object_angle_min_max_get(RealHandle, out min, out max);
224 double max = BarAngleMaximum;
225 Interop.Eext.eext_circle_object_angle_min_max_set(RealHandle, (double)value, max);
230 /// Sets or gets the maximum angle of the circle slider bar.
232 public double BarAngleMaximum
238 Interop.Eext.eext_circle_object_angle_min_max_get(RealHandle, out min, out max);
243 double min = BarAngleMinimum;
244 Interop.Eext.eext_circle_object_angle_min_max_set(RealHandle, min, (double)value);
249 /// Sets or gets the minimum values for the circle slider.
252 /// This defines the allowed minimum values to be selected by the user.
253 /// If the actual value is less than min, it is updated to min.
254 /// Actual value can be obtained with Value.By default, min is equal to 0.0.
256 public double Minimum
262 Interop.Eext.eext_circle_object_value_min_max_get(RealHandle, out min, out max);
267 double max = Maximum;
268 Interop.Eext.eext_circle_object_value_min_max_set(RealHandle, (double)value, max);
273 /// Sets or gets the maximum values for the circle slider.
276 /// This defines the allowed maximum values to be selected by the user.
277 /// If the actual value is bigger then max, it is updated to max.
278 /// Actual value can be obtained with Value.By default, min is equal to 0.0, and max is equal to 1.0.
279 /// Maximum must be greater than minimum, otherwise the behavior is undefined.
281 public double Maximum
287 Interop.Eext.eext_circle_object_value_min_max_get(RealHandle, out min, out max);
292 double min = Minimum;
293 Interop.Eext.eext_circle_object_value_min_max_set(RealHandle, min, (double)value);
298 /// Gets or sets the value displayed by the circle slider.
301 /// The value must to be between Minimum and Maximum values.
307 return Interop.Eext.eext_circle_object_value_get(RealHandle);
311 Interop.Eext.eext_circle_object_value_set(RealHandle, (double)value);
316 /// Gets or sets the radius value for the circle slider bar.
318 public double BarRadius
322 return Interop.Eext.eext_circle_object_radius_get(RealHandle); ;
326 Interop.Eext.eext_circle_object_radius_set(RealHandle, value);
331 /// Gets or sets the radius value for the circle slider background.
333 public double BackgroundRadius
337 return Interop.Eext.eext_circle_object_item_radius_get(RealHandle, "bg"); ;
341 Interop.Eext.eext_circle_object_item_radius_set(RealHandle, "bg", value);
345 protected override IntPtr CreateHandle(EvasObject parent)
347 IntPtr surface = IntPtr.Zero;
348 if (parent is Conformant)
350 surface = Interop.Eext.eext_circle_surface_conformant_add(parent);
352 else if (parent is Layout)
354 surface = Interop.Eext.eext_circle_surface_layout_add(parent);
356 else if (parent is Naviframe)
358 surface = Interop.Eext.eext_circle_surface_naviframe_add(parent.RealHandle);
361 IntPtr handle = Interop.Eext.eext_circle_object_slider_add(parent, surface);
362 if (surface == IntPtr.Zero)
364 EvasObject p = parent;
365 while (!(p is Window))
369 var w = (p as Window).ScreenSize.Width;
370 var h = (p as Window).ScreenSize.Height;
371 Interop.Evas.evas_object_resize(handle, w, h);
374 Interop.Eext.eext_rotary_object_event_activated_set(handle, true);