mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 12:32:10 +01:00
menu gallery: scroll and more arrows show the small glyph, not the ribbon's icon side
The Styles gallery's up, down and more buttons are icon buttons, and in a ribbon an icon-only button's glyph takes the ribbon's small icon side (17), which made the arrows far larger than the old ribbon's. A new GlyphRole::Compact shows the glyph at size.icon.glyph_sm whatever the control size and skips that ribbon side; the gallery sets it on its three buttons, and on the one it measures. Other icon buttons are unchanged. Reference: storytold/wordcraft#7679. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d445d2cf26
commit
4c6c3bb6e1
3 files changed
+10
-6
No files matched your search
@@ -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::<GalleryWords>();
|
||||
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<K: Clone + Eq + Hash + Send + Sync + 'static> 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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user