/// <since_tizen> 6 </since_tizen>
public Button() : base()
{
+ Focusable = true;
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Button(string style) : base(style)
{
+ Focusable = true;
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Button(ButtonStyle buttonStyle) : base(buttonStyle)
{
+ Focusable = true;
}
/// <summary>
// If the OnThemeChangedEvent is not implemented, ApplyStyle()
base.OnThemeChanged(sender, e);
}
+
+ /// <summary>
+ /// when the derived class of Control is used as container and itself is not Focusable, this can be used when calling SetCurrentFocusView()
+ /// this can return Focusable View inside of itself. this can be utilized when default algorithm is enabled and when the case of setting first key focus in container.
+ /// </summary>
+ /// <returns>Focusable View inside of container</returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal virtual View PassFocusableViewInsideIfNeeded()
+ {
+ return this;
+ }
+
}
}
/// DateChangedEventArgs default constructor.
/// <param name="date">date value of DatePicker.</param>
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public DateChangedEventArgs(DateTime date)
{
Date = date;
private Picker dayPicker;
private Picker monthPicker;
private Picker yearPicker;
-
+
/// <summary>
/// Creates a new instance of DatePicker.
/// </summary>
public DatePicker()
{
}
-
+
/// <summary>
/// Creates a new instance of DatePicker.
/// </summary>
/// </summary>
/// <since_tizen> 9 </since_tizen>
public event EventHandler<DateChangedEventArgs> DateChanged;
-
+
/// <summary>
/// The Date value of DatePicker.
/// </summary>
{
MinValue = 1,
MaxValue = 31,
+ Focusable = true,
};
dayPicker.ValueChanged += OnDayValueChanged;
{
MinValue = 1,
MaxValue = 12,
+ Focusable = true,
};
monthPicker.ValueChanged += OnMonthValueChanged;
{
MinValue = 1970,
MaxValue = 2100,
+ Focusable = true,
};
yearPicker.ValueChanged += OnYearValueChanged;
}
}
+ /// <summary>
+ /// ToDo : only key navigation is enabled, but value editing is not yet added. for example, after enter key and up/down key the value need be changed.
+ /// </summary>
+ /// <param name="currentFocusedView"></param>
+ /// <param name="direction"></param>
+ /// <param name="loopEnabled"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
+ {
+ if (currentFocusedView == yearPicker)
+ {
+ if (direction == View.FocusDirection.Right)
+ {
+ return monthPicker;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return null;
+ }
+ }
+ else if (currentFocusedView == monthPicker)
+ {
+ if (direction == View.FocusDirection.Right)
+ {
+ return dayPicker;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return yearPicker;
+ }
+ }
+ else if (currentFocusedView == dayPicker)
+ {
+ if (direction == View.FocusDirection.Right)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return monthPicker;
+ }
+ }
+ return null;
+ }
+
private void Initialize()
{
HeightSpecification = LayoutParamPolicies.MatchParent;
- Layout = new LinearLayout() {
+ Layout = new LinearLayout()
+ {
LinearOrientation = LinearLayout.Orientation.Horizontal,
};
if (currentDate.Day == e.Value) return;
currentDate = new DateTime(currentDate.Year, currentDate.Month, e.Value);
-
+
OnDateChanged();
}
private void OnMonthValueChanged(object sender, ValueChangedEventArgs e)
- {
+ {
if (currentDate.Month == e.Value) return;
MaxDaySet(currentDate.Year, e.Value);
}
private void OnYearValueChanged(object sender, ValueChangedEventArgs e)
- {
+ {
if (currentDate.Year == e.Value) return;
MaxDaySet(e.Value, currentDate.Month);
}
private void OnDateChanged()
- {
+ {
DateChangedEventArgs eventArgs = new DateChangedEventArgs(currentDate);
DateChanged?.Invoke(this, eventArgs);
}
DateTimeFormatInfo DateFormat = CultureInfo.CurrentCulture.DateTimeFormat;
String temp = DateFormat.ShortDatePattern;
String[] strArray = temp.Split(' ', '/');
- foreach (String format in strArray) {
- if (format.IndexOf("M") != -1|| format.IndexOf("m") != -1) Add(monthPicker);
+ foreach (String format in strArray)
+ {
+ if (format.IndexOf("M") != -1 || format.IndexOf("m") != -1) Add(monthPicker);
else if (format.IndexOf("d") != -1 || format.IndexOf("D") != -1) Add(dayPicker);
else if (format.IndexOf("y") != -1 || format.IndexOf("Y") != -1) Add(yearPicker);
}
public AppBar() : base()
{
Initialize();
+ //to use GetNextFocusableView
+ SetKeyboardNavigationSupport(true);
}
/// <summary>
public AppBar(string style) : base(style)
{
Initialize();
+ //to use GetNextFocusableView
+ SetKeyboardNavigationSupport(true);
}
/// <summary>
public AppBar(AppBarStyle appBarStyle) : base(appBarStyle)
{
Initialize();
+ //to use GetNextFocusableView
+ SetKeyboardNavigationSupport(true);
}
/// <summary>
{
return;
}
-
+ navigationContent.Focusable = true;
ResetContent();
}
}
{
textLabel.Text = Title;
}
+ else
+ {
+ titleContent.Focusable = true;
+ }
ResetContent();
}
if (actionViewStyle == null) actionViewStyle = (ViewStyle)appBarStyle.ActionView?.Clone();
else actionViewStyle.MergeDirectly(appBarStyle.ActionView);
-
+
styleApplied = true;
}
}
}
+
+ /// <summary>
+ /// ToDo : only key navigation is enabled, but value editing is not yet added. for example, after enter key and up/down key the value need be changed.
+ /// </summary>
+ /// <param name="currentFocusedView"></param>
+ /// <param name="direction"></param>
+ /// <param name="loopEnabled"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
+ {
+ if (currentFocusedView == null)
+ {
+ if (navigationContent != null && navigationContent.Focusable)
+ {
+ return navigationContent;
+ }
+ else if (titleContent != null && titleContent.Focusable)
+ {
+ return titleContent;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if (currentFocusedView == this)
+ {
+ return null;
+ }
+ else if (currentFocusedView == navigationContent)
+ {
+ if (direction == View.FocusDirection.Up)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Right)
+ {
+ if (titleContent != null && titleContent.Focusable)
+ {
+ return titleContent;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if (direction == View.FocusDirection.Down)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return null;
+ }
+ }
+ else if (currentFocusedView == titleContent)
+ {
+ if (direction == View.FocusDirection.Up)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Right)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Down)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ if (navigationContent != null && navigationContent.Focusable)
+ {
+ return navigationContent;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ }
+ return null;
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal override View PassFocusableViewInsideIfNeeded()
+ {
+ if (navigationContent != null && navigationContent.Focusable)
+ {
+ return navigationContent;
+ }
+ else if (titleContent != null && titleContent.Focusable)
+ {
+ return titleContent;
+ }
+ return this;
+ }
+
}
}
NotifyPropertyChanged();
}
}
+
+ /// <summary>
+ /// for the case of ContentPage, it sets key focus on AppBar's NavigationContent
+ /// </summary>
+ protected internal override void RestoreKeyFocus()
+ {
+ if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ {
+ if (LastFocusedView)
+ {
+ FocusManager.Instance.SetCurrentFocusView(LastFocusedView);
+ }
+ else
+ {
+ if (AppBar != null)
+ {
+ FocusManager.Instance.SetCurrentFocusView(AppBar.PassFocusableViewInsideIfNeeded());
+ }
+ else
+ {
+ FocusManager.Instance.ClearFocus();
+ }
+ }
+ }
+ }
+
private View InternalContent
{
get
{
if (page is DialogPage == false)
{
- topPage.SetVisible(false);
+ topPage.SetVisible(false);
}
// Need to update Content of the new page
page.InvokeAppearing();
curTop.InvokeDisappearing();
+ curTop.SaveKeyFocus();
+
//TODO: The following transition codes will be replaced with view transition.
InitializeAnimation();
//Invoke Page events
page.InvokeAppeared();
NotifyAccessibilityStatesChangeOfPages(curTop, page);
+
+ page.RestoreKeyFocus();
};
newAnimation.Play();
}
else
{
ShowContentOfPage(page);
+ page.RestoreKeyFocus();
}
}
//Invoke Page events
newTop.InvokeAppearing();
curTop.InvokeDisappearing();
+ curTop.SaveKeyFocus();
//TODO: The following transition codes will be replaced with view transition.
InitializeAnimation();
//Invoke Page events
newTop.InvokeAppeared();
+
+ newTop.RestoreKeyFocus();
};
newAnimation.Play();
}
RetrieveTaggedViews(taggedViewsInCurrentTopPage, currentTopPage, true);
List<KeyValuePair<View, View>> sameTaggedViewPair = new List<KeyValuePair<View, View>>();
- foreach(View currentTopPageView in taggedViewsInCurrentTopPage)
+ foreach (View currentTopPageView in taggedViewsInCurrentTopPage)
{
bool findPair = false;
- foreach(View newTopPageView in taggedViewsInNewTopPage)
+ foreach (View newTopPageView in taggedViewsInNewTopPage)
{
- if((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) &&
+ if ((currentTopPageView.TransitionOptions != null) && (newTopPageView.TransitionOptions != null) &&
currentTopPageView.TransitionOptions?.TransitionTag == newTopPageView.TransitionOptions?.TransitionTag)
{
sameTaggedViewPair.Add(new KeyValuePair<View, View>(currentTopPageView, newTopPageView));
break;
}
}
- if(findPair)
+ if (findPair)
{
taggedViewsInNewTopPage.Remove(sameTaggedViewPair[sameTaggedViewPair.Count - 1].Value);
}
}
- foreach(KeyValuePair<View, View> pair in sameTaggedViewPair)
+ foreach (KeyValuePair<View, View> pair in sameTaggedViewPair)
{
taggedViewsInCurrentTopPage.Remove(pair.Key);
}
TransitionSet newTransitionSet = new TransitionSet();
- foreach(KeyValuePair<View, View> pair in sameTaggedViewPair)
+ foreach (KeyValuePair<View, View> pair in sameTaggedViewPair)
{
TransitionItem pairTransition = transition.CreateTransition(pair.Key, pair.Value, pushTransition);
- if(pair.Value.TransitionOptions?.TransitionWithChild ?? false)
+ if (pair.Value.TransitionOptions?.TransitionWithChild ?? false)
{
pairTransition.TransitionWithChild = true;
}
newTransitionSet.Finished += (object sender, EventArgs e) =>
{
- if(newTopPage.Layout != null)
+ if (newTopPage.Layout != null)
{
newTopPage.Layout.RequestLayout();
}
- if(currentTopPage.Layout != null)
+ if (currentTopPage.Layout != null)
{
currentTopPage.Layout.RequestLayout();
}
return instance.InternalDisappearingTransition;
});
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal BaseComponents.View LastFocusedView = null;
+
private Navigator navigator = null;
// Default transition is Fade.
{
Disappeared?.Invoke(this, new PageDisappearedEventArgs());
}
+
+ /// <summary>
+ /// works only when DefaultAlgorithm is enabled.
+ /// to save the currently focused View when disappeared.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal virtual void SaveKeyFocus()
+ {
+ if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ {
+ var currentFocusedView = FocusManager.Instance.GetCurrentFocusView();
+ if (currentFocusedView)
+ {
+ var findChild = FindDescendantByID(currentFocusedView.ID);
+ if (findChild)
+ {
+ LastFocusedView = findChild;
+ return;
+ }
+ }
+ LastFocusedView = null;
+ }
+ }
+
+ /// <summary>
+ /// works only when DefaultAlgorithm is enabled.
+ /// to set key focused View when showing.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected internal virtual void RestoreKeyFocus()
+ {
+ if (FocusManager.Instance.IsDefaultAlgorithmEnabled())
+ {
+ if (LastFocusedView)
+ {
+ FocusManager.Instance.SetCurrentFocusView(LastFocusedView);
+ }
+ else
+ {
+ var temp = new Tizen.NUI.BaseComponents.View()
+ {
+ Size = new Size(0.1f, 0.1f, 0.0f),
+ Position = new Position(0, 0, 0),
+ Focusable = true,
+ };
+ this.Add(temp);
+ temp.LowerToBottom();
+ FocusManager.Instance.SetCurrentFocusView(temp);
+ var focused = FocusManager.Instance.GetNearestFocusableActor(this, temp, Tizen.NUI.BaseComponents.View.FocusDirection.Down);
+ if (focused)
+ {
+ FocusManager.Instance.SetCurrentFocusView(focused);
+ }
+ else
+ {
+ FocusManager.Instance.ClearFocus();
+ }
+ temp.Unparent();
+ temp.Dispose();
+ }
+ }
+
+ }
+
}
}
/// TimeChangedEventArgs default constructor.
/// <param name="time">time value of TimePicker.</param>
/// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public TimeChangedEventArgs(DateTime time)
{
Time = time;
/// <since_tizen> 9 </since_tizen>
public TimePicker()
{
+ SetKeyboardNavigationSupport(true);
}
/// <summary>
/// <since_tizen> 9 </since_tizen>
public TimePicker(string style) : base(style)
{
+ SetKeyboardNavigationSupport(true);
}
/// <summary>
/// <since_tizen> 9 </since_tizen>
public TimePicker(TimePickerStyle timePickerStyle) : base(timePickerStyle)
{
+ SetKeyboardNavigationSupport(true);
}
/// <summary>
else hourPicker.CurrentValue = currentTime.Hour - 12;
ampmPicker.CurrentValue = 2;
}
- else
+ else
{
isAm = true;
if (currentTime.Hour == 0) hourPicker.CurrentValue = 12;
hourPicker.MaxValue = 23;
hourPicker.CurrentValue = currentTime.Hour;
}
- else
+ else
{
hourPicker.MinValue = 1;
hourPicker.MaxValue = 12;
{
MinValue = 1,
MaxValue = 12,
+ Focusable = true,
};
hourPicker.ValueChanged += OnHourValueChanged;
{
MinValue = 0,
MaxValue = 59,
+ Focusable = true,
};
minutePicker.ValueChanged += OnMinuteValueChanged;
{
MinValue = 1,
MaxValue = 2,
+ Focusable = true,
};
ampmPicker.ValueChanged += OnAmpmValueChanged;
//Apply CellPadding.
if (timePickerStyle?.CellPadding != null && Layout != null)
((LinearLayout)Layout).CellPadding = new Size2D(timePickerStyle.CellPadding.Width, timePickerStyle.CellPadding.Height);
-
+
//Apply Internal Pickers style.
if (timePickerStyle?.Pickers != null && hourPicker != null && minutePicker != null && ampmPicker != null)
{
ampmPicker.ApplyStyle(timePickerStyle.Pickers);
}
}
-
+
+ /// <summary>
+ /// ToDo : only key navigation is enabled, but value editing is not yet added. for example, after enter key and up/down key the value need be changed.
+ /// </summary>
+ /// <param name="currentFocusedView"></param>
+ /// <param name="direction"></param>
+ /// <param name="loopEnabled"></param>
+ /// <returns></returns>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
+ {
+ if (currentFocusedView == hourPicker)
+ {
+ if (direction == View.FocusDirection.Right)
+ {
+ return minutePicker;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return null;
+ }
+ }
+ else if (currentFocusedView == minutePicker)
+ {
+ if (direction == View.FocusDirection.Right)
+ {
+ return ampmPicker;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return hourPicker;
+ }
+ }
+ else if (currentFocusedView == ampmPicker)
+ {
+ if (direction == View.FocusDirection.Right)
+ {
+ return null;
+ }
+ else if (direction == View.FocusDirection.Left)
+ {
+ return minutePicker;
+ }
+ }
+ return null;
+ }
+
+
[SuppressMessage("Microsoft.Reliability",
"CA2000:DisposeObjectsBeforeLosingScope",
Justification = "The CellPadding will be dispose when the time picker disposed")]
{
HeightSpecification = LayoutParamPolicies.MatchParent;
- Layout = new LinearLayout() {
+ Layout = new LinearLayout()
+ {
LinearOrientation = LinearLayout.Orientation.Horizontal,
};
Console.WriteLine("initialize");
if (!is24HourView)
{
- if (isAm)
+ if (isAm)
{
if (e.Value == 12) ChangeTime(0, 0, true);
else ChangeTime(e.Value, 0, true);
}
- else
+ else
{
if (e.Value == 12) ChangeTime(12, 0, true);
else ChangeTime(e.Value + 12, 0, true);
}
else
ChangeTime(e.Value, 0, true);
-
+
OnTimeChanged();
}
private void OnMinuteValueChanged(object sender, ValueChangedEventArgs e)
- {
+ {
if (currentTime.Minute == e.Value) return;
ChangeTime(0, e.Value, false);
}
private void OnAmpmValueChanged(object sender, ValueChangedEventArgs e)
- {
+ {
if ((isAm && e.Value == 1) || (!isAm && e.Value == 2)) return;
if (e.Value == 1)
isAm = true;
}
- else
+ else
{ //PM
if (currentTime.Hour == 0) ChangeTime(12, 0, true);
else ChangeTime(currentTime.Hour + 12, 0, true);
}
private void OnTimeChanged()
- {
+ {
TimeChangedEventArgs eventArgs = new TimeChangedEventArgs(currentTime);
TimeChanged?.Invoke(this, eventArgs);
}
String timePattern = timeFormatInfo.ShortTimePattern;
String[] timePatternArray = timePattern.Split(' ', ':');
- foreach (String format in timePatternArray) {
- if (format.IndexOf("H") != -1|| format.IndexOf("h") != -1) Add(hourPicker);
+ foreach (String format in timePatternArray)
+ {
+ if (format.IndexOf("H") != -1 || format.IndexOf("h") != -1) Add(hourPicker);
else if (format.IndexOf("M") != -1 || format.IndexOf("m") != -1) Add(minutePicker);
- else if (format.IndexOf("t") != -1)
+ else if (format.IndexOf("t") != -1)
{
is24HourView = false;
ampmForceSet = false;
//FIXME: There is no localeChanged Event for Component now
// AMPM text has to update when system locale changed.
CultureInfo info = CultureInfo.CurrentCulture;
- ampmText = new string[] {info.DateTimeFormat.AMDesignator, info.DateTimeFormat.PMDesignator};
+ ampmText = new string[] { info.DateTimeFormat.AMDesignator, info.DateTimeFormat.PMDesignator };
ampmPicker.DisplayedValues = new ReadOnlyCollection<string>(ampmText);
}
}
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void FocusedViewEnterKeyEventCallback2(IntPtr view);
+ private View internalFocusIndicator = null;
+
/// <summary>
/// PreFocusChange will be triggered before the focus is going to be changed.<br />
/// The FocusManager makes the best guess for which view to focus towards the given direction, but applications might want to change that.<br />
{
Interop.FocusManager.SetFocusIndicatorActor(SwigCPtr, View.getCPtr(indicator));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ internalFocusIndicator = indicator;
}
internal View GetFocusIndicatorView()
{
//to fix memory leak issue, match the handle count with native side.
IntPtr cPtr = Interop.FocusManager.GetFocusIndicatorActor(SwigCPtr);
- View ret = this.GetInstanceSafely<View>(cPtr);
- return ret;
+ internalFocusIndicator = this.GetInstanceSafely<View>(cPtr);
+ return internalFocusIndicator;
}
internal PreFocusChangeSignal PreFocusChangeSignal()
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class AppBarExample : ContentPage, IExample
+ {
+ private View rootContent;
+ private AppBar appBar;
+ private TextLabel label;
+ private Button button;
+ private int count;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public AppBarExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "AppBar Default Style",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ // AppBar examples.
+ appBar = new AppBar()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Title = "This is AppBar",
+ AutoNavigationContent = false,
+ };
+ rootContent.Add(appBar);
+
+ label = new TextLabel
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = $"title: {appBar.Title}"
+ };
+ rootContent.Add(label);
+
+ button = new Tizen.NUI.Components.Button
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = "change title"
+ };
+ rootContent.Add(button);
+
+ button.Clicked += (s, e) =>
+ {
+ appBar.Title = $"This is AppBar(clk {count++})";
+ label.Text = $"title: {appBar.Title}";
+ };
+
+ Content = rootContent;
+ }
+ }
+}
private Window window;
public void Activate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Activate()\n");
}
public void Deactivate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()\n");
window = null;
}
{
Text = "Enabled"
};
- enabledButton.EnableFocus();
enabledButton.Clicked += (object obj, ClickedEventArgs ev) =>
{
Log.Info(this.GetType().Name, "Enabled Button Clicked\n");
Text = "Unselected",
IsSelectable = true,
};
- selectableButton.EnableFocus();
selectableButton.Clicked += (object obj, ClickedEventArgs ev) =>
{
Log.Info(this.GetType().Name, "Selected Button Clicked\n");
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class CheckBoxExample : ContentPage, IExample
+ {
+ private View rootContent;
+ private CheckBox checkBox1, checkBox2, checkBox3;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public CheckBoxExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "CheckBox Default Style",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ // CheckBox examples.
+ checkBox1 = new CheckBox()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ rootContent.Add(checkBox1);
+
+ checkBox2 = new CheckBox()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ rootContent.Add(checkBox2);
+
+ checkBox3 = new CheckBox()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ };
+ rootContent.Add(checkBox3);
+
+ Content = rootContent;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class DatePickerExample : ContentPage, IExample
+ {
+ private View rootContent;
+ private DatePicker datePicker;
+ private TextLabel label;
+ private Button button;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public DatePickerExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "DatePicker Default Style",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ // Picker style examples.
+ datePicker = new DatePicker()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Date = DateTime.Now
+ };
+ rootContent.Add(datePicker);
+
+
+ label = new TextLabel
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = $"Date: {datePicker.Date.ToString()}"
+ };
+ rootContent.Add(label);
+
+ button = new Tizen.NUI.Components.Button
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = "set date"
+ };
+ rootContent.Add(button);
+
+ button.Clicked += (s, e) =>
+ {
+ label.Text = $"Date: {datePicker.Date.ToString()}";
+ };
+
+ Content = rootContent;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class LoadingExample : ContentPage, IExample
+ {
+ private const int testSizeWidth = 150;
+ private const int testSizeHeight = 150;
+ private View rootContent;
+ private Loading loading;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public LoadingExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "Loading Default Style",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ // Loading examples.
+ var path = Tizen.Applications.Application.Current.DirectoryInfo.Resource;
+ var imageArray = new string[36];
+ for (int i = 0; i < 36; i++)
+ {
+ if (i < 10)
+ {
+ imageArray[i] = path + "loading/loading_0" + i + ".png";
+ }
+ else
+ {
+ imageArray[i] = path + "loading/loading_" + i + ".png";
+ }
+ }
+
+ loading = new Loading()
+ {
+ WidthSpecification = testSizeWidth,
+ HeightSpecification = testSizeHeight,
+ ImageArray = imageArray,
+ };
+ rootContent.Add(loading);
+
+ Content = rootContent;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class MenuExample : ContentPage, IExample
+ {
+ private View rootContent;
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public MenuExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "Menu Default Style",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ Content = rootContent;
+
+
+ var pageContent = new Button()
+ {
+ Text = "Page Content",
+ CornerRadius = 0,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ };
+
+ var moreButton = new Button()
+ {
+ Text = "More",
+ };
+
+ var appBar = new AppBar()
+ {
+ AutoNavigationContent = false,
+ Title = "Title",
+ Actions = new View[] { moreButton, },
+ };
+
+ var page = new ContentPage()
+ {
+ AppBar = appBar,
+ Content = pageContent,
+ };
+
+ rootContent.Add(page);
+
+ var menuItem = new MenuItem() { Text = "Menu" };
+ menuItem.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ {
+ global::System.Console.WriteLine($"1st MenuItem's IsSelected is changed to {args.IsSelected}.");
+ };
+
+ var menuItem2 = new MenuItem() { Text = "Menu2" };
+ menuItem2.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ {
+ global::System.Console.WriteLine($"2nd MenuItem's IsSelected is changed to {args.IsSelected}.");
+ };
+
+ var menuItem3 = new MenuItem() { Text = "Menu3" };
+ menuItem3.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ {
+ global::System.Console.WriteLine($"3rd MenuItem's IsSelected is changed to {args.IsSelected}.");
+ };
+
+ var menuItem4 = new MenuItem() { Text = "Menu4" };
+ menuItem4.SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
+ {
+ global::System.Console.WriteLine($"4th MenuItem's IsSelected is changed to {args.IsSelected}.");
+ };
+
+ moreButton.Clicked += (object sender, ClickedEventArgs args) =>
+ {
+ var menu = new Menu()
+ {
+ Anchor = moreButton,
+ HorizontalPositionToAnchor = Menu.RelativePosition.Center,
+ VerticalPositionToAnchor = Menu.RelativePosition.End,
+ Items = new MenuItem[] { menuItem, menuItem2, menuItem3, menuItem4 },
+ };
+ menu.Post();
+ };
+ }
+ }
+}
colorView.WidthSpecification = (isHorizontal? 200 : LayoutParamPolicies.MatchParent);
colorView.HeightSpecification = (isHorizontal? LayoutParamPolicies.MatchParent : 200);
colorView.BackgroundColor = new Color((float)rnd.Next(256)/256f, (float)rnd.Next(256)/256f, (float)rnd.Next(256)/256f, 1);
- colorView.EnableFocus();
scrollView.Add(colorView);
}
private List<DirectionOption> directionMenu;
public void Activate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Activate()\n");
+ Log.Info(this.GetType().Name, $"this.GetType().Name={this.GetType().Name}, Activate()\n");
}
public void Deactivate()
{
- Log.Info(this.GetType().Name, $"@@@ this.GetType().Name={this.GetType().Name}, Deactivate()\n");
+ Log.Info(this.GetType().Name, $"this.GetType().Name={this.GetType().Name}, Deactivate()\n");
window = null;
directionMenu = null;
}
};
item.Label.SetBinding(TextLabel.TextProperty, "Direction");
item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- item.EnableFocus();
return item;
}),
ScrollingDirection = ScrollableBase.Direction.Vertical,
Page scrollDirPage = new ScrollableBaseDirectionExample(directionItem.Direction);
window = NUIApplication.GetDefaultWindow();
window.GetDefaultNavigator().Push(scrollDirPage);
- FocusableExtension.SetFocusOnPage(scrollDirPage);
}
directionListView.SelectedItem = null;
};
--- /dev/null
+/*
+ * Copyright(c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.StyleGuide
+{
+ // IExample inehrited class will be automatically added in the main examples list.
+ internal class TimePickerExample : ContentPage, IExample
+ {
+ private View rootContent;
+ private TimePicker timePicker;
+ private TextLabel label;
+ private Button button;
+
+ public void Activate()
+ {
+ }
+ public void Deactivate()
+ {
+ }
+
+ /// Modify this method for adding other examples.
+ public TimePickerExample() : base()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent;
+ HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ // Navigator bar title is added here.
+ AppBar = new AppBar()
+ {
+ Title = "TimePicker Default Style",
+ };
+
+ // Example root content view.
+ // you can decorate, add children on this view.
+ rootContent = new View()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+
+ Layout = new LinearLayout()
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ CellPadding = new Size2D(10, 20),
+ },
+ };
+
+ // Picker style examples.
+ timePicker = new TimePicker()
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Time = DateTime.Now
+ };
+ rootContent.Add(timePicker);
+
+
+ label = new TextLabel
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = $"Time: {timePicker.Time.ToString()}"
+ };
+ rootContent.Add(label);
+
+ button = new Tizen.NUI.Components.Button
+ {
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ Text = "set time"
+ };
+ rootContent.Add(button);
+
+ button.Clicked += (s, e) =>
+ {
+ label.Text = $"Time: {timePicker.Time.ToString()}";
+ };
+
+ Content = rootContent;
+ }
+ }
+}
namespace Tizen.NUI.StyleGuide
{
-
- /// Helder static extension class for Focusable.
- /// NUI default behavior is unfocusable in key or touch,
- /// this class help to setting focusable features easily.
- public static class FocusableExtension
- {
- public static FocusManager FocusManager;
- public static void EnableFocus(this View view)
- {
- view.Focusable = true;
- view.FocusableInTouch = true;
- }
-
- public static void EnableAutoFocusable()
- {
- FocusManager = FocusManager.Instance;
- FocusManager.EnableDefaultAlgorithm(true);
- FocusManager.FocusIndicator = new View()
- {
- PositionUsesPivotPoint = true,
- PivotPoint = new Position(0, 0, 0),
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- BorderlineColor = Color.Orange,
- BorderlineWidth = 4.0f,
- BorderlineOffset = -1f,
- BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.2f),
- };
- }
-
- public static void SetFocusOnPage(Page page)
- {
- View focusCandidate = null;
- if (page == null) return;
-
- if (page is ContentPage contentPage)
- {
- focusCandidate = contentPage.AppBar?.NavigationContent;
- focusCandidate.Focusable = true;
- }
-
- if (focusCandidate == null)
- {
- foreach (View child in page.Children)
- {
- if (child.Focusable)
- {
- focusCandidate = child;
- }
- }
- }
-
- Log.Info("FocusableExtension", $"Focus candidate {focusCandidate}\n");
-
- if (focusCandidate != null)
- {
- FocusManager.SetCurrentFocusView(focusCandidate);
- }
- }
- }
-
public class SearchField : View
{
public TextField SearchTextField;
var searchTextBox = CreateSearchText();
SearchTextField = CreateTextField();
- SearchTextField.EnableFocus();
var underline = CreateUnderline();
searchTextBox.Add(SearchTextField);
searchTextBox.Add(underline);
SearchButton = CreateSearchButton();
- SearchButton.EnableFocus();
Add(searchTextBox);
Add(SearchButton);
WidthSpecification = LayoutParamPolicies.MatchParent,
HeightSpecification = LayoutParamPolicies.WrapContent,
MinimumSize = new Size2D(0, 40),
+ Focusable = true, //BaseComponents' Focusable is false as a default value, true should be set to navigate key focus and edit text.
};
}
foreach (Type type in assembly.GetTypes())
{
- Console.WriteLine($"@@@ type.Name={type.Name}, type.FullName={type.FullName}");
+ Console.WriteLine($"type.Name={type.Name}, type.FullName={type.FullName}");
if (exampleType.IsAssignableFrom(type) && type.Name != "SampleMain" && this.GetType() != type && type.IsClass)
{
NamePool.Add(new Tuple<string, string>(type.Name, type.FullName));
if (navigator.PageCount == 0)
{
- Exit();
+ Exit();
}
}
}
public void OnSelectionChanged(object sender, SelectionChangedEventArgs ev)
{
- Console.WriteLine($"@@@ OnSelectionChanged() {ev.CurrentSelection}");
+ Console.WriteLine($"OnSelectionChanged() {ev.CurrentSelection}");
if (ev.CurrentSelection.Count == 0) return;
if (ev.CurrentSelection[0] is ControlMenu selItem)
{
- Console.WriteLine($"@@@ selItem.Name={selItem.Name}, selItem.FullName={selItem.FullName}");
+ Console.WriteLine($"selItem.Name={selItem.Name}, selItem.FullName={selItem.FullName}");
RunSample(selItem?.FullName);
}
colView.SelectedItem = null;
base.OnCreate();
Initialize();
SetMainPage();
+
+ focusManager = FocusManager.Instance;
+
+ //set user customized focus indicator
+ if (!focusManager.FocusIndicator)
+ {
+ focusManager.FocusIndicator = new View()
+ {
+ PositionUsesPivotPoint = true,
+ PivotPoint = new Position(0, 0, 0),
+ WidthResizePolicy = ResizePolicyType.FillToParent,
+ HeightResizePolicy = ResizePolicyType.FillToParent,
+ BorderlineColor = Color.Orange,
+ BorderlineWidth = 4.0f,
+ BorderlineOffset = -1f,
+ BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.2f),
+ };
+ }
+
+ //enable FocusManger default algorithm
+ focusManager.EnableDefaultAlgorithm(true);
}
private void Initialize()
{
window.Title = "NUI Style Guide";
window.KeyEvent += OnKeyEvent;
- FocusableExtension.EnableAutoFocusable();
-
navigator = window.GetDefaultNavigator();
navigator.Popped += (object obj, PoppedEventArgs ev) =>
{
Page top = navigator.Peek();
- FocusableExtension.SetFocusOnPage(top);
};
}
var appBarStyle = ThemeManager.GetStyle("Tizen.NUI.Components.AppBar");
var moreButton = new Button(((AppBarStyle)appBarStyle).BackButton);
moreButton.Icon.ResourceUrl = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "menu.png";
- moreButton.EnableFocus();
appBar.NavigationContent = moreButton;
};
item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
- item.EnableFocus();
+ item.Focusable = true; //BaseComponents' Focusable is false as a default value, true should be set to navigate key focus.
return item;
}),
Header = myTitle,
AppBar = appBar,
Content = pageContent,
};
- page.Focusable = true;
navigator.Push(page);
- FocusableExtension.SetFocusOnPage(page);
}
private void RunSample(string name)
IExample example = typeof(Program).Assembly?.CreateInstance(name) as IExample;
- Console.WriteLine($"@@@ typeof(Program).Assembly={typeof(Program).Assembly}, name={name}");
+ Console.WriteLine($"typeof(Program).Assembly={typeof(Program).Assembly}, name={name}");
if (example != null)
{
example.Activate();
if (example is Page examplePage)
{
- examplePage.Focusable = true;
navigator.Push(examplePage);
- FocusableExtension.SetFocusOnPage(examplePage);
}
}
else
{
- Console.WriteLine($"@@@ examle is null!");
+ Console.WriteLine($"examle is null!");
}
}