Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,11 +659,13 @@ pub fn checkbox(
pos2(rect.left(), rect.center().y - box_side / 2.0),
Vec2::splat(box_side),
);
// A checkbox box reads as a square — `radius_sm` on an 18 px box looks
// like a circle, so use the tighter `radius_xs`.
ui.painter()
.rect_filled(box_rect, t.rounding_sm(), lerp_color(t.card, t.accent, on));
.rect_filled(box_rect, t.rounding_xs(), lerp_color(t.card, t.accent, on));
let border = lerp_color(lerp_color(t.border, t.border_strong, hv), t.accent, on);
ui.painter()
.rect_stroke(box_rect.shrink(0.5), t.rounding_sm(), Stroke::new(1.0, border));
.rect_stroke(box_rect.shrink(0.5), t.rounding_xs(), Stroke::new(1.0, border));
if on > 0.01 {
let c = box_rect.center();
let stroke = Stroke::new(2.0, t.accent_ink.gamma_multiply(on));
Expand Down
10 changes: 10 additions & 0 deletions src/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ pub struct Tokens {
pub success: Color32,

/// Corner radii.
/// Extra-small — tight controls where `radius_sm` reads as a circle
/// (checkbox boxes, small swatches).
pub radius_xs: f32,
pub radius_sm: f32,
pub radius_md: f32,
pub radius_lg: f32,
Expand Down Expand Up @@ -104,6 +107,7 @@ impl Tokens {
danger: Color32::from_rgb(0xef, 0x5c, 0x68),
warning: Color32::from_rgb(0xe0, 0xa4, 0x3f),
success: Color32::from_rgb(0x3e, 0xcf, 0x8e),
radius_xs: 4.0,
radius_sm: 7.0,
radius_md: 12.0,
radius_lg: 16.0,
Expand Down Expand Up @@ -138,6 +142,7 @@ impl Tokens {
danger: Color32::from_rgb(0xcf, 0x43, 0x4c),
warning: Color32::from_rgb(0xb8, 0x7a, 0x18),
success: Color32::from_rgb(0x1a, 0x9d, 0x6a),
radius_xs: 4.0,
radius_sm: 7.0,
radius_md: 12.0,
radius_lg: 16.0,
Expand Down Expand Up @@ -167,4 +172,9 @@ impl Tokens {
pub fn rounding_sm(&self) -> egui::Rounding {
egui::Rounding::same(self.radius_sm)
}

/// `radius_xs` as an [`egui::Rounding`].
pub fn rounding_xs(&self) -> egui::Rounding {
egui::Rounding::same(self.radius_xs)
}
}
Loading