namespace Moli.Desktop.Runtime;
/// In-memory per-widget overlay that never writes layout.json.
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;
}
/// Effective click-through / visibility rules used by runtime, surfaces and tests.
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;
}