bacd141119008a0e9a95969967887ad6953f17ba
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / Style / ImageViewStyle.cs
1 /*
2  * Copyright(c) 2021 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.Binding;
19
20 namespace Tizen.NUI.BaseComponents
21 {
22     /// <summary>
23     /// The base class for Children attributes in Components.
24     /// </summary>
25     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
26     [EditorBrowsable(EditorBrowsableState.Never)]
27     public class ImageViewStyle : ViewStyle
28     {
29         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
30         [EditorBrowsable(EditorBrowsableState.Never)]
31         public static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector<string>), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
32         {
33             var imageViewStyle = (ImageViewStyle)bindable;
34             imageViewStyle.resourceUrlSelector = ((Selector<string>)newValue)?.Clone();
35         },
36         defaultValueCreator: (bindable) =>
37         {
38             var imageViewStyle = (ImageViewStyle)bindable;
39             return imageViewStyle.resourceUrlSelector;
40         });
41         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         public static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector<Rectangle>), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
44         {
45             var imageViewStyle = (ImageViewStyle)bindable;
46             imageViewStyle.borderSelector = ((Selector<Rectangle>)newValue)?.Clone();
47         },
48         defaultValueCreator: (bindable) =>
49         {
50             var imageViewStyle = (ImageViewStyle)bindable;
51             return imageViewStyle.borderSelector;
52         });
53         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
54         [EditorBrowsable(EditorBrowsableState.Never)]
55         public static readonly BindableProperty BorderOnlyProperty = BindableProperty.Create(nameof(BorderOnly), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
56         {
57             var imageViewStyle = (ImageViewStyle)bindable;
58             imageViewStyle.borderOnly = (bool?)newValue;
59         },
60         defaultValueCreator: (bindable) =>
61         {
62             var imageViewStyle = (ImageViewStyle)bindable;
63             return imageViewStyle.borderOnly;
64         });
65         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         public static readonly BindableProperty SynchronosLoadingProperty = BindableProperty.Create(nameof(SynchronosLoading), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
68         {
69             var imageViewStyle = (ImageViewStyle)bindable;
70             imageViewStyle.synchronosLoading = (bool?)newValue;
71         },
72         defaultValueCreator: (bindable) =>
73         {
74             var imageViewStyle = (ImageViewStyle)bindable;
75             return imageViewStyle.synchronosLoading;
76         });
77         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
78         [EditorBrowsable(EditorBrowsableState.Never)]
79         public static readonly BindableProperty OrientationCorrectionProperty = BindableProperty.Create(nameof(OrientationCorrection), typeof(bool?), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
80         {
81             var imageViewStyle = (ImageViewStyle)bindable;
82             imageViewStyle.orientationCorrection = (bool?)newValue;
83         },
84         defaultValueCreator: (bindable) =>
85         {
86             var imageViewStyle = (ImageViewStyle)bindable;
87             return imageViewStyle.orientationCorrection;
88         });
89
90         private bool? borderOnly;
91         private bool? synchronosLoading;
92         private bool? orientationCorrection;
93         private Selector<string> resourceUrlSelector;
94         private Selector<Rectangle> borderSelector;
95
96         static ImageViewStyle() { }
97
98         /// <summary>
99         /// Create an empty instance.
100         /// </summary>
101         [EditorBrowsable(EditorBrowsableState.Never)]
102         public ImageViewStyle() : base()
103         {
104         }
105
106         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
107         [EditorBrowsable(EditorBrowsableState.Never)]
108         public bool? BorderOnly
109         {
110             get => (bool?)GetValue(BorderOnlyProperty);
111             set => SetValue(BorderOnlyProperty, value);
112         }
113
114         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
115         [EditorBrowsable(EditorBrowsableState.Never)]
116         public bool? SynchronosLoading
117         {
118             get => (bool?)GetValue(SynchronosLoadingProperty);
119             set => SetValue(SynchronosLoadingProperty, value);
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 bool? OrientationCorrection
125         {
126             get => (bool?)GetValue(OrientationCorrectionProperty);
127             set => SetValue(OrientationCorrectionProperty, value);
128         }
129
130         /// <summary>
131         /// Image URL.
132         /// </summary>
133         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
134         [EditorBrowsable(EditorBrowsableState.Never)]
135         public Selector<string> ResourceUrl
136         {
137             get
138             {
139                 Selector<string> tmp = (Selector<string>)GetValue(ResourceUrlSelectorProperty);
140                 return (null != tmp) ? tmp : resourceUrlSelector = new Selector<string>();
141             }
142             set => SetValue(ResourceUrlSelectorProperty, value);
143         }
144
145         /// <summary>
146         /// Image border.
147         /// </summary>
148         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
149         [EditorBrowsable(EditorBrowsableState.Never)]
150         public Selector<Rectangle> Border
151         {
152             get
153             {
154                 Selector<Rectangle> tmp = (Selector<Rectangle>)GetValue(BorderSelectorProperty);
155                 return (null != tmp) ? tmp : borderSelector = new Selector<Rectangle>();
156             }
157             set => SetValue(BorderSelectorProperty, value);
158         }
159     }
160 }