b91d0b814aca0a147c575da04100f2f9dc18322f
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / Style / Constants.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
18 using System;
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
21
22 namespace Tizen.NUI.Components
23 {
24     /// <summary>
25     /// Enumeration for describing the states of the view.
26     /// </summary>
27     [FlagsAttribute]
28     // Please remove this enum when 'Tizen.NUI.BaseComponents.Button.StateChangedEventArgs' and 'Tizen.NUI.BaseComponents.Slider.StateChangedArgs' are removed.
29     [Obsolete("This will be removed in API10. Please use Tizen.NUI.BaseComponents.ControlState instead!")]
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public enum ControlStates
32     {
33         /// <summary>
34         /// The normal state.
35         /// </summary>
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         Normal = 0,
38         /// <summary>
39         /// The focused state.
40         /// </summary>
41         [EditorBrowsable(EditorBrowsableState.Never)]
42         Focused = 1,
43         /// <summary>
44         /// The disabled state.
45         /// </summary>
46         [EditorBrowsable(EditorBrowsableState.Never)]
47         Disabled = 2,
48         /// <summary>
49         /// The Selected state.
50         /// </summary>
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         Selected = 4,
53         /// <summary>
54         /// The Pressed state.
55         /// </summary>
56         [EditorBrowsable(EditorBrowsableState.Never)]
57         Pressed = 8,
58         /// <summary>
59         /// The DisabledFocused state.
60         /// </summary>
61         [EditorBrowsable(EditorBrowsableState.Never)]
62         DisabledFocused = Disabled | Focused,
63         /// <summary>
64         /// The SelectedFocused state.
65         /// </summary>
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         SelectedFocused = Focused | Selected,
68         /// <summary>
69         /// The DisabledSelected state.
70         /// </summary>
71         [EditorBrowsable(EditorBrowsableState.Never)]
72         DisabledSelected = Disabled | Selected,
73     }
74
75     //FIXME: Please remove this Extension class when ControlStates is removed.
76     [EditorBrowsable(EditorBrowsableState.Never)]
77     internal static class ControlStatesExtension
78     {
79         public static ControlStates FromControlStateClass(ControlState controlState)
80         {
81             if (controlState == ControlState.Normal)
82                 return ControlStates.Normal;
83             if (controlState == ControlState.Focused)
84                 return ControlStates.Focused;
85             if (controlState == ControlState.Disabled)
86                 return ControlStates.Disabled;
87             if (controlState == ControlState.Selected)
88                 return ControlStates.Selected;
89             if (controlState == ControlState.Pressed)
90                 return ControlStates.Pressed;
91             if (controlState == ControlState.DisabledFocused)
92                 return ControlStates.DisabledFocused;
93             if (controlState == ControlState.SelectedFocused)
94                 return ControlStates.SelectedFocused;
95             if (controlState == ControlState.DisabledSelected)
96                 return ControlStates.DisabledSelected;
97
98             return ControlStates.Normal;
99         }
100     }
101 }
102