Resolve FitR destinations using shipped box geometry

This commit is contained in:
gloamxun committed 2026-11-21 05:18:07 +08:00
1 parent 22154b53a6
commit 003d5d8726
8 files changed
+123 -40

No files matched your search

+21 -2
View File
@@ -21,7 +21,7 @@ pub struct LinkStart {
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub enum DestinationView {
pub enum DestinationView<Rectangle = [Option<i32>; 3]> {
Xyz(Option<i32>),
Fit,
FitH,
@@ -29,6 +29,25 @@ pub enum DestinationView {
FitB,
FitBH,
FitBV,
FitR(Rectangle),
}
impl<Rectangle> DestinationView<Rectangle> {
pub(crate) fn map_rectangle<Output>(
self,
map: impl FnOnce(Rectangle) -> Output,
) -> DestinationView<Output> {
match self {
Self::Xyz(zoom) => DestinationView::Xyz(zoom),
Self::Fit => DestinationView::Fit,
Self::FitH => DestinationView::FitH,
Self::FitV => DestinationView::FitV,
Self::FitB => DestinationView::FitB,
Self::FitBH => DestinationView::FitBH,
Self::FitBV => DestinationView::FitBV,
Self::FitR(rectangle) => DestinationView::FitR(map(rectangle)),
}
}
}
#[derive(
@@ -73,7 +92,7 @@ pub struct LinkAnnotation {
pub struct PageDestination {
pub destination: DestinationId<String>,
pub point: [i64; 2],
pub view: DestinationView,
pub view: DestinationView<[i64; 4]>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub structure: Option<u32>,
}