Stroke: the panel's rows share one label column

The Weight, Arrowheads, Scale, Align and Profile rows each sized their
own label column, so their controls started at different x positions.
The panel now shows its rows in one FieldGroup, and they share the
widest label.
This commit is contained in:
dotCooCoo committed 2026-11-28 18:01:58 -08:00
1 parent ac031311a2
commit 8270b4f982
2 files changed
+17 -2

No files matched your search

+7 -2
View File
@@ -12,7 +12,7 @@ use craft::ui::buttons::IconButton;
use craft::ui::choice::Segmented;
use craft::ui::contract::{Bind, Entry, FieldLabelRole, Props as _, Show as _, ShowContainer as _, SideLabel, Sizing, TooltipSpec};
use craft::ui::display::Divider;
use craft::ui::form::Field;
use craft::ui::form::{Field, FieldGroup};
use craft::ui::layout_components::{Grid, Row};
use craft::ui::list::ThumbAspect;
use craft::ui::menu::PanelRow;
@@ -362,8 +362,13 @@ pub(crate) fn link_field(app: &mut VectorcraftApp, ui: &mut Ui, label: &'static
}
/// The Stroke panel: the weight, the stroke editor (cap, corner, align, dashes), arrowheads, scale, align and the
/// width profile.
/// width profile. The panel's own rows share one label column, so their controls start at one x.
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
FieldGroup::new(tl!("Stroke Options")).show(ui, |ui, _| rows(app, ui));
}
/// The rows of [`show`].
fn rows(app: &mut VectorcraftApp, ui: &mut Ui) {
use craft::ui::runtime::env::{WordRows, WordsOverride, with_env};
let st = current_stroke(app);
+10
View File
@@ -24,3 +24,13 @@ fn turning_dashes_on_fits_them_to_corners_and_turning_back_on_restores_the_last_
let d = toggle_dashes(&mut panel).expect("dashes on");
assert_eq!((d.pattern, d.align_corners), (vec![4.0, 2.0], false));
}
#[test]
fn the_panel_rows_start_their_controls_at_one_x() {
let mut panel = Panel::new(app_with_rect(), stroke::show);
panel.frame();
panel.frame();
let starts: Vec<(&str, f32)> = ["Weight", "Start arrowhead", "Profile"].into_iter().map(|name| (name, panel.rect(name).min.x)).collect();
let first = starts[0].1;
assert!(starts.iter().all(|(_, x)| (x - first).abs() < 0.5), "controls start at {starts:?}");
}