9fd3e97b444b2fe039de4aba354474c056ede0ca
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / LoadingStyle.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.BaseComponents;
19 using Tizen.NUI.Binding;
20
21 namespace Tizen.NUI.Components
22 {
23     /// <summary>
24     /// LoadingStyle is a class which saves Loading's ux data.
25     /// </summary>
26     /// <since_tizen> 8 </since_tizen>
27     public class LoadingStyle : ControlStyle
28     {
29         /// <summary>The FrameRateSelector bindable property.</summary>
30         [EditorBrowsable(EditorBrowsableState.Never)]
31         public static readonly BindableProperty FrameRateSelectorProperty = BindableProperty.Create("FrameRateSelector", typeof(Selector<int?>), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
32         {
33             ((LoadingStyle)bindable).frameRate = ((Selector<int?>)newValue)?.Clone();
34         },
35         defaultValueCreator: (bindable) =>
36         {
37             return ((LoadingStyle)bindable).frameRate;
38         });
39
40         /// <summary>The LoadingSize bindable property.</summary>
41         [EditorBrowsable(EditorBrowsableState.Never)]
42         public static readonly BindableProperty LoadingSizeProperty = BindableProperty.Create(nameof(LoadingSize), typeof(Size), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
43         {
44             ((LoadingStyle)bindable).Size = (Size)newValue;
45         },
46         defaultValueCreator: (bindable) =>
47         {
48             return ((LoadingStyle)bindable).Size;
49         });
50
51         /// <summary>The Images bindable property.</summary>
52         [EditorBrowsable(EditorBrowsableState.Never)]
53         public static readonly BindableProperty ImagesProperty = BindableProperty.Create(nameof(Images), typeof(string[]), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
54         {
55             ((LoadingStyle)bindable).images = (string[])((string[])newValue)?.Clone();
56         },
57         defaultValueCreator: (bindable) =>
58         {
59             return ((LoadingStyle)bindable).images;
60         });
61
62         private Selector<int?> frameRate;
63         private string[] images;
64
65         static LoadingStyle() { }
66
67         /// <summary>
68         /// Creates a new instance of a LoadingStyle.
69         /// </summary>
70         /// <since_tizen> 8 </since_tizen>
71         public LoadingStyle() : base() { }
72
73         /// <summary>
74         /// Creates a new instance of a LoadingStyle with style.
75         /// </summary>
76         /// <param name="style">Create LoadingStyle by style customized by user.</param>
77         /// <since_tizen> 8 </since_tizen>
78         public LoadingStyle(LoadingStyle style) : base(style)
79         {
80         }
81
82         /// <summary>
83         /// Gets or sets loading image resources.
84         /// </summary>
85         /// <since_tizen> 8 </since_tizen>
86         public string[] Images
87         {
88             get => (string[])GetValue(ImagesProperty);
89             set => SetValue(ImagesProperty, value);
90         }
91
92         /// <summary>
93         /// Gets or sets loading image size.
94         /// </summary>
95         /// <since_tizen> 8 </since_tizen>
96         public Size LoadingSize
97         {
98             get => (Size)GetValue(LoadingSizeProperty);
99             set => SetValue(LoadingSizeProperty, value);
100         }
101
102         /// <summary>
103         /// Gets or sets loading frame per second.
104         /// </summary>
105         /// <since_tizen> 8 </since_tizen>
106         public Selector<int?> FrameRate
107         {
108             get => (Selector<int?>)GetValue(FrameRateSelectorProperty);
109             set => SetValue(FrameRateSelectorProperty, value);
110         }
111
112         /// <summary>
113         /// Style's clone function.
114         /// </summary>
115         /// <param name="bindableObject">The style that need to copy.</param>
116         /// <since_tizen> 8 </since_tizen>
117         public override void CopyFrom(BindableObject bindableObject)
118         {
119             base.CopyFrom(bindableObject);
120         }
121     }
122 }