refactor(editor): render property checkboxes/radio via jian Checkbox/Radio

The widget + size-section check rows and the flex gap-alignment radio
now paint through jian Checkbox / Radio (first consumers) instead of
hand-rolled box+check / ring+dot; row hit-tests are unchanged.
This commit is contained in:
Kayshen-X 2026-06-20 12:27:22 +08:00
parent 962cfae904
commit f3e7a149ef
3 changed files with 24 additions and 43 deletions

View file

@ -42,7 +42,6 @@ const GAP_ROW_H: f32 = 20.0;
const GAP_ROW_GAP: f32 = 2.0;
/// RadioCircle geometry (compact ring + dot).
const RADIO_SIZE: f32 = 13.0;
const RADIO_DOT: f32 = 7.0;
/// x-offset from a radio row's left to its content (TS `gap-1.5` = 6px
/// + the 14px circle).
const RADIO_GUTTER: f32 = 6.0 + RADIO_SIZE;
@ -681,22 +680,15 @@ fn paint_radio_circle(cx: &mut PaintCx<'_>, theme: &Theme, x: f32, y: f32, selec
origin: Point2D::new(x, y),
size: Point2D::new(RADIO_SIZE, RADIO_SIZE),
};
let border = if selected {
theme.primary
} else {
theme.muted_foreground
};
cx.backend
.stroke_round_rect(ring, RADIO_SIZE / 2.0, border, 1.5);
if selected {
let off = (RADIO_SIZE - RADIO_DOT) / 2.0;
let dot = Rect {
origin: Point2D::new(x + off, y + off),
size: Point2D::new(RADIO_DOT, RADIO_DOT),
};
cx.backend
.fill_round_rect(dot, RADIO_DOT / 2.0, theme.primary);
jian_widgets::components::radio::Radio {
selected,
enabled: true,
}
.paint(
cx.backend,
ring,
&crate::widgets::button::tokens_from_theme(theme),
);
}
/// 10px muted label vertically centred in a `GAP_ROW_H` radio row.

View file

@ -760,20 +760,15 @@ fn paint_check_row(
origin: Point2D::new(x, y + 3.0),
size: Point2D::new(16.0, 16.0),
};
if checked {
cx.backend.fill_round_rect(box_rect, 4.0, theme.primary);
draw_icon(
cx.backend,
Icon::Check,
Point2D::new(box_rect.origin.x + 1.0, box_rect.origin.y + 1.0),
14.0,
theme.primary_foreground,
1.8,
);
} else {
cx.backend
.stroke_round_rect(box_rect, 4.0, theme.border, 1.0);
jian_widgets::components::checkbox::Checkbox {
checked,
enabled: true,
}
.paint(
cx.backend,
box_rect,
&crate::widgets::button::tokens_from_theme(theme),
);
let lbl = TextLayout::single_run(
label,
"system-ui",

View file

@ -15,7 +15,6 @@
//! out of scope (JSON-only).
use crate::theme::Theme;
use crate::widgets::icons::{draw_icon, Icon};
use crate::widgets::property_panel::{NodeSnapshot, PropertyPanelAction, WidgetKind};
use crate::widgets::property_panel_inputs::{
paint_input_with_prefix_focused_state, paint_section_divider, paint_section_label,
@ -287,20 +286,15 @@ fn paint_check_row(
origin: Point2D::new(x, y + 7.0),
size: Point2D::new(16.0, 16.0),
};
if checked {
cx.backend.fill_round_rect(box_rect, 4.0, theme.primary);
draw_icon(
cx.backend,
Icon::Check,
Point2D::new(box_rect.origin.x + 1.0, box_rect.origin.y + 1.0),
14.0,
theme.primary_foreground,
1.8,
);
} else {
cx.backend
.stroke_round_rect(box_rect, 4.0, theme.border, 1.0);
jian_widgets::components::checkbox::Checkbox {
checked,
enabled: true,
}
.paint(
cx.backend,
box_rect,
&crate::widgets::button::tokens_from_theme(theme),
);
let lbl = TextLayout::single_run(
label,
"system-ui",