mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 09:08:11 +00:00
Merge pull request #3482 from storytold/fix/wordcraft-7679-gallery-arrow-size
ui-widgets: a compact glyph role keeps the ribbon gallery's arrows small (storytold/wordcraft#7679)
This commit is contained in:
@@ -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