This commit is contained in:
CortexCore
2023-10-24 23:38:22 +08:00
parent 2c4710bc5d
commit bd40165ade
152 changed files with 3681 additions and 1531 deletions

View File

@@ -512,6 +512,12 @@ namespace BITKit
}
public static partial class UIToolkitExtensions
{
public static VisualElement Create(this VisualElement self, VisualTreeAsset asset)
{
var clone = asset.CloneTree();
self.Add(clone);
return clone;
}
public static T Create<T>(this VisualElement self, string name = Constant.EmetyString) where T : VisualElement, new()
{
var element = new T();
@@ -522,6 +528,16 @@ namespace BITKit
self.Add(element);
return element;
}
public static T Create<T>(this VisualElement self,Func<VisualElement> createFactory, string name = Constant.EmetyString) where T : VisualElement, new()
{
var element = createFactory.Invoke();
if (string.IsNullOrEmpty(name) is false)
{
element.name = name;
}
self.Add(element);
return element as T;
}
public static bool GetActive(this VisualElement self) => self.style.display.value == DisplayStyle.Flex;
public static void SetActive(this VisualElement self, bool active)
{