[NUI] Public Style apis (#1434)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / ScrollbarStyle.cs
1 /*
2  * Copyright(c) 2019 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     /// ScrollBarStyle is a class which saves Scrollbar's ux data.
25     /// </summary>
26     /// <since_tizen> 8 </since_tizen>
27     public class ScrollBarStyle : ControlStyle
28     {
29         static ScrollBarStyle() { }
30
31         /// <summary>
32         /// Creates a new instance of a ScrollBarStyle.
33         /// </summary>
34         /// <since_tizen> 8 </since_tizen>
35         public ScrollBarStyle() : base()
36         {
37             InitSubStyle();
38             Direction = ScrollBar.DirectionType.Horizontal;
39         }
40
41         /// <summary>
42         /// Creates a new instance of a ScrollBarStyle with style.
43         /// </summary>
44         /// <param name="style">Create ScrollBarStyle by style customized by user.</param>
45         /// <since_tizen> 8 </since_tizen>
46         public ScrollBarStyle(ScrollBarStyle style) : base(style)
47         {
48             if (null == style) return;
49
50             InitSubStyle();
51
52             this.CopyFrom(style);
53         }
54
55         /// <summary>
56         /// Get or set track image style.
57         /// </summary>
58         /// <since_tizen> 8 </since_tizen>
59         public ImageViewStyle Track { get; set; }
60
61         /// <summary>
62         /// Get or set thumb image style.
63         /// </summary>
64         /// <since_tizen> 8 </since_tizen>
65         public ImageViewStyle Thumb { get; set; }
66
67         /// <summary>
68         /// Get or set direction type.
69         /// </summary>
70         /// <since_tizen> 8 </since_tizen>
71         public ScrollBar.DirectionType? Direction { get; set; }
72
73         /// <summary>
74         /// Get or set duration.
75         /// </summary>
76         /// <since_tizen> 8 </since_tizen>
77         public uint Duration { get; set; }
78
79         /// <summary>
80         /// Style's clone function.
81         /// </summary>
82         /// <param name="bindableObject">The style that need to copy.</param>
83         /// <since_tizen> 8 </since_tizen>
84         public override void CopyFrom(BindableObject bindableObject)
85         {
86             base.CopyFrom(bindableObject);
87
88             ScrollBarStyle scrollBarStyle = bindableObject as ScrollBarStyle;
89
90             if (null != scrollBarStyle)
91             {
92                 if (null != scrollBarStyle.Track)
93                 {
94                     Track?.CopyFrom(scrollBarStyle.Track);
95                 }
96
97                 if (null != scrollBarStyle.Thumb)
98                 {
99                     Thumb?.CopyFrom(scrollBarStyle.Thumb);
100                 }
101
102                 Direction = scrollBarStyle.Direction;
103                 Duration = scrollBarStyle.Duration;
104             }
105         }
106
107         private void InitSubStyle()
108         {
109             Track = new ImageViewStyle()
110             {
111                 PositionUsesPivotPoint = true,
112                 ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
113                 PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
114                 WidthResizePolicy = ResizePolicyType.FillToParent,
115                 HeightResizePolicy = ResizePolicyType.FillToParent
116             };
117
118             Thumb = new ImageViewStyle()
119             {
120                 PositionUsesPivotPoint = true,
121                 ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
122                 PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
123                 WidthResizePolicy = ResizePolicyType.Fixed,
124                 HeightResizePolicy = ResizePolicyType.Fixed
125             };
126         }
127     }
128 }