Skip to Content
Docs模组FizzyLayer/Modal/Toast

Layer 层级系统 / Modal / Notification Toast

Overlay layer 体系

OverlayLayerKey(priority 从低到高):

  • HUD (100)
  • NOTIFICATION (200)
  • MODAL (300)
  • ANNOUNCE (900)
  • DEBUG (1000)

布局模式:

  • FIXED_ANCHOR
  • PER_INSTANCE_ANCHOR
  • MANUAL

OverlayLayerStack 提供:

  • add/remove/clear/hide
  • 按 layer policy 渲染
  • 鼠标输入分发(click/release/drag/scroll/move)
  • focus 与 pointer capture 管理

ModalSpec 支持:

  • title(Component)
  • message(Component)
  • widthPx(int)
  • heightPx(int)
  • anchor(Anchor)

调用示例:

ModalManager.show( ModalSpec.builder() .title(Component.literal("Confirm")) .message(Component.literal("Apply this action?")) .widthPx(240) .heightPx(100) .build() );

Notification Toast 系统

NotificationSpec 支持:

  • title(Component)
  • message(Component)
  • level(NotificationLevel) -> INFO/SUCCESS/WARNING/ERROR
  • durationTicks(int)
  • anchor(Anchor)

调用示例:

NotificationManager.show( NotificationSpec.builder() .title(Component.literal("Saved")) .message(Component.literal("Profile updated")) .level(NotificationLevel.SUCCESS) .durationTicks(80) .build() );
Last updated on