TilePanelWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A composite widget that renders an infinite, pannable and zoomable tile map.
public sealed record TilePanelWidget : CompositeWidget<TilePanelNode>, IEquatable<Hex1bWidget>, IEquatable<CompositeWidget<TilePanelNode>>, IEquatable<TilePanelWidget>Inheritance
Object → Hex1bWidget → CompositeWidget<TilePanelNode> → TilePanelWidget
Implements
Properties
CameraX
The camera X position in tile coordinates.
Returns: Double
public double CameraX { get; init; }CameraY
The camera Y position in tile coordinates.
Returns: Double
public double CameraY { get; init; }DataSource
The tile data source providing tile content.
Returns: ITileDataSource
public required ITileDataSource DataSource { get; init; }PointsOfInterest
Points of interest to display on the map.
Returns: IReadOnlyList<TilePointOfInterest>
public IReadOnlyList<TilePointOfInterest> PointsOfInterest { get; init; }ZoomLevel
The zoom level. 0 = 1x, 1 = 2x, 2 = 4x, -1 = 0.5x, etc. Each level doubles/halves the tile render size.
Returns: Int32
public int ZoomLevel { get; init; }Methods
BuildContentAsync(TilePanelNode, ReconcileContext)
Builds the content widget tree for this composite widget. Called during reconciliation to determine what widgets to render.
Parameters:
node(TilePanelNode): The composite node managing this widget's state.context(ReconcileContext): The reconciliation context.
Returns: Task<Hex1bWidget>
A task that resolves to the widget representing this composite's content.
protected override Task<Hex1bWidget> BuildContentAsync(TilePanelNode node, ReconcileContext context)OnPan(Action<TilePanelPanEventArgs>)
Attaches a synchronous pan handler.
Parameters:
handler(Action<TilePanelPanEventArgs>):
Returns: TilePanelWidget
public TilePanelWidget OnPan(Action<TilePanelPanEventArgs> handler)OnPan(Func<TilePanelPanEventArgs, Task>)
Attaches an asynchronous pan handler.
Parameters:
handler(Func<TilePanelPanEventArgs, Task>):
Returns: TilePanelWidget
public TilePanelWidget OnPan(Func<TilePanelPanEventArgs, Task> handler)OnPoiClicked(Action<TilePanelPoiClickedEventArgs>)
Attaches a synchronous POI click handler.
Parameters:
handler(Action<TilePanelPoiClickedEventArgs>):
Returns: TilePanelWidget
public TilePanelWidget OnPoiClicked(Action<TilePanelPoiClickedEventArgs> handler)OnPoiClicked(Func<TilePanelPoiClickedEventArgs, Task>)
Attaches an asynchronous POI click handler.
Parameters:
handler(Func<TilePanelPoiClickedEventArgs, Task>):
Returns: TilePanelWidget
public TilePanelWidget OnPoiClicked(Func<TilePanelPoiClickedEventArgs, Task> handler)OnZoom(Action<TilePanelZoomEventArgs>)
Attaches a synchronous zoom handler.
Parameters:
handler(Action<TilePanelZoomEventArgs>):
Returns: TilePanelWidget
public TilePanelWidget OnZoom(Action<TilePanelZoomEventArgs> handler)OnZoom(Func<TilePanelZoomEventArgs, Task>)
Attaches an asynchronous zoom handler.
Parameters:
handler(Func<TilePanelZoomEventArgs, Task>):
Returns: TilePanelWidget
public TilePanelWidget OnZoom(Func<TilePanelZoomEventArgs, Task> handler)UpdateNode(TilePanelNode)
Called during reconciliation to update the node's properties from the widget. Override this to copy widget properties to the node before building content.
Parameters:
node(TilePanelNode): The node to update.
protected override void UpdateNode(TilePanelNode node)WithPointsOfInterest(IReadOnlyList<TilePointOfInterest>)
Sets the points of interest to display on the map.
Parameters:
Returns: TilePanelWidget
public TilePanelWidget WithPointsOfInterest(IReadOnlyList<TilePointOfInterest> pois)Fields
PanDown
Rebindable action: Pan camera down.
Returns: ActionId
public static readonly ActionId PanDownPanDownFast
Rebindable action: Pan camera down fast.
Returns: ActionId
public static readonly ActionId PanDownFastPanLeft
Rebindable action: Pan camera left.
Returns: ActionId
public static readonly ActionId PanLeftPanLeftFast
Rebindable action: Pan camera left fast.
Returns: ActionId
public static readonly ActionId PanLeftFastPanRight
Rebindable action: Pan camera right.
Returns: ActionId
public static readonly ActionId PanRightPanRightFast
Rebindable action: Pan camera right fast.
Returns: ActionId
public static readonly ActionId PanRightFastPanUp
Rebindable action: Pan camera up.
Returns: ActionId
public static readonly ActionId PanUpPanUpFast
Rebindable action: Pan camera up fast.
Returns: ActionId
public static readonly ActionId PanUpFastResetPosition
Rebindable action: Reset camera to origin.
Returns: ActionId
public static readonly ActionId ResetPositionZoomIn
Rebindable action: Zoom in.
Returns: ActionId
public static readonly ActionId ZoomInZoomOut
Rebindable action: Zoom out.
Returns: ActionId
public static readonly ActionId ZoomOutRemarks
TilePanel composes a for tile rendering, elements for positioning points of interest, and a for layering and overlay support.
Camera position and zoom are controlled externally by the user via and event handlers. The user updates their state in response to events, and the new position flows back as widget properties — following the "controlled component" pattern.
Examples
var cameraX = 0.0;
var cameraY = 0.0;
var zoom = 0;
ctx.TilePanel(myDataSource, cameraX, cameraY, zoom)
.WithPointsOfInterest([new TilePointOfInterest(5, 3, "📍", "Spawn")])
.OnPan(e => { cameraX += e.DeltaX; cameraY += e.DeltaY; })
.OnZoom(e => zoom = e.NewZoomLevel)