Skip to content

💡 translate: shift an element's paint without affecting flow #82

@natemoo-re

Description

@natemoo-re

Is your feature request related to a problem?

There's no way to nudge an element a few cells from where layout placed it while leaving its neighbors put. The only offset tool today is floating, which pulls the element out of flow so siblings reflow to fill the gap. A fixed(5) row holding element a (text A) followed by text B renders "AB "; we can't shift A two cells right while B stays put, since anything that moves A collapses B back to column 0. That rules out small visual nudges (badges, carets, hover) that shouldn't disturb surrounding layout.

Describe the solution you'd like

A render-time translate that shifts an element's painted cells (and its descendants') by {x, y} after flow layout, mirroring the CSS translate property (exact name TBD). It does not change layout: the element keeps its computed flow slot and siblings don't move. It's purely a visual displacement, with the element's reported bounds following the shift so hit-testing stays correct. Above, a keeps its slot at x=0, B stays at column 1, and a paints two cells over to yield " BA ".

const node = open("a", {
  layout: {
    translate: { x: 2, y: 0 },
  },
});

Describe alternatives you've considered

floating removes the element from flow (siblings collapse), so it can't do an in-place nudge. Post-processing the rendered grid in TS can't see clip regions, backgrounds, or descendant bounds, and info.bounds would still report the un-shifted position—breaking hit-testing and hover. A renderer-side translate keeps bounds and paint in sync.

Additional context

Failing test case on nm/repro/translate (test · diff). Today bounds.x is 0 instead of 2 and the row renders "AB " instead of " BA ". This likely lives in ops.ts:97-120 (the pack layout group has no translate slot) and ops.ts:245-253 (OpenElement.layout has no translate field), with the render-time shift applied where the layout group is decoded (src/clayterm.c:499-516).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions