List rows: a row in_label_column keeps its label in the label column and leaves the empty toggle columns before it empty; Brush Tip Shape lines up with the section names

This commit is contained in:
aiongg
2026-11-13 02:48:04 +00:00
parent f780c31085
commit d9566067a7
4 changed files with 21 additions and 11 deletions
@@ -324,11 +324,11 @@ impl<'a, K: Value + Eq + Hash> BrushSectionList<'a, K> {
let state = ToggleState::of(section.enabled == Some(true));
row = row.toggle(ToggleCell::check(CHECK, state, switch_name.clone()).row_press());
}
BrushSectionKind::Pane => {
if let Some(on) = section.enabled {
row = row.toggle(ToggleCell::check(CHECK, ToggleState::of(on), enable_name.clone()).row_press());
}
}
BrushSectionKind::Pane => match section.enabled {
Some(on) => row = row.toggle(ToggleCell::check(CHECK, ToggleState::of(on), enable_name.clone()).row_press()),
// A pane without an enable box (Brush Tip Shape) lines its name up with the others.
None => row = row.in_label_column(),
},
}
if let Some(locked) = section.locked {
let tip = if locked { words.unlock_tip.clone() } else { words.lock_tip.clone() };
+6
View File
@@ -114,6 +114,11 @@ pub struct ListRow<'a> {
/// The row has `space.gap.row` of empty room above its content, to set a group off from the one before.
#[prop]
pub(super) space_above: bool,
/// The label stays in its label column: the toggle columns this row leaves empty before it stay empty, as Brush
/// Settings' Brush Tip Shape lines up with the names of the sections that have an enable box. Without it the
/// label band spans the empty toggle columns next to it, as Layer Style's Styles row starts at the row's start.
#[prop(flag)]
pub(super) in_label_column: bool,
/// Whether the row is its own AccessKit node; a face inside another component's part turns it off.
#[prop]
pub(super) node: bool,
@@ -281,6 +286,7 @@ impl<'a> ListRow<'a> {
strong: false,
heading: false,
space_above: false,
in_label_column: false,
node: true,
ink: RowInk::Normal,
tone: Tone::Neutral,
+3 -2
View File
@@ -313,7 +313,8 @@ impl ListRow<'_> {
/// The positions in `cells_of` of the label column and of the first and last column the label band spans: its
/// own and every toggle column between it and the nearest cell the row fills on each side. A row lays out only
/// the toggle columns it fills, as a heading row without toggles starts at the row's start.
/// the toggle columns it fills, as a heading row without toggles starts at the row's start; a row `in_label_column`
/// spans none before its label column.
pub(super) fn label_span(&self, cells_of: &[(ColumnKey, Rect)]) -> Option<(usize, usize, usize)> {
let label = self.label_column(cells_of)?;
let at = cells_of.iter().position(|(key, _)| key == label)?;
@@ -321,7 +322,7 @@ impl ListRow<'_> {
let key = &cells_of[*position].0;
self.toggle_columns.contains(key) && !self.toggles.iter().any(|toggle| toggle.column == *key)
};
let first = (0..at).rev().take_while(open).last().unwrap_or(at);
let first = if self.in_label_column { at } else { (0..at).rev().take_while(open).last().unwrap_or(at) };
let last = (at + 1..cells_of.len()).take_while(open).last().unwrap_or(at);
Some((at, first, last))
}
+7 -4
View File
@@ -480,7 +480,8 @@ fn a_cell_field_stands_in_its_cell_takes_the_click_and_reports_its_edit() {
/// A row's label band takes the toggle columns it leaves empty next to it, up to the nearest toggle it fills: a row
/// without toggles starts its label at the row's start, a row with the first toggle only starts it inside the second
/// column, and a row with both starts it past them.
/// column, and a row with both starts it past them. A row without toggles that keeps its label in the label column
/// starts it past them too.
#[trial]
fn a_rows_label_takes_the_empty_toggle_columns_next_to_it() {
use craft_behavior::{ColumnKey, ColumnWidth};
@@ -490,13 +491,13 @@ fn a_rows_label_takes_the_empty_toggle_columns_next_to_it() {
const INCLUDE: ColumnKey = ColumnKey::new("include");
const DIALOG: ColumnKey = ColumnKey::new("dialog");
const NAME: ColumnKey = ColumnKey::new("name");
const LABELS: [&str; 3] = ["Set", "Action", "Step"];
const LABELS: [&str; 4] = ["Set", "Action", "Step", "Tip"];
let ends = Rc::new(Cell::new((0.0_f32, 0.0_f32)));
let held = ends.clone();
let mut fixture = Fixture::new(move |ui| {
let toggle = |key| ColumnSpec::toggle(key, "", ToggleColumn::default());
let columns = vec![toggle(INCLUDE), toggle(DIALOG), ColumnSpec::new(NAME, "", ColumnWidth::fill(1.0))];
let keys = [0_usize, 1, 2];
let keys = [0_usize, 1, 2, 3];
let source = keyed(&keys, |key: &usize| *key);
let _ = List::new("Actions").columns(columns).show_items(ui, &source, &mut |key, icx| {
let end = |column| icx.cell(&column).map_or(0.0, |cell| cell.right());
@@ -506,7 +507,8 @@ fn a_rows_label_takes_the_empty_toggle_columns_next_to_it() {
match key {
0 => row,
1 => row.toggle(check(INCLUDE)),
_ => row.toggle(check(INCLUDE)).toggle(check(DIALOG)),
2 => row.toggle(check(INCLUDE)).toggle(check(DIALOG)),
_ => row.in_label_column(),
}
});
});
@@ -526,6 +528,7 @@ fn a_rows_label_takes_the_empty_toggle_columns_next_to_it() {
assert!(start("Set") < include, "a row without toggles starts its label in the first toggle column");
assert!(start("Action") > include && start("Action") < dialog, "a row with the first toggle starts its label in the second column");
assert!(start("Step") > dialog, "a row with both toggles starts its label past them");
assert!(start("Tip") > dialog, "a row that keeps its label in the label column leaves the toggle columns empty");
}
/// In a list of toggle columns only, the label takes the room past the last column: it shows whole, as measure counts