[Bluetooth][Non-ACR] Fix no data exception issue (#787)
[platform/core/csapi/tizenfx.git] / internals / src / EflSharp / EflSharp / Circle / CircleSpinner.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Efl
6 {
7     namespace Ui
8     {
9         namespace Wearable
10         {
11             /// <summary>
12             /// CircleSpinnerMarker is a part used to set the color of the marker.
13             /// </summary>
14             /// <since_tizen> 6 </since_tizen>
15             public class CircleSpinnerMarker : ICircleColor
16             {
17                 IntPtr _handle;
18                 public CircleSpinnerMarker(IntPtr CircleHandle) { _handle = CircleHandle; }
19
20                 /// <summary>
21                 /// Sets the color of the marker on the circle spinner.
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_item_color_set(_handle, "default", r, g, b, a);
28                 }
29
30                 /// <summary>
31                 /// Gets the color of the marker on the circle spinner.
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_item_color_get(_handle, "default", out r, out g, out b, out a);
39                 }
40             }
41
42             /// <summary>
43             /// The CircleSpinner is a widget to display and handle the spinner value by the rotary event.
44             /// </summary>
45             /// <since_tizen> 6 </since_tizen>
46             public class CircleSpinner : Efl.Ui.Spin, ICircleWidget
47             {
48                 double _angleRatio = -1.0;
49
50                 IntPtr _handle;
51                 public virtual IntPtr CircleHandle => _handle;
52
53                 /// <summary>
54                 /// Sets or gets the color of the marker.
55                 /// </summary>
56                 /// <since_tizen> 6 </since_tizen>
57                 public CircleSpinnerMarker Marker;
58
59                 /// <summary>
60                 /// Creates and initializes a new instance of the CircleSpinner class.
61                 /// </summary>
62                 /// <param name="parent">The Efl.Ui.Widget to which the new CircleSpinner will be attached as a child.</param>
63                 /// <since_tizen> 6 </since_tizen>
64                 public CircleSpinner(Efl.Ui.Widget parent) : base(parent)
65                 {
66                     _handle = Interop.Eext.eext_circle_object_spinner_add(this.NativeHandle, IntPtr.Zero);
67
68                     Marker = new CircleSpinnerMarker(_handle);
69
70                     elm_layout_content_set(this.NativeHandle, "efl.swallow.vg", CircleHandle);
71                 }
72
73                 [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)]
74                 internal static extern bool elm_layout_content_set(IntPtr obj, string swallow, IntPtr content);
75
76                 /// <summary>
77                 /// Sets or gets the circle spinner angle per each spinner value.
78                 /// </summary>
79                 /// <since_tizen> 6 </since_tizen>
80                 public double AngleRatio
81                 {
82                     get
83                     {
84                         if (_angleRatio <= 0)
85                         {
86                             double Minimum, Maximum;
87
88                             GetRangeMinMax(out Minimum, out Maximum);
89                             if (Maximum == Minimum)
90                             {
91                                 return 0.0;
92                             }
93                             else
94                             {
95                                 return 360 / (Maximum - Minimum);
96                             }
97                         }
98
99                         return _angleRatio;
100                     }
101                     set
102                     {
103                         if (value > 0)
104                         {
105                             if (_angleRatio == value) return;
106
107                             _angleRatio = value;
108
109                             Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
110                         }
111                     }
112                 }
113
114                 /// <summary>
115                 /// Sets or gets the disabled state of the circle spinner.
116                 /// </summary>
117                 /// <since_tizen> 6 </since_tizen>
118                 public bool Disable
119                 {
120                     get => !Enable;
121                     set => Enable = !value;
122                 }
123
124                 /// <summary>
125                 /// Sets or gets the enabled state of the circle spinner.
126                 /// </summary>
127                 /// <since_tizen> 6 </since_tizen>
128                 public bool Enable
129                 {
130                     get
131                     {
132                         return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
133                     }
134                     set
135                     {
136                         Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
137                     }
138                 }
139
140                 /// <summary>
141                 /// Sets or gets the line width of the marker.
142                 /// </summary>
143                 /// <since_tizen> 6 </since_tizen>
144                 public int MarkerLineWidth
145                 {
146                     get
147                     {
148                         return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
149                     }
150                     set
151                     {
152                         Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
153                     }
154                 }
155
156                 /// <summary>
157                 /// Sets or gets the radius of the marker.
158                 /// </summary>
159                 /// <since_tizen> 6 </since_tizen>
160                 public double MarkerRadius
161                 {
162                     get
163                     {
164                         return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
165                     }
166                     set
167                     {
168                         Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
169                     }
170                 }
171             }
172         }
173     }
174 }