1
This commit is contained in:
@@ -28,10 +28,55 @@ namespace BITKit.UX
|
||||
protected abstract string DocumentPath { get; }
|
||||
public VisualElement RootVisualElement { get; set; }
|
||||
protected VisualTreeAsset VisualTreeAsset { get; private set; }
|
||||
private readonly ValidHandle _isBusy = new();
|
||||
protected UIToolKitPanel(IUXService uxService)
|
||||
{
|
||||
UXService = uxService;
|
||||
uxService.Register(this);
|
||||
InitializeAsync().Forget();
|
||||
}
|
||||
|
||||
private async UniTask InitializeAsync()
|
||||
{
|
||||
await _isBusy;
|
||||
using var b = _isBusy.GetHandle();
|
||||
if (RootVisualElement is null)
|
||||
{
|
||||
VisualTreeAsset = await ModService.LoadAsset<VisualTreeAsset>(DocumentPath);
|
||||
|
||||
RootVisualElement = UXService.Root.As<VisualElement>().Create(VisualTreeAsset);
|
||||
RootVisualElement.pickingMode = PickingMode.Ignore;
|
||||
RootVisualElement.style.position = Position.Absolute;
|
||||
RootVisualElement.style.left = 0;
|
||||
RootVisualElement.style.right = 0;
|
||||
RootVisualElement.style.top = 0;
|
||||
RootVisualElement.style.bottom = 0;
|
||||
|
||||
var invisible = RootVisualElement.Create<VisualElement>();
|
||||
invisible.name = "invisible_return_generate";
|
||||
invisible.style.position = Position.Absolute;
|
||||
invisible.pickingMode = PickingMode.Ignore;
|
||||
invisible.style.left = 0;
|
||||
invisible.style.right = 0;
|
||||
invisible.style.top = 0;
|
||||
invisible.style.bottom = 0;
|
||||
invisible.SendToBack();
|
||||
|
||||
if (CloseWhenClickOutside)
|
||||
{
|
||||
invisible.RegisterCallback<MouseDownEvent>(x => { OnReturn(); });
|
||||
invisible.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
if (IsWindow)
|
||||
{
|
||||
invisible.style.backgroundColor = new Color(0, 0, 0, 0.9f);
|
||||
}
|
||||
|
||||
UXUtils.Inject(this);
|
||||
|
||||
RootVisualElement.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Optional<float> EntryDuration { get; }= new();
|
||||
@@ -62,42 +107,8 @@ namespace BITKit.UX
|
||||
OnEntry?.Invoke();
|
||||
}
|
||||
async UniTask IEntryElement.EntryAsync()
|
||||
{
|
||||
if (RootVisualElement is null)
|
||||
{
|
||||
VisualTreeAsset = await ModService.LoadAsset<VisualTreeAsset>(DocumentPath);
|
||||
|
||||
RootVisualElement = UXService.Root.As<VisualElement>().Create(VisualTreeAsset);
|
||||
RootVisualElement.pickingMode = PickingMode.Ignore;
|
||||
RootVisualElement.style.position = Position.Absolute;
|
||||
RootVisualElement.style.left = 0;
|
||||
RootVisualElement.style.right = 0;
|
||||
RootVisualElement.style.top = 0;
|
||||
RootVisualElement.style.bottom = 0;
|
||||
|
||||
var invisible = RootVisualElement.Create<VisualElement>();
|
||||
invisible.name = "invisible_return_generate";
|
||||
invisible.style.position = Position.Absolute;
|
||||
invisible.pickingMode = PickingMode.Ignore;
|
||||
invisible.style.left = 0;
|
||||
invisible.style.right = 0;
|
||||
invisible.style.top = 0;
|
||||
invisible.style.bottom = 0;
|
||||
invisible.SendToBack();
|
||||
|
||||
if (CloseWhenClickOutside)
|
||||
{
|
||||
invisible.RegisterCallback<MouseDownEvent>(x => { OnReturn(); });
|
||||
invisible.pickingMode = PickingMode.Position;
|
||||
}
|
||||
|
||||
if (IsWindow)
|
||||
{
|
||||
invisible.style.backgroundColor = new Color(0, 0, 0, 0.9f);
|
||||
}
|
||||
|
||||
UXUtils.Inject(this);
|
||||
}
|
||||
{
|
||||
await InitializeAsync();
|
||||
|
||||
RootVisualElement.SetActive(true);
|
||||
RootVisualElement.AddToClassList(USSEntry);
|
||||
|
Reference in New Issue
Block a user