Skip to content

Fold-aware layouts and Form fold semantics - #6402

Open
shai-almog wants to merge 6 commits into
masterfrom
fold-aware-layouts
Open

shai-almog wants to merge 6 commits into
masterfrom
fold-aware-layouts

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Summary

Codename One already reports fold state (DevicePosture, posture listeners, simulator and Android support), but nothing in the UI reacted to it. This PR adds fold-aware layouts and makes forms respond to folds.

  • Layout fold behaviour: getFoldBehavior() returns FOLD_IGNORE (the default, so existing layouts are unchanged), FOLD_REVALIDATE or FOLD_ANIMATE. getFoldAnimationDuration() sets the animation length. setFoldState/getFoldState read the hinge through the new FoldState snapshot, which is relative to the container. A fixed state can stand in for the device (previews, virtual hinges, tests).
  • FoldLayout: a primary and a secondary pane. With a vertical hinge (book or dual screen) the panes sit side by side with the hinge left empty. With a horizontal hinge (flip or table-top) the primary goes above and the secondary below. With no fold, a fallback applies: primary only, stacked, or split.
  • FoldAvoidingLayout: wraps any layout and fits each half of the container to its own side of the hinge.
  • Form: listens for posture changes while it owns the surface. It ignores events where the fold itself hasn't changed, calls onFoldChanged(FoldState), then animates or revalidates the content pane according to its layouts. It revalidates instead of animating when reduced motion is on. A form whose content pane uses FoldLayout doesn't scroll.
  • Screenshot tests: four fold animation tests, each driven by an explicit FoldState so the frames match on every port:
    • FoldBookOpenScreenshotTest: a list/detail screen opening across a vertical hinge.
    • FoldTableTopScreenshotTest: a media screen moving into table-top posture.
    • FoldAvoidingGridScreenshotTest: a grid splitting around a vertical hinge.
    • FoldFlipGridScreenshotTest: a grid splitting around a horizontal hinge.
  • Docs and data: a developer guide section with two compiled snippets, and a port-status feature entry.

Testing

  • Unit tests (FoldLayoutTest, FormFoldBehaviorTest) cover pane geometry for each posture and fallback, no child under the hinge, switching a container's layout without losing children, the padded split, the live device fold through the test implementation, ignoring repeated events, panes filling a non-scrolling form, and the listener being removed when the form is no longer showing.
  • scripts/pre-push-gates.sh --full passes. The steps it lists as NOT RUN are CI-only.
  • The golden images for the new screenshot tests will come from golden capture.
  • Not yet run on a real foldable simulator skin. The form's automatic relayout has been exercised only through the test implementation.

🤖 Generated with Claude Code

shai-almog and others added 5 commits December 5, 2026 18:49
…ntics

Layouts declare how a form responds to a fold or posture change
(FOLD_IGNORE / FOLD_REVALIDATE / FOLD_ANIMATE) and read the hinge through
FoldState. The current form listens for posture changes, calls
onFoldChanged and revalidates or animates its content pane accordingly.
Adds animation screenshot tests for book, table-top and flip folds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gate fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e hinge, padded split, hidden collapsed pane)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out bounds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tent pane

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Golden capture needs attention

Test iOS UI build scripts capture was cancelled; re-run Golden capture

Whatever did arrive is committed; the next push captures only what is still missing. A test that cannot render on some port needs a // cn1ss-skip: <ports> declaration.

Run at a2221fe3db59

…e prefix

Form.postureListener's class, Form$PostureListener, starts with the Form prefix; the
addComponent fallback took it for the form and rebuilt its content pane with a FlowLayout,
blanking the Chart2 animation screenshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant