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.
18 using System.ComponentModel;
19 using System.Diagnostics;
21 namespace ElmSharp.Wearable
24 /// Circle scroller provides the scrollbar with a circular movement, and is scrolled by the Rotary event.
26 /// <since_tizen> preview </since_tizen>
27 public class CircleScroller : Scroller, IRotaryActionWidget
30 CircleSurface _surface;
33 /// Creates and initializes a new instance of the CircleScroller class.
35 /// <param name="parent">The <see cref="EvasObject"/> to which the new CircleScroller will be attached as a child.</param>
36 /// <param name="surface">The surface for drawing circle features for this widget.</param>
37 /// <since_tizen> preview </since_tizen>
38 public CircleScroller(EvasObject parent, CircleSurface surface) : base()
40 Debug.Assert(parent == null || surface == null || parent.IsRealized);
46 /// Creates and initializes a new instance of the Circle Scroller class.
48 /// <param name="parent">The parent of the new Circle CircleScroller instance.</param>
49 /// <since_tizen> preview </since_tizen>
50 [Obsolete("It is not safe for guess circle surface from parent and create new surface by every new widget")]
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public CircleScroller(EvasObject parent) : this(parent, CircleSurface.CreateCircleSurface(parent))
54 ((IRotaryActionWidget)this).Activate();
58 /// Gets the handle for the Circle widget.
60 /// <since_tizen> preview </since_tizen>
61 public virtual IntPtr CircleHandle => _circleHandle;
64 /// Gets the handle for the circle surface used in this widget.
66 /// <since_tizen> preview </since_tizen>
67 public virtual CircleSurface CircleSurface => _surface;
70 /// Sets or gets the disabled state of this widget.
72 /// <since_tizen> preview </since_tizen>
73 [Obsolete("Use IsEnabled")]
74 [EditorBrowsable(EditorBrowsableState.Never)]
78 set => IsEnabled = !value;
82 /// Sets or gets the state of the widget, which might be enabled or disabled.
84 /// <since_tizen> preview </since_tizen>
85 public override bool IsEnabled
89 return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
93 Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
98 /// Sets or gets the value of HorizontalScrollBarVisiblePolicy.
101 /// ScrollBarVisiblePolicy.Auto means the horizontal scrollbar is made visible if it is needed, otherwise kept hidden.
102 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
104 /// <since_tizen> preview </since_tizen>
105 public override ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
110 Interop.Eext.eext_circle_object_scroller_policy_get(CircleHandle, out policy, IntPtr.Zero);
111 return (ScrollBarVisiblePolicy)policy;
115 ScrollBarVisiblePolicy v = VerticalScrollBarVisiblePolicy;
116 Interop.Eext.eext_circle_object_scroller_policy_set(CircleHandle, (int)value, (int)v);
121 /// Sets or gets the value of VerticalScrollBarVisiblePolicy.
124 /// ScrollBarVisiblePolicy.Auto means the vertical scrollbar is made visible if it is needed, otherwise kept hidden.
125 /// ScrollBarVisiblePolicy.Visible turns it on all the time, and ScrollBarVisiblePolicy.Invisible always keeps it off.
127 /// <since_tizen> preview </since_tizen>
128 public override ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
133 Interop.Eext.eext_circle_object_scroller_policy_get(CircleHandle, IntPtr.Zero, out policy);
134 return (ScrollBarVisiblePolicy)policy;
138 ScrollBarVisiblePolicy h = HorizontalScrollBarVisiblePolicy;
139 Interop.Eext.eext_circle_object_scroller_policy_set(CircleHandle, (int)h, (int)value);
144 /// Sets or gets the color of the vertical scroll bar.
146 /// <since_tizen> preview </since_tizen>
147 public Color VerticalScrollBarColor
155 Interop.Eext.eext_circle_object_color_get(CircleHandle, out r, out g, out b, out a);
156 return Color.FromRgba(r, g, b, a);
160 Interop.Eext.eext_circle_object_color_set(CircleHandle, value.R, value.G, value.B, value.A);
165 /// Sets or gets the color of the horizontal scroll bar.
167 /// <since_tizen> preview </since_tizen>
168 public Color HorizontalScrollBarColor
176 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "horizontal,scroll,bar", out r, out g, out b, out a);
177 return Color.FromRgba(r, g, b, a);
181 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "horizontal,scroll,bar", value.R, value.G, value.B, value.A);
186 /// Sets or gets the color of the vertical scroll background.
188 /// <since_tizen> preview </since_tizen>
189 public Color VerticalScrollBackgroundColor
197 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "vertical,scroll,bg", out r, out g, out b, out a);
198 return Color.FromRgba(r, g, b, a);
202 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "vertical,scroll,bg", value.R, value.G, value.B, value.A);
207 /// Sets or gets the color of the horizontal scroll background.
209 /// <since_tizen> preview </since_tizen>
210 public Color HorizontalScrollBackgroundColor
218 Interop.Eext.eext_circle_object_item_color_get(CircleHandle, "horizontal,scroll,bg", out r, out g, out b, out a);
219 return Color.FromRgba(r, g, b, a);
223 Interop.Eext.eext_circle_object_item_color_set(CircleHandle, "horizontal,scroll,bg", value.R, value.G, value.B, value.A);
228 /// Sets or gets the line width of the vertical scroll bar.
230 /// <since_tizen> preview </since_tizen>
231 public int VerticalScrollBarLineWidth
235 return Interop.Eext.eext_circle_object_line_width_get(CircleHandle);
239 Interop.Eext.eext_circle_object_line_width_set(CircleHandle, value);
244 /// Sets or gets the line width of the horizontal scroll bar.
246 /// <since_tizen> preview </since_tizen>
247 public int HorizontalScrollBarLineWidth
251 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "horizontal,scroll,bar");
255 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "horizontal,scroll,bar", value);
260 /// Sets or gets the line width of the vertical scroll background.
262 /// <since_tizen> preview </since_tizen>
263 public int VerticalScrollBackgroundLineWidth
267 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "vertical,scroll,bg");
271 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "vertical,scroll,bg", value);
276 /// Sets or gets the line width of the horizontal scroll background.
278 /// <since_tizen> preview </since_tizen>
279 public int HorizontalScrollBackgroundLineWidth
283 return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "horizontal,scroll,bg");
287 Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "horizontal,scroll,bg", value);
292 /// Sets or gets the radius of the vertical scroll bar.
294 /// <since_tizen> preview </since_tizen>
295 public double VerticalScrollBarRadius
299 return Interop.Eext.eext_circle_object_radius_get(CircleHandle);
303 Interop.Eext.eext_circle_object_radius_set(CircleHandle, value);
308 /// Sets or gets the radius of the horizontal scroll bar.
310 /// <since_tizen> preview </since_tizen>
311 public double HorizontalScrollBarRadius
315 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "horizontal,scroll,bar");
319 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "horizontal,scroll,bar", value);
324 /// Sets or gets the radius of the vertical scroll background.
326 /// <since_tizen> preview </since_tizen>
327 public double VerticalScrollBackgroundRadius
331 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "vertical,scroll,bg");
335 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "vertical,scroll,bg", value);
340 /// Sets or gets the radius of the horizontal scroll background.
342 /// <since_tizen> preview </since_tizen>
343 public double HorizontalScrollBackgroundRadius
347 return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "horizontal,scroll,bg");
351 Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "horizontal,scroll,bg", value);
356 /// Creates a widget handle.
358 /// <param name="parent">Parent EvasObject.</param>
359 /// <returns>Handle IntPtr.</returns>
360 /// <since_tizen> preview </since_tizen>
361 protected override IntPtr CreateHandle(EvasObject parent)
363 IntPtr handle = base.CreateHandle(parent);
364 _circleHandle = Interop.Eext.eext_circle_object_scroller_add(RealHandle == IntPtr.Zero ? handle : RealHandle, CircleSurface.Handle);