DrawMode

sealed interface DrawMode

The interaction mode the draw engine is currently in. Sealed so every place that branches on mode (the reducer, and eventually the host UI) is guaranteed by the compiler to handle every case — adding a new mode later surfaces every place that needs updating as a compile error.

Inheritors

Types

Link copied to clipboard
data class Combine(val entityId: EntityId, val kind: CombineKind, val idPrefix: String) : DrawMode

Waiting for the second shape of a merge or a cut: the polygon entityId is the one that was selected, and the next tap on another polygon (DrawEvent.Click with a hitEntityId) does kind with it, as DrawEvent.MergeWith or DrawEvent.CutBy would, and goes back to Select of entityId (or to Idle when a cut took all of it). A tap on nothing or on entityId itself cancels, as does a DrawEvent.ModeChange to anything else; a tap on a shape that isn't a polygon is ignored. New vertices get ids made from idPrefix (see DrawEvent.MergeWith). The shape entityId is highlighted as selected meanwhile.

Link copied to clipboard
data class Draw(val entityType: DrawableEntityType, val pendingVertices: List<GeoPosition>, val style: ShapeStyle = DEFAULT_STYLE, val activeDrag: DrawMode.Draw.ActiveDrag? = null, val targetEntityId: EntityId? = null) : DrawMode

A new shape is being sketched. pendingVertices holds the points placed so far. This is a draft, not yet a real entity — it isn't subject to com.tcsappdev.worldwinddraw.core.geometry.DrawnPolygon/ com.tcsappdev.worldwinddraw.core.geometry.DrawnPolyline's minimum-vertex-count rules until DrawEvent.FinishDrawing actually commits it as one (see DrawEngineReducer), using style for the new entity.

Link copied to clipboard
data class Edit(val entityId: EntityId, val activeDrag: DrawMode.Edit.ActiveDrag? = null, val selectedVertexId: VertexId? = null) : DrawMode

entityId's vertices are being edited (selected, dragged, or having points inserted).

Link copied to clipboard
object Idle : DrawMode

Nothing is happening; a tap can select a shape or fall through to panning.

Link copied to clipboard
object Pan : DrawMode

The user is moving the camera; drawing/editing gestures are suspended.

Link copied to clipboard
data class Select(val entityId: EntityId) : DrawMode

entityId is highlighted as selected, but not yet in edit mode.

Functions

Link copied to clipboard
open fun styleStateFor(entityId: EntityId): StyleState

Which StyleState should be rendered in while the engine is in this mode: StyleState.EDITING or StyleState.SELECTED for the one entity Edit/Select names, StyleState.DEFAULT for every other entity and every other mode. HOVER and DISABLED aren't derivable from a mode — nothing in the engine produces them yet.