Add per-side border widths and colors - #3391
Open
Cretezy wants to merge 4 commits into
Open
Conversation
Cretezy
marked this pull request as ready for review
July 17, 2026 15:17
Cretezy
force-pushed
the
agent/per-side-border-widths-and-colors
branch
from
July 17, 2026 20:05
a084bba to
f67b665
Compare
Cretezy
force-pushed
the
agent/per-side-border-widths-and-colors
branch
from
July 17, 2026 21:19
f0c72c1 to
393382b
Compare
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.
Summary
Implements per-side border widths and colors for #703.
border::SideplusBorder::{top,right,bottom,left}overrides while retaining the existing uniformcolorandwidthAPI as fallbacks.0) edges, and scales only opposing pairs that would exceed the quad bounds.Borderliterals, rustdocs, the custom-quad example, and core/software/wgpu smoke coverage.Motivation
Today a
Bordercan vary its corner radii but all four edges must share one color and width. This makes common UI patterns—such as dividers on collapsible headers, active-edge indicators, and asymmetric outlines—require custom drawing despite all widgets already flowing throughrenderer::Quad.The change exposes that capability once in the shared border API, so every quad-backed widget can use it without introducing widget-specific styling APIs or changing layout/padding behavior.
Design and trade-offs
Sideuses optional overrides. That keepsborder::color(...)andborder::width(...)source-compatible as uniform defaults, makes builder order irrelevant, and allows replacing a side withSide::default()to clear overrides. Side widths remain solid-only; dashed/dotted styles and gradient border colors are intentionally out of scope.For rendering, borders stay inside the quad. Opposing widths are proportionally constrained only when their sum exceeds the corresponding dimension. The GPU path computes an outer rounded contour with an asymmetrically inset inner contour and chooses corner colors along CSS-style diagonal joins. The tiny-skia path keeps the existing efficient stroke route for uniform borders; non-uniform borders use a clipped ring and elliptical inner arcs where adjacent widths differ. Shadows still follow the outer radius.
I found this approach to be the least breaking, only requiring adding
..Border::default()to previousBorder { }definitions.Validation
cargo fmt --all -- --checkcargo test -p iced_core -p iced_tiny_skia -p iced_wgpu --libcargo test -p iced_core --doccargo check --workspacegit diff --checkcargo clippy -p iced_core -p iced_tiny_skia -p iced_wgpu --lib -- -D warningswas also run; it stops on an existing unrelatedimage::Batch::default()lint inwgpu/src/layer.rs:410.