ElyTable: the sheet's size follows every scale change; its end stays reachable after a zoom (T-05)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 18:11:39 -04:00
1 parent 201aa4fc5a
commit 7a12a28b67
15 files changed
+294 -25

No files matched your search

+4 -11
View File
@@ -33,10 +33,7 @@ pub use input::{CONTEXT, Copy, Cut, Paste, init};
pub use off::read_off;
pub use render::scheme;
/// One tile edge in twips.
pub const TILE_TWIPS: i32 = 3840;
/// Twips per pixel at zoom 1.0 and DPI 1.0.
pub(crate) const TWIPS_PER_PIXEL: f32 = 15.0;
pub(crate) use crate::{TILE_TWIPS, TWIPS_PER_PIXEL};
/// Document/view conversion under one zoom and DPI (LOK-04).
#[derive(Clone, Copy, Debug, PartialEq)]
@@ -147,7 +144,7 @@ pub struct LokView {
/// A document's size and page frames, in twips.
pub type Layout = ((i64, i64), Vec<Rect>);
type Measured = io::Result<Layout>;
use sheet::{Measured, measure};
/// A page's colour; the kernel's Ely schemes share it.
pub fn paper(cx: &gpui::App) -> gpui::Hsla {
@@ -165,10 +162,6 @@ pub fn layout(worker: &mut Worker, doc: &Doc) -> io::Result<Layout> {
Ok((doc.size(worker)?, doc.pages(worker)?))
}
/// Reads the layout under the worker lock.
fn measure(worker: &Mutex<Worker>, doc: &Doc) -> Measured {
layout(&mut worker.lock().expect("the worker lock"), doc)
}
impl EventEmitter<LokError> for LokView {}
@@ -362,8 +355,8 @@ impl LokView {
// What the view shows is the document at this revision.
self.seen_revision(batch.revision);
match measured {
Some(Ok(((width, height), pages))) => {
self.doc_size = (width as i32, height as i32);
Some(Ok((((width, height), pages), zoom))) => {
self.doc_size = self.at_scale((width as i32, height as i32), zoom);
if pages.len() != self.pages.len() {
log::info!("lok: {} pages", pages.len());
}