Skip to content

Commit 6239fdb

Browse files
committed
fix: apply overshoot in semi infinite layout to all directions
1 parent e1d48ef commit 6239fdb

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

crates/rnote-engine/src/camera.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::engine::{EngineTask, EngineTaskSender};
55
use crate::tasks::{OneOffTaskError, OneOffTaskHandle};
66
use crate::{Document, WidgetFlags};
77
use p2d::bounding_volume::Aabb;
8-
use rnote_compose::ext::Affine2Ext;
8+
use rnote_compose::ext::{AabbExt, Affine2Ext};
99
use serde::{Deserialize, Serialize};
1010
use std::time::Duration;
1111
use tracing::error;
@@ -132,28 +132,21 @@ impl Camera {
132132

133133
/// The minimum and maximum surface bounds (document including overshoot) in surface coordinate space.
134134
pub fn surface_mins_maxs(&self, doc: &Document) -> (na::Vector2<f64>, na::Vector2<f64>) {
135-
let bounds = self
135+
let document_bounds = self
136136
.document_to_view_transform()
137137
.transform_aabb(doc.bounds());
138138

139-
let (h_lower, h_upper) = match doc.config.layout {
140-
Layout::FixedSize | Layout::ContinuousVertical => (
141-
bounds.mins.x - Self::OVERSHOOT_HORIZONTAL,
142-
bounds.maxs.x + Self::OVERSHOOT_HORIZONTAL,
143-
),
144-
Layout::SemiInfinite => (bounds.mins.x - Self::OVERSHOOT_HORIZONTAL, bounds.maxs.x),
145-
Layout::Infinite => (bounds.mins.x, bounds.maxs.x),
146-
};
147-
let (v_lower, v_upper) = match doc.config.layout {
148-
Layout::FixedSize | Layout::ContinuousVertical => (
149-
bounds.mins.y - Self::OVERSHOOT_VERTICAL,
150-
bounds.maxs.y + Self::OVERSHOOT_VERTICAL,
151-
),
152-
Layout::SemiInfinite => (bounds.mins.y - Self::OVERSHOOT_VERTICAL, bounds.maxs.y),
153-
Layout::Infinite => (bounds.mins.y, bounds.maxs.y),
139+
let bounds = match doc.config.layout {
140+
Layout::FixedSize | Layout::ContinuousVertical | Layout::SemiInfinite => {
141+
document_bounds.extend_by(na::vector![
142+
Self::OVERSHOOT_HORIZONTAL,
143+
Self::OVERSHOOT_VERTICAL
144+
])
145+
}
146+
Layout::Infinite => document_bounds,
154147
};
155148

156-
(na::vector![h_lower, v_lower], na::vector![h_upper, v_upper])
149+
(bounds.mins.coords, bounds.maxs.coords)
157150
}
158151

159152
/// The current viewport size in surface coordinate space.

0 commit comments

Comments
 (0)