58e6cd83aab3332db862cf4a17e0d458c8695d16
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / Circle / CircleSlider.cs
1 using System;
2 using System.ComponentModel;
3 using System.Diagnostics;
4
5 namespace Efl
6 {
7     namespace Ui
8     {
9         namespace Wearable
10         {
11             /// <summary>
12             /// CircleSliderBar is a part used to set the color of the bar.
13             /// </summary>
14             /// <since_tizen> 6 </since_tizen>
15             public class CircleSliderBar : ICircleColor
16             {
17                 IntPtr _handle;
18                 public CircleSliderBar(IntPtr CircleHandle) { _handle = CircleHandle; }
19
20                 /// <summary>
21                 /// Sets the color of the bar on the circle slider.
22                 /// </summary>
23                 /// <since_tizen> 6 </since_tizen>
24                 public void SetColor(int r, int g, int b, int a)
25                 {
26                     if (_handle != null)
27                         Interop.Eext.eext_circle_object_color_set(_handle, r, g, b, a);
28                 }
29
30                 /// <summary>
31                 /// Gets the color of the bar on the circle slider.
32                 /// </summary>
33                 /// <since_tizen> 6 </since_tizen>
34                 public void GetColor(out int r, out int g, out int b, out int a)
35                 {
36                     r = g = b = a = -1;
37                     if (_handle != null)
38                         Interop.Eext.eext_circle_object_color_get(_handle, out r, out g, out b, out a);
39                 }
40             }
41
42             /// <summary>
43             /// CircleSliderBarBackground is a part used to set the background color of the bar.
44             /// </summary>
45             /// <since_tizen> 6 </since_tizen>
46             public class CircleSliderBarBackground : ICircleColor
47             {
48                 IntPtr _handle;
49                 public CircleSliderBarBackground(IntPtr CircleHandle) { _handle = CircleHandle; }
50
51                 /// <summary>
52                 /// Sets the background color of the bar on the circle slider.
53                 /// </summary>
54                 /// <since_tizen> 6 </since_tizen>
55                 public void SetColor(int r, int g, int b, int a)
56                 {
57                     if (_handle != null)
58                         Interop.Eext.eext_circle_object_item_color_set(_handle, "bg", r, g, b, a);
59                 }
60
61                 /// <summary>
62                 /// Gets the background color of the bar on the circle slider.
63                 /// </summary>
64                 /// <since_tizen> 6 </since_tizen>
65                 public void GetColor(out int r, out int g, out int b, out int a)
66                 {
67                     r = g = b = a = -1;
68                     if (_handle != null)
69                         Interop.Eext.eext_circle_object_item_color_get(_handle, "bg", out r, out g, out b, out a);
70                 }
71             }
72
73             /// <summary>
74             /// CircleSlider is a circular designed widget used to select a value in a range by the rotary event.
75             /// </summary>
76             /// <since_tizen> 6 </since_tizen>
77             public class CircleSlider : Efl.Ui.Layout, ICircleWidget
78             {
79                 IntPtr _handle;
80                 /// <summary>
81                 /// Get the handle for the circle widget.
82                 /// </summary>
83                 /// <since_tizen> 6 </since_tizen>
84                 public virtual IntPtr CircleHandle => _handle;
85
86                 /// <summary>
87                 /// Changed will be triggered when the circle slider value changes.
88                 /// </summary>
89                 /// <since_tizen> 6 </since_tizen>
90                 public event EventHandler Changed;
91                 const string ChangedEventName = "value,changed";
92                 private Interop.Evas.SmartCallback smartChanged;
93
94                 /// <summary>
95                 /// Sets or gets the color of the bar.
96                 /// </summary>
97                 /// <since_tizen> 6 </since_tizen>
98                 public CircleSliderBar Bar;
99
100                 /// <summary>
101                 /// Sets or gets the background color of the bar.
102                 /// </summary>
103                 /// <since_tizen> 6 </since_tizen>
104                 public CircleSliderBarBackground BarBackground;
105
106                 /// <summary>
107                 /// Creates and initializes a new instance of the CircleSlider class.
108                 /// </summary>
109                 /// <param name="parent">The Efl.Ui.Widget to which the new CircleSlider will be attached as a child.</param>
110                 /// <since_tizen> 6 </since_tizen>
111                 public CircleSlider(Efl.Ui.Widget parent) : base(parent)
112                 {
113                     _handle = Interop.Eext.eext_circle_object_slider_add(parent.NativeHandle, IntPtr.Zero);
114
115                     Bar = new Efl.Ui.Wearable.CircleSliderBar(_handle);
116                     BarBackground = new Efl.Ui.Wearable.CircleSliderBarBackground(_handle);
117
118                     smartChanged = new Interop.Evas.SmartCallback((d, o, e) =>
119                     {
120                         Changed?.Invoke(this, EventArgs.Empty);
121                     });
122
123                     Interop.Evas.evas_object_smart_callback_add(_handle, ChangedEventName, smartChanged, IntPtr.Zero);
124
125                     elm_layout_content_set(this.NativeHandle, "efl.swallow.vg", CircleHandle);
126                 }
127
128                 [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)]
129                 internal static extern bool elm_layout_content_set(IntPtr obj, string swallow, IntPtr content);
130
131                 public override Efl.Object FinalizeAdd()
132                 {
133                     this.SetTheme("circle_slider", null, null);
134                     return this;
135                 }
136
137                 /// <summary>
138                 /// Sets or gets the step by which the circle slider bar moves.
139                 /// </summary>
140                 /// <since_tizen> 6 </since_tizen>
141                 public double Step
142                 {
143                     get
144                     {
145                         return Interop.Eext.eext_circle_object_slider_step_get(CircleHandle);
146                     }
147                     set
148                     {
149                         Interop.Eext.eext_circle_object_slider_step_set(CircleHandle, (double)value);
150                     }
151                 }
152
153
154                 /// <summary>
155                 /// Sets or gets the disabled state of the circle slider.
156                 /// </summary>
157                 /// <since_tizen> 6 </since_tizen>
158                 public bool Disable
159                 {
160                     get => !Enable;
161                     set => Enable = !value;
162                 }
163
164                 /// <summary>
165                 /// Sets or gets the enabled state of the circle slider.
166                 /// </summary>
167                 /// <since_tizen> 6 </since_tizen>
168                 public bool Enable
169                 {
170                     get
171                     {
172                         return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
173                     }
174                     set
175                     {
176                         Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
177                     }
178                 }
179
180                 /// <summary>
181                 /// Sets or gets the line width of the circle slider bar.
182                 /// </summary>
183                 public int BarLineWidth
184                 {
185                     get
186                     {
187                         return Interop.Eext.eext_circle_object_line_width_get(CircleHandle);
188                     }
189                     set
190                     {
191                         Interop.Eext.eext_circle_object_line_width_set(CircleHandle, value);
192                     }
193                 }
194
195                 /// <summary>
196                 /// Sets or gets the line width of the circle slider background.
197                 /// </summary>
198                 /// <since_tizen> 6 </since_tizen>
199                 public int BackgroundLineWidth
200                 {
201                     get
202                     {
203                         return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "bg");
204                     }
205                     set
206                     {
207                         Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "bg", value);
208                     }
209                 }
210
211                 /// <summary>
212                 /// Sets or gets the angle in degree of the circle slider bar.
213                 /// </summary>
214                 /// <since_tizen> 6 </since_tizen>
215                 public double BarAngle
216                 {
217                     get
218                     {
219                         return Interop.Eext.eext_circle_object_angle_get(CircleHandle);
220                     }
221                     set
222                     {
223                         Interop.Eext.eext_circle_object_angle_set(CircleHandle, value);
224                     }
225                 }
226
227                 /// <summary>
228                 /// Sets or gets the angle in degree of the circle slider background.
229                 /// </summary>
230                 /// <since_tizen> 6 </since_tizen>
231                 public double BackgroundAngle
232                 {
233                     get
234                     {
235                         return Interop.Eext.eext_circle_object_item_angle_get(CircleHandle, "bg");
236                     }
237                     set
238                     {
239                         Interop.Eext.eext_circle_object_item_angle_set(CircleHandle, "bg", value);
240                     }
241                 }
242
243                 /// <summary>
244                 /// Sets or gets the angle offset for the slider bar.
245                 /// Offset value means start position of the slider bar.
246                 /// </summary>
247                 /// <since_tizen> 6 </since_tizen>
248                 public double BarAngleOffset
249                 {
250                     get
251                     {
252                         return Interop.Eext.eext_circle_object_angle_offset_get(CircleHandle);
253                     }
254                     set
255                     {
256                         Interop.Eext.eext_circle_object_angle_offset_set(CircleHandle, value);
257                     }
258                 }
259
260                 /// <summary>
261                 /// Sets or gets the angle offset for the circle slider background.
262                 /// Offset value means start position of the circle slider background.
263                 /// </summary>
264                 /// <since_tizen> 6 </since_tizen>
265                 public double BackgroundAngleOffset
266                 {
267                     get
268                     {
269                         return Interop.Eext.eext_circle_object_item_angle_offset_get(CircleHandle, "bg");
270                     }
271                     set
272                     {
273                         Interop.Eext.eext_circle_object_item_angle_offset_set(CircleHandle, "bg", value);
274                     }
275                 }
276
277                 /// <summary>
278                 /// Sets or gets the minimum angle of the circle slider bar.
279                 /// </summary>
280                 /// <since_tizen> 6 </since_tizen>
281                 public double BarAngleMinimum
282                 {
283                     get
284                     {
285                         double min;
286                         double max;
287                         Interop.Eext.eext_circle_object_angle_min_max_get(CircleHandle, out min, out max);
288                         return min;
289                     }
290                     set
291                     {
292                         double max = BarAngleMaximum;
293                         Interop.Eext.eext_circle_object_angle_min_max_set(CircleHandle, (double)value, max);
294                     }
295                 }
296
297                 /// <summary>
298                 /// Sets or gets the maximum angle of the circle slider bar.
299                 /// </summary>
300                 /// <since_tizen> 6 </since_tizen>
301                 public double BarAngleMaximum
302                 {
303                     get
304                     {
305                         double min;
306                         double max;
307                         Interop.Eext.eext_circle_object_angle_min_max_get(CircleHandle, out min, out max);
308                         return max;
309                     }
310                     set
311                     {
312                         double min = BarAngleMinimum;
313                         Interop.Eext.eext_circle_object_angle_min_max_set(CircleHandle, min, (double)value);
314                     }
315                 }
316
317                 /// <summary>
318                 /// Sets or gets the minimum values for the circle slider.
319                 /// </summary>
320                 /// <since_tizen> 6 </since_tizen>
321                 public double Minimum
322                 {
323                     get
324                     {
325                         double min;
326                         double max;
327                         Interop.Eext.eext_circle_object_value_min_max_get(CircleHandle, out min, out max);
328                         return min;
329                     }
330                     set
331                     {
332                         double max = Maximum;
333                         Interop.Eext.eext_circle_object_value_min_max_set(CircleHandle, (double)value, max);
334                     }
335                 }
336
337                 /// <summary>
338                 /// Sets or gets the maximum values for the circle slider.
339                 /// </summary>
340                 /// <since_tizen> 6 </since_tizen>
341                 public double Maximum
342                 {
343                     get
344                     {
345                         double min;
346                         double max;
347                         Interop.Eext.eext_circle_object_value_min_max_get(CircleHandle, out min, out max);
348                         return max;
349                     }
350                     set
351                     {
352                         double min = Minimum;
353                         Interop.Eext.eext_circle_object_value_min_max_set(CircleHandle, min, (double)value);
354                     }
355                 }
356
357                 /// <summary>
358                 /// Gets or sets the value displayed by the circle slider.
359                 /// </summary>
360                 /// <since_tizen> 6 </since_tizen>
361                 public double Value
362                 {
363                     get
364                     {
365                         return Interop.Eext.eext_circle_object_value_get(CircleHandle);
366                     }
367                     set
368                     {
369                         Interop.Eext.eext_circle_object_value_set(CircleHandle, (double)value);
370                     }
371                 }
372
373                 /// <summary>
374                 /// Gets or sets the radius value for the circle slider bar.
375                 /// </summary>
376                 /// <since_tizen> 6 </since_tizen>
377                 public double BarRadius
378                 {
379                     get
380                     {
381                         return Interop.Eext.eext_circle_object_radius_get(CircleHandle);
382                     }
383                     set
384                     {
385                         Interop.Eext.eext_circle_object_radius_set(CircleHandle, (double)value);
386                     }
387                 }
388
389                 /// <summary>
390                 /// Gets or sets the radius value for the circle slider background.
391                 /// </summary>
392                 /// <since_tizen> 6 </since_tizen>
393                 public double BackgroundRadius
394                 {
395                     get
396                     {
397                         return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "bg");
398                     }
399                     set
400                     {
401                         Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "bg", value);
402                     }
403                 }
404             }
405         }
406     }
407 }