[NUI] Change CornerRadius type to Vector4 from float (#2863)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / Style / ViewStyleBindableProperty.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System.ComponentModel;
18 using Tizen.NUI.Binding;
19
20 namespace Tizen.NUI.BaseComponents
21 {
22     public partial class ViewStyle
23     {
24         /// <summary> Bindable property of BackgroundImage. Please do not open it. </summary>
25         [EditorBrowsable(EditorBrowsableState.Never)]
26         public static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector<string>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
27         {
28             var viewStyle = (ViewStyle)bindable;
29
30             if (newValue == null)
31             {
32                 viewStyle.backgroundImageSelector = null;
33             }
34             else
35             {
36                 viewStyle.backgroundImageSelector = (Selector<string>)newValue;
37                 viewStyle.backgroundColorSelector = null;
38             }
39         },
40         defaultValueCreator: (bindable) =>
41         {
42             return ((ViewStyle)bindable).backgroundImageSelector;
43         });
44
45         /// <summary> Bindable property of Focusable. Please do not open it. </summary>
46         [EditorBrowsable(EditorBrowsableState.Never)]
47         public static readonly BindableProperty FocusableProperty = BindableProperty.Create(nameof(Focusable), typeof(bool?), typeof(ViewStyle), null,
48             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).focusable = (bool?)newValue,
49             defaultValueCreator: (bindable) => ((ViewStyle)bindable).focusable
50         );
51
52         /// <summary> Bindable property of Focusable. Please do not open it. </summary>
53         [EditorBrowsable(EditorBrowsableState.Never)]
54         public static readonly BindableProperty Size2DProperty = BindableProperty.Create(nameof(Size2D), typeof(Size2D), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
55         {
56             var viewStyle = (ViewStyle)bindable;
57             viewStyle.size = newValue == null ? null : new Size((Size2D)newValue);
58         },
59         defaultValueCreator: (bindable) =>
60         {
61             var viewStyle = (ViewStyle)bindable;
62             return viewStyle.size == null ? null : (Size2D)viewStyle.size;
63         });
64
65         /// <summary> Bindable property of Opacity. Please do not open it. </summary>
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public static readonly BindableProperty OpacitySelectorProperty = BindableProperty.Create("OpacitySelector", typeof(Selector<float?>), typeof(ViewStyle), null,
68             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).opacitySelector = (Selector<float?>)newValue,
69             defaultValueCreator: (bindable) => ((ViewStyle)bindable).opacitySelector
70         );
71
72         /// <summary> Bindable property of Position2D. Please do not open it. </summary>
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public static readonly BindableProperty Position2DProperty = BindableProperty.Create(nameof(Position2D), typeof(Position2D), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
75         {
76             var viewStyle = (ViewStyle)bindable;
77             viewStyle.position = newValue == null ? null : new Position((Position2D)newValue);
78         },
79         defaultValueCreator: (bindable) =>
80         {
81             var viewStyle = (ViewStyle)bindable;
82             return viewStyle.position == null ? null : new Position2D(viewStyle.position);
83         });
84
85         /// <summary> Bindable property of PositionUsesPivotPoint. Please do not open it. </summary>
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public static readonly BindableProperty PositionUsesPivotPointProperty = BindableProperty.Create(nameof(PositionUsesPivotPoint), typeof(bool?), typeof(ViewStyle), null,
88             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).positionUsesPivotPoint = (bool?)newValue,
89             defaultValueCreator: (bindable) => ((ViewStyle)bindable).positionUsesPivotPoint
90         );
91
92         /// <summary> Bindable property of ParentOrigin. Please do not open it. </summary>
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public static readonly BindableProperty ParentOriginProperty = BindableProperty.Create(nameof(ParentOrigin), typeof(Position), typeof(ViewStyle), null,
95             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).parentOrigin = (Position)newValue,
96             defaultValueCreator: (bindable) => ((ViewStyle)bindable).parentOrigin
97         );
98
99         /// <summary> Bindable property of PivotPoint. Please do not open it. </summary>
100         [EditorBrowsable(EditorBrowsableState.Never)]
101         public static readonly BindableProperty PivotPointProperty = BindableProperty.Create(nameof(PivotPoint), typeof(Position), typeof(ViewStyle), null,
102             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).pivotPoint = (Position)newValue,
103             defaultValueCreator: (bindable) => ((ViewStyle)bindable).pivotPoint
104         );
105
106         /// <summary> Bindable property of SizeWidth. Please do not open it. </summary>
107         [EditorBrowsable(EditorBrowsableState.Never)]
108         public static readonly BindableProperty SizeWidthProperty = BindableProperty.Create(nameof(SizeWidth), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
109         {
110             var viewStyle = (ViewStyle)bindable;
111             if (newValue != null)
112             {
113                 if (viewStyle.size == null)
114                 {
115                     if ((float)newValue == 0) return;
116                 }
117                 viewStyle.size = new Size((float)newValue, viewStyle.size?.Height ?? 0);
118             }
119         },
120         defaultValueCreator: (bindable) =>
121         {
122             return ((ViewStyle)bindable).size?.Width;
123         });
124
125         /// <summary> Bindable property of SizeHeight. Please do not open it. </summary>
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         public static readonly BindableProperty SizeHeightProperty = BindableProperty.Create(nameof(SizeHeight), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
128         {
129             var viewStyle = (ViewStyle)bindable;
130             if (newValue != null)
131             {
132                 if (viewStyle.size == null)
133                 {
134                     if ((float)newValue == 0) return;
135                 }
136                 viewStyle.size = new Size(viewStyle.size?.Width ?? 0, (float)newValue);
137             }
138         },
139         defaultValueCreator: (bindable) =>
140         {
141             return ((ViewStyle)bindable).size?.Height;
142         });
143
144         /// <summary> Bindable property of Position. Please do not open it. </summary>
145         [EditorBrowsable(EditorBrowsableState.Never)]
146         public static readonly BindableProperty PositionProperty = BindableProperty.Create(nameof(Position), typeof(Position), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
147         {
148             var viewStyle = (ViewStyle)bindable;
149             viewStyle.position = (Position)newValue;
150             if (viewStyle.position != null && viewStyle.position.X == 0 && viewStyle.position.Y == 0)
151             {
152                 viewStyle.position = null;
153             }
154         },
155         defaultValueCreator: (bindable) =>
156         {
157             var viewStyle = (ViewStyle)bindable;
158             return viewStyle.position;
159         });
160
161         /// <summary> Bindable property of PositionX. Please do not open it. </summary>
162         [EditorBrowsable(EditorBrowsableState.Never)]
163         public static readonly BindableProperty PositionXProperty = BindableProperty.Create(nameof(PositionX), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
164         {
165             var viewStyle = (ViewStyle)bindable;
166             if (newValue != null)
167             {
168                 if (viewStyle.position == null)
169                 {
170                     if ((float)newValue == 0) return;
171                 }
172                 viewStyle.position = new Position((float)newValue, viewStyle.position?.Y ?? 0);
173             }
174         },
175         defaultValueCreator: (bindable) =>
176         {
177             return ((ViewStyle)bindable).position?.X;
178         });
179
180         /// <summary> Bindable property of PositionY. Please do not open it. </summary>
181         [EditorBrowsable(EditorBrowsableState.Never)]
182         public static readonly BindableProperty PositionYProperty = BindableProperty.Create(nameof(PositionY), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
183         {
184             var viewStyle = (ViewStyle)bindable;
185             if (newValue != null)
186             {
187                 if (viewStyle.position == null)
188                 {
189                     if ((float)newValue == 0) return;
190                 }
191                 viewStyle.position = new Position(viewStyle.position?.X ?? 0, (float)newValue);
192             }
193         },
194         defaultValueCreator: (bindable) =>
195         {
196             return ((ViewStyle)bindable).position?.Y;
197         });
198
199         /// <summary> Bindable property of Orientation. Please do not open it. </summary>
200         [EditorBrowsable(EditorBrowsableState.Never)]
201         public static readonly BindableProperty OrientationProperty = BindableProperty.Create(nameof(Orientation), typeof(Rotation), typeof(ViewStyle), null,
202             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).orientation = (Rotation)newValue,
203             defaultValueCreator: (bindable) => ((ViewStyle)bindable).orientation
204         );
205
206         /// <summary> Bindable property of DrawMode. Please do not open it. </summary>
207         [EditorBrowsable(EditorBrowsableState.Never)]
208         public static readonly BindableProperty DrawModeProperty = BindableProperty.Create(nameof(DrawMode), typeof(DrawModeType?), typeof(ViewStyle), null,
209             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).drawMode = (DrawModeType?)newValue,
210             defaultValueCreator: (bindable) => ((ViewStyle)bindable).drawMode
211         );
212
213         /// <summary> Bindable property of SizeModeFactor. Please do not open it. </summary>
214         [EditorBrowsable(EditorBrowsableState.Never)]
215         public static readonly BindableProperty SizeModeFactorProperty = BindableProperty.Create(nameof(SizeModeFactor), typeof(Vector3), typeof(ViewStyle), null,
216             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).sizeModeFactor = (Vector3)newValue,
217             defaultValueCreator: (bindable) => ((ViewStyle)bindable).sizeModeFactor
218         );
219
220         /// <summary> Bindable property of WidthResizePolicy. Please do not open it. </summary>
221         [EditorBrowsable(EditorBrowsableState.Never)]
222         public static readonly BindableProperty WidthResizePolicyProperty = BindableProperty.Create(nameof(WidthResizePolicy), typeof(ResizePolicyType?), typeof(ViewStyle), null,
223             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).widthResizePolicy = (ResizePolicyType?)newValue,
224             defaultValueCreator: (bindable) => ((ViewStyle)bindable).widthResizePolicy
225         );
226
227         /// <summary> Bindable property of HeightResizePolicy. Please do not open it. </summary>
228         [EditorBrowsable(EditorBrowsableState.Never)]
229         public static readonly BindableProperty HeightResizePolicyProperty = BindableProperty.Create(nameof(HeightResizePolicy), typeof(ResizePolicyType?), typeof(ViewStyle), null,
230             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).heightResizePolicy = (ResizePolicyType?)newValue,
231             defaultValueCreator: (bindable) => ((ViewStyle)bindable).heightResizePolicy
232         );
233
234         /// <summary> Bindable property of WidthForHeight. Please do not open it. </summary>
235         [EditorBrowsable(EditorBrowsableState.Never)]
236         public static readonly BindableProperty WidthForHeightProperty = BindableProperty.Create(nameof(WidthForHeight), typeof(bool?), typeof(ViewStyle), null,
237             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).widthForHeight = (bool?)newValue,
238             defaultValueCreator: (bindable) => ((ViewStyle)bindable).widthForHeight
239         );
240
241         /// <summary> Bindable property of HeightForWidth. Please do not open it. </summary>
242         [EditorBrowsable(EditorBrowsableState.Never)]
243         public static readonly BindableProperty HeightForWidthProperty = BindableProperty.Create(nameof(HeightForWidth), typeof(bool?), typeof(ViewStyle), null,
244             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).heightForWidth = (bool?)newValue,
245             defaultValueCreator: (bindable) => ((ViewStyle)bindable).heightForWidth
246         );
247
248         /// <summary> Bindable property of Padding. Please do not open it. </summary>
249         [EditorBrowsable(EditorBrowsableState.Never)]
250         public static readonly BindableProperty PaddingProperty = BindableProperty.Create(nameof(Padding), typeof(Extents), typeof(ViewStyle), null,
251             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).padding = (Extents)newValue,
252             defaultValueCreator: (bindable) => ((ViewStyle)bindable).padding
253         );
254
255         /// <summary> Bindable property of MinimumSize. Please do not open it. </summary>
256         [EditorBrowsable(EditorBrowsableState.Never)]
257         public static readonly BindableProperty MinimumSizeProperty = BindableProperty.Create(nameof(MinimumSize), typeof(Size2D), typeof(ViewStyle), null,
258             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).minimumSize = (Size2D)newValue,
259             defaultValueCreator: (bindable) => ((ViewStyle)bindable).minimumSize
260         );
261
262         /// <summary> Bindable property of MaximumSize. Please do not open it. </summary>
263         [EditorBrowsable(EditorBrowsableState.Never)]
264         public static readonly BindableProperty MaximumSizeProperty = BindableProperty.Create(nameof(MaximumSize), typeof(Size2D), typeof(ViewStyle), null,
265             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).maximumSize = (Size2D)newValue,
266             defaultValueCreator: (bindable) => ((ViewStyle)bindable).maximumSize
267         );
268
269         /// <summary> Bindable property of ClippingMode. Please do not open it. </summary>
270         [EditorBrowsable(EditorBrowsableState.Never)]
271         public static readonly BindableProperty ClippingModeProperty = BindableProperty.Create(nameof(ClippingMode), typeof(ClippingModeType?), typeof(ViewStyle), null,
272             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).clippingMode = (ClippingModeType?)newValue,
273             defaultValueCreator: (bindable) => ((ViewStyle)bindable).clippingMode
274         );
275
276         /// <summary> Bindable property of Size. Please do not open it. </summary>
277         [EditorBrowsable(EditorBrowsableState.Never)]
278         public static readonly BindableProperty SizeProperty = BindableProperty.Create(nameof(Size), typeof(Size), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
279         {
280             var viewStyle = (ViewStyle)bindable;
281             viewStyle.size = (Size)newValue;
282             if (viewStyle.size != null && viewStyle.size.Width == 0 && viewStyle.size.Height == 0)
283             {
284                 viewStyle.size = null;
285             }
286         },
287         defaultValueCreator: (bindable) =>
288         {
289             var viewStyle = (ViewStyle)bindable;
290             return viewStyle.size;
291         });
292
293         /// <summary> Bindable property of Margin. Please do not open it. </summary>
294         [EditorBrowsable(EditorBrowsableState.Never)]
295         public static readonly BindableProperty MarginProperty = BindableProperty.Create(nameof(Margin), typeof(Extents), typeof(ViewStyle), null,
296             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).margin = (Extents)newValue,
297             defaultValueCreator: (bindable) => ((ViewStyle)bindable).margin
298         );
299
300         /// <summary> Bindable property of BackgroundColor. Please do not open it. </summary>
301         [EditorBrowsable(EditorBrowsableState.Never)]
302         public static readonly BindableProperty BackgroundColorSelectorProperty = BindableProperty.Create("BackgroundColorSelector", typeof(Selector<Color>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
303         {
304             var viewStyle = (ViewStyle)bindable;
305
306             if (newValue == null)
307             {
308                 viewStyle.backgroundColorSelector = null;
309             }
310             else
311             {
312                 viewStyle.backgroundColorSelector = (Selector<Color>)newValue;
313                 viewStyle.backgroundImageSelector = null;
314             }
315
316         },
317         defaultValueCreator: (bindable) =>
318         {
319             return ((ViewStyle)bindable).backgroundColorSelector;
320         });
321
322         /// <summary> Bindable property of ColorSelector. Please do not open it. </summary>
323         [EditorBrowsable(EditorBrowsableState.Never)]
324         public static readonly BindableProperty ColorSelectorProperty = BindableProperty.Create("ColorSelector", typeof(Selector<Color>), typeof(ViewStyle), null,
325             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).colorSelector = (Selector<Color>)newValue,
326             defaultValueCreator: (bindable) => ((ViewStyle)bindable).colorSelector
327         );
328
329         /// <summary> Bindable property of BackgroundImageBorder. Please do not open it. </summary>
330         [EditorBrowsable(EditorBrowsableState.Never)]
331         public static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector<Rectangle>), typeof(ViewStyle), null,
332             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).backgroundImageBorderSelector = (Selector<Rectangle>)newValue,
333             defaultValueCreator: (bindable) => ((ViewStyle)bindable).backgroundImageBorderSelector
334         );
335
336         /// <summary> Bindable property of ImageShadow. Please do not open it. </summary>
337         [EditorBrowsable(EditorBrowsableState.Never)]
338         public static readonly BindableProperty ImageShadowSelectorProperty = BindableProperty.Create("ImageShadowSelector", typeof(Selector<ImageShadow>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
339         {
340             var viewStyle = (ViewStyle)bindable;
341
342             viewStyle.imageShadow = (Selector<ImageShadow>)newValue;
343
344             if (viewStyle.imageShadow != null)
345             {
346                 viewStyle.boxShadow = null;
347             }
348         },
349         defaultValueCreator: (bindable) =>
350         {
351             var viewStyle = (ViewStyle)bindable;
352             return ((ViewStyle)bindable).imageShadow;
353         });
354
355         /// <summary> Bindable property of BoxShadow. Please do not open it. </summary>
356         [EditorBrowsable(EditorBrowsableState.Never)]
357         public static readonly BindableProperty BoxShadowSelectorProperty = BindableProperty.Create("BoxShadowSelector", typeof(Selector<Shadow>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
358         {
359             var viewStyle = (ViewStyle)bindable;
360
361             viewStyle.boxShadow = (Selector<Shadow>)newValue;
362
363             if (viewStyle.boxShadow != null)
364             {
365                 viewStyle.imageShadow = null;
366             }
367         },
368         defaultValueCreator: (bindable) =>
369         {
370             var viewStyle = (ViewStyle)bindable;
371             return ((ViewStyle)bindable).boxShadow;
372         });
373
374         /// <summary> Bindable property of CornerRadius. Please do not open it. </summary>
375         [EditorBrowsable(EditorBrowsableState.Never)]
376         public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(nameof(CornerRadius), typeof(Vector4), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
377         {
378             ((ViewStyle)bindable).cornerRadius = (Vector4)newValue;
379         }, defaultValueCreator: (bindable) => ((ViewStyle)bindable).cornerRadius);
380
381         /// <summary> Bindable property of CornerRadiusPolicy. Please do not open it. </summary>
382         [EditorBrowsable(EditorBrowsableState.Never)]
383         public static readonly BindableProperty CornerRadiusPolicyProperty = BindableProperty.Create(nameof(CornerRadiusPolicy), typeof(VisualTransformPolicyType?), typeof(ViewStyle), null,
384             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).cornerRadiusPolicy = (VisualTransformPolicyType?)newValue,
385             defaultValueCreator: (bindable) => ((ViewStyle)bindable).cornerRadiusPolicy
386         );
387
388         /// <summary> Bindable property of ThemeChangeSensitive. Please do not open it. </summary>
389         [EditorBrowsable(EditorBrowsableState.Never)]
390         public static readonly BindableProperty ThemeChangeSensitiveProperty = BindableProperty.Create(nameof(ThemeChangeSensitive), typeof(bool?), typeof(ViewStyle), null,
391             propertyChanged: (bindable, oldValue, newValue) => ((ViewStyle)bindable).themeChangeSensitive = (bool?)newValue,
392             defaultValueCreator: (bindable) => ((ViewStyle)bindable).themeChangeSensitive
393         );
394     }
395 }