Feature/383 css like support for styling controls#384
Draft
flsobral wants to merge 18 commits into
Draft
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.