//! Menus and keys of the viewer (PDF-01).
use ely_ui::commands;
use gpui::{
App, Context, Div, InteractiveElement as _, KeyBinding, Menu, MenuItem, Window, actions,
};
use crate::layout::{ACTUAL, Mode, Zoom};
use crate::view::PdfView;
use crate::viewer::Viewer;
actions!(
pdf,
[
Continuous,
SinglePage,
TwoPages,
ZoomIn,
ZoomOut,
FitWidth,
FitPage,
ActualSize,
RotateLeft,
RotateRight,
NextPage,
PreviousPage,
FirstPage,
LastPage,
CopyText,
Find
]
);
/// Zoom steps, in pixels a point.
const STEPS: [f32; 9] = [0.5, 0.67, 0.8, 1.0, ACTUAL, 1.6, 2.0, 3.0, 4.0];
pub fn bind(cx: &mut App) {
crate::organize::bind(cx);
crate::writes::bind(cx);
let at = Some(commands::CONTEXT);
cx.bind_keys([
KeyBinding::new("secondary-=", ZoomIn, at),
KeyBinding::new("secondary--", ZoomOut, at),
KeyBinding::new("secondary-0", ActualSize, at),
KeyBinding::new("secondary-]", RotateRight, at),
KeyBinding::new("secondary-[", RotateLeft, at),
KeyBinding::new("pagedown", NextPage, at),
KeyBinding::new("pageup", PreviousPage, at),
KeyBinding::new("home", FirstPage, at),
KeyBinding::new("end", LastPage, at),
KeyBinding::new("secondary-c", CopyText, at),
KeyBinding::new("secondary-f", Find, at),
]);
}
pub fn menus(cx: &App) -> Vec