This commit is contained in:
CortexCore
2023-09-01 14:33:54 +08:00
parent 4fadd3a530
commit 8ef5c7ec0a
451 changed files with 1048940 additions and 2028 deletions

View File

@@ -23,12 +23,18 @@ namespace BITKit.UX
{
name = "tabs"
};
private readonly UxmlBoolAttributeDescription m_allowFocus = new ()
{
name = "allowFocus",
defaultValue = true
};
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc)
{
base.Init(ve, bag, cc);
var tabBar = (TabBar)ve;
tabBar.CurrentTab = m_TabBarAttribute.GetValueFromBag(bag, cc);
tabBar.Tabs = m_TabsAttribute.GetValueFromBag(bag, cc);
tabBar.allowFocus = m_allowFocus.GetValueFromBag(bag, cc);
}
}
public new class UxmlFactory : UxmlFactory<TabBar, UxmlTraits> { }
@@ -58,6 +64,22 @@ namespace BITKit.UX
SetTabs(value);
}
}
private bool allowFocus;
public bool AllowFocus
{
get => allowFocus;
set
{
allowFocus = value;
foreach (var x in _buttons)
{
x.focusable = value;
}
}
}
private void SetTabs(string value)
{
var split = value.Split(",");
@@ -72,6 +94,7 @@ namespace BITKit.UX
var index = i;
var button = _buttons[i] = this.Create<Button>();
button.text = tabName;
button.focusable = allowFocus;
button.clicked += () => CurrentTab = index;
}
}