Skip to content

Feature/383 css like support for styling controls#384

Draft
flsobral wants to merge 18 commits into
masterfrom
feature/383-css-like-support-for-styling-controls
Draft

Feature/383 css like support for styling controls#384
flsobral wants to merge 18 commits into
masterfrom
feature/383-css-like-support-for-styling-controls

Conversation

@flsobral

@flsobral flsobral commented Jun 9, 2026

Copy link
Copy Markdown
Member

CSS-like styling for controls!

The goal is not full CSS support, but to support a CSS-like subset, parsed from real CSS, skipping unsupported properties. This is supported by classes modeled after CSS properties and new classes to handle geometry calculation and rendering the controls. Using CSS is not required, the same results can be obtained by using these classes directly, but it is a lot easier to just use CSS and let the parser do this work.

flsobral added 18 commits June 8, 2026 20:23
Introduce the RRect and Span gfx primitives on the SDK side and wire the
private geometry helpers to native implementations.

Register the new bindings in the VM and include gfx_RRect.c in the build.
Add drawRRect support across the VM gfx pipeline, including
Skia integration, raster fallback, and the required native bindings for
Graphics and rounded-rectangle geometry.
Introduce gfx.Paint and gfx.PathEffect as low-level drawing primitives
inspired by Skia.

Update Graphics.drawLine to accept a Paint object and wire the native
binding to read the line color from Paint for now.
Introduce the box style model, including layout, paint, border, clip,
shape, elevation, and shadow types.

Add the CSS parser, geometry resolver, and painter used to turn box
styles into computed geometry and rendered output.
Introduce UnitsConverter.toPixels(double) for callers that need
fractional unit conversion and document the UnitsConverter API with
Javadocs for the class and its public methods.
Move the shadow outset calculation from BoxGeometry into Elevation so the
derived value lives with the immutable elevation model.

This keeps geometry focused on box resolution and lets callers read the
precomputed outset directly from Elevation.
Move corner-radii inset and clamp operations from BoxGeometry into
CornerRadii so the shape math lives with the radii model itself.

Update BoxGeometry and BoxPainter to use the new CornerRadii API.
Add the ControlRenderer abstraction for control-level visual rendering
and rename BoxPainter to BoxRenderer to match its broader role.

This establishes the renderer contract that future control renderers can
implement.
Change the control renderer child clip contract to return RRect instead
of Rect, allowing renderers to expose rounded and rectangular clip
shapes through a single type.
Propagate inherited graphics clips when painting child controls and
restore container clips after painting.

Also cache user insets separately from border-derived insets so container
layout can recompute them consistently.
Store the control renderer on Control and expose setter and getter
methods for it.

Use the renderer outset when expanding the repaint area and add hooks
for subclasses to react to renderer-driven style changes.
Use the control renderer to draw containers, compute insets, and provide
the cached children clip.

Refresh renderer-derived container state when the style changes.
Convert parsed CSS padding and border radius lengths through the unit
converter so browser-style px values match controls sized with dp.
Ensure BoxRenderer passes an opaque ARGB color when drawing box
backgrounds so CSS colors are not treated as fully transparent.
Add CSS parsing for a base selector and its :active rule, merging the
active declarations over the base box style.

Let BoxRenderer use the active style while a control is pressed and keep
the largest style outset available for repaint bounds.
Draw the configured control renderer as the button background without
short-circuiting the normal text and image painting flow.

Skip legacy button background and press effect painting when a renderer
is present so the rendered style is not overwritten.
@flsobral flsobral self-assigned this Jun 9, 2026
@flsobral flsobral added feature New feature or request All platforms Issue related to the all platforms labels Jun 9, 2026
@flsobral flsobral linked an issue Jun 9, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

All platforms Issue related to the all platforms feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSS like support for styling controls

1 participant