diff --git a/crates/menu/src/ribbon/gallery.rs b/crates/menu/src/ribbon/gallery.rs index 4375f7053..f026ac82a 100644 --- a/crates/menu/src/ribbon/gallery.rs +++ b/crates/menu/src/ribbon/gallery.rs @@ -19,7 +19,7 @@ use craft_ui::primitives::textures::{Revision, ThumbSource, Thumbnails}; use craft_ui::primitives::{ContentPainterCx, HAlign, PaintShape, TextRun}; use craft_ui::runtime::env::Label; use craft_ui::runtime::focus::KeyUse; -use craft_ui::style::{ComponentStyle, Flags, FocusLook, StyleColor, StyleCx, TypeRole}; +use craft_ui::style::{ComponentStyle, Flags, FocusLook, GlyphRole, StyleColor, StyleCx, TypeRole}; use craft_ui::tile_grid::{CaptionPlace, Tile, TileGrid}; use egui::{ColorImage, CornerRadius, Rect, Response, Ui, Vec2}; @@ -189,7 +189,7 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + 'static> Gallery<'a, K> { fn sizes(&self, cx: &MeasureCx<'_, Self>) -> Sizes { let words = cx.env.words::(); - let button = cx.face(IconButton::new(IconId::new("more")).label(words.more.clone())); + let button = cx.face(IconButton::new(IconId::new("more")).label(words.more.clone()).glyphs(GlyphRole::Compact)); Sizes { tile: cx.face(GalleryTile::blank(self.aspect, self.thumb_size, self.captioned())), button, gap: cx.gap() } } } @@ -723,9 +723,9 @@ impl Component for Gallery<'_, K> draw.rule(craft_ui::style::RuleKind::Divider, egui::pos2(self.column.left(), y1), egui::pos2(self.column.right(), y1)); draw.rule(craft_ui::style::RuleKind::Divider, egui::pos2(self.column.left(), y2), egui::pos2(self.column.right(), y2)); } - ui.face(UP, IconButton::new(IconId::new("chevron_up")).label(words.up.clone()).enabled(start > 0)); - ui.face(DOWN, IconButton::new(IconId::new("chevron_down")).label(words.down.clone()).enabled(start < last)); - ui.face(MORE, IconButton::new(IconId::new("more")).label(words.more.clone())); + ui.face(UP, IconButton::new(IconId::new("chevron_up")).label(words.up.clone()).enabled(start > 0).glyphs(GlyphRole::Compact)); + ui.face(DOWN, IconButton::new(IconId::new("chevron_down")).label(words.down.clone()).enabled(start < last).glyphs(GlyphRole::Compact)); + ui.face(MORE, IconButton::new(IconId::new("more")).label(words.more.clone()).glyphs(GlyphRole::Compact)); } /// The context request is recorded after `update`, so `finish` reads it: a secondary click on a tile, or the Menu diff --git a/crates/ui-contract/src/style/cx.rs b/crates/ui-contract/src/style/cx.rs index aecffc52d..44d934200 100644 --- a/crates/ui-contract/src/style/cx.rs +++ b/crates/ui-contract/src/style/cx.rs @@ -38,6 +38,9 @@ pub enum GlyphRole { ToolRail, /// A list row's trailing icon button: the control glyph, resting in `text.faint` and in the variant's ink under the pointer. PanelRail, + /// A stack of small arrow buttons (a gallery's scroll arrows): `size.icon.glyph_sm` whatever the control size, and + /// a ribbon's small icon side does not widen it. + Compact, } /// What `fn style` gets. Tokens are read here and nowhere else. diff --git a/crates/ui-widgets/src/buttons/face.rs b/crates/ui-widgets/src/buttons/face.rs index d1070aa95..b27b517c0 100644 --- a/crates/ui-widgets/src/buttons/face.rs +++ b/crates/ui-widgets/src/buttons/face.rs @@ -407,9 +407,10 @@ pub(crate) fn icon_face(cx: &StyleCx<'_>) -> IconFace { GlyphRole::Tool => (icon.md, None), GlyphRole::ToolRail => (icon.lg, Some(text.muted)), GlyphRole::PanelRail => (cx.glyph(), Some(text.faint)), + GlyphRole::Compact => (icon.glyph_sm, None), _ => (cx.glyph(), None), }; - let side = super::small_icon(cx, side); + let side = if cx.glyph_role() == GlyphRole::Compact { side } else { super::small_icon(cx, side) }; let mut ink = off.text.clone(); if let Some(rest) = rest { ink.off.rest = cx.color(rest);