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.ComponentModel;
18 using Tizen.NUI.Binding;
19 using Tizen.NUI.Components;
21 namespace Tizen.NUI.BaseComponents
24 /// Selector class, which is related by Control State, it is base class for other Selector.
26 /// <since_tizen> 6 </since_tizen>
27 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
28 [EditorBrowsable(EditorBrowsableState.Never)]
29 public class Selector<T> : BindableObject
31 /// <since_tizen> 6 </since_tizen>
32 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 public static implicit operator Selector<T>(T value)
35 Selector<T> selector = new Selector<T>();
43 /// <since_tizen> 6 </since_tizen>
44 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
45 [EditorBrowsable(EditorBrowsableState.Never)]
54 /// <since_tizen> 6 </since_tizen>
55 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
56 [EditorBrowsable(EditorBrowsableState.Never)]
65 /// <since_tizen> 6 </since_tizen>
66 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
67 [EditorBrowsable(EditorBrowsableState.Never)]
76 /// <since_tizen> 6 </since_tizen>
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)]
87 /// <since_tizen> 6 </since_tizen>
88 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
89 [EditorBrowsable(EditorBrowsableState.Never)]
98 /// <since_tizen> 6 </since_tizen>
99 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
100 [EditorBrowsable(EditorBrowsableState.Never)]
107 /// DisabledFocused State.
109 /// <since_tizen> 6 </since_tizen>
110 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
111 [EditorBrowsable(EditorBrowsableState.Never)]
112 public T DisabledFocused
118 /// SelectedFocused State.
120 /// <since_tizen> 6 </since_tizen>
121 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
122 public T SelectedFocused
128 /// DisabledSelected State.
130 /// <since_tizen> 6 </since_tizen>
131 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 public T DisabledSelected
141 /// <since_tizen> 6 </since_tizen>
142 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
143 [EditorBrowsable(EditorBrowsableState.Never)]
150 /// Get value by State.
152 /// <since_tizen> 6 </since_tizen>
153 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
154 [EditorBrowsable(EditorBrowsableState.Never)]
155 public T GetValue(ControlStates state)
163 case ControlStates.Normal:
164 return Normal != null? Normal : Other;
165 case ControlStates.Focused:
166 return Focused != null? Focused : Other;
167 case ControlStates.Pressed:
168 return Pressed != null? Pressed : Other;
169 case ControlStates.Disabled:
170 return Disabled != null? Disabled : Other;
171 case ControlStates.Selected:
172 return Selected != null? Selected : Other;
173 case ControlStates.DisabledFocused:
174 return DisabledFocused != null? DisabledFocused : Other;
175 case ControlStates.DisabledSelected:
176 return DisabledSelected != null? DisabledSelected : Other;
177 case ControlStates.SelectedFocused:
178 return SelectedFocused != null ? SelectedFocused : Other;
186 /// <since_tizen> 6 </since_tizen>
187 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
188 [EditorBrowsable(EditorBrowsableState.Never)]
189 public void Clone(Selector<T> selector)
192 Normal = selector.Normal;
193 Focused = selector.Focused;
194 Pressed = selector.Pressed;
195 Disabled = selector.Disabled;
196 Selected = selector.Selected;
197 DisabledSelected = selector.DisabledSelected;
198 DisabledFocused = selector.DisabledFocused;
199 SelectedFocused = selector.SelectedFocused;
200 Other = selector.Other;
204 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
205 [EditorBrowsable(EditorBrowsableState.Never)]
206 public class TriggerableSelector<T> : Selector<T>
208 public TriggerableSelector(View view, BindableProperty bindableProperty)
211 targetBindableProperty = bindableProperty;
212 view.ControlStateChangeEvent += OnViewControlState;
218 /// <since_tizen> 6 </since_tizen>
219 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
220 [EditorBrowsable(EditorBrowsableState.Never)]
221 public new void Clone(Selector<T> selector)
223 base.Clone(selector);
225 if (null != targetView && null != GetValue(targetView.ControlState))
227 targetView.SetValue(targetBindableProperty, GetValue(targetView.ControlState));
231 private void OnViewControlState(View obj, ControlStates state)
233 if (null != obj && null != GetValue(state))
235 obj.SetValue(targetBindableProperty, GetValue(state));
239 private View targetView;
240 private BindableProperty targetBindableProperty;