refactor(editor): render fill/effect color swatches via jian Swatch

The gradient-stop and shadow-color swatches now paint through jian
Swatch (alpha-aware checker + fill) instead of the local paint_alpha_checker
+ separate fill; drops paint_alpha_checker and its public re-export.
Bumps vendor/jian to 9c13e8d (checker now theme-independent, so the
transparency pattern stays visible in dark mode).
This commit is contained in:
Kayshen-X 2026-06-20 13:05:03 +08:00
parent 8a8c97f90a
commit dc67272bad
3 changed files with 21 additions and 51 deletions

View file

@ -240,8 +240,16 @@ fn paint_effect_color_row(cx: &mut PaintCx<'_>, theme: &Theme, color: Color, rec
origin: Point2D::new(rect.origin.x + 38.0, rect.origin.y + 7.0),
size: Point2D::new(16.0, 16.0),
};
super::property_panel_fill::paint_alpha_checker_public(cx, swatch, 3.0);
cx.backend.fill_round_rect(swatch, 3.0, color);
jian_widgets::components::swatch::Swatch {
color,
radius: 3.0,
border: false,
}
.paint(
cx.backend,
swatch,
&crate::widgets::button::tokens_from_theme(theme),
);
// `rgba(r,g,b,a)` text after the swatch — matches the spec.
let text = format!(
"rgba({},{},{},{:.2})",

View file

@ -558,8 +558,16 @@ fn paint_fill_gradient_body(
origin: Point2D::new(hex_rect.origin.x + 6.0, hex_rect.origin.y + 5.0),
size: Point2D::new(16.0, 16.0),
};
paint_alpha_checker(cx, swatch, 3.0);
cx.backend.fill_round_rect(swatch, 3.0, stop.color);
jian_widgets::components::swatch::Swatch {
color: stop.color,
radius: 3.0,
border: false,
}
.paint(
cx.backend,
swatch,
&crate::widgets::button::tokens_from_theme(theme),
);
// Display only `#RRGGBB` — the swatch on the left already
// conveys per-stop transparency. Alpha is preserved at
// commit time, so the user never types raw alpha digits.
@ -734,49 +742,3 @@ pub fn stop_hex_rgb_only(hex: &str) -> String {
};
format!("#{}", body.to_uppercase())
}
/// Public re-export so sibling widget modules (e.g. the effects
/// section's colour row) can reuse the same alpha-aware swatch
/// background without duplicating the geometry.
pub fn paint_alpha_checker_public(cx: &mut PaintCx<'_>, rect: Rect, radius: f32) {
paint_alpha_checker(cx, rect, radius);
}
/// Paint a 2×2 light/dark checker behind a colour swatch so a
/// partially or fully transparent fill reads as "transparent"
/// instead of looking like the input pill's background. The
/// caller paints the (possibly translucent) stop colour on top.
fn paint_alpha_checker(cx: &mut PaintCx<'_>, rect: Rect, radius: f32) {
let light = Color {
r: 0.95,
g: 0.95,
b: 0.95,
a: 1.0,
};
let dark = Color {
r: 0.78,
g: 0.78,
b: 0.78,
a: 1.0,
};
cx.backend.fill_round_rect(rect, radius, light);
let hx = rect.size.x / 2.0;
let hy = rect.size.y / 2.0;
// Skia has no clipped round-rect for sub-rect fills, so paint
// the two darker quadrants as plain rects — the surrounding
// light fill already supplies the rounded silhouette.
cx.backend.fill_rect(
Rect {
origin: Point2D::new(rect.origin.x + hx, rect.origin.y),
size: Point2D::new(hx, hy),
},
dark,
);
cx.backend.fill_rect(
Rect {
origin: Point2D::new(rect.origin.x, rect.origin.y + hy),
size: Point2D::new(hx, hy),
},
dark,
);
}

2
vendor/jian vendored

@ -1 +1 @@
Subproject commit 3b5db9116dcb3c4582bd00098225f662099ee59c
Subproject commit 9c13e8d767a2d0255ec6741c7ca9938520feaa99