namespace Moli.Desktop.Runtime;
|
|
/// <summary>In-memory per-widget overlay that never writes <c>layout.json</c>.</summary>
|
public sealed record WidgetSessionOverlay
|
{
|
public static WidgetSessionOverlay Empty { get; } = new();
|
|
public bool? Interactable { get; init; }
|
public bool? Visible { get; init; }
|
|
public bool HasInteractableOverride => Interactable is not null;
|
public bool HasVisibleOverride => Visible is not null;
|
}
|
|
/// <summary>Effective click-through / visibility rules used by runtime, surfaces and tests.</summary>
|
public static class WidgetSurfaceRules
|
{
|
public static bool ComputeClickThrough(
|
bool isEditMode,
|
bool isSafeInputMode,
|
WidgetSessionOverlay overlay,
|
bool layoutClickThrough)
|
{
|
if (isEditMode || isSafeInputMode)
|
{
|
return false;
|
}
|
|
if (overlay.Interactable is { } interactable)
|
{
|
return !interactable;
|
}
|
|
return layoutClickThrough;
|
}
|
|
public static bool ComputeVisible(WidgetSessionOverlay overlay, bool layoutVisible)
|
=> overlay.Visible ?? layoutVisible;
|
}
|