buttons: a stacked face takes tile corners; RecentList::remove and BackstageView::back_look options

A stacked push, toggle or split button shares the icon face's corners (control corners unless the variant is
explicitly full), so a capsule radius no longer rounds a two-line stack into a circle that cuts its label.
RecentList gains RecentRemove (Revealed by default, Always shows every row's remove part) and BackstageView
gains BackLook (Labelled by default, Glyph draws Back as the glyph alone); each has a story and a trial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-28 17:24:14 +00:00
1 parent c6898679b7
commit fc5cb2bab5
14 files changed
+200 -40

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ use craft_ui::style::{ComponentStyle, StyleCx};
use craft_ui::tabs::{StripEnd, Tab, TabKind, TabRole, TabStrip, TabStripOutput};
use egui::{Id, Pos2, Rect, Response, Ui, Vec2, vec2};
pub use backstage::{BackstageCommands, BackstageEntry, BackstageEvent, BackstageOutput, BackstageView};
pub use backstage::{BackLook, BackstageCommands, BackstageEntry, BackstageEvent, BackstageOutput, BackstageView};
pub use craft_ui::buttons::{GroupLevel, RibbonBody, RibbonLook};
pub use gallery::{Gallery, GalleryFace, GalleryItem, GalleryMore, GalleryOutput};
pub use group::{GroupWords, RibbonGroup};
+34 -9
View File
@@ -7,7 +7,7 @@ use std::fmt::Debug;
use std::hash::Hash;
use craft_behavior::{Metrics, NavShape, Roving};
use craft_ui::buttons::{Button, ControlPlace};
use craft_ui::buttons::{Button, ControlPlace, IconButton};
use craft_ui::contract::{
BodyCx, BodyLayout, Common, Component, Container, ContainerProps, Cx, Gap, LeastWidth, NoValue, Outcome, Pad, Props as _, Role, Scroll,
Show as _, ShowContainer as _, Sizing,
@@ -41,12 +41,24 @@ pub struct BackstageView<'a, K: Clone + Eq + Hash + Send + Sync + Debug + 'stati
bottom: &'a [BackstageEntry<'a, K>],
heading: Option<Label>,
focus_shown: bool,
back_look: BackLook,
}
/// How the side menu shows its Back control.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum BackLook {
/// The back glyph and the word Back, a row as wide as the entries under it.
#[default]
Labelled,
/// The back glyph alone, named and tooltipped Back: DeckCraft's File view.
Glyph,
}
impl<'a, K: Clone + Eq + Hash + Send + Sync + Debug + 'static> BackstageView<'a, K> {
/// A File view with the given page shown.
pub fn new(shown: K) -> Self {
Self { shown, back: true, groups: Vec::new(), bottom: &[], heading: None, focus_shown: false }
Self { shown, back: true, groups: Vec::new(), bottom: &[], heading: None, focus_shown: false, back_look: BackLook::default() }
}
/// Whether the view offers the Back command.
@@ -55,6 +67,12 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + Debug + 'static> BackstageView<'a,
self
}
/// How the Back control shows (default `BackLook::Labelled`).
pub fn back_look(mut self, look: BackLook) -> Self {
self.back_look = look;
self
}
/// Adds a group of entries to the side menu.
pub fn group(mut self, entries: &'a [BackstageEntry<'a, K>]) -> Self {
self.groups.push(entries);
@@ -120,13 +138,20 @@ impl<'a, K: Clone + Eq + Hash + Send + Sync + Debug + 'static> BackstageView<'a,
.gap(Gap::None)
.show_at(ui, rail, |ui, _| {
if self.back {
let back = Button::new(words.back.clone())
.icon(craft_behavior::IconId::new("chevron_left"))
.variant(Variant::GHOST)
.sizing(Sizing::FillWidth)
.align(HAlign::Start)
.show(ui);
if craft_ui::contract::clicked(&back.response) {
let glyph = craft_behavior::IconId::new("chevron_left");
let back = match self.back_look {
BackLook::Labelled => {
Button::new(words.back.clone())
.icon(glyph)
.variant(Variant::GHOST)
.sizing(Sizing::FillWidth)
.align(HAlign::Start)
.show(ui)
.response
}
BackLook::Glyph => IconButton::new(glyph).label(words.back.clone()).tooltip(words.back.clone()).show(ui).response,
};
if craft_ui::contract::clicked(&back) {
event = Some(BackstageEvent::Back);
}
}
+13 -7
View File
@@ -1,6 +1,6 @@
//! Stories of the File view.
use super::{BackstageEntry, BackstageEvent, BackstageView};
use super::{BackLook, BackstageEntry, BackstageEvent, BackstageView};
use craft_behavior::IconId;
use craft_ui::contract::{Show as _, ShowContainer as _};
use craft_ui::display::Text;
@@ -11,22 +11,28 @@ use egui::Ui;
#[story(BackstageView<'static, u32>, covers = [Default], drive = Drive::Never)]
fn backstage(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
show(ui, data, true, false)
show(ui, data, true, false, BackLook::Labelled)
}
#[story(BackstageView<'static, u32>, covers = [], drive = Drive::Never)]
fn backstage_no_document(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
show(ui, data, false, false)
show(ui, data, false, false, BackLook::Labelled)
}
#[story(BackstageView<'static, u32>, covers = [], drive = Drive::Custom(focus_home))]
fn backstage_focused_entry(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
show(ui, data, true, false)
show(ui, data, true, false, BackLook::Labelled)
}
#[story(BackstageView<'static, u32>, covers = [], drive = Drive::Never)]
fn backstage_long_labels(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
show(ui, data, true, true)
show(ui, data, true, true, BackLook::Labelled)
}
/// `BackLook::Glyph`: the Back control is the back glyph alone.
#[story(BackstageView<'static, u32>, covers = [], drive = Drive::Never)]
fn backstage_back_glyph(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
show(ui, data, true, false, BackLook::Glyph)
}
const HOME: u32 = 0;
@@ -44,7 +50,7 @@ fn focus_home(fixture: &mut Fixture) {
}
}
fn show(ui: &mut Ui, data: &mut StoryData, document: bool, long: bool) -> StoryOutput {
fn show(ui: &mut Ui, data: &mut StoryData, document: bool, long: bool, back_look: BackLook) -> StoryOutput {
let room = stage(ui);
let shown = data.value("shown", HOME);
let top = [
@@ -64,7 +70,7 @@ fn show(ui: &mut Ui, data: &mut StoryData, document: bool, long: bool) -> StoryO
Stack::new()
.fill()
.show_at(ui, room, |ui, cx| {
let mut view = BackstageView::new(*shown).back(document).group(&top).bottom(&bottom);
let mut view = BackstageView::new(*shown).back(document).back_look(back_look).group(&top).bottom(&bottom);
if document {
view = view.group(&file);
}
+24 -3
View File
@@ -4,7 +4,7 @@ use std::cell::{Cell, RefCell};
use std::rc::Rc;
use craft_behavior::IconId;
use craft_menu::ribbon::{BackstageCommands, BackstageEntry, BackstageEvent, BackstageView};
use craft_menu::ribbon::{BackLook, BackstageCommands, BackstageEntry, BackstageEvent, BackstageView};
use craft_ui::buttons::Button;
use craft_ui::contract::{Bind, Props as _, Role, Show as _};
use craft_ui::runtime::commands::CommandSet as _;
@@ -28,6 +28,7 @@ struct Seen {
focus: Cell<bool>,
rerun: Cell<bool>,
passes: Cell<usize>,
back_look: Cell<BackLook>,
events: RefCell<Vec<(usize, BackstageEvent<u32>)>>,
}
@@ -47,8 +48,12 @@ fn fixture(keyboard: bool) -> (Fixture, Rc<Seen>) {
BackstageEntry::page(DISABLED, "Unavailable", IconId::new("file")).enabled(false),
];
let bottom = [BackstageEntry::page(ABOUT, "About", IconId::new("info"))];
let view: BackstageView<'_, u32> =
BackstageView::new(out.shown.get()).group(&first).group(&second).bottom(&bottom).focus_shown(focus);
let view: BackstageView<'_, u32> = BackstageView::new(out.shown.get())
.back_look(out.back_look.get())
.group(&first)
.group(&second)
.bottom(&bottom)
.focus_shown(focus);
let shown = view.show(ui, cx, |ui, _| {
TextField::new("Search", Bind::bound(&mut text)).show(ui);
Button::new("Home").show(ui);
@@ -145,6 +150,22 @@ fn backstage_escape_and_back_report_back() {
assert!(take(&seen).is_empty(), "a disabled page cannot report Show");
}
/// `BackLook::Glyph` draws Back as the glyph alone: a control narrower than the entries' rows, still named Back,
/// that reports Back when clicked.
#[trial]
fn a_glyph_back_is_narrower_than_the_entries_and_still_goes_back() {
let (mut fixture, seen) = fixture(false);
fixture.room(egui::vec2(900.0, 650.0)).settle();
let labelled = menu(&fixture, "Back").rect.width();
seen.back_look.set(BackLook::Glyph);
fixture.idle(2);
let back = menu(&fixture, "Back");
assert!(back.rect.width() < labelled, "the glyph Back is narrower than the labelled one");
assert!(back.rect.width() < menu(&fixture, "Home").rect.width(), "the glyph Back is narrower than an entry's row");
fixture.click(&back);
assert_eq!(take(&seen), vec![BackstageEvent::Back]);
}
#[trial]
fn backstage_arrows_show_pages_and_enter_acts() {
let (mut fixture, seen) = fixture(true);
+1 -1
View File
@@ -40,7 +40,7 @@ pub(crate) mod start;
pub(crate) mod viewport_window;
pub use recent::{RecentFile, RecentSort, RecentView, Template, ThumbKey, sort_recent};
pub use recent_list::RecentList;
pub use recent_list::{RecentList, RecentRemove};
pub use start::{
FolderListing, PINNED_FILES_SHOWN, PinnedFile, PinnedFolder, StartAction, StartLayout, StartLink, StartLinkTarget, StartOutput,
StartPinnedCommands, StartPlace, StartRecentCommands, StartScreen,
+27 -6
View File
@@ -30,6 +30,17 @@ use std::path::PathBuf;
type HeaderControls<'a> = Box<dyn FnMut(&mut Ui, &mut BodyCx<'_>) + 'a>;
/// When a recent row of a list shows its remove button.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum RecentRemove {
/// On a hovered or selected row, or while the button has focus: a quiet list.
#[default]
Revealed,
/// On every row, so the list says at a glance that each file can be taken off it: DeckCraft's File page.
Always,
}
/// The recent files as rows, with the commands of a recent file and its context menu. The files arrive in the order
/// the app wants them shown; the list does not sort.
#[must_use = "show the list with `show`"]
@@ -43,6 +54,7 @@ pub struct RecentList<'a> {
now: Option<i64>,
thumbnails: Option<ThumbHost<'a>>,
picture: (u16, u16),
remove: RecentRemove,
}
impl<'a> RecentList<'a> {
@@ -57,9 +69,16 @@ impl<'a> RecentList<'a> {
now: None,
thumbnails: None,
picture: (PICTURE_WIDE, PICTURE_HIGH),
remove: RecentRemove::default(),
}
}
/// When a row shows its remove button (default `RecentRemove::Revealed`).
pub fn remove(mut self, remove: RecentRemove) -> Self {
self.remove = remove;
self
}
/// The title of the existing section, in place of its localized Recent title.
pub fn heading(mut self, heading: impl Into<Label>) -> Self {
self.heading = Some(heading.into());
@@ -107,7 +126,7 @@ impl<'a> RecentList<'a> {
/// Shows the rows in their own section and reports what the user did.
pub fn show(self, ui: &mut Ui) -> StartOutput {
let RecentList { recent, heading, controls, max_recent, empty, now, thumbnails, picture } = self;
let RecentList { recent, heading, controls, max_recent, empty, now, thumbnails, picture, remove } = self;
let env = Env::of(ui);
let words = env.words::<ShellWords>();
let actions = RefCell::new(Vec::new());
@@ -128,6 +147,7 @@ impl<'a> RecentList<'a> {
new_label: None,
open_label: None,
heading_sections: false,
remove,
};
let files: Vec<RecentFile> = recent.iter().take(max_recent).cloned().collect();
let empty = empty.unwrap_or_else(|| words.no_recent.clone());
@@ -236,11 +256,12 @@ pub(super) fn recent_body(
Some(age) => row.trailing(age),
None => row,
};
let row = row.trailing_part_revealed(
REMOVE,
TrailingFace::Icon(IconSpec::svg(IconId::new("close"))),
words.remove_recent.fill(&[("name", file.name.as_str())]),
);
let (face, name) =
(TrailingFace::Icon(IconSpec::svg(IconId::new("close"))), words.remove_recent.fill(&[("name", file.name.as_str())]));
let row = match page.remove {
RecentRemove::Revealed => row.trailing_part_revealed(REMOVE, face, name),
RecentRemove::Always => row.trailing_part(REMOVE, face, name),
};
match page.thumbnails {
Some((thumbnails, source)) => {
let key = ThumbKey::Recent(file.path.clone());
+4 -1
View File
@@ -5,7 +5,7 @@
pub(crate) mod stories;
use super::recent::{RecentFile, RecentSort, RecentView, Template, ThumbKey, sort_recent};
use super::recent_list::{RecentList, recent_body};
use super::recent_list::{RecentList, RecentRemove, recent_body};
use super::words::ShellWords;
use crate::buttons::button::ButtonStyleKey;
use crate::buttons::{Button, ControlPlace, Link};
@@ -582,6 +582,8 @@ pub(super) struct Page<'p> {
pub(super) open_label: Option<&'p Label>,
/// PdfCraft's section look (`StartScreen::heading_sections`).
pub(super) heading_sections: bool,
/// When a recent row shows its remove button.
pub(super) remove: RecentRemove,
}
impl<'p> Page<'p> {
@@ -760,6 +762,7 @@ impl StartScreen<'_> {
new_label: new_label.as_ref(),
open_label: open_label.as_ref(),
heading_sections,
remove: RecentRemove::Revealed,
actions: &actions,
};
let view = RefCell::new(view);
+8 -1
View File
@@ -6,7 +6,7 @@ use crate::contract::{Bind, Props as _, Show as _};
use crate::notices::Notice;
use crate::primitives::{FakeThumbSource, ThumbnailOptions, Thumbnails};
use crate::runtime::env::Label;
use crate::shell::{RecentFile, RecentList, RecentSort, RecentView, ScreenModeCommands, Template, ThumbKey};
use crate::shell::{RecentFile, RecentList, RecentRemove, RecentSort, RecentView, ScreenModeCommands, Template, ThumbKey};
use crate::testing::{Drive, StoryData, StoryOutput, story};
use crate::text::TextField;
use craft_behavior::IconId;
@@ -270,6 +270,13 @@ fn recent_list_with_header_controls(ui: &mut Ui, data: &mut StoryData) -> StoryO
.into()
}
/// `RecentRemove::Always`: every row shows its remove button, not only the hovered or selected one.
#[story(RecentList<'static>, covers = [], drive = Drive::Never)]
fn recent_list_remove_always(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
let files = plain_files();
RecentList::new(&files).now(Some(NOW)).remove(RecentRemove::Always).show(ui).into()
}
/// No recent files: the muted line under the heading, at the reading start.
#[story(RecentList<'static>, covers = [], drive = Drive::Never)]
fn recent_list_empty(ui: &mut Ui, _: &mut StoryData) -> StoryOutput {
+39 -2
View File
@@ -7,8 +7,8 @@ use craft_ui::contract::{Bind, Role, Show as _};
use craft_ui::display::Text;
use craft_ui::runtime::env::{Env, RootEnv};
use craft_ui::shell::{
FolderListing, PINNED_FILES_SHOWN, PinnedFile, PinnedFolder, RecentFile, RecentList, RecentSort, RecentView, ShellWords, StartAction,
StartLayout, StartLink, StartPlace, StartScreen, Template,
FolderListing, PINNED_FILES_SHOWN, PinnedFile, PinnedFolder, RecentFile, RecentList, RecentRemove, RecentSort, RecentView, ShellWords,
StartAction, StartLayout, StartLink, StartPlace, StartScreen, Template,
};
use craft_ui::testing::pointer::{moved, secondary};
use craft_ui::testing::{Fixture, Target, trial};
@@ -198,6 +198,43 @@ fn a_recent_row_names_its_full_path_and_reveals_remove_on_hover_or_focus() {
assert!(log.borrow().contains(&StartAction::ClearRecent), "Clear reports ClearRecent: {:?}", log.borrow());
}
/// `RecentRemove::Always` shows every row's remove part with the pointer away and nothing focused, where the default
/// shows none, and the shown part removes its own row's file.
#[trial]
fn a_list_that_always_shows_remove_offers_it_on_every_row_at_rest() {
let at_rest = |remove: RecentRemove| {
let log: Log = Rc::default();
let seen = Rc::clone(&log);
let files = vec![RecentFile::new("/tmp/work/Poster.psd", "Poster.psd"), RecentFile::new("/tmp/work/Flyer.psd", "Flyer.psd")];
let mut fixture = Fixture::new(move |ui| {
let out = RecentList::new(&files).remove(remove).show(ui);
seen.borrow_mut().extend(out.actions);
});
fixture.room(egui::Vec2::new(700.0, 500.0));
fixture.settle();
fixture.frame(vec![moved(egui::pos2(699.0, 499.0))]);
fixture.idle(2);
let removes: Vec<Target> = fixture
.by_role(Role::BUTTON)
.into_iter()
.filter(|button| fixture.tree().name_of(button.node).is_some_and(|name| name.starts_with("Remove")))
.collect();
(fixture, log, removes)
};
let (_, _, hidden) = at_rest(RecentRemove::Revealed);
assert!(hidden.is_empty(), "the default list keeps its remove parts hidden at rest");
let (mut fixture, log, shown) = at_rest(RecentRemove::Always);
assert_eq!(shown.len(), 2, "the always list shows one remove part per row");
let flyer = recent_row(&fixture, "Flyer.psd").expect("the Flyer row shows");
let remove = shown.iter().find(|button| flyer.rect.contains(button.center())).expect("the Flyer row has its remove part");
fixture.click(remove).idle(2);
assert_eq!(
log.borrow().as_slice(),
[StartAction::RemoveRecent(PathBuf::from("/tmp/work/Flyer.psd"))],
"the shown part removes its own row's file"
);
}
/// A recent file's menu offers Show in Folder exactly where the platform can reveal a file, and the menu key (off
/// macOS, which has none) and Shift+F10 open it from the focused card. The menu is told by "Clear Recent Files", which only the menu has: the
/// card's hover action carries "Remove from Recent" too.
+3 -1
View File
@@ -306,7 +306,9 @@ impl Component for Button<'_> {
None => ButtonStyle::of(cx),
};
if key.arrangement == Arrangement::Stacked {
style.metrics = face::stacked_metrics(cx, &cx.variant_look());
let parts = face::arranged_look(cx, key.arrangement);
style.surface = face::surface(cx, &parts);
style.metrics = face::stacked_metrics(cx, &parts);
}
if let Some(least) = key.least_width {
style.metrics.min_size.x = style.metrics.min_size.x.max(least.points(cx.tokens));
+21 -6
View File
@@ -352,6 +352,26 @@ pub(super) fn stacked_metrics(cx: &StyleCx<'_>, parts: &VariantParts) -> Metrics
metrics
}
/// The corners of a face that is a tile rather than a capsule (an icon face, a stacked face): an explicitly
/// full-radius variant keeps its resolved maximal corners; the other variants use the control corners.
fn tile_corners(cx: &StyleCx<'_>, parts: &VariantParts) -> egui::CornerRadius {
if cx.variant.resolve(cx.tokens).radius == craft_theme::RadiusStep::Full {
parts.radius
} else {
UiTokens::corner(cx.tokens.shape.radius.control)
}
}
/// The variant's parts for a face of `arrangement`. A stacked face takes the tile corners: a capsule's round ends would
/// cut into the icon and the label lines stacked between them.
pub(super) fn arranged_look(cx: &StyleCx<'_>, arrangement: Arrangement) -> VariantParts {
let mut parts = cx.variant_look();
if arrangement == Arrangement::Stacked {
parts.radius = tile_corners(cx, &parts);
}
parts
}
/// `metrics` or `stacked_metrics`, by `arrangement`.
pub(super) fn metrics_of(cx: &StyleCx<'_>, parts: &VariantParts, arrangement: Arrangement) -> Metrics {
match arrangement {
@@ -423,12 +443,7 @@ pub(crate) fn icon_face(cx: &StyleCx<'_>) -> IconFace {
if let Some(rest) = rest {
ink.off.rest = cx.color(rest);
}
// PLAN: assumed RadiusStep::Full (canvas-w5)
let radius = if cx.variant.resolve(cx.tokens).radius == craft_theme::RadiusStep::Full {
off.radius
} else {
UiTokens::corner(cx.tokens.shape.radius.control)
};
let radius = tile_corners(cx, &off);
IconFace {
surface: on_surface(cx, &off, &on).radius(radius),
metrics: Metrics::new().min_size(Vec2::splat(super::row_height(cx, cx.control().height))),
@@ -221,7 +221,7 @@ impl<T: Value + 'static> Component for SplitButton<'_, T> {
fn style(cx: &StyleCx<'_>, key: SplitButtonStyleKey<T>) -> SplitButtonStyle {
let cx = &super::placed(cx);
let parts = cx.variant_look();
let parts = face::arranged_look(cx, key.arrangement);
let metrics = face::metrics_of(cx, &parts, key.arrangement);
let mut surface = face::surface(cx, &parts);
let (fill, clear) = (parts.fill.off, cx.color(craft_theme::Rgba::TRANSPARENT));
@@ -144,7 +144,7 @@ impl Component for ToggleButton<'_> {
// ribbon is flat at rest as the ribbon's push buttons are (`placed`): no edge until the pointer is over it, and
// the on plate while on.
let cx = &if key.icon_only { cx.with_variant(Variant::GHOST) } else { super::placed(cx) };
let (off, on) = (cx.variant_look(), face::on_parts(cx));
let (off, on) = (face::arranged_look(cx, key.arrangement), face::on_parts(cx));
let (mut text, mut icon) = face::ink(cx);
let (mut surface, metrics) = if key.icon_only {
let face = face::icon_face(cx);
+23
View File
@@ -417,6 +417,29 @@ fn seen(type_name: &str, name: &str, show: impl Fn(&mut Ui) + 'static) -> (Optio
(style.looks.surface.clone(), fixture.by_label(name).expect("the control").rect.width())
}
/// A stacked push or split button is a tile: where a one-line button of the same variant is a capsule, the stacked
/// face's corners stay tighter, so its round ends never cut into the icon and label lines between them.
#[trial]
fn a_stacked_buttons_corners_stay_tighter_than_a_capsules() {
let corner = |look: Option<craft_ui::style::SurfaceLook>| f32::from(look.expect("the button has a surface").radius.nw);
let button = std::any::type_name::<Button<'static>>();
let (inline, _) = seen(button, "Create Handouts", |ui| {
let _ = Button::new("Create Handouts").icon(IconId::new("copy")).show(ui);
});
let (tile, _) = seen(button, "Create Handouts", |ui| {
let _ = Button::new("Create Handouts").icon(IconId::new("copy")).arrangement(Arrangement::Stacked).show(ui);
});
assert!(corner(tile) < corner(inline), "a stacked button's corners are tighter than the capsule's");
let split = std::any::type_name::<SplitButton<'static, usize>>();
let (inline, _) = seen(split, "Paste", |ui| {
let _ = SplitButton::new("Paste", &[Entry::new(1_usize, "Keep text only")]).show(ui);
});
let (tile, _) = seen(split, "Paste", |ui| {
let _ = SplitButton::new("Paste", &[Entry::new(1_usize, "Keep text only")]).arrangement(Arrangement::Stacked).show(ui);
});
assert!(corner(tile) < corner(inline), "a stacked split button's corners are tighter than the capsule's");
}
/// Shows `show` where a ribbon group shows its content.
fn in_ribbon(ui: &mut Ui, show: impl FnOnce(&mut Ui)) {
with_env(