[NUI] Add ThemeManager (#2034)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / Style / ViewStyle.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;
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using Tizen.NUI.Binding;
21
22 namespace Tizen.NUI.BaseComponents
23 {
24     /// <summary>
25     /// The base class for Children attributes in Components.
26     /// </summary>
27     /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
28     [EditorBrowsable(EditorBrowsableState.Never)]
29     public partial class ViewStyle : BindableObject, IDisposable
30     {
31         private bool disposed = false;
32
33         private string styleName;
34         private View.States? state;
35         private View.States? subState;
36         private float? flex;
37         private int? alignSelf;
38         private Vector4 flexMargin;
39         private Vector2 cellIndex;
40         private float? rowSpan;
41         private float? columnSpan;
42         private HorizontalAlignmentType? cellHorizontalAlignment;
43         private VerticalAlignmentType? cellVerticalAlignment;
44         private View leftFocusableView;
45         private View rightFocusableView;
46         private View upFocusableView;
47         private View downFocusableView;
48         private bool? focusable;
49         private bool? positionUsesPivotPoint;
50         private int? siblingOrder;
51         private Position parentOrigin;
52         private Position pivotPoint;
53         private Position position;
54         private Rotation orientation;
55         private Vector3 scale;
56         private string name;
57         private bool? sensitive;
58         private bool? leaveRequired;
59         private bool? inheritOrientation;
60         private bool? inheritScale;
61         private DrawModeType? drawMode;
62         private Vector3 sizeModeFactor;
63         private ResizePolicyType? widthResizePolicy;
64         private ResizePolicyType? heightResizePolicy;
65         private SizeScalePolicyType? sizeScalePolicy;
66         private bool? widthForHeight;
67         private bool? heightForWidth;
68         private Extents padding;
69         private Size2D minimumSize;
70         private Size2D maximumSize;
71         private bool? inheritPosition;
72         private ClippingModeType? clippingMode;
73         private Size size;
74         private bool? inheritLayoutDirection;
75         private ViewLayoutDirectionType? layoutDirection;
76         private Extents margin;
77         private float? weight;
78         private bool? enableControlState;
79         private bool? themeChangeSensitive;
80
81         private Selector<ImageShadow> imageShadow;
82         private Selector<Shadow> boxShadow;
83         private Selector<string> backgroundImageSelector;
84         private Selector<float?> cornerRadius;
85         private Selector<float?> opacitySelector;
86         private Selector<Color> backgroundColorSelector;
87         private Selector<Rectangle> backgroundImageBorderSelector;
88         private Selector<Color> colorSelector;
89
90         static ViewStyle() { }
91
92         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public ViewStyle() { }
95
96         /// <summary>   
97         /// destructor. This is HiddenAPI. recommended not to use in public.    
98         /// </summary>  
99         [EditorBrowsable(EditorBrowsableState.Never)]
100         ~ViewStyle()
101         {
102             Dispose();
103         }
104
105         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
106         [EditorBrowsable(EditorBrowsableState.Never)]
107         public ViewStyle(ViewStyle viewAttributes)
108         {
109             CopyFrom(viewAttributes);
110         }
111
112         /// <summary>
113         /// Create an instance and set properties from the given view.
114         /// </summary>
115         /// <param name="view">The View that includes property data.</param>
116         [EditorBrowsable(EditorBrowsableState.Never)]
117         public ViewStyle(View view)
118         {
119             CopyPropertiesFromView(view);
120         }
121
122         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
123         [EditorBrowsable(EditorBrowsableState.Never)]
124         public string StyleName
125         {
126             get => (string)GetValue(StyleNameProperty);
127             set => SetValue(StyleNameProperty, value);
128         }
129
130         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
131         [EditorBrowsable(EditorBrowsableState.Never)]
132         public Selector<string> BackgroundImage
133         {
134             get
135             {
136                 Selector<string> image = (Selector<string>)GetValue(BackgroundImageSelectorProperty);
137                 return (null != image) ? image : backgroundImageSelector = new Selector<string>();
138             }
139             set => SetValue(BackgroundImageSelectorProperty, value);
140         }
141
142         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
143         [EditorBrowsable(EditorBrowsableState.Never)]
144         public View.States? State
145         {
146             get => (View.States?)GetValue(StateProperty);
147             set => SetValue(StateProperty, value);
148         }
149
150         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
151         [EditorBrowsable(EditorBrowsableState.Never)]
152         public View.States? SubState
153         {
154             get => (View.States?)GetValue(SubStateProperty);
155             set => SetValue(SubStateProperty, value);
156         }
157
158         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
159         [EditorBrowsable(EditorBrowsableState.Never)]
160         public float? Flex
161         {
162             get => (float?)GetValue(FlexProperty);
163             set => SetValue(FlexProperty, value);
164         }
165
166         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
167         [EditorBrowsable(EditorBrowsableState.Never)]
168         public int? AlignSelf
169         {
170             get => (int?)GetValue(AlignSelfProperty);
171             set => SetValue(AlignSelfProperty, value);
172         }
173
174         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
175         [EditorBrowsable(EditorBrowsableState.Never)]
176         public Vector4 FlexMargin
177         {
178             get => (Vector4)GetValue(FlexMarginProperty);
179             set => SetValue(FlexMarginProperty, value);
180         }
181
182         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
183         [EditorBrowsable(EditorBrowsableState.Never)]
184         public Vector2 CellIndex
185         {
186             get => (Vector2)GetValue(CellIndexProperty);
187             set => SetValue(CellIndexProperty, value);
188         }
189
190         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
191         [EditorBrowsable(EditorBrowsableState.Never)]
192         public float? RowSpan
193         {
194             get => (float?)GetValue(RowSpanProperty);
195             set => SetValue(RowSpanProperty, value);
196         }
197
198         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
199         [EditorBrowsable(EditorBrowsableState.Never)]
200         public float? ColumnSpan
201         {
202             get => (float?)GetValue(ColumnSpanProperty);
203             set => SetValue(ColumnSpanProperty, value);
204         }
205
206         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
207         [EditorBrowsable(EditorBrowsableState.Never)]
208         public HorizontalAlignmentType? CellHorizontalAlignment
209         {
210             get => (HorizontalAlignmentType?)GetValue(CellHorizontalAlignmentProperty);
211             set => SetValue(CellHorizontalAlignmentProperty, value);
212         }
213
214         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
215         [EditorBrowsable(EditorBrowsableState.Never)]
216         public VerticalAlignmentType? CellVerticalAlignment
217         {
218             get => (VerticalAlignmentType?)GetValue(CellVerticalAlignmentProperty);
219             set => SetValue(CellVerticalAlignmentProperty, value);
220         }
221
222         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
223         [EditorBrowsable(EditorBrowsableState.Never)]
224         public View LeftFocusableView
225         {
226             get => (View)GetValue(LeftFocusableViewProperty);
227             set => SetValue(LeftFocusableViewProperty, value);
228         }
229
230         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
231         [EditorBrowsable(EditorBrowsableState.Never)]
232         public View RightFocusableView
233         {
234             get => (View)GetValue(RightFocusableViewProperty);
235             set => SetValue(RightFocusableViewProperty, value);
236         }
237
238         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
239         [EditorBrowsable(EditorBrowsableState.Never)]
240         public View UpFocusableView
241         {
242             get => (View)GetValue(UpFocusableViewProperty);
243             set => SetValue(UpFocusableViewProperty, value);
244         }
245
246         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
247         [EditorBrowsable(EditorBrowsableState.Never)]
248         public View DownFocusableView
249         {
250             get => (View)GetValue(DownFocusableViewProperty);
251             set => SetValue(DownFocusableViewProperty, value);
252         }
253
254         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
255         [EditorBrowsable(EditorBrowsableState.Never)]
256         public bool? Focusable
257         {
258             get => (bool?)GetValue(FocusableProperty);
259             set => SetValue(FocusableProperty, value);
260         }
261
262         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
263         [EditorBrowsable(EditorBrowsableState.Never)]
264         public Size2D Size2D
265         {
266             get => (Size2D)GetValue(Size2DProperty);
267             set => SetValue(Size2DProperty, value);
268         }
269
270         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
271         [EditorBrowsable(EditorBrowsableState.Never)]
272         public Selector<float?> Opacity
273         {
274             get
275             {
276                 Selector<float?> opacity = (Selector<float?>)GetValue(OpacitySelectorProperty);
277                 return (null != opacity) ? opacity : opacitySelector = new Selector<float?>();
278             }
279             set => SetValue(OpacitySelectorProperty, value);
280         }
281
282         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
283         [EditorBrowsable(EditorBrowsableState.Never)]
284         public Position2D Position2D
285         {
286             get => (Position2D)GetValue(Position2DProperty);
287             set => SetValue(Position2DProperty, value);
288         }
289
290         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
291         [EditorBrowsable(EditorBrowsableState.Never)]
292         public bool? PositionUsesPivotPoint
293         {
294             get => (bool?)GetValue(PositionUsesPivotPointProperty);
295             set => SetValue(PositionUsesPivotPointProperty, value);
296         }
297
298         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
299         [EditorBrowsable(EditorBrowsableState.Never)]
300         public int? SiblingOrder
301         {
302             get => (int?)GetValue(SiblingOrderProperty);
303             set => SetValue(SiblingOrderProperty, value);
304         }
305
306         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
307         [EditorBrowsable(EditorBrowsableState.Never)]
308         public Position ParentOrigin
309         {
310             get => (Position)GetValue(ParentOriginProperty);
311             set => SetValue(ParentOriginProperty, value);
312         }
313
314         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
315         [EditorBrowsable(EditorBrowsableState.Never)]
316         public Position PivotPoint
317         {
318             get => (Position)GetValue(PivotPointProperty);
319             set => SetValue(PivotPointProperty, value);
320         }
321
322         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
323         [EditorBrowsable(EditorBrowsableState.Never)]
324         public float? SizeWidth
325         {
326             get => (float?)GetValue(SizeWidthProperty);
327             set => SetValue(SizeWidthProperty, value);
328         }
329
330         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
331         [EditorBrowsable(EditorBrowsableState.Never)]
332         public float? SizeHeight
333         {
334             get => (float?)GetValue(SizeHeightProperty);
335             set => SetValue(SizeHeightProperty, value);
336         }
337
338         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
339         [EditorBrowsable(EditorBrowsableState.Never)]
340         public Position Position
341         {
342             get => (Position)GetValue(PositionProperty);
343             set => SetValue(PositionProperty, value);
344         }
345
346         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
347         [EditorBrowsable(EditorBrowsableState.Never)]
348         public float? PositionX
349         {
350             get => (float?)GetValue(PositionXProperty);
351             set => SetValue(PositionXProperty, value);
352         }
353
354         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
355         [EditorBrowsable(EditorBrowsableState.Never)]
356         public float? PositionY
357         {
358             get => (float?)GetValue(PositionYProperty);
359             set => SetValue(PositionYProperty, value);
360         }
361
362         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
363         [EditorBrowsable(EditorBrowsableState.Never)]
364         public float? PositionZ
365         {
366             get => (float?)GetValue(PositionZProperty);
367             set => SetValue(PositionZProperty, value);
368         }
369
370         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
371         [EditorBrowsable(EditorBrowsableState.Never)]
372         public Rotation Orientation
373         {
374             get => (Rotation)GetValue(OrientationProperty);
375             set => SetValue(OrientationProperty, value);
376         }
377
378         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
379         [EditorBrowsable(EditorBrowsableState.Never)]
380         public Vector3 Scale
381         {
382             get => (Vector3)GetValue(ScaleProperty);
383             set => SetValue(ScaleProperty, value);
384         }
385
386         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
387         [EditorBrowsable(EditorBrowsableState.Never)]
388         public float? ScaleX
389         {
390             get => (float?)GetValue(ScaleXProperty);
391             set => SetValue(ScaleXProperty, value);
392         }
393
394         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
395         [EditorBrowsable(EditorBrowsableState.Never)]
396         public float? ScaleY
397         {
398             get => (float?)GetValue(ScaleYProperty);
399             set => SetValue(ScaleYProperty, value);
400         }
401
402         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
403         [EditorBrowsable(EditorBrowsableState.Never)]
404         public float? ScaleZ
405         {
406             get => (float?)GetValue(ScaleZProperty);
407             set => SetValue(ScaleZProperty, value);
408         }
409
410         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
411         [EditorBrowsable(EditorBrowsableState.Never)]
412         public string Name
413         {
414             get => (string)GetValue(NameProperty);
415             set => SetValue(NameProperty, value);
416         }
417
418         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
419         [EditorBrowsable(EditorBrowsableState.Never)]
420         public bool? Sensitive
421         {
422             get => (bool?)GetValue(SensitiveProperty);
423             set => SetValue(SensitiveProperty, value);
424         }
425
426         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
427         [EditorBrowsable(EditorBrowsableState.Never)]
428         public bool? LeaveRequired
429         {
430             get => (bool?)GetValue(LeaveRequiredProperty);
431             set => SetValue(LeaveRequiredProperty, value);
432         }
433
434         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
435         [EditorBrowsable(EditorBrowsableState.Never)]
436         public bool? InheritOrientation
437         {
438             get => (bool?)GetValue(InheritOrientationProperty);
439             set => SetValue(InheritOrientationProperty, value);
440         }
441
442         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
443         [EditorBrowsable(EditorBrowsableState.Never)]
444         public bool? InheritScale
445         {
446             get => (bool?)GetValue(InheritScaleProperty);
447             set => SetValue(InheritScaleProperty, value);
448         }
449
450         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
451         [EditorBrowsable(EditorBrowsableState.Never)]
452         public DrawModeType? DrawMode
453         {
454             get => (DrawModeType?)GetValue(DrawModeProperty);
455             set => SetValue(DrawModeProperty, value);
456         }
457
458         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
459         [EditorBrowsable(EditorBrowsableState.Never)]
460         public Vector3 SizeModeFactor
461         {
462             get => (Vector3)GetValue(SizeModeFactorProperty);
463             set => SetValue(SizeModeFactorProperty, value);
464         }
465
466         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
467         [EditorBrowsable(EditorBrowsableState.Never)]
468         public ResizePolicyType? WidthResizePolicy
469         {
470             get => (ResizePolicyType?)GetValue(WidthResizePolicyProperty);
471             set => SetValue(WidthResizePolicyProperty, value);
472         }
473
474         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
475         [EditorBrowsable(EditorBrowsableState.Never)]
476         public ResizePolicyType? HeightResizePolicy
477         {
478             get => (ResizePolicyType?)GetValue(HeightResizePolicyProperty);
479             set => SetValue(HeightResizePolicyProperty, value);
480         }
481
482         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
483         [EditorBrowsable(EditorBrowsableState.Never)]
484         public SizeScalePolicyType? SizeScalePolicy
485         {
486             get => (SizeScalePolicyType?)GetValue(SizeScalePolicyProperty);
487             set => SetValue(SizeScalePolicyProperty, value);
488         }
489
490         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
491         [EditorBrowsable(EditorBrowsableState.Never)]
492         public bool? WidthForHeight
493         {
494             get => (bool?)GetValue(WidthForHeightProperty);
495             set => SetValue(WidthForHeightProperty, value);
496         }
497
498         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
499         [EditorBrowsable(EditorBrowsableState.Never)]
500         public bool? HeightForWidth
501         {
502             get => (bool?)GetValue(HeightForWidthProperty);
503             set => SetValue(HeightForWidthProperty, value);
504         }
505
506         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
507         [EditorBrowsable(EditorBrowsableState.Never)]
508         public Extents Padding
509         {
510             get
511             {
512                 Extents tmp = (Extents)GetValue(PaddingProperty);
513                 return (null != tmp) ? tmp : padding = new Extents(OnPaddingChanged, 0, 0, 0, 0);
514             }
515             set => SetValue(PaddingProperty, value);
516         }
517
518         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
519         [EditorBrowsable(EditorBrowsableState.Never)]
520         public Size2D MinimumSize
521         {
522             get => (Size2D)GetValue(MinimumSizeProperty);
523             set => SetValue(MinimumSizeProperty, value);
524         }
525
526         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
527         [EditorBrowsable(EditorBrowsableState.Never)]
528         public Size2D MaximumSize
529         {
530             get => (Size2D)GetValue(MaximumSizeProperty);
531             set => SetValue(MaximumSizeProperty, value);
532         }
533
534         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
535         [EditorBrowsable(EditorBrowsableState.Never)]
536         public bool? InheritPosition
537         {
538             get => (bool?)GetValue(InheritPositionProperty);
539             set => SetValue(InheritPositionProperty, value);
540         }
541
542         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
543         [EditorBrowsable(EditorBrowsableState.Never)]
544         public ClippingModeType? ClippingMode
545         {
546             get => (ClippingModeType?)GetValue(ClippingModeProperty);
547             set => SetValue(ClippingModeProperty, value);
548         }
549
550         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
551         [EditorBrowsable(EditorBrowsableState.Never)]
552         public Size Size
553         {
554             get
555             {
556                 Size tmp = (Size)GetValue(SizeProperty);
557                 return (null != tmp) ? tmp : size = new Size((float? width, float? height, float? depth) =>
558                     {
559                         float targetWidth = 0;
560                         float targetHeight = 0;
561                         float targetDepth = 0;
562
563                         if (size != null)
564                         {
565                             targetWidth = size.Width;
566                             targetHeight = size.Height;
567                             targetDepth = size.Depth;
568                         }
569                         if (width != null) { targetWidth = (float)width; }
570                         if (height != null) { targetHeight = (float)height; }
571                         if (depth != null) { targetDepth = (float)depth; }
572
573                         Size = new Size(targetWidth, targetHeight, targetDepth);
574                     }, 0, 0, 0);
575             }
576             set => SetValue(SizeProperty, value);
577         }
578
579         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
580         [EditorBrowsable(EditorBrowsableState.Never)]
581         public bool? InheritLayoutDirection
582         {
583             get => (bool?)GetValue(InheritLayoutDirectionProperty);
584             set => SetValue(InheritLayoutDirectionProperty, value);
585         }
586
587         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
588         [EditorBrowsable(EditorBrowsableState.Never)]
589         public ViewLayoutDirectionType? LayoutDirection
590         {
591             get => (ViewLayoutDirectionType?)GetValue(LayoutDirectionProperty);
592             set => SetValue(LayoutDirectionProperty, value);
593         }
594
595         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
596         [EditorBrowsable(EditorBrowsableState.Never)]
597         public Extents Margin
598         {
599             get
600             {
601                 Extents tmp = (Extents)GetValue(MarginProperty);
602                 return (null != tmp) ? tmp : margin = new Extents(OnMarginChanged, 0, 0, 0, 0);
603             }
604             set => SetValue(MarginProperty, value);
605         }
606
607         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
608         [EditorBrowsable(EditorBrowsableState.Never)]
609         public float? Weight
610         {
611             get => (float?)GetValue(WeightProperty);
612             set => SetValue(WeightProperty, value);
613         }
614
615         /// <summary> View BackgroundColor </summary>
616         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
617         [EditorBrowsable(EditorBrowsableState.Never)]
618         public Selector<Color> BackgroundColor
619         {
620             get
621             {
622                 Selector<Color> color = (Selector<Color>)GetValue(BackgroundColorSelectorProperty);
623                 return (null != color) ? color : backgroundColorSelector = new Selector<Color>();
624             }
625             set => SetValue(BackgroundColorSelectorProperty, value);
626         }
627
628         /// <summary>
629         /// Color
630         /// </summary>
631         [EditorBrowsable(EditorBrowsableState.Never)]
632         public Selector<Color> Color
633         {
634             get
635             {
636                 Selector<Color> color = (Selector<Color>)GetValue(ColorSelectorProperty);
637                 return (null != color) ? color : colorSelector = new Selector<Color>();
638             }
639             set => SetValue(ColorSelectorProperty, value);
640         }
641
642         /// <summary>View BackgroundBorder</summary>
643         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
644         [EditorBrowsable(EditorBrowsableState.Never)]
645         public Selector<Rectangle> BackgroundImageBorder
646         {
647             get
648             {
649                 Selector<Rectangle> border = (Selector<Rectangle>)GetValue(BackgroundImageBorderSelectorProperty);
650                 return (null != border) ? border : backgroundImageBorderSelector = new Selector<Rectangle>();
651             }
652             set => SetValue(BackgroundImageBorderSelectorProperty, value);
653         }
654
655         /// <summary>
656         /// Describes a shadow as an image for a View.
657         /// It is null by default.
658         /// </summary>
659         /// <remarks>
660         /// If BoxShadow is not null, the ImageShadow value will be ignored.
661         /// </remarks>
662         [EditorBrowsable(EditorBrowsableState.Never)]
663         public Selector<ImageShadow> ImageShadow
664         {
665             get => (Selector<ImageShadow>)GetValue(ImageShadowSelectorProperty);
666             set => SetValue(ImageShadowSelectorProperty, value);
667         }
668
669         /// <summary>
670         /// Describes a box shaped shadow drawing for a View.
671         /// It is null by default.
672         /// </summary>
673         [EditorBrowsable(EditorBrowsableState.Never)]
674         public Selector<Shadow> BoxShadow
675         {
676             get => (Selector<Shadow>)GetValue(BoxShadowSelectorProperty);
677             set => SetValue(BoxShadowSelectorProperty, value);
678         }
679
680         /// <summary>
681         /// The radius for the rounded corners of the View
682         /// </summary>
683         [EditorBrowsable(EditorBrowsableState.Never)]
684         public Selector<float?> CornerRadius
685         {
686             get => (Selector<float?>)GetValue(CornerRadiusProperty);
687             set => SetValue(CornerRadiusProperty, value);
688         }
689
690         /// <summary>
691         /// The EnableControlState value of the View.
692         /// </summary>
693         [EditorBrowsable(EditorBrowsableState.Never)]
694         public bool? EnableControlState
695         {
696             get => (bool?)GetValue(EnableControlStateProperty);
697             set => SetValue(EnableControlStateProperty, value);
698         }
699
700         /// <summary>
701         /// The ThemeChangeSensitive value of the View.
702         /// </summary>
703         [EditorBrowsable(EditorBrowsableState.Never)]
704         public bool? ThemeChangeSensitive
705         {
706             get => (bool?)GetValue(ThemeChangeSensitiveProperty);
707             set => SetValue(ThemeChangeSensitiveProperty, value);
708         }
709
710
711         /// <summary>
712         /// Allow null properties when merging it into other Theme.
713         /// If the value is true, the null properties reset target properties of the other ViewStyle with same key when merge.
714         /// It is used in <seealso cref="Theme.Merge(string)"/>, <seealso cref="Theme.Merge(Theme)"/>.
715         /// It is also used in <seealso cref="Theme.GetStyle(string)"/> when the Theme has a parent and needs to merge.
716         /// Please note that it is false by default.
717         /// </summary>
718         [EditorBrowsable(EditorBrowsableState.Never)]
719         public bool SolidNull { get; set; } = false;
720
721         /// <summary>
722         /// Set style's bindable properties from the view.
723         /// </summary>
724         /// <param name="view">The view that includes property data.</param>
725         [EditorBrowsable(EditorBrowsableState.Never)]
726         public virtual void CopyPropertiesFromView(View view)
727         {
728             if (view == null) return;
729
730             BindableProperty.GetBindablePropertysOfType(GetType(), out var styleProperties);
731             BindableProperty.GetBindablePropertysOfType(view.GetType(), out var viewProperties);
732
733
734             if (styleProperties == null || viewProperties == null) return;
735
736             foreach (var stylePropertyItem in styleProperties)
737             {
738                 viewProperties.TryGetValue(stylePropertyItem.Key, out var viewProperty);
739
740                 if (viewProperty == null) continue;
741
742                 SetValue(stylePropertyItem.Value, view.GetValue(viewProperty));
743             }
744         }
745
746         /// <summary>Create a cloned ViewStyle.</summary>
747         [EditorBrowsable(EditorBrowsableState.Never)]
748         public ViewStyle Clone()
749         {
750             var cloned = CreateInstance();
751             cloned.CopyFrom(this);
752
753             return cloned;
754         }
755
756         /// <summary>Create a cloned ViewStyle.</summary>
757         [EditorBrowsable(EditorBrowsableState.Never)]
758         public void Merge(ViewStyle other)
759         {
760             AllowNullCopy = other?.SolidNull ?? false;
761             CopyFrom(other);
762             AllowNullCopy = false;
763         }
764
765         internal ViewStyle CreateInstance()
766         {
767             return (ViewStyle)Activator.CreateInstance(GetType());
768         }
769
770         private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom)
771         {
772             Padding = new Extents(start, end, top, bottom);
773         }
774
775         private void OnMarginChanged(ushort start, ushort end, ushort top, ushort bottom)
776         {
777             Margin = new Extents(start, end, top, bottom);
778         }
779
780         /// <summary>
781         /// Releases any unmanaged resources used by this object. Can also dispose any other disposable objects.
782         /// </summary>
783         /// <param name="disposing">If true, disposes any disposable objects. If false, does not dispose disposable objects.</param>
784         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
785         [EditorBrowsable(EditorBrowsableState.Never)]
786         protected virtual void Dispose(bool disposing)
787         {
788             if (disposed)
789                 return;
790
791             if (disposing)
792             {
793                 cellIndex?.Dispose();
794                 downFocusableView?.Dispose();
795                 flexMargin?.Dispose();
796                 leftFocusableView?.Dispose();
797                 margin?.Dispose();
798                 maximumSize?.Dispose();
799                 minimumSize?.Dispose();
800                 orientation?.Dispose();
801                 padding?.Dispose();
802                 parentOrigin?.Dispose();
803                 pivotPoint?.Dispose();
804                 position?.Dispose();
805                 rightFocusableView?.Dispose();
806                 scale?.Dispose();
807                 size?.Dispose();
808                 sizeModeFactor?.Dispose();
809                 upFocusableView?.Dispose();
810             }
811             disposed = true;
812         }
813
814         /// <summary>
815         /// Dispose the window resources
816         /// </summary>
817         /// <returns></returns>
818         /// <since_tizen> 6 </since_tizen>
819         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
820         [EditorBrowsable(EditorBrowsableState.Never)]
821         public void Dispose()
822         {
823             Dispose(true);
824         }
825     }
826 }