[EflSharp] Update Circle and efl cs files (#995)
[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, Efl.Ui.IRangeInteractive, ICircleWidget
47             {
48                 double _angleRatio = -1.0;
49                 double _step = 1.0;
50
51                 IntPtr _handle;
52                 public virtual IntPtr CircleHandle => _handle;
53
54                 /// <summary>
55                 /// Sets or gets the color of the marker.
56                 /// </summary>
57                 /// <since_tizen> 6 </since_tizen>
58                 public CircleSpinnerMarker Marker;
59
60                 public event EventHandler SteadyEvt;
61
62                 /// <summary>
63                 /// Creates and initializes a new instance of the CircleSpinner class.
64                 /// </summary>
65                 /// <param name="parent">The Efl.Ui.Widget to which the new CircleSpinner will be attached as a child.</param>
66                 /// <since_tizen> 6 </since_tizen>
67                 public CircleSpinner(Efl.Ui.Widget parent) : base(parent)
68                 {
69                     _handle = Interop.Eext.eext_circle_object_spinner_add(this.NativeHandle, IntPtr.Zero);
70
71                     Marker = new CircleSpinnerMarker(_handle);
72
73                     elm_layout_content_set(this.NativeHandle, "efl.swallow.vg", CircleHandle);
74                 }
75
76                 [System.Runtime.InteropServices.DllImport(efl.Libs.Elementary)]
77                 internal static extern bool elm_layout_content_set(IntPtr obj, string swallow, IntPtr content);
78
79                 /// <summary>
80                 /// Sets or gets the circle spinner angle per each spinner value.
81                 /// </summary>
82                 /// <since_tizen> 6 </since_tizen>
83                 public double AngleRatio
84                 {
85                     get
86                     {
87                         if (_angleRatio <= 0)
88                         {
89                             double Minimum, Maximum;
90
91                             GetRangeLimits(out Minimum, out Maximum);
92                             if (Maximum == Minimum)
93                             {
94                                 return 0.0;
95                             }
96                             else
97                             {
98                                 return 360 / (Maximum - Minimum);
99                             }
100                         }
101
102                         return _angleRatio;
103                     }
104                     set
105                     {
106                         if (value > 0)
107                         {
108                             if (_angleRatio == value) return;
109
110                             _angleRatio = value;
111
112                             Interop.Eext.eext_circle_object_spinner_angle_set(CircleHandle, _angleRatio);
113                         }
114                     }
115                 }
116
117                 /// <summary>
118                 /// Sets or gets the disabled state of the circle spinner.
119                 /// </summary>
120                 /// <since_tizen> 6 </since_tizen>
121                 public bool Disable
122                 {
123                     get => !Enable;
124                     set => Enable = !value;
125                 }
126
127                 /// <summary>
128                 /// Sets or gets the enabled state of the circle spinner.
129                 /// </summary>
130                 /// <since_tizen> 6 </since_tizen>
131                 public bool Enable
132                 {
133                     get
134                     {
135                         return !Interop.Eext.eext_circle_object_disabled_get(CircleHandle);
136                     }
137                     set
138                     {
139                         Interop.Eext.eext_circle_object_disabled_set(CircleHandle, !value);
140                     }
141                 }
142
143                 /// <summary>
144                 /// Sets or gets the line width of the marker.
145                 /// </summary>
146                 /// <since_tizen> 6 </since_tizen>
147                 public int MarkerLineWidth
148                 {
149                     get
150                     {
151                         return Interop.Eext.eext_circle_object_item_line_width_get(CircleHandle, "default");
152                     }
153                     set
154                     {
155                         Interop.Eext.eext_circle_object_item_line_width_set(CircleHandle, "default", value);
156                     }
157                 }
158
159                 /// <summary>
160                 /// Sets or gets the radius of the marker.
161                 /// </summary>
162                 /// <since_tizen> 6 </since_tizen>
163                 public double MarkerRadius
164                 {
165                     get
166                     {
167                         return Interop.Eext.eext_circle_object_item_radius_get(CircleHandle, "default");
168                     }
169                     set
170                     {
171                         Interop.Eext.eext_circle_object_item_radius_set(CircleHandle, "default", value);
172                     }
173                 }
174                 
175                 public double GetRangeStep()
176                 {
177                     return _step;
178                 }
179
180                 public void SetRangeStep(double step)
181                 {
182                     _step = step;
183                 }
184
185                 public double RangeStep
186                 {
187                     get
188                     {
189                         return GetRangeStep();
190                     }
191                     set
192                     {
193                         SetRangeStep(value);
194                     }
195                 }
196             }
197         }
198     }
199 }