diff --git a/crates/ui-widgets/src/bars/bar.rs b/crates/ui-widgets/src/bars/bar.rs index 570e4e7d8..711fb3490 100644 --- a/crates/ui-widgets/src/bars/bar.rs +++ b/crates/ui-widgets/src/bars/bar.rs @@ -11,7 +11,7 @@ use crate::layout_components::Row; use crate::runtime::access::Name; use crate::runtime::commands::{CommandSet as _, Commands as _}; use crate::runtime::env::Label; -use crate::style::{ComponentStyle, StyleCx, SurfaceKind}; +use crate::style::{ComponentStyle, GlyphRole, StyleCx, SurfaceKind}; use craft_behavior::{IconId, Metrics, NavShape, Roving, Sense}; use craft_theme::ControlSize; use egui::{Response, Ui}; @@ -129,6 +129,9 @@ impl<'a> Bar<'a> { if kind == BarKind::Status { props = props.live(Politeness::Polite); } + if kind == BarKind::Options { + props = props.child_glyphs(GlyphRole::Tool); + } Bar { common: Common::new(), props, kind, commit_cancel: None, committed: false, cancelled: false, trailing: None }.label(label) } diff --git a/crates/ui-widgets/tests/it/bars/bar.rs b/crates/ui-widgets/tests/it/bars/bar.rs index 2bad1d981..bc72d33fd 100644 --- a/crates/ui-widgets/tests/it/bars/bar.rs +++ b/crates/ui-widgets/tests/it/bars/bar.rs @@ -14,6 +14,7 @@ use craft_ui::display::Text; use craft_ui::form::Field; use craft_ui::layout_components::{Row, Stack}; use craft_ui::pickers::Select; +use craft_ui::style::GlyphRole; use craft_ui::testing::focus::AccessActionKind; use craft_ui::testing::layout::Block; use craft_ui::testing::{Fixture, shrink_least_runs, trial}; @@ -449,6 +450,26 @@ fn a_labelled_check_box_in_a_row_in_a_bar_lays_out_under_rtl() { assert!(label.max.x <= alpha.min.x + SLACK, "the check box {label:?} follows Alpha {alpha:?} from the right"); } +/// An icon-only button in an options bar draws its icon at the tool size, as the align strip's buttons do. +#[trial] +fn an_icon_button_in_an_options_bar_draws_its_icon_at_the_tool_size() { + let mut fixture = Fixture::new(|ui| { + Bar::new("Options", BarKind::Options).show(ui, |ui, _| { + IconButton::new(IconId::new("settings")).label("Plain").show(ui); + IconButton::new(IconId::new("settings")).label("Tool").glyphs(GlyphRole::Tool).show(ui); + }); + }); + fixture.room(Vec2::new(400.0, 80.0)).settle(); + let sides: Vec = fixture + .styles_of(std::any::type_name::>()) + .iter() + .flat_map(|seen| seen.looks.icons.iter().map(|icon| icon.side)) + .collect(); + // Buttons that resolve the same looks share one recorded style, so a single side means they agree. + assert!(!sides.is_empty(), "the buttons resolved a style"); + assert!(sides.iter().all(|side| (side - sides[0]).abs() <= 0.01), "the options bar's button and the tool button differ: {sides:?}"); +} + /// Each pass's stops, each with the roving group it registered in. type StopGroups = Rc)>>>>;