2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 using System.Collections.Generic;
18 using System.ComponentModel;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Binding;
22 namespace Tizen.NUI.Components
25 /// ControlStyle is a base class of NUI.Components style.
27 /// <since_tizen> 6 </since_tizen>
28 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class ControlStyle : ViewStyle
32 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public static readonly BindableProperty BackgroundImageProperty = BindableProperty.Create("ControlBackgroundImage", typeof(Selector<string>), typeof(ControlStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
36 var controlStyle = (ControlStyle)bindable;
37 if (null == controlStyle.backgroundImage) controlStyle.backgroundImage = new Selector<string>();
38 controlStyle.backgroundImage.Clone((Selector<string>)newValue);
40 defaultValueCreator: (bindable) =>
42 var controlStyle = (ControlStyle)bindable;
43 return controlStyle.backgroundImage;
45 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
46 [EditorBrowsable(EditorBrowsableState.Never)]
47 public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create("ControlBackgroundColor", typeof(Selector<Color>), typeof(ControlStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
49 var controlStyle = (ControlStyle)bindable;
50 if (null == controlStyle.backgroundColor) controlStyle.backgroundColor = new Selector<Color>();
51 controlStyle.backgroundColor.Clone((Selector<Color>)newValue);
53 defaultValueCreator: (bindable) =>
55 var controlStyle = (ControlStyle)bindable;
56 return controlStyle.backgroundColor;
58 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
59 [EditorBrowsable(EditorBrowsableState.Never)]
60 public static readonly BindableProperty BackgroundImageBorderProperty = BindableProperty.Create("ControlBackgroundImageBorder", typeof(Selector<Rectangle>), typeof(ControlStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
62 var controlStyle = (ControlStyle)bindable;
63 if (null == controlStyle.backgroundImageBorder) controlStyle.backgroundImageBorder = new Selector<Rectangle>();
64 controlStyle.backgroundImageBorder.Clone((Selector<Rectangle>)newValue);
66 defaultValueCreator: (bindable) =>
68 var controlStyle = (ControlStyle)bindable;
69 return controlStyle.backgroundImageBorder;
71 private Selector<string> backgroundImage;
72 private Selector<Rectangle> backgroundImageBorder;
73 private Selector<Color> backgroundColor;
75 /// Creates a new instance of a ControlStyle.
77 /// <since_tizen> 6 </since_tizen>
78 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
79 [EditorBrowsable(EditorBrowsableState.Never)]
80 public ControlStyle() : base()
86 /// Creates a new instance of a ControlStyle with style.
88 /// <param name="style">Create ControlStyle by style customized by user.</param>
89 /// <since_tizen> 6 </since_tizen>
90 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
91 [EditorBrowsable(EditorBrowsableState.Never)]
92 public ControlStyle(ControlStyle style) : base(style)
94 if(null == style) return;
101 /// <summary>Background image resource.</summary>
102 /// This will be public opened in tizen__6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
103 [EditorBrowsable(EditorBrowsableState.Never)]
104 public new Selector<string> BackgroundImage
108 Selector<string> image = (Selector<string>)GetValue(BackgroundImageProperty);
109 return (null != image) ? image : backgroundImage = new Selector<string>();
111 set => SetValue(BackgroundImageProperty, value);
114 /// <summary>Background image border.</summary>
115 /// This will be public opened in tizen__6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
116 [EditorBrowsable(EditorBrowsableState.Never)]
117 public new Selector<Rectangle> BackgroundImageBorder
121 Selector<Rectangle> boder = (Selector<Rectangle>)GetValue(BackgroundImageBorderProperty);
122 return (null != boder) ? boder : backgroundImageBorder = new Selector<Rectangle>();
124 set => SetValue(BackgroundImageBorderProperty, value);
127 /// <summary>Background image color. </summary>
128 /// This will be public opened in tizen__6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 public new Selector<Color> BackgroundColor
134 Selector<Color> color = (Selector<Color>)GetValue(BackgroundColorProperty);
135 return (null != color) ? color : backgroundColor = new Selector<Color>();
137 set => SetValue(BackgroundColorProperty, value);
141 /// Shadow image's Style.
143 /// <since_tizen> 6 </since_tizen>
144 /// This will be public opened in tizen__6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
145 [EditorBrowsable(EditorBrowsableState.Never)]
146 public ImageViewStyle Shadow { get; set; }
148 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
149 [EditorBrowsable(EditorBrowsableState.Never)]
150 public override void CopyFrom(BindableObject bindableObject)
152 base.CopyFrom(bindableObject);
154 ControlStyle controlStyle = bindableObject as ControlStyle;
156 if (null != controlStyle)
158 if (null != controlStyle.Shadow)
160 Shadow.CopyFrom(controlStyle.Shadow);
162 if (null != controlStyle.BackgroundImage)
164 if (null == BackgroundImage) BackgroundImage = new Selector<string>();
165 BackgroundImage.Clone(controlStyle.BackgroundImage);
167 if (null != controlStyle.BackgroundImageBorder)
169 if (null == BackgroundImageBorder) BackgroundImageBorder = new Selector<Rectangle>();
170 BackgroundImageBorder.Clone(controlStyle.BackgroundImageBorder);
172 if (null != controlStyle.BackgroundColor)
174 if (null == BackgroundColor) BackgroundColor = new Selector<Color>();
175 BackgroundColor.Clone(controlStyle.BackgroundColor);
180 private void InitSubstyle()
182 Shadow = new ImageViewStyle()
184 PositionUsesPivotPoint = true,
185 ParentOrigin = Tizen.NUI.ParentOrigin.Center,
186 PivotPoint = Tizen.NUI.PivotPoint.Center,
187 WidthResizePolicy = ResizePolicyType.FillToParent,
188 HeightResizePolicy = ResizePolicyType.FillToParent
190 Shadow.PropertyChanged += SubStyleCalledEvent;
193 private void SubStyleCalledEvent(object sender, global::System.EventArgs e)