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 : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<TilePanelWidget>

Inheritance ​

Object → Hex1bWidget → 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; }

PoiList ​

Points of interest to display on the map.

Returns: IReadOnlyList<TilePointOfInterest>

csharp
public IReadOnlyList<TilePointOfInterest> PoiList { 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 ​

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)

PointsOfInterest(IReadOnlyList<TilePointOfInterest>) ​

Sets the points of interest to display on the map.

Parameters:

Returns: TilePanelWidget

csharp
public TilePanelWidget PointsOfInterest(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)
    .PointsOfInterest([new TilePointOfInterest(5, 3, "📍", "Spawn")])
    .OnPan(e => { cameraX += e.DeltaX; cameraY += e.DeltaY; })
    .OnZoom(e => zoom = e.NewZoomLevel)

Released under the MIT License.