PannableCanvas¶
@Composable
fun PannableCanvas(
modifier: Modifier = Modifier,
state: PannableCanvasState = rememberPannableCanvasState(),
backgroundTexture: ResourceLocation? = null,
backgroundTextureSize: Int = 32,
backgroundTint: Int = -1,
backgroundParallax: Float = 1.0f,
panelTexture: String = "surface",
panelVariant: String? = "inset_transparent",
panelContentPadding: Int = 2,
content: @Composable
() -> Unit
)
A fixed-size viewport (modifier's own size) over a single, arbitrarily large child, panned by click-dragging anywhere inside it - the same "pan around a graph" interaction the vanilla advancements screen (and Thaumcraft's Thaumonomicon, and quest-book mods generally) uses, built on the same Layout/Renderer primitives Scrollable is, minus the scrollbar/lerp animation (NodeTreeView's node graph pans 1:1 with the drag, not eased). Content outside the viewport is clipped via a scissor, matching how Scrollable hides its own overflowed content.
The scroll wheel adjusts PannableCanvasState.zoom by PannableCanvasState.ZOOM_STEP per notch, anchored on the cursor (see PannableCanvasState.zoomBy) - content itself decides what "zoom" actually means for whatever it draws (PannableCanvas only owns the shared zoom number/pan-math, not any particular rendering of it); NodeTreeView is the one consumer that currently does anything with it.
Parameters¶
-
backgroundTexture: When given, tiled across the whole viewport and panned alongside
content(the same "infinite paper" backdrop Thaumonomicon-style guide/skill-tree screens use, analogous to vanilla's own repeating dirt background) - a plain, unpanned background belongs onmodifierinstead (e.g. viaPanel/Surface), since a texture given here specifically moves. -
backgroundTextureSize:
backgroundTexture's own tile size in pixels (it's sampled with wrapping, so it must actually tile at this size - 32 matches vanilla'soptions_background). -
backgroundTint: Packed ARGB tint applied to
backgroundTexture--1draws it unmodified. -
backgroundParallax: How fast
backgroundTexturepans relative tocontent-1fis exact lockstep, below that trails behind (a parallax depth cue),0fpins it in place. -
panelTexture: /
panelVariantA themedSurfaceframe drawn over the whole viewport (seeSurface's owndrawOverContent), wrapping everyPannableCanvasin a bordered panel by default.modifierapplies to this outer frame. PasspanelVariant = nullto opt out. -
panelContentPadding: How far the pannable viewport sits inset from
panelVariant's own edge, so its own corners don't peek through the border's transparent rounded corners. Ignored whenpanelVariantisnull. Defaults to this theme's own nine-slice border thickness.