mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-01 05:58:12 -06:00
fix(ui): Read mode hides the quick toolbar (#2646)
Read mode hides the tools, not the navigation panes, as Acrobat's does and as switch_mode already says, but the floating quick toolbar was still drawn over the page there. It is now hidden in Read mode, and entering Read mode puts the current tool down (back to Select), so no markup tool stays active without a toolbar to show it. The right rail, the page navigation and the V/H shortcuts are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f0c9901c39
commit
c66384f92b
@@ -3893,7 +3893,10 @@ pub fn document_area(app: &mut PdfCraftApp, index: usize, ui: &mut egui::Ui) {
|
||||
if copy_selected {
|
||||
app.execute("edit.copy");
|
||||
}
|
||||
quick_bar(app, avail, ui);
|
||||
// Read mode hides the tools (#2646).
|
||||
if app.mode != crate::Mode::Read {
|
||||
quick_bar(app, avail, ui);
|
||||
}
|
||||
if let Some((source, file, destination)) = remote_open {
|
||||
app.open_remote_link(source, file, destination);
|
||||
}
|
||||
|
||||
@@ -2169,6 +2169,7 @@ impl PdfCraftApp {
|
||||
/// Switches workspace because the user chose to (mode bar, Read mode command). Entering Read
|
||||
/// mode closes the right panel, as Acrobat's Read mode hides its panes, and leaving it reopens
|
||||
/// that panel. The rail stays in Read mode, and its buttons open panels there too (#932).
|
||||
/// Read mode hides the quick toolbar, so entering it also puts the current tool down.
|
||||
pub(crate) fn switch_mode(&mut self, mode: Mode, select_tools: bool) {
|
||||
let was_read = self.mode == Mode::Read;
|
||||
if select_tools {
|
||||
@@ -2178,6 +2179,7 @@ impl PdfCraftApp {
|
||||
}
|
||||
if mode == Mode::Read && !was_read {
|
||||
self.right_before_read = self.right.take();
|
||||
self.quick_tool = QuickTool::Select;
|
||||
} else if mode != Mode::Read && was_read {
|
||||
let before = self.right_before_read.take();
|
||||
if self.right.is_none() {
|
||||
|
||||
@@ -246,6 +246,24 @@ fn read_mode_closes_the_panes_and_leaving_it_brings_them_back() {
|
||||
assert_eq!(h.state().right, Some(RightPanel::Pages));
|
||||
}
|
||||
|
||||
/// Read mode hides the quick toolbar too, and puts down the tool that was in use (#2646).
|
||||
#[test]
|
||||
fn read_mode_hides_the_quick_toolbar() {
|
||||
use pdfcraft_ui_egui::{Mode, QuickTool};
|
||||
let mut h = harness(|app| app.open_bytes("fixture.pdf", None, FIXTURE.to_vec()).expect("fixture opens"));
|
||||
h.get_by_label("Hand (H)").click();
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().quick_tool, QuickTool::Hand);
|
||||
h.get_by_label("Read").click();
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label("Select (V)").is_none(), "no quick toolbar in Read mode");
|
||||
assert_eq!(h.state().quick_tool, QuickTool::Select);
|
||||
h.state_mut().run_command("view.read_mode");
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.state().mode, Mode::AllTools);
|
||||
h.get_by_label("Select (V)");
|
||||
}
|
||||
|
||||
/// A pane closed in Read mode stays closed on the way out: leaving Read mode doesn't bring back the
|
||||
/// pane saved on the way in, and closing Comments keeps its close preference.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user