Skip to content

TilePanelWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A composite widget that renders an infinite, pannable and zoomable tile map.

csharp
public sealed record TilePanelWidget : CompositeWidget<TilePanelNode>, IEquatable<Hex1bWidget>, IEquatable<CompositeWidget<TilePanelNode>>, IEquatable<TilePanelWidget>

Inheritance

ObjectHex1bWidget → CompositeWidget<TilePanelNode> → TilePanelWidget

Implements

Properties

CameraX

The camera X position in tile coordinates.

Returns: Double

csharp
public double CameraX { get; init; }

CameraY

The camera Y position in tile coordinates.

Returns: Double

csharp
public double CameraY { get; init; }

DataSource

The tile data source providing tile content.

Returns: ITileDataSource

csharp
public required ITileDataSource DataSource { get; init; }

PointsOfInterest

Points of interest to display on the map.

Returns: IReadOnlyList<TilePointOfInterest>

csharp
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

csharp
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:

Returns: Task<Hex1bWidget>

A task that resolves to the widget representing this composite's content.

csharp
protected override Task<Hex1bWidget> BuildContentAsync(TilePanelNode node, ReconcileContext context)

OnPan(Action<TilePanelPanEventArgs>)

Attaches a synchronous pan handler.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget OnPan(Action<TilePanelPanEventArgs> handler)

OnPan(Func<TilePanelPanEventArgs, Task>)

Attaches an asynchronous pan handler.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget OnPan(Func<TilePanelPanEventArgs, Task> handler)

OnPoiClicked(Action<TilePanelPoiClickedEventArgs>)

Attaches a synchronous POI click handler.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget OnPoiClicked(Action<TilePanelPoiClickedEventArgs> handler)

OnPoiClicked(Func<TilePanelPoiClickedEventArgs, Task>)

Attaches an asynchronous POI click handler.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget OnPoiClicked(Func<TilePanelPoiClickedEventArgs, Task> handler)

OnZoom(Action<TilePanelZoomEventArgs>)

Attaches a synchronous zoom handler.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget OnZoom(Action<TilePanelZoomEventArgs> handler)

OnZoom(Func<TilePanelZoomEventArgs, Task>)

Attaches an asynchronous zoom handler.

Parameters:

Returns: TilePanelWidget

csharp
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:

csharp
protected override void UpdateNode(TilePanelNode node)

WithPointsOfInterest(IReadOnlyList<TilePointOfInterest>)

Sets the points of interest to display on the map.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget WithPointsOfInterest(IReadOnlyList<TilePointOfInterest> pois)

Fields

PanDown

Rebindable action: Pan camera down.

Returns: ActionId

csharp
public static readonly ActionId PanDown

PanDownFast

Rebindable action: Pan camera down fast.

Returns: ActionId

csharp
public static readonly ActionId PanDownFast

PanLeft

Rebindable action: Pan camera left.

Returns: ActionId

csharp
public static readonly ActionId PanLeft

PanLeftFast

Rebindable action: Pan camera left fast.

Returns: ActionId

csharp
public static readonly ActionId PanLeftFast

PanRight

Rebindable action: Pan camera right.

Returns: ActionId

csharp
public static readonly ActionId PanRight

PanRightFast

Rebindable action: Pan camera right fast.

Returns: ActionId

csharp
public static readonly ActionId PanRightFast

PanUp

Rebindable action: Pan camera up.

Returns: ActionId

csharp
public static readonly ActionId PanUp

PanUpFast

Rebindable action: Pan camera up fast.

Returns: ActionId

csharp
public static readonly ActionId PanUpFast

ResetPosition

Rebindable action: Reset camera to origin.

Returns: ActionId

csharp
public static readonly ActionId ResetPosition

ZoomIn

Rebindable action: Zoom in.

Returns: ActionId

csharp
public static readonly ActionId ZoomIn

ZoomOut

Rebindable action: Zoom out.

Returns: ActionId

csharp
public static readonly ActionId ZoomOut

Remarks

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

csharp
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)

Released under the MIT License.