[NUI] remove "_" and refactoring naming to pascal case.
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / TextFieldSelectorData.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
18 namespace Tizen.NUI.BaseComponents
19 {
20     /// <summary>
21     /// The class storing extra data for a TextField to optimize size of it.
22     /// </summary>
23     internal class TextFieldSelectorData
24     {
25         public TriggerableSelector<string> TranslatableText { get; } = new TriggerableSelector<string>(TextField.TranslatableTextProperty);
26         public TriggerableSelector<string> Text { get; } = new TriggerableSelector<string>(TextField.TextProperty);
27         public TriggerableSelector<string> FontFamily { get; } = new TriggerableSelector<string>(TextField.FontFamilyProperty);
28         public TriggerableSelector<Color> TextColor { get; } = new TriggerableSelector<Color>(TextField.TextColorProperty, GetTextColor);
29         public TriggerableSelector<float?> PointSize { get; } = new TriggerableSelector<float?>(TextField.PointSizeProperty);
30         public TriggerableSelector<string> TranslatablePlaceholderText { get; } = new TriggerableSelector<string>(TextField.TranslatablePlaceholderTextProperty);
31         public TriggerableSelector<Vector4> PlaceholderTextColor { get; } = new TriggerableSelector<Vector4>(TextField.PlaceholderTextColorProperty, delegate (View view)
32         {
33             Vector4 color = new Vector4();
34             if (view.GetProperty(TextField.Property.PlaceholderTextColor).Get(color))
35             {
36                 return color;
37             }
38             return null;
39         });
40
41         public TriggerableSelector<Vector4> PrimaryCursorColor { get; } = new TriggerableSelector<Vector4>(TextField.PrimaryCursorColorProperty, delegate (View view)
42         {
43             Vector4 color = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
44             if (view.GetProperty(TextField.Property.PrimaryCursorColor).Get(color))
45             {
46                 return color;
47             }
48             return null;
49         });
50
51         public void Reset(View view)
52         {
53             TranslatableText.Reset(view);
54             Text.Reset(view);
55             FontFamily.Reset(view);
56             TextColor.Reset(view);
57             PointSize.Reset(view);
58             TranslatablePlaceholderText.Reset(view);
59             PlaceholderTextColor.Reset(view);
60             PrimaryCursorColor.Reset(view);
61         }
62
63         private static Color GetTextColor(View view)
64         {
65             Color color = new Color();
66             if (view.GetProperty(TextField.Property.TextColor).Get(color))
67             {
68                 return color;
69             }
70             return null;
71         }
72     }
73 }