mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 08:44:24 +00:00
Scroll gets a strip indicator: arrows above and below the view that scroll while the pointer rests on them, taking height from the view and never width. Menu and inline menus use it, so every menu layer, the menu bar's included, scrolls in the room it has. overlay::place opens a side overlay that runs past the bounds the other way when it fits there, so a tall submenu of a low row opens upward.
53 lines
1.9 KiB
Rust
53 lines
1.9 KiB
Rust
//! `Menu` and `MenuItem`: the columns of an inline menu's rows.
|
|
|
|
mod bar;
|
|
|
|
mod closed;
|
|
|
|
mod native;
|
|
|
|
mod openers;
|
|
|
|
mod overflow;
|
|
|
|
mod pick_focus;
|
|
|
|
mod rows;
|
|
|
|
mod submenus;
|
|
|
|
use craft_behavior::IconId;
|
|
use craft_ui::contract::{Show as _, ShowContainer as _};
|
|
use craft_ui::layout_components::Stack;
|
|
use craft_ui::menu::{Menu, MenuItem};
|
|
use craft_ui::primitives::IconSpec;
|
|
use craft_ui::testing::{Fixture, trial};
|
|
|
|
/// Regression: an inline menu inside a content-sized container shows by the record its container's measuring run
|
|
/// left, so its own body runs only for real; the rows before the first iconed or checked row still take the columns,
|
|
/// in every frame (a tab strip's overflow menu checks only the shown tab).
|
|
#[trial]
|
|
fn rows_of_an_inline_menu_shown_from_its_container_record_take_the_columns_of_later_rows() {
|
|
let mut fixture = Fixture::new(|ui| {
|
|
Stack::new().show(ui, |ui, _| {
|
|
Menu::inline("Tabs").show(ui, |ui, _| {
|
|
MenuItem::new("Layers").show(ui);
|
|
MenuItem::new("History").icon(IconSpec::svg(IconId::new("history"))).show(ui);
|
|
MenuItem::new("Swatches").check(true).show(ui);
|
|
});
|
|
});
|
|
});
|
|
let at = |fixture: &Fixture, label: &str| fixture.texts().iter().find(|text| text.text.replace('&', "") == label).map(|text| text.rect.left());
|
|
let mut frames = 0;
|
|
while at(&fixture, "Swatches").is_none() && frames < 8 {
|
|
fixture.frame(vec![]);
|
|
frames += 1;
|
|
}
|
|
let x = |fixture: &Fixture, label: &str| at(fixture, label).expect("the row is shown");
|
|
for frame in 0..3 {
|
|
assert_eq!(x(&fixture, "Layers"), x(&fixture, "Swatches"), "frame {frame}: a plain row takes the mark and icon columns");
|
|
assert_eq!(x(&fixture, "History"), x(&fixture, "Swatches"), "frame {frame}: an iconed row takes the mark column");
|
|
fixture.frame(vec![]);
|
|
}
|
|
}
|