mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 05:37:04 +00:00
Merge branch 'pdf-red/fw-shell' into area/fw-red-1
This commit is contained in:
@@ -548,6 +548,11 @@ impl StartScreen<'_> {
|
||||
let rail = !links.is_empty() && {
|
||||
let rail_width = rail_stack().measure_in(ui, Proposal::Ideal, |ui, _| rail_body(ui)).x;
|
||||
let sections_least = page_stack().measure_in(ui, Proposal::Min, |ui, cx| page_body(ui, cx, true)).x;
|
||||
eprintln!(
|
||||
"DIAG host_sections_sit_at_their_place_and_count_in_the_rail_decision: rail {rail_width} least {sections_least} room {} gap {}",
|
||||
ui.available_width(),
|
||||
env.tokens.space.gap.section
|
||||
);
|
||||
ui.available_width() >= rail_width + env.tokens.space.gap.section + sections_least
|
||||
};
|
||||
|
||||
@@ -880,8 +885,10 @@ impl ItemSource<PinnedKey> for PinnedRows<'_> {}
|
||||
fn pinned_row<'r>(words: &ShellWords, row: PinnedRow<'_>) -> ListRow<'r> {
|
||||
match row {
|
||||
PinnedRow::Folder(folder) => {
|
||||
let mut heading =
|
||||
ListRow::new(Label::from(folder.name.clone())).detail(folder.path.display().to_string()).icon(IconSpec::svg(IconId::new("folder"))).depth(0);
|
||||
let mut heading = ListRow::new(Label::from(folder.name.clone()))
|
||||
.detail(folder.path.display().to_string())
|
||||
.icon(IconSpec::svg(IconId::new("folder")))
|
||||
.depth(0);
|
||||
if !listed_files(folder).is_empty() {
|
||||
heading = heading.group(!folder.folded);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ fn picture_source() -> FakeThumbSource<ThumbKey> {
|
||||
|
||||
/// Six files and three templates, none with a picture: every tile shows the placeholder.
|
||||
fn plain_files() -> Vec<RecentFile> {
|
||||
let file = |name: &str, age: i64| RecentFile::new(PathBuf::from("/home/user/Pictures").join(name), name).opened(NOW - age).created(NOW - age - DAY);
|
||||
let file =
|
||||
|name: &str, age: i64| RecentFile::new(PathBuf::from("/home/user/Pictures").join(name), name).opened(NOW - age).created(NOW - age - DAY);
|
||||
vec![
|
||||
file("Harbour.psd", 30),
|
||||
file("Poster draft.psd", 2 * HOUR),
|
||||
|
||||
@@ -85,9 +85,11 @@ fn a_double_click_on_the_empty_room_opens_and_one_on_a_card_opens_only_its_file(
|
||||
}
|
||||
|
||||
/// A recent file's menu offers Show in Folder exactly where the platform can reveal a file, and the menu key and
|
||||
/// Shift+F10 open it from the focused card.
|
||||
/// 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.
|
||||
#[trial]
|
||||
fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() {
|
||||
const MENU_ONLY: &str = "Clear Recent Files";
|
||||
let (mut fixture, _log) = screen();
|
||||
let card = fixture.by_label("Poster.psd").expect("the card shows");
|
||||
fixture.click(&card).idle(2);
|
||||
@@ -96,16 +98,18 @@ fn the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal() {
|
||||
fixture.frame(vec![secondary(at, true)]);
|
||||
fixture.frame(vec![secondary(at, false)]);
|
||||
fixture.idle(3);
|
||||
assert!(fixture.by_label("Remove from Recent").is_some(), "a right click on a recent file opens its menu");
|
||||
assert!(fixture.by_label(MENU_ONLY).is_some(), "a right click on a recent file opens its menu");
|
||||
assert_eq!(fixture.by_label("Show in Folder").is_some(), craft_platform::open::CAN_REVEAL);
|
||||
|
||||
for (key, modifiers) in [(Key::Menu, Modifiers::NONE), (Key::F10, Modifiers::SHIFT)] {
|
||||
fixture.key(Key::Escape, Modifiers::NONE).idle(3);
|
||||
assert!(fixture.by_label("Remove from Recent").is_none(), "Escape closes the menu before {key:?}");
|
||||
let remove = fixture.by_label("Remove from Recent").map(|found| fixture.tree().role_of(found.node));
|
||||
eprintln!("DIAG the_recent_menu_offers_show_in_folder_where_the_platform_can_reveal: {key:?} after Escape: remove {remove:?}");
|
||||
assert!(fixture.by_label(MENU_ONLY).is_none(), "Escape closes the menu before {key:?}");
|
||||
let card = fixture.by_label("Poster.psd").expect("the card shows");
|
||||
fixture.click(&card).idle(2);
|
||||
fixture.key(key, modifiers).idle(3);
|
||||
assert!(fixture.by_label("Remove from Recent").is_some(), "{key:?} with {modifiers:?} opens the focused card's menu");
|
||||
assert!(fixture.by_label(MENU_ONLY).is_some(), "{key:?} with {modifiers:?} opens the focused card's menu");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,8 +201,9 @@ fn pinned_screen(folders: Vec<PinnedFolder>) -> (Fixture, Log, Pins, Notes) {
|
||||
let folders = held.borrow().clone();
|
||||
let env = Env::of(ui);
|
||||
let words = env.words::<ShellWords>();
|
||||
*words_seen.borrow_mut() =
|
||||
[&words.looking_for_files, &words.folder_unavailable].map(|word| env.view().resolve(&Label::from(word.clone())).as_str().to_owned()).to_vec();
|
||||
*words_seen.borrow_mut() = [&words.looking_for_files, &words.folder_unavailable]
|
||||
.map(|word| env.view().resolve(&Label::from(word.clone())).as_str().to_owned())
|
||||
.to_vec();
|
||||
let out = StartScreen::new(Bind::bound(&mut view), Bind::bound(&mut sort), &[]).pinned(&folders).show(ui);
|
||||
seen.borrow_mut().extend(out.actions);
|
||||
});
|
||||
@@ -229,7 +234,8 @@ fn a_listed_pinned_folder_folds_shows_more_and_opens_its_files() {
|
||||
assert_eq!(fixture.by_label(&file_name(n)).is_some(), n < PINNED_FILES_SHOWN, "only the first {PINNED_FILES_SHOWN} files show: {n}");
|
||||
}
|
||||
let painted = |fixture: &Fixture, text: &str| fixture.texts().iter().any(|painted| painted.text == text);
|
||||
let notes = notes.borrow();
|
||||
// Owned: the screen writes the notes again in every pass, and a borrow held across the frames below would panic it.
|
||||
let notes = notes.borrow().clone();
|
||||
assert!(painted(&fixture, ¬es[0]), "a pending folder says it is still listing");
|
||||
assert!(painted(&fixture, ¬es[1]), "an unavailable folder says so");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user