mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-02 06:28:49 -06:00
51 lines
1.8 KiB
Rust
51 lines
1.8 KiB
Rust
//! Left tool panel (All tools + tool sub-panels, generated from the engine catalogue) and the
|
|
//! right-hand panels (Comments, Bookmarks, Pages, Fields, Layers, Attachments).
|
|
|
|
use egui::{Align, Align2, Color32, CornerRadius, Layout, Rect, Sense, Stroke, pos2, vec2};
|
|
use pdfcraft_engine::catalog::{self, Availability, TOOL_GROUPS, ToolGroup, ToolItem};
|
|
use pdfcraft_render::{DocInfo, FieldKind, OutlineItem};
|
|
|
|
use crate::theme::{self, Tokens};
|
|
use crate::{LeftPanel, PdfCraftApp, RightPanel, icons, widgets};
|
|
|
|
pub(super) mod all_tools_ui;
|
|
mod bookmarks;
|
|
pub(super) mod comments_panel;
|
|
mod edit;
|
|
pub(super) mod format_text_ui;
|
|
pub(super) mod organize_panel;
|
|
pub(super) mod page_selection_ui;
|
|
mod pages;
|
|
mod right;
|
|
pub(super) mod search_ui;
|
|
pub mod side_panels;
|
|
mod tools;
|
|
|
|
pub use bookmarks::BmAction;
|
|
pub(crate) use bookmarks::ellipsized_prefix;
|
|
pub use right::right_panel;
|
|
pub use tools::left_panel;
|
|
pub(crate) use tools::panel_header;
|
|
|
|
// ───────────────────────────────────────────────────────────────────────────── right panels
|
|
|
|
pub(crate) enum Nav {
|
|
Page(usize),
|
|
/// A bookmark's destination: its page and where on it.
|
|
Dest(usize, pdfcraft_render::DestView),
|
|
Flash(usize, [f32; 4]),
|
|
}
|
|
|
|
pub fn human_size(n: usize) -> String {
|
|
match n {
|
|
n if n >= 1 << 20 => format!("{:.1} MB", n as f64 / (1u64 << 20) as f64),
|
|
n if n >= 1 << 10 => format!("{:.1} KB", n as f64 / (1u64 << 10) as f64),
|
|
n => byte_count(n),
|
|
}
|
|
}
|
|
|
|
/// An exact size in bytes, with the count's own plural form.
|
|
pub fn byte_count(n: usize) -> String {
|
|
crate::i18n::trn(crate::i18n::current(), n as u64, "{n} byte", "{n} bytes")
|
|
}
|