mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-10 08:51:25 +00:00
Merge pull request #5802 from dotCooCoo/fix/thumb-worker-hidden
Stop queued Layers thumbnails when both thumbnail panels are hidden
This commit is contained in:
@@ -270,6 +270,11 @@ pub(crate) fn showing(ui: &UiState, panel: &str) -> bool {
|
||||
(ui.open_panel.as_deref() == Some(panel) && iconic) || (!iconic && layout.panel_state(&panel.to_string()) == craft_ui::docking::PanelState::Front)
|
||||
}
|
||||
|
||||
/// Can either panel that uses row thumbnails be seen, including in a floating window or flyout?
|
||||
fn thumbnail_panel_showing(ui: &UiState) -> bool {
|
||||
ui.dock && ui.screen_mode < 3 && (showing(ui, "layers") || showing(ui, "links"))
|
||||
}
|
||||
|
||||
/// Where a panel with no other destination goes: a panel of the first expanded dock column,
|
||||
/// else of any column.
|
||||
fn first_dock_panel(layout: &Layout<String>, except: &str) -> Option<String> {
|
||||
@@ -1173,6 +1178,11 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
app.open_dropped_files(window.dropped, None, shift);
|
||||
}
|
||||
forward_keys(app, &ctx, output.forwarded_events, output.forwarded_modifiers);
|
||||
if !thumbnail_panel_showing(&app.ui) {
|
||||
// No panel can ask for these rows again this pass. Keep the cache of open documents, but
|
||||
// discard worker jobs queued behind the one already rendering.
|
||||
crate::panels::layers::show_thumbs_of(None);
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a modal is open: a dialog, About, the command palette, a native file dialog, or a
|
||||
|
||||
@@ -161,6 +161,25 @@ fn a_tab_dragged_out_floats_and_comes_back_where_it_was_after_its_window_closes(
|
||||
assert!(h.tab("layers").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thumbnail_work_is_needed_only_while_layers_or_links_can_be_seen() {
|
||||
let mut h = Harness::new();
|
||||
h.app.run("window.panel", json!({"panel": "layers"})).unwrap();
|
||||
assert!(thumbnail_panel_showing(&h.app.ui));
|
||||
h.app.ui.dock = false;
|
||||
assert!(!thumbnail_panel_showing(&h.app.ui), "Tab hides every panel");
|
||||
h.app.ui.dock = true;
|
||||
h.app.ui.screen_mode = 3;
|
||||
assert!(!thumbnail_panel_showing(&h.app.ui), "presentation mode hides panels");
|
||||
h.app.ui.screen_mode = 0;
|
||||
h.app.run("window.panel.float", json!({"panel": "layers"})).unwrap();
|
||||
assert!(thumbnail_panel_showing(&h.app.ui), "a floating Layers panel still needs thumbnails");
|
||||
h.app.run("window.panel", json!({"panel": "layers", "toggle": true})).unwrap();
|
||||
assert!(!thumbnail_panel_showing(&h.app.ui));
|
||||
h.app.run("window.panel", json!({"panel": "links"})).unwrap();
|
||||
assert!(thumbnail_panel_showing(&h.app.ui), "the Links flyout also uses row thumbnails");
|
||||
}
|
||||
|
||||
/// A Character field shortcut with the Character panel in front of its floating window brings
|
||||
/// that window forward and leaves the panel showing.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user