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