Expand replaces Widen: fill the window in both directions

From the development repository at 3f1da52.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
ackandClaude Opus 4.8 committed 2026-10-11 19:43:17 +02:00
1 parent 51e66db9a1
commit cc0b8dbd31
9 files changed
+102 -72

No files matched your search

+12 -8
View File
@@ -1027,12 +1027,16 @@ async function enterSession(invitationText, name, notebook) {
renderer.sheetScale();
session.sendViewCommand('sheet');
});
// "Widen" makes the sheet itself wider, until it fills the window at
// the present zoom; nothing on it moves (Andy, 2026-10-08).
element('zoom_widen').addEventListener('click', () => {
const room = renderer.available().width / renderer.cssPixelsPerUnit;
const widened = session.widenPage(room);
if (widened) log(`Page widened to ${session.page.baseWidth / 100} cm`);
// "Expand" makes the sheet itself fill the window at the present zoom,
// in both directions; nothing on it moves (Andy, 2026-10-08 for the
// width, both ways 2026-10-11).
element('zoom_expand').addEventListener('click', () => {
const room = renderer.available();
const expanded = session.expandPage(room.width / renderer.cssPixelsPerUnit,
room.height / renderer.cssPixelsPerUnit);
if (expanded) {
log(`Page expanded to ${session.page.baseWidth / 100} by ${session.page.baseHeight / 100} cm`);
}
});
element('zoom_shrink').addEventListener('click', () => {
if (session.shrinkPage()) {
@@ -1062,7 +1066,7 @@ async function enterSession(invitationText, name, notebook) {
const hideTool = /** @type {HTMLElement} */ (document.querySelector('[data-tool=hide]'));
hideTool.hidden = !session.mayMakePages();
if (hideTool.hidden && tool === 'hide') /** @type {HTMLElement} */ (document.querySelector('[data-tool=pen]')).click();
element('zoom_widen').hidden = !session.mayMakePages();
element('zoom_expand').hidden = !session.mayMakePages();
element('zoom_shrink').hidden = !session.mayMakePages();
}
showHostTools();
@@ -1413,7 +1417,7 @@ function showParticipants(session, renderer) {
// A checkbox with its label to the left, like Extend (Andy, 2026-10-09).
const allowLine = document.createElement('label');
allowLine.className = 'allow_line';
allowLine.setAttribute('data-help', 'Make this participant a co-host: they may then start pages, put images on the page and arrange them, load notebook pages, widen, shrink and hide, as you can.');
allowLine.setAttribute('data-help', 'Make this participant a co-host: they may then start pages, put images on the page and arrange them, load notebook pages, expand, shrink and hide, as you can.');
const allow = document.createElement('input');
allow.type = 'checkbox';
allow.className = 'allow';
+30 -21
View File
@@ -479,28 +479,37 @@ export class Session {
}
/**
* Make the sheet wider, for more room to write (Andy, 2026-10-08:
* "Widen" enlarges the page rather than zooming). Everyone's page
* widens; it is a change to the page, so it needs the right to make
* pages, and it ends the chance to take back an image.
* @param {number} width The page's new width, if wider than now.
* @returns {boolean} Whether the page widened.
* Make the sheet fill the window, for more room to write (Andy,
* 2026-10-08 as "Widen", which only grew the width; both ways since
* 2026-10-11, since there is no reason width alone suits anyone).
* Everyone's page grows; it is a change to the page, so it needs the
* right to make pages, and it ends the chance to take back an image.
* @param {number} width The page's new width, if wider than now.
* @param {number} height The page's new height, if taller than now.
* @returns {boolean} Whether the page grew.
*/
widenPage(width) {
expandPage(width, height) {
const page = this.page;
const added = Math.round(width) - page.width;
if (!this.mayMakePages() || page.number === 0 || added <= 0) return false;
// Equally on both sides of the PAGE as it is, writing included (the
// sheet may lie inside a page that writing has grown; measured from
// the sheet, the page came out short, Andy, 2026-10-08): what is on
// the page stays where it is seen. The same whole number of units on
// each side, since the page is centred on the screen: an odd growth
// split 1199 and 1200 moved the page's centre half a unit, a fraction
// of a pixel that showed as a one-pixel move on Olion (2026-10-09).
const half = Math.floor(added / 2);
if (half === 0) return false;
page.baseLeft = page.left - half;
page.baseWidth = page.width + 2 * half;
if (!this.mayMakePages() || page.number === 0) return false;
// Equally on both sides, and top and bottom, of the PAGE as it is,
// writing included (the sheet may lie inside a page that writing has
// grown; measured from the sheet, the page came out short, Andy,
// 2026-10-08): what is on the page stays where it is seen. The same
// whole number of units on each side, since the page is centred on
// the screen: an odd growth split 1199 and 1200 moved the centre half
// a unit, a pixel's fraction that showed as a one-pixel move on Olion
// (2026-10-09). A dimension already filling the window does not grow.
const addLeft = Math.floor((Math.round(width) - page.width) / 2);
const addTop = Math.floor((Math.round(height) - page.height) / 2);
if (addLeft <= 0 && addTop <= 0) return false;
if (addLeft > 0) {
page.baseLeft = page.left - addLeft;
page.baseWidth = page.width + 2 * addLeft;
}
if (addTop > 0) {
page.baseTop = page.top - addTop;
page.baseHeight = page.height + 2 * addTop;
}
page.imagesRevision += 1;
this.send(0, { type: 'page', page: page.descriptor() });
this.extentChanged(true);
@@ -510,7 +519,7 @@ export class Session {
/**
* Make the sheet the smallest that holds everything on the page with
* the margin around it ("Shrink", Andy, 2026-10-08). A change to the
* page like "Widen".
* page like "Expand".
* @returns {boolean} Whether the sheet changed.
*/
shrinkPage() {