Skip to content

Conversation

@rock3r
Copy link
Collaborator

@rock3r rock3r commented Nov 11, 2025

This adds an action to the ui-inspector module that toggles the showLayoutBounds value for all currently attached ComposePanels. It also registers an AWT hierarchy listener, if the toggle is on, to capture when a new ComposePanel is added to the hierarchy and make sure the setting is respected in cases where panels are detached and then re-attached (the setting is lost when the panel is detached as it disposes a lot of internal state).

Screen.Recording.2025-11-09.at.19.52.57.mov

When toggled, the action also tries to cause a recomposition in all the panels so that the bounds do start showing right away, but it doesn't seem to always work/cause a full redraw. Any interaction or change in bounds on the panels will cause the panels to redraw, and that is mostly good enough for now.

Given the approach is reflection-heavy, it is prone to breaking if there are changes in CMP internals; when we have a better, official API for it, we'll be able to have a more robust impl.

CC @igordmn @batya239 @jreznot


Note

Introduces an internal action that toggles showLayoutBounds for all Compose panels, using reflection, auto-updates on panel attach via AWT listener, and registers the action in resources.

  • UI Inspector / Compose:
    • Add ToggleComposeLayoutBoundsAction to toggle showLayoutBounds across active Compose containers; updates presentation text based on state.
    • Implement LayoutBoundsToggler to reflectively set owner.showLayoutBounds, invalidate layers, trigger revalidate/repaint, and listen for AWT HierarchyEvent attachments.
    • Introduce ComposeUtil to locate Compose containers (ComposePanel/ComposeWindow) and traverse to root layout nodes via reflection.
    • Add ReflectHelper for cached reflective field/method access.
  • Action Registration / Resources:
    • Register action ToggleComposeLayoutBounds in PlatformActions.xml under internal UI tools.
    • Add action text key action.ToggleComposeLayoutBounds.text to ActionsBundle.properties.

Written by Cursor Bugbot for commit 0033818. This will update automatically on new commits. Configure here.

This adds an action to the ui-inspector module that toggles the
showLayoutBounds value for all currently attached ComposePanels.
It also registers an AWT hierarchy listener, if the toggle is
on, to capture when a new ComposePanel is added to the hierarchy
and make sure the setting is respected in cases where panels are
detached and then re-attached (the setting is lost when the
panel is detached as it disposes a lot of internal state).

When toggled, the action also tries to cause a recomposition in
all the panels so that the bounds do start showing right away,
but it doesn't seem to always work/cause a full redraw. Any
interaction or change in bounds on the panels will cause the
panels to redraw, and that is mostly good enough for now.

Given the approach is reflection-heavy, it is prone to breaking
if there are changes in CMP internals; when we have a better,
official API for it, we'll be able to have a more robust impl.
@rock3r rock3r self-assigned this Nov 11, 2025
@rock3r rock3r requested a review from batya239 November 11, 2025 15:32
@rock3r rock3r marked this pull request as draft November 18, 2025 16:01
@rock3r
Copy link
Collaborator Author

rock3r commented Nov 18, 2025

Moved to draft since I contributed a better way to enable this in CMP and it will land in CMP 1.11-alpha01.

I will also move this action to the DevKit plugin.

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