Skip to content

Commit

Permalink
Merge commit 'refs/pull/4715/head' of https://github.com/Samsung/TizenFX
Browse files Browse the repository at this point in the history
 into DevelNUI
  • Loading branch information
everLEEst committed Nov 3, 2022
2 parents 857e07d + 2f16a85 commit 75ee312
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 27 deletions.
79 changes: 58 additions & 21 deletions src/Tizen.NUI.Components/Controls/TabContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ namespace Tizen.NUI.Components
/// <since_tizen> 9 </since_tizen>
public class TabContent : Control
{
private IList<View> views;

private void Initialize()
{
SelectedIndex = -1;
views = new List<View>();
Views = new List<View>();
}

/// <summary>
Expand Down Expand Up @@ -62,11 +60,17 @@ public TabContent(ControlStyle style) : base(style)
[EditorBrowsable(EditorBrowsableState.Never)]
protected int SelectedIndex { get; set; }

/// <summary>
/// A list of content views.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
protected IList<View> Views { get; set; }

/// <summary>
/// Gets the count of views.
/// </summary>
/// <since_tizen> 9 </since_tizen>
public int ViewCount => views.Count;
public int ViewCount => Views.Count;

/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
Expand All @@ -83,57 +87,78 @@ public override void OnInitialize()
/// <param name="view">A view to be added to TabContent.</param>
/// <exception cref="ArgumentNullException">Thrown when the argument view is null.</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
protected internal void AddView(View view)
protected virtual void AddView(View view)
{
if (view == null)
{
throw new ArgumentNullException(nameof(view), "view should not be null.");
}

views.Add(view);
Views.Add(view);

if (SelectedIndex == -1)
{
Select(0);
}
}

/// <summary>
/// Adds a view to TabContent.
/// </summary>
/// <param name="view">A view to be added to TabContent.</param>
/// <exception cref="ArgumentNullException">Thrown when the argument view is null.</exception>
internal void AddContentView(View view)
{
AddView(view);
}

/// <summary>
/// Removes a view from TabContent.
/// </summary>
/// <param name="view">A view to be removed from TabContent.</param>
/// <exception cref="ArgumentNullException">Thrown when the argument view is null.</exception>
/// <exception cref="ArgumentException">Thrown when the argument view does not exist in TabContent.</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
protected internal void RemoveView(View view)
protected virtual void RemoveView(View view)
{
if (view == null)
{
throw new ArgumentNullException(nameof(view), "view should not be null.");
}

if (views.Contains(view) == false)
if (Views.Contains(view) == false)
{
throw new ArgumentException("view does not exist in TabContent.", nameof(view));
}

int index = views.IndexOf(view);
int index = Views.IndexOf(view);

views.Remove(view);
Views.Remove(view);

if (index == SelectedIndex)
{
if (views.Count == 0)
if (Views.Count == 0)
{
Select(-1);
}
else if (SelectedIndex == views.Count)
else if (SelectedIndex == Views.Count)
{
Select(SelectedIndex - 1);
}
}
}

/// <summary>
/// Removes a view from TabContent.
/// </summary>
/// <param name="view">A view to be removed from TabContent.</param>
/// <exception cref="ArgumentNullException">Thrown when the argument view is null.</exception>
/// <exception cref="ArgumentException">Thrown when the argument view does not exist in TabContent.</exception>
internal void RemoveContentView(View view)
{
RemoveView(view);
}

/// <summary>
/// Selects a view at the specified index of TabContent.
/// The indices of views in TabContent are basically the order of adding to TabContent by <see cref="TabView.AddTab"/>.
Expand All @@ -142,26 +167,38 @@ protected internal void RemoveView(View view)
/// <param name="index">The index of a view in TabContent where the view will be selected.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the index is less than -1, or greater than or equal to the number of views.</exception>
[EditorBrowsable(EditorBrowsableState.Never)]
protected internal void Select(int index)
protected virtual void Select(int index)
{
if ((index < -1) || (index >= views.Count))
if ((index < -1) || (index >= Views.Count))
{
throw new ArgumentOutOfRangeException(nameof(index), "index should not be greater than or equal to -1, and less than the number of views.");
}

if (SelectedIndex != -1)
{
Remove(views[SelectedIndex]);
Remove(Views[SelectedIndex]);
}

if (index != -1)
{
Add(views[index]);
Add(Views[index]);
}

SelectedIndex = index;
}

/// <summary>
/// Selects a view at the specified index of TabContent.
/// The indices of views in TabContent are basically the order of adding to TabContent by <see cref="TabView.AddTab"/>.
/// So a view's index in TabContent can be changed whenever <see cref="TabView.AddTab"/> or <see cref="TabView.RemoveTab"/> is called.
/// </summary>
/// <param name="index">The index of a view in TabContent where the view will be selected.</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the index is less than -1, or greater than or equal to the number of views.</exception>
internal void SelectContentView(int index)
{
Select(index);
}

/// <summary>
/// Gets the view at the specified index of TabContent.
/// The indices of views in TabContent are basically the order of adding to TabContent by <see cref="TabView.AddTab"/>.
Expand All @@ -172,12 +209,12 @@ protected internal void Select(int index)
/// <since_tizen> 9 </since_tizen>
public View GetView(int index)
{
if ((index < 0) || (index >= views.Count))
if ((index < 0) || (index >= Views.Count))
{
throw new ArgumentOutOfRangeException(nameof(index), "index should not be greater than or equal to 0, and less than the number of views.");
}

return views[index];
return Views[index];
}

/// <inheritdoc/>
Expand All @@ -191,14 +228,14 @@ protected override void Dispose(DisposeTypes type)

if (type == DisposeTypes.Explicit)
{
if (views != null)
if (Views != null)
{
foreach (View view in views)
foreach (View view in Views)
{
Utility.Dispose(view);
}

views = null;
Views = null;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Tizen.NUI.Components/Controls/TabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void tabButtonSelectedHandler(object sender, TabButtonSelectedEventArgs
{
if ((content != null) && (content.ViewCount > args.Index))
{
content.Select(args.Index);
content.SelectContentView(args.Index);
}
}

Expand Down Expand Up @@ -225,7 +225,7 @@ public void AddTab(TabButton tabButton, View view)

if (Content != null)
{
Content.AddView(view);
Content.AddContentView(view);
}
}

Expand All @@ -248,7 +248,7 @@ public void RemoveTab(int index)
var view = Content.GetView(index);
if (view != null)
{
Content.RemoveView(view);
Content.RemoveContentView(view);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tizen.NUI/src/internal/Interop/Interop.ControlDevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private AccessibilityDelegate()
public static extern IntPtr DaliAccessibilityDuplicateString(string arg);

[DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_Accessibility_SetAccessibilityDelegate")]
public static extern IntPtr DaliAccessibilitySetAccessibilityDelegate(IntPtr arg1_accessibilityDelegate, int arg2_accessibilityDelegateSize);
public static extern IntPtr DaliAccessibilitySetAccessibilityDelegate(IntPtr arg1_accessibilityDelegate, uint arg2_accessibilityDelegateSize);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private static void RegisterAccessibilityDelegate()
var ptr = Marshal.AllocHGlobal(size);

Marshal.StructureToPtr(ad, ptr, false);
Interop.ControlDevel.DaliAccessibilitySetAccessibilityDelegate(ptr, size);
Interop.ControlDevel.DaliAccessibilitySetAccessibilityDelegate(ptr, Convert.ToUInt32(size));
}

private static View GetViewFromRefObject(IntPtr refObjectPtr)
Expand Down
3 changes: 2 additions & 1 deletion src/Tizen.NUI/src/public/Window/BorderWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ internal bool EnableBorder(IBorderInterface borderInterface, BorderCloseDelegate
}
else
{
borderInterface.OnMaximize(IsMaximized());
WindowSize += new Size2D((int)borderInterface.BorderLineThickness * 2, (int)(borderHeight + borderInterface.BorderLineThickness * 2));
}

Expand Down Expand Up @@ -638,7 +639,7 @@ public void OnMaximize(bool isMaximized)
{
Padding = prePadding;
}

}

protected override bool HitTest(Touch touch)
Expand Down

0 comments on commit 75ee312

Please sign in to comment.