mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 21:29:35 +00:00
Merge pull request #9091 from dotCooCoo/fix/issue-9051
Fix #9051: Display Print Size shows 100% at the display's physical size
This commit is contained in:
@@ -61,8 +61,9 @@ pollster = "1"
|
||||
# which src/host_services.rs uses to read the path PhotoCraft registers under App Paths.
|
||||
# Win32_Devices_Display has `QueryDisplayConfig`, Win32_UI_ColorSystem the display's ICC profile and
|
||||
# Win32_System_LibraryLoader `GetProcAddress`, which src/display_profile.rs uses to read the
|
||||
# display's color profile for the canvas.
|
||||
windows = { version = "0.62", features = ["Win32_Devices_Display", "Win32_Foundation", "Win32_Graphics_DirectWrite", "Win32_Graphics_Gdi", "Win32_System_LibraryLoader", "Win32_System_Registry", "Win32_System_Threading", "Win32_UI_ColorSystem", "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_Input_Pointer", "Win32_UI_WindowsAndMessaging"] }
|
||||
# display's color profile for the canvas. Win32_UI_HiDpi has `GetDpiForMonitor`, which
|
||||
# src/windows_display_size.rs uses to read a monitor's raw density for Display Print Size.
|
||||
windows = { version = "0.62", features = ["Win32_Devices_Display", "Win32_Foundation", "Win32_Graphics_DirectWrite", "Win32_Graphics_Gdi", "Win32_System_LibraryLoader", "Win32_System_Registry", "Win32_System_Threading", "Win32_UI_ColorSystem", "Win32_UI_HiDpi", "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_Input_Pointer", "Win32_UI_WindowsAndMessaging"] }
|
||||
# The renderer's worker count follows those cores (src/windows_cores.rs).
|
||||
vectorcraft-render = { workspace = true }
|
||||
|
||||
@@ -83,7 +84,8 @@ objc2-core-text = { version = "0.3", default-features = false, features = ["std"
|
||||
# The windows' Metal layers and the sRGB color space they are tagged with (src/mac_color_space.rs).
|
||||
# Zlib OR Apache-2.0 OR MIT, already in the build through wgpu with these features.
|
||||
objc2-quartz-core = { version = "0.3", default-features = false, features = ["std", "objc2-core-foundation", "objc2-core-graphics", "CALayer", "CAMetalLayer"] }
|
||||
objc2-core-graphics = { version = "0.3", default-features = false, features = ["std", "CGColorSpace"] }
|
||||
# CGDisplayScreenSize gives a display's physical size for Display Print Size (src/screen_density.rs).
|
||||
objc2-core-graphics = { version = "0.3", default-features = false, features = ["std", "CGColorSpace", "CGDirectDisplay", "CGDisplayConfiguration"] }
|
||||
# Waits for the answer of a file dialog shown as a sheet (src/main.rs, #867). MIT OR Apache-2.0,
|
||||
# already in the build through eframe.
|
||||
pollster = "1"
|
||||
|
||||
@@ -184,6 +184,11 @@ impl App {
|
||||
let now = ctx.input(|i| i.time);
|
||||
if let Some(w) = &self.winit_window {
|
||||
self.display_profile.tick(w, now, self.app.session.prefs.monitor_profile_display, &self.app.display_profile, ctx);
|
||||
if let Some(read) = self.screen_density.tick(w, self.app.session.prefs.display_print_size, ctx) {
|
||||
self.app.services.screens = read.screens;
|
||||
self.app.set_screen_reading(read.main);
|
||||
ctx.request_repaint();
|
||||
}
|
||||
}
|
||||
self.app.tick(ctx);
|
||||
if self.app.ui.status == "quit" {
|
||||
|
||||
@@ -60,6 +60,7 @@ mod process_identity;
|
||||
mod profile_root;
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
mod quit_windows;
|
||||
mod screen_density;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
mod single_instance;
|
||||
#[cfg(windows)]
|
||||
@@ -69,6 +70,8 @@ mod window_frame;
|
||||
mod windows_alt_codes;
|
||||
#[cfg(windows)]
|
||||
mod windows_cores;
|
||||
#[cfg(windows)]
|
||||
mod windows_display_size;
|
||||
mod windows_stylus;
|
||||
mod windows_symbol_chars;
|
||||
mod xwayland;
|
||||
@@ -206,6 +209,9 @@ struct App {
|
||||
held_files: Vec<String>,
|
||||
/// Reads the profile of the display that shows the main window, for the canvas.
|
||||
display_profile: display_profile::Reader,
|
||||
/// Measures the density of the display that shows the main window, for Display Print Size at
|
||||
/// 100% Zoom.
|
||||
screen_density: screen_density::Tracker,
|
||||
/// When this frame's input hook started, for the hang report's frame times (`hang_watch`).
|
||||
frame_start: Option<std::time::Instant>,
|
||||
/// The shortest time between the starts of two frames, while the window presents without vsync
|
||||
@@ -989,6 +995,7 @@ fn main() -> std::process::ExitCode {
|
||||
winit_window,
|
||||
held_files,
|
||||
display_profile: Default::default(),
|
||||
screen_density: Default::default(),
|
||||
frame_start: None,
|
||||
min_frame,
|
||||
last_frame_began: None,
|
||||
|
||||
@@ -0,0 +1,817 @@
|
||||
//! The densities of the connected displays, in points (at each display's scale factor) per inch,
|
||||
//! for Preferences › General › Display Print Size at 100% Zoom (`Services::screen_ppi` for the
|
||||
//! display that shows most of the main window, `Services::screens` for every display): a
|
||||
//! display's size in points divided by the physical size the system reports for it.
|
||||
//!
|
||||
//! - macOS: `CGDisplayScreenSize`.
|
||||
//! - Windows: `GetDpiForMonitor`'s raw density (`windows_display_size`).
|
||||
//! - X11 on Linux, XWayland included: the RandR output's width and height in millimeters.
|
||||
//! - Wayland on Linux: the physical width and height of the compositor's `wl_output` for the display.
|
||||
//! - Other systems: no size, so an inch takes 96 points.
|
||||
//!
|
||||
//! A display that reports no size, or a size no display has, gives `None`, and an inch then takes
|
||||
//! 96 points. While the preference is on, the displays are listed once a second while the app
|
||||
//! draws. When the list changes, a background thread reads every display's size, and a later
|
||||
//! frame takes the result. A reading that fails is tried again after [`RETRY_AFTER`] seconds, and
|
||||
//! the displays are read again [`READ_AGAIN_AFTER`] seconds after the last reading; the app draws a
|
||||
//! frame for each of these when nothing else makes it draw.
|
||||
|
||||
use std::sync::mpsc::{Receiver, TryRecvError};
|
||||
|
||||
use vectorcraft_ui_egui::{ScreenDensity, ScreenPpi};
|
||||
use winit::dpi::{PhysicalPosition, PhysicalSize};
|
||||
use winit::monitor::MonitorHandle;
|
||||
|
||||
/// Seconds between two listings of the displays.
|
||||
const LOOK_EVERY: f64 = 1.0;
|
||||
|
||||
/// Seconds after a failed reading before the same displays are read again.
|
||||
const RETRY_AFTER: f64 = 10.0;
|
||||
|
||||
/// Seconds after a reading before the same displays are read again: a display can be replaced by
|
||||
/// one the listing cannot tell apart (the same connector, resolution and scale).
|
||||
const READ_AGAIN_AFTER: f64 = 60.0;
|
||||
|
||||
/// Millimeters in an inch.
|
||||
const MM_PER_INCH: f64 = 25.4;
|
||||
|
||||
/// How far the horizontal and vertical densities of one display may differ, as a fraction of the
|
||||
/// larger: square pixels on a display that reports its true size give two densities this close.
|
||||
const AXES_AGREE: f64 = 0.1;
|
||||
|
||||
/// A connected display as winit lists it: what a reading needs, and what tells two lists apart.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct Display {
|
||||
name: Option<String>,
|
||||
position: PhysicalPosition<i32>,
|
||||
size: PhysicalSize<u32>,
|
||||
/// The display's scale factor, as its bits.
|
||||
scale: u64,
|
||||
/// The system's id of the display ([`native_id`]).
|
||||
id: i64,
|
||||
}
|
||||
|
||||
impl Display {
|
||||
fn of(m: &MonitorHandle) -> Self {
|
||||
Self { name: m.name(), position: m.position(), size: m.size(), scale: m.scale_factor().to_bits(), id: native_id(m) }
|
||||
}
|
||||
}
|
||||
|
||||
/// One display's physical size in millimeters: `None` when the system reports none, an error when
|
||||
/// asking for it failed.
|
||||
type Size = Result<Option<[f64; 2]>, String>;
|
||||
|
||||
/// The physical sizes of displays, one for each display read, or why none could be read.
|
||||
type Reading = Result<Vec<Size>, String>;
|
||||
|
||||
/// What the host hands the app: the density of the main window's display, unread while that
|
||||
/// display is unknown or has not answered yet, and every display's that answered.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub(crate) struct Densities {
|
||||
pub(crate) main: ScreenPpi,
|
||||
pub(crate) screens: Vec<ScreenDensity>,
|
||||
}
|
||||
|
||||
/// What a display answered: its physical size (`Some(None)` for none), or `None` while it has not
|
||||
/// answered.
|
||||
type Answer = Option<Option<[f64; 2]>>;
|
||||
|
||||
/// What a listing gives: the displays, the one that shows most of the main window, and the main
|
||||
/// window's scale factor.
|
||||
type Listing = (Vec<Display>, Option<Display>, f64);
|
||||
|
||||
/// Keeps the densities current from the main window's frames.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct Tracker {
|
||||
/// When the displays were last listed.
|
||||
looked: Option<f64>,
|
||||
/// The display that showed most of the main window at the last listing, and the window's scale
|
||||
/// factor then.
|
||||
current: Option<(Display, f64)>,
|
||||
/// The displays of the last reading that finished, each with what it answered.
|
||||
read: Option<Vec<(Display, Answer)>>,
|
||||
/// The displays of the last reading that failed, and when it failed.
|
||||
failed: Option<(Vec<Display>, f64)>,
|
||||
/// The reading in progress: the displays it reads, and where its result arrives.
|
||||
running: Option<(Vec<Display>, Receiver<Reading>)>,
|
||||
/// The reading in progress started before the preference was last turned off: its result is
|
||||
/// dropped when it arrives, and no other reading starts until then.
|
||||
obsolete: bool,
|
||||
/// What [`Self::tick`] returned last.
|
||||
reported: Option<Densities>,
|
||||
/// The displays of the last listing.
|
||||
listed: Option<Vec<Display>>,
|
||||
/// When the last reading that finished ended.
|
||||
read_at: f64,
|
||||
/// When the first tick ran: the tracker's clock, which runs while the window draws nothing.
|
||||
origin: Option<std::time::Instant>,
|
||||
}
|
||||
|
||||
impl Tracker {
|
||||
/// Lists the displays when a listing is due and Display Print Size is `enabled`, starts a
|
||||
/// reading on a background thread when they changed, and returns the densities when they
|
||||
/// differ from what it returned before. The thread asks `ctx` for a frame when its reading is
|
||||
/// ready.
|
||||
pub(crate) fn tick(&mut self, window: &winit::window::Window, enabled: bool, ctx: &egui::Context) -> Option<Densities> {
|
||||
let now = self.origin.get_or_insert_with(std::time::Instant::now).elapsed().as_secs_f64();
|
||||
let list = || {
|
||||
// winit stops on a display that went away while it is being asked about (Windows); that
|
||||
// listing is dropped, and the next one is made a second later.
|
||||
let listing = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
let current = window.current_monitor().map(|m| Display::of(&m));
|
||||
(window.available_monitors().map(|m| Display::of(&m)).collect::<Vec<_>>(), current, window.scale_factor())
|
||||
}));
|
||||
listing.map_err(|_| log::debug!("a display went away while the displays were listed")).ok()
|
||||
};
|
||||
let wayland = is_wayland(window);
|
||||
let start = |displays: Vec<Display>| {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let ctx = ctx.clone();
|
||||
let spawned = std::thread::Builder::new().name("display size".into()).spawn(move || {
|
||||
// The app may have quit, and dropped the receiver, before the reading ends.
|
||||
let _ = tx.send(read_all(&displays, wayland));
|
||||
ctx.request_repaint();
|
||||
});
|
||||
spawned.map(|_| rx).map_err(|e| format!("couldn't start reading the displays' sizes: {e}"))
|
||||
};
|
||||
let densities = self.update(now, enabled, list, start);
|
||||
// A failed reading is tried again at a listing RETRY_AFTER seconds later, also in an app
|
||||
// that is not drawing. A reading in progress asks for a frame when it ends.
|
||||
if enabled
|
||||
&& self.running.is_none()
|
||||
&& let Some((_, at)) = &self.failed
|
||||
{
|
||||
let due = (at + RETRY_AFTER).max(self.looked.map_or(0.0, |l| l + LOOK_EVERY));
|
||||
ctx.request_repaint_after(std::time::Duration::from_secs_f64((due - now).clamp(0.0, RETRY_AFTER)));
|
||||
} else if enabled && self.running.is_none() && self.read.is_some() {
|
||||
// An app that is not drawing still lists and reads the displays READ_AGAIN_AFTER seconds
|
||||
// after the last reading.
|
||||
let due = (self.read_at + READ_AGAIN_AFTER).max(self.looked.map_or(0.0, |l| l + LOOK_EVERY));
|
||||
ctx.request_repaint_after(std::time::Duration::from_secs_f64((due - now).clamp(0.0, READ_AGAIN_AFTER)));
|
||||
}
|
||||
densities
|
||||
}
|
||||
|
||||
/// [`Self::tick`] with the listing (`list`) and the start of a reading (`start`) passed in.
|
||||
fn update(
|
||||
&mut self,
|
||||
now: f64,
|
||||
enabled: bool,
|
||||
list: impl FnOnce() -> Option<Listing>,
|
||||
start: impl FnOnce(Vec<Display>) -> Result<Receiver<Reading>, String>,
|
||||
) -> Option<Densities> {
|
||||
let was_running = self.running.is_some();
|
||||
if let Some((displays, rx)) = self.running.take() {
|
||||
match rx.try_recv() {
|
||||
Err(TryRecvError::Empty) => self.running = Some((displays, rx)),
|
||||
_ if self.obsolete => self.obsolete = false,
|
||||
Ok(Ok(sizes)) => {
|
||||
// A display whose size could not be read keeps what an earlier reading gave it,
|
||||
// or stays unanswered, until the reading is tried again.
|
||||
let mut failed = false;
|
||||
let read: Vec<_> = displays
|
||||
.iter()
|
||||
.zip(sizes.into_iter().chain(std::iter::repeat(Ok(None))))
|
||||
.map(|(d, s)| {
|
||||
let mm = s.map(Some).unwrap_or_else(|e| {
|
||||
log::debug!("couldn't read a display's physical size: {e}");
|
||||
failed = true;
|
||||
self.earlier(d)
|
||||
});
|
||||
(d.clone(), mm)
|
||||
})
|
||||
.collect();
|
||||
self.failed = failed.then_some((displays, now));
|
||||
self.read = Some(read);
|
||||
self.read_at = now;
|
||||
}
|
||||
Ok(Err(e)) => {
|
||||
log::debug!("couldn't read the displays' physical sizes: {e}");
|
||||
self.fail(displays, now);
|
||||
}
|
||||
Err(TryRecvError::Disconnected) => {
|
||||
log::debug!("the reading of the displays' physical sizes stopped without a result");
|
||||
self.fail(displays, now);
|
||||
}
|
||||
}
|
||||
}
|
||||
// When a reading ends, the displays are listed again at once: they may have changed while
|
||||
// it ran, and the frame its end asked for may be the last one for a while.
|
||||
if was_running && self.running.is_none() {
|
||||
self.looked = None;
|
||||
}
|
||||
if !enabled {
|
||||
// Turned on again, the displays are read and the densities reported anew: a display
|
||||
// may have been replaced meanwhile by one that lists the same.
|
||||
self.reported = None;
|
||||
self.read = None;
|
||||
self.failed = None;
|
||||
self.looked = None;
|
||||
self.obsolete = self.running.is_some();
|
||||
return None;
|
||||
}
|
||||
// The densities change only at a listing, and one follows the end of every reading.
|
||||
let listing = !self.looked.is_some_and(|at| (at..at + LOOK_EVERY).contains(&now));
|
||||
if !listing && self.reported.is_some() {
|
||||
return None;
|
||||
}
|
||||
if listing {
|
||||
self.looked = Some(now);
|
||||
}
|
||||
if let Some((displays, current, scale)) = listing.then(list).flatten() {
|
||||
// winit can give the window's display as it was before a change of resolution: the
|
||||
// display is found in the listing by its id and name.
|
||||
let current = current.map(|c| displays.iter().find(|d| d.id == c.id && d.name == c.name).cloned().unwrap_or(c));
|
||||
self.current = current.map(|c| (c, scale));
|
||||
self.listed = Some(displays.clone());
|
||||
// These displays are read once, and again RETRY_AFTER seconds after a reading of them
|
||||
// failed in whole or in part.
|
||||
let known = self.read.as_ref().is_some_and(|r| r.iter().map(|(d, _)| d).eq(displays.iter()));
|
||||
let due = match &self.failed {
|
||||
Some((d, at)) if *d == displays => !(*at..*at + RETRY_AFTER).contains(&now),
|
||||
_ => !known || now - self.read_at >= READ_AGAIN_AFTER,
|
||||
};
|
||||
if self.running.is_none() && due {
|
||||
match start(displays.clone()) {
|
||||
Ok(rx) => self.running = Some((displays, rx)),
|
||||
Err(e) => {
|
||||
log::warn!("{e}");
|
||||
self.fail(displays, now);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let read = self.read.as_ref()?;
|
||||
// The main window counts in its own scale factor, which on Wayland can be a fraction where
|
||||
// the display gives a whole number. A window on no display (a Wayland window before it is
|
||||
// shown, or after its display went), or on one that is being read or has not answered, has
|
||||
// its density unread.
|
||||
let main = match &self.current {
|
||||
Some((c, scale)) => match read.iter().find(|(d, _)| d == c) {
|
||||
Some((d, Some(mm))) => ScreenPpi::Read(mm.and_then(|mm| points_per_inch(d.size, *scale, mm))),
|
||||
_ => ScreenPpi::Unread,
|
||||
},
|
||||
None => ScreenPpi::Unread,
|
||||
};
|
||||
// The displays where the last listing has them, each with what the reading of it gave; a
|
||||
// display the readings have not reached yet is unread.
|
||||
let listed = self.listed.as_deref().unwrap_or_default();
|
||||
let screens = listed
|
||||
.iter()
|
||||
.map(|d| {
|
||||
let [w, h] = [d.size.width, d.size.height].map(|v| i32::try_from(v).unwrap_or(i32::MAX));
|
||||
let scale = f64::from_bits(d.scale);
|
||||
let mm = read.iter().find(|(e, _)| e == d).and_then(|(_, mm)| *mm);
|
||||
let ppi = mm.map_or(ScreenPpi::Unread, |mm| ScreenPpi::Read(mm.and_then(|mm| points_per_inch(d.size, scale, mm))));
|
||||
ScreenDensity { rect: [d.position.x, d.position.y, w, h], scale, ppi }
|
||||
})
|
||||
.collect();
|
||||
let densities = Densities { main, screens };
|
||||
if self.reported.as_ref() == Some(&densities) {
|
||||
return None;
|
||||
}
|
||||
match main {
|
||||
ScreenPpi::Read(Some(p)) => log::info!("the window's display has {p:.1} points to an inch"),
|
||||
ScreenPpi::Read(None) => log::info!("the window's display reports no physical size; an inch is 96 points"),
|
||||
ScreenPpi::Unread => log::info!("the window's display has not been read; an inch is 96 points"),
|
||||
}
|
||||
self.reported = Some(densities.clone());
|
||||
Some(densities)
|
||||
}
|
||||
}
|
||||
|
||||
impl Tracker {
|
||||
/// What the last reading gave display `d`, when it answered.
|
||||
fn earlier(&self, d: &Display) -> Answer {
|
||||
self.read.as_ref()?.iter().find(|(e, _)| e == d)?.1
|
||||
}
|
||||
|
||||
/// Records that reading `displays` failed at `now`; they are read again after [`RETRY_AFTER`]
|
||||
/// seconds. After an earlier reading, they become the displays known, each with what that
|
||||
/// reading gave it, if anything. Before any reading, nothing is reported yet.
|
||||
fn fail(&mut self, displays: Vec<Display>, now: f64) {
|
||||
if self.read.is_some() {
|
||||
let read = displays.iter().map(|d| (d.clone(), self.earlier(d))).collect();
|
||||
self.read = Some(read);
|
||||
}
|
||||
self.failed = Some((displays, now));
|
||||
}
|
||||
}
|
||||
|
||||
/// The density, in points per inch, of a display `size` physical pixels wide and high, drawn at
|
||||
/// `scale` pixels to a point, that the system says is `mm` millimeters wide and high. `None` for a
|
||||
/// size that is no display's: zero or less, an aspect ratio given in place of the size (16 × 9,
|
||||
/// 160 × 90 and the like), axes whose densities disagree in either orientation, or a pixel density
|
||||
/// outside [`vectorcraft_ui_egui::state::SCREEN_PPI_RANGE`]. The range applies to the pixels, before
|
||||
/// the scale divides them into points. A display turned a quarter turn may report the size of its
|
||||
/// panel upright, so the axes are also tried swapped.
|
||||
pub(crate) fn points_per_inch(size: PhysicalSize<u32>, scale: f64, mm: [f64; 2]) -> Option<f64> {
|
||||
if !(scale.is_finite() && scale > 0.0) || mm.iter().any(|v| !(v.is_finite() && *v > 0.0)) || aspect_as_size(mm) {
|
||||
return None;
|
||||
}
|
||||
let pixels = [f64::from(size.width), f64::from(size.height)];
|
||||
let density = |[w, h]: [f64; 2]| [pixels[0] / (w / MM_PER_INCH), pixels[1] / (h / MM_PER_INCH)];
|
||||
let agree = |[x, y]: [f64; 2]| (x - y).abs() <= AXES_AGREE * x.max(y);
|
||||
let [x, y] = [density(mm), density([mm[1], mm[0]])].into_iter().find(|d| agree(*d))?;
|
||||
let ppi = (x + y) / 2.0;
|
||||
vectorcraft_ui_egui::state::SCREEN_PPI_RANGE.contains(&ppi).then_some(ppi / scale)
|
||||
}
|
||||
|
||||
/// Whether `mm` is an aspect ratio that a display's EDID gave in place of its size: 16:9, 16:10
|
||||
/// or 4:3, in centimeters or tenths of them.
|
||||
fn aspect_as_size(mm: [f64; 2]) -> bool {
|
||||
const RATIOS: [[f64; 2]; 3] = [[16.0, 9.0], [16.0, 10.0], [4.0, 3.0]];
|
||||
let sorted = if mm[0] >= mm[1] { mm } else { [mm[1], mm[0]] };
|
||||
RATIOS.iter().any(|r| [1.0, 10.0].iter().any(|k| sorted == [r[0] * k, r[1] * k]))
|
||||
}
|
||||
|
||||
/// Whether `window` is a Wayland window, whose displays the compositor describes.
|
||||
#[cfg(target_os = "linux")]
|
||||
fn is_wayland(window: &winit::window::Window) -> bool {
|
||||
use winit::raw_window_handle::{HasWindowHandle as _, RawWindowHandle};
|
||||
window.window_handle().ok().is_some_and(|h| matches!(h.as_raw(), RawWindowHandle::Wayland(_)))
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn is_wayland(_: &winit::window::Window) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
/// The system's id of `monitor`: the display id on macOS, the monitor handle on Windows, the RandR
|
||||
/// CRTC on X11.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn native_id(monitor: &MonitorHandle) -> i64 {
|
||||
use winit::platform::macos::MonitorHandleExtMacOS as _;
|
||||
i64::from(monitor.native_id())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn native_id(monitor: &MonitorHandle) -> i64 {
|
||||
use winit::platform::windows::MonitorHandleExtWindows as _;
|
||||
monitor.hmonitor() as i64
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn native_id(monitor: &MonitorHandle) -> i64 {
|
||||
use winit::platform::x11::MonitorHandleExtX11 as _;
|
||||
i64::from(monitor.native_id())
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", windows, target_os = "linux")))]
|
||||
fn native_id(_: &MonitorHandle) -> i64 {
|
||||
0
|
||||
}
|
||||
|
||||
/// The physical width and height, in millimeters, the system reports for each of `displays`.
|
||||
#[cfg(target_os = "macos")]
|
||||
fn read_all(displays: &[Display], _: bool) -> Reading {
|
||||
Ok(displays
|
||||
.iter()
|
||||
.map(|d| {
|
||||
Ok(u32::try_from(d.id).ok().map(|id| {
|
||||
let size = objc2_core_graphics::CGDisplayScreenSize(id);
|
||||
[size.width, size.height]
|
||||
}))
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn read_all(displays: &[Display], _: bool) -> Reading {
|
||||
Ok(displays
|
||||
.iter()
|
||||
.map(|d| {
|
||||
let dpi = crate::windows_display_size::raw_dpi(d.id as isize)?;
|
||||
Ok(dpi.map(|[x, y]| [f64::from(d.size.width) / x * MM_PER_INCH, f64::from(d.size.height) / y * MM_PER_INCH]))
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn read_all(displays: &[Display], wayland: bool) -> Reading {
|
||||
if wayland { wayland::read_all(displays) } else { x11::read_all(displays) }
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", windows, target_os = "linux")))]
|
||||
fn read_all(displays: &[Display], _: bool) -> Reading {
|
||||
Ok(displays.iter().map(|_| Ok(None)).collect())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod x11 {
|
||||
use x11rb::CURRENT_TIME;
|
||||
use x11rb::protocol::randr;
|
||||
|
||||
use super::{Display, Reading, Size};
|
||||
|
||||
/// The millimeters RandR reports for the first output of each display's CRTC.
|
||||
pub(super) fn read_all(displays: &[Display]) -> Reading {
|
||||
let (conn, _) = x11rb::connect(None).map_err(|e| format!("couldn't connect to the X11 display: {e}"))?;
|
||||
let ask = |e: x11rb::errors::ConnectionError| format!("couldn't ask the X11 display: {e}");
|
||||
// RandR answers only a client that gave the version it speaks; 1.2 has CRTCs and outputs.
|
||||
randr::query_version(&conn, 1, 2).map_err(ask)?.reply().map_err(|e| format!("the X11 display has no RandR 1.2: {e}"))?;
|
||||
let size = |d: &Display| -> Size {
|
||||
let Ok(crtc) = u32::try_from(d.id) else { return Ok(None) };
|
||||
let info = randr::get_crtc_info(&conn, crtc, CURRENT_TIME)
|
||||
.map_err(ask)?
|
||||
.reply()
|
||||
.map_err(|e| format!("the X11 display has no such CRTC: {e}"))?;
|
||||
let Some(output) = info.outputs.first() else { return Ok(None) };
|
||||
let info = randr::get_output_info(&conn, *output, CURRENT_TIME)
|
||||
.map_err(ask)?
|
||||
.reply()
|
||||
.map_err(|e| format!("the X11 display has no such output: {e}"))?;
|
||||
Ok(Some([f64::from(info.mm_width), f64::from(info.mm_height)]))
|
||||
};
|
||||
Ok(displays.iter().map(size).collect())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
mod wayland {
|
||||
use wayland_client::globals::{GlobalListContents, registry_queue_init};
|
||||
use wayland_client::protocol::wl_output::{self, WlOutput};
|
||||
use wayland_client::protocol::wl_registry::{self, WlRegistry};
|
||||
use wayland_client::{Connection, Dispatch, QueueHandle};
|
||||
|
||||
use super::{Display, Reading};
|
||||
|
||||
/// The physical size the compositor gives for the output of each display's name, asked on a
|
||||
/// connection of its own; with no name, or a compositor that names no outputs, the only
|
||||
/// output's.
|
||||
pub(super) fn read_all(displays: &[Display]) -> Reading {
|
||||
let conn = Connection::connect_to_env().map_err(|e| format!("no Wayland compositor: {e}"))?;
|
||||
let (globals, mut queue) = registry_queue_init::<Outputs>(&conn).map_err(|e| e.to_string())?;
|
||||
let qh = queue.handle();
|
||||
let mut state = Outputs::default();
|
||||
for global in globals.contents().clone_list().into_iter().filter(|g| g.interface == "wl_output") {
|
||||
// Version 4 names the output; older ones give its size only.
|
||||
let output: WlOutput = globals.registry().bind(global.name, global.version.min(4), &qh, state.outputs.len());
|
||||
state.outputs.push((output, Output::default()));
|
||||
}
|
||||
// The compositor sends each output's geometry, name and `done` in reply to the bind.
|
||||
queue.roundtrip(&mut state).map_err(|e| e.to_string())?;
|
||||
let found: Vec<&Output> = state.outputs.iter().map(|(_, o)| o).collect();
|
||||
let named = found.iter().any(|o| o.name.is_some());
|
||||
Ok(displays
|
||||
.iter()
|
||||
.map(|d| {
|
||||
let pick = match d.name.as_deref() {
|
||||
Some(name) if named => found.iter().find(|o| o.name.as_deref() == Some(name)),
|
||||
_ if found.len() == 1 => found.first(),
|
||||
_ => None,
|
||||
};
|
||||
Ok(pick.and_then(|o| o.mm))
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// One output's name and physical size.
|
||||
#[derive(Default)]
|
||||
struct Output {
|
||||
name: Option<String>,
|
||||
mm: Option<[f64; 2]>,
|
||||
}
|
||||
|
||||
/// The outputs bound, each with what its events gave.
|
||||
#[derive(Default)]
|
||||
struct Outputs {
|
||||
outputs: Vec<(WlOutput, Output)>,
|
||||
}
|
||||
|
||||
impl Dispatch<WlRegistry, GlobalListContents> for Outputs {
|
||||
fn event(_: &mut Self, _: &WlRegistry, _: wl_registry::Event, _: &GlobalListContents, _: &Connection, _: &QueueHandle<Self>) {}
|
||||
}
|
||||
|
||||
impl Dispatch<WlOutput, usize> for Outputs {
|
||||
fn event(state: &mut Self, _: &WlOutput, event: wl_output::Event, index: &usize, _: &Connection, _: &QueueHandle<Self>) {
|
||||
let Some((_, output)) = state.outputs.get_mut(*index) else { return };
|
||||
match event {
|
||||
wl_output::Event::Geometry { physical_width, physical_height, .. } => {
|
||||
output.mm = Some([f64::from(physical_width), f64::from(physical_height)]);
|
||||
}
|
||||
wl_output::Event::Name { name } => output.name = Some(name),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::cell::Cell;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
|
||||
use super::*;
|
||||
|
||||
/// A 14-inch laptop panel at twice its points: 3024 × 1964 pixels, 302 × 196 mm, draws 127
|
||||
/// points to an inch, more than the 96 a fixed inch assumes.
|
||||
#[test]
|
||||
fn a_laptop_panel_has_more_points_to_an_inch_than_the_reference() {
|
||||
let ppi = points_per_inch(PhysicalSize::new(3024, 1964), 2.0, [302.0, 196.0]);
|
||||
assert!(ppi.is_some_and(|p| p > 96.0 && (p - 1512.0 / (302.0 / MM_PER_INCH)).abs() < 1.0), "{ppi:?}");
|
||||
}
|
||||
|
||||
/// The same display in a scaled mode (more points on the same glass) draws more points to an
|
||||
/// inch, and at a higher scale factor fewer: the density counts the window's points.
|
||||
#[test]
|
||||
fn the_density_counts_points_at_the_windows_scale() {
|
||||
let at = |w, h, scale| points_per_inch(PhysicalSize::new(w, h), scale, [527.0, 296.0]).unwrap_or(0.0);
|
||||
assert!(at(1920, 1080, 1.0) > 0.0);
|
||||
assert!(at(2560, 1440, 1.0) > at(1920, 1080, 1.0), "more pixels on the same glass");
|
||||
assert!(at(3840, 2160, 2.0) < at(3840, 2160, 1.5), "a larger scale factor makes each point larger");
|
||||
}
|
||||
|
||||
/// A display turned a quarter turn whose system reports its panel's size upright still
|
||||
/// measures; axes that disagree either way do not.
|
||||
#[test]
|
||||
fn a_turned_display_measures_and_disagreeing_axes_do_not() {
|
||||
let upright = points_per_inch(PhysicalSize::new(1920, 1080), 1.0, [527.0, 296.0]);
|
||||
let turned = points_per_inch(PhysicalSize::new(1080, 1920), 1.0, [527.0, 296.0]);
|
||||
assert!(upright.is_some() && turned.is_some());
|
||||
assert!((upright.unwrap_or(0.0) - turned.unwrap_or(1.0)).abs() < 1e-9);
|
||||
assert_eq!(points_per_inch(PhysicalSize::new(1920, 1080), 1.0, [527.0, 527.0]), None);
|
||||
}
|
||||
|
||||
/// Sizes no display has give no density: none, an aspect ratio in place of the size, and
|
||||
/// densities past the range a display can have.
|
||||
#[test]
|
||||
fn reports_that_are_no_displays_size_give_no_density() {
|
||||
let at = |mm| points_per_inch(PhysicalSize::new(1920, 1080), 1.0, mm);
|
||||
for mm in [[0.0, 0.0], [-1.0, 300.0], [f64::NAN, 300.0], [160.0, 90.0], [16.0, 9.0], [160.0, 100.0], [40.0, 30.0], [9.0, 16.0]] {
|
||||
assert_eq!(at(mm), None, "{mm:?}");
|
||||
}
|
||||
assert_eq!(points_per_inch(PhysicalSize::new(1920, 1080), 0.0, [527.0, 296.0]), None, "no scale");
|
||||
assert_eq!(points_per_inch(PhysicalSize::new(100, 56), 1.0, [5270.0, 2960.0]), None, "under the range");
|
||||
assert_eq!(points_per_inch(PhysicalSize::new(7680, 4320), 1.0, [53.0, 30.0]), None, "over it");
|
||||
}
|
||||
|
||||
/// The range applies to the display's pixels: a 1920 × 1080 display of 527 × 296 mm drawn at
|
||||
/// scale 4 has about 23 points to an inch, which is a real density.
|
||||
#[test]
|
||||
fn a_large_scale_factor_does_not_put_a_display_out_of_range() {
|
||||
let ppi = points_per_inch(PhysicalSize::new(1920, 1080), 4.0, [527.0, 296.0]);
|
||||
let pixels = points_per_inch(PhysicalSize::new(1920, 1080), 1.0, [527.0, 296.0]).unwrap_or(0.0);
|
||||
assert!(ppi.is_some_and(|p| p < 30.0 && (p - pixels / 4.0).abs() < 1e-9), "{ppi:?}");
|
||||
let print = vectorcraft_ui_egui::state::print_ppi(true, ppi);
|
||||
assert_eq!(print, ppi, "Actual Size counts from it, not from 96");
|
||||
}
|
||||
|
||||
/// A 1920 × 1080 display at scale 1 and position `x`, named `name`.
|
||||
fn display(name: &str, x: i32) -> Display {
|
||||
Display {
|
||||
name: Some(name.into()),
|
||||
position: PhysicalPosition::new(x, 0),
|
||||
size: PhysicalSize::new(1920, 1080),
|
||||
scale: 1.0f64.to_bits(),
|
||||
id: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// The sizes of a 24-inch display (about 92 points to an inch) and a 27-inch one (about 82).
|
||||
const SIZES: [[f64; 2]; 2] = [[531.0, 299.0], [598.0, 336.0]];
|
||||
|
||||
/// A reading that gives every display one of [`SIZES`], in turn.
|
||||
fn sizes(n: usize) -> Reading {
|
||||
Ok((0..n).map(|i| Ok(Some(SIZES[i % SIZES.len()]))).collect())
|
||||
}
|
||||
|
||||
/// Drives a tracker: counts its listings and readings, and hands out the sender of the reading
|
||||
/// it started last.
|
||||
struct Rig {
|
||||
tracker: Tracker,
|
||||
displays: Vec<Display>,
|
||||
current: usize,
|
||||
/// The window's display as winit last gave it, when that lags behind the listing.
|
||||
lagging: Option<Display>,
|
||||
window_scale: f64,
|
||||
lists: Cell<usize>,
|
||||
reads: Cell<usize>,
|
||||
sender: Option<Sender<Reading>>,
|
||||
fail_to_start: bool,
|
||||
}
|
||||
|
||||
impl Rig {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
tracker: Tracker::default(),
|
||||
displays: vec![display("left", 0), display("right", 1920)],
|
||||
current: 0,
|
||||
lagging: None,
|
||||
window_scale: 1.0,
|
||||
lists: Cell::new(0),
|
||||
reads: Cell::new(0),
|
||||
sender: None,
|
||||
fail_to_start: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn tick(&mut self, now: f64, enabled: bool) -> Option<Densities> {
|
||||
let current = self.lagging.clone().or_else(|| self.displays.get(self.current).cloned());
|
||||
let (displays, scale) = (self.displays.clone(), self.window_scale);
|
||||
let (lists, reads, fail) = (&self.lists, &self.reads, self.fail_to_start);
|
||||
let mut sender = None;
|
||||
let out = self.tracker.update(
|
||||
now,
|
||||
enabled,
|
||||
|| {
|
||||
lists.set(lists.get() + 1);
|
||||
Some((displays, current, scale))
|
||||
},
|
||||
|_| {
|
||||
reads.set(reads.get() + 1);
|
||||
if fail {
|
||||
return Err("no thread".into());
|
||||
}
|
||||
let (tx, rx) = channel();
|
||||
sender = Some(tx);
|
||||
Ok(rx)
|
||||
},
|
||||
);
|
||||
if sender.is_some() {
|
||||
self.sender = sender;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn finish(&mut self, reading: Reading) {
|
||||
if let Some(tx) = self.sender.take() {
|
||||
tx.send(reading).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The first listing starts a reading, and the densities arrive once the reading ends, without
|
||||
/// a frame waiting for it. The main window's density is its display's, and every display gets
|
||||
/// its own.
|
||||
#[test]
|
||||
fn the_densities_arrive_when_the_reading_ends() {
|
||||
let mut rig = Rig::new();
|
||||
assert_eq!(rig.tick(0.0, true), None, "the reading runs in the background");
|
||||
assert_eq!(rig.reads.get(), 1);
|
||||
assert_eq!(rig.tick(2.0, true), None, "still running: no second reading");
|
||||
assert_eq!(rig.reads.get(), 1);
|
||||
rig.finish(sizes(2));
|
||||
let got = rig.tick(2.1, true).unwrap_or_else(|| panic!("the densities"));
|
||||
let ppi = got.screens.iter().map(|s| s.ppi.ppi().unwrap_or(0.0)).collect::<Vec<_>>();
|
||||
assert!(ppi[0] > ppi[1] && ppi[1] > 0.0, "the smaller display is denser: {ppi:?}");
|
||||
assert_eq!(got.main, ScreenPpi::Read(Some(ppi[0])), "the main window is on the left display");
|
||||
assert_eq!(got.screens[1].rect, [1920, 0, 1920, 1080]);
|
||||
assert_eq!(rig.tick(5.0, true), None, "nothing changed");
|
||||
assert_eq!(rig.reads.get(), 1, "the same displays are not read again");
|
||||
assert_eq!(rig.tick(5.2, false), None, "off, nothing is reported");
|
||||
assert_eq!(rig.tick(5.4, true), None, "turned on again, the displays are read again at once");
|
||||
assert_eq!(rig.reads.get(), 2);
|
||||
rig.finish(sizes(2));
|
||||
assert_eq!(rig.tick(5.5, true), Some(got), "and the densities reported anew");
|
||||
}
|
||||
|
||||
/// The displays are listed at most once a second, and not at all with the preference off.
|
||||
#[test]
|
||||
fn the_displays_are_listed_once_a_second_while_the_preference_is_on() {
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.tick(0.5, true);
|
||||
assert_eq!(rig.lists.get(), 1);
|
||||
rig.tick(1.0, true);
|
||||
assert_eq!(rig.lists.get(), 2);
|
||||
rig.tick(5.0, false);
|
||||
assert_eq!(rig.lists.get(), 2, "off, nothing is asked of the system");
|
||||
}
|
||||
|
||||
/// The main window moving to the other display reports that display's density without a new
|
||||
/// reading; a display joining the list is read again, and while a display that changed is
|
||||
/// read, the densities reported before stay.
|
||||
#[test]
|
||||
fn a_change_of_display_is_reported() {
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.finish(sizes(2));
|
||||
let left = rig.tick(0.1, true).and_then(|d| d.main.ppi());
|
||||
rig.current = 1;
|
||||
let right = rig.tick(1.5, true).and_then(|d| d.main.ppi());
|
||||
assert!(left.is_some() && right.is_some() && left != right, "{left:?} then {right:?}");
|
||||
assert_eq!(rig.reads.get(), 1);
|
||||
// A window drawn at 1.5 pixels a point (a fractional scale the display does not list)
|
||||
// has fewer points to an inch than the display's own scale of 1 gives.
|
||||
rig.window_scale = 1.5;
|
||||
let scaled = rig.tick(2.6, true).and_then(|d| d.main.ppi());
|
||||
assert!(scaled.zip(right).is_some_and(|(s, r)| (s * 1.5 - r).abs() < 1e-9), "{scaled:?} at 1.5, {right:?} at 1");
|
||||
rig.window_scale = 1.0;
|
||||
rig.displays.push(display("third", 3840));
|
||||
rig.tick(4.0, true);
|
||||
assert_eq!(rig.reads.get(), 2, "a new display is read");
|
||||
rig.finish(sizes(3));
|
||||
rig.tick(4.5, true);
|
||||
// The window's display changes resolution: until it is read again its density is unread.
|
||||
rig.displays[1].size = PhysicalSize::new(2560, 1440);
|
||||
assert_eq!(rig.tick(6.0, true).map(|d| d.main), Some(ScreenPpi::Unread), "the display is being read");
|
||||
assert_eq!(rig.reads.get(), 3);
|
||||
rig.finish(sizes(3));
|
||||
let sharper = rig.tick(6.1, true).and_then(|d| d.main.ppi());
|
||||
assert!(sharper.zip(right).is_some_and(|(s, r)| s > r), "more pixels on the same glass: {sharper:?}, {right:?}");
|
||||
// winit still gives the window's display at its old resolution: it is found by its name.
|
||||
let mut old = rig.displays[1].clone();
|
||||
old.size = PhysicalSize::new(1920, 1080);
|
||||
rig.lagging = Some(old);
|
||||
rig.window_scale = 1.25;
|
||||
let lagging = rig.tick(7.2, true).and_then(|d| d.main.ppi());
|
||||
assert!(lagging.zip(sharper).is_some_and(|(l, s)| (l * 1.25 - s).abs() < 1e-9), "{lagging:?} from {sharper:?}");
|
||||
rig.lagging = None;
|
||||
// It changes again and this time the reading fails: its density is unread.
|
||||
rig.displays[1].size = PhysicalSize::new(3840, 2160);
|
||||
let reading = rig.tick(8.5, true).unwrap_or_else(|| panic!("a report"));
|
||||
assert_eq!(reading.main, ScreenPpi::Unread, "the display is being read: {reading:?}");
|
||||
assert!(reading.screens.iter().any(|s| s.rect[2] == 3840 && s.ppi == ScreenPpi::Unread), "listed where it is now, unread: {reading:?}");
|
||||
rig.finish(Err("the display server went away".into()));
|
||||
assert_eq!(rig.tick(8.6, true), None, "the failed reading leaves it unread");
|
||||
}
|
||||
|
||||
/// A display that changes while a reading runs is read as soon as that reading ends.
|
||||
#[test]
|
||||
fn a_change_during_a_reading_is_read_when_it_ends() {
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.displays[1].size = PhysicalSize::new(2560, 1440);
|
||||
rig.tick(1.0, true);
|
||||
assert_eq!(rig.reads.get(), 1, "one reading at a time");
|
||||
rig.finish(sizes(2));
|
||||
rig.tick(1.2, true);
|
||||
assert_eq!(rig.reads.get(), 2, "the changed display is read at once");
|
||||
}
|
||||
|
||||
/// A display whose size could not be read does not hold back the others, and the displays are
|
||||
/// read again after a while.
|
||||
#[test]
|
||||
fn one_display_that_fails_leaves_the_others() {
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.finish(Ok(vec![Ok(Some(SIZES[0])), Err("no answer".into())]));
|
||||
let got = rig.tick(0.1, true).unwrap_or_else(|| panic!("the densities"));
|
||||
assert!(got.main.ppi().is_some() && got.screens[1].ppi == ScreenPpi::Unread, "the display that did not answer is unread: {got:?}");
|
||||
rig.tick(5.0, true);
|
||||
assert_eq!(rig.reads.get(), 1, "not again at once");
|
||||
rig.tick(0.1 + RETRY_AFTER, true);
|
||||
assert_eq!(rig.reads.get(), 2, "tried again");
|
||||
rig.finish(sizes(2));
|
||||
let full = rig.tick(11.0, true).unwrap_or_else(|| panic!("the densities"));
|
||||
assert!(full.screens.iter().all(|s| s.ppi.ppi().is_some()), "{full:?}");
|
||||
rig.tick(30.0, true);
|
||||
assert_eq!(rig.reads.get(), 2, "and left alone once every display was read");
|
||||
// A display joins, and the window's display, unchanged, fails to answer: it keeps its size.
|
||||
rig.displays.push(display("third", 3840));
|
||||
rig.tick(32.0, true);
|
||||
rig.finish(Ok(vec![Err("no answer".into()), Ok(Some(SIZES[1])), Ok(Some(SIZES[0]))]));
|
||||
let kept = rig.tick(32.1, true).unwrap_or_else(|| panic!("the densities"));
|
||||
assert!(kept.main.ppi().is_some() && kept.main == full.main, "{kept:?}");
|
||||
// A window on no display has its density unread.
|
||||
rig.current = 9;
|
||||
assert_eq!(rig.tick(34.0, true).map(|d| d.main), Some(ScreenPpi::Unread));
|
||||
// The window's display fails to answer the first reading: its density is unread, not a
|
||||
// display without a size.
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.finish(Ok(vec![Err("no answer".into()), Ok(Some(SIZES[1]))]));
|
||||
let first = rig.tick(0.1, true).unwrap_or_else(|| panic!("the densities"));
|
||||
assert_eq!((first.main, first.screens[0].ppi), (ScreenPpi::Unread, ScreenPpi::Unread), "{first:?}");
|
||||
}
|
||||
|
||||
/// A reading that fails, or a thread that cannot start, is tried again after a while; the
|
||||
/// same displays are not read on every listing until then.
|
||||
#[test]
|
||||
fn a_failed_reading_is_tried_again() {
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.finish(Err("the display server went away".into()));
|
||||
assert_eq!(rig.tick(1.0, true), None);
|
||||
assert_eq!(rig.reads.get(), 1, "not again at once");
|
||||
rig.tick(5.0, true);
|
||||
assert_eq!(rig.reads.get(), 1);
|
||||
rig.tick(1.0 + RETRY_AFTER, true);
|
||||
assert_eq!(rig.reads.get(), 2, "tried again");
|
||||
rig.finish(sizes(2));
|
||||
assert!(rig.tick(12.0, true).is_some_and(|d| d.main.ppi().is_some()), "and read");
|
||||
let mut rig = Rig::new();
|
||||
rig.fail_to_start = true;
|
||||
rig.tick(0.0, true);
|
||||
rig.tick(1.0 + RETRY_AFTER, true);
|
||||
assert_eq!(rig.reads.get(), 2, "a thread that did not start is tried again too");
|
||||
}
|
||||
|
||||
/// Displays that list the same are read again a while after the last reading, so a display
|
||||
/// replaced by one on the same connector at the same resolution and scale gets its own size.
|
||||
#[test]
|
||||
fn displays_that_list_the_same_are_read_again_after_a_while() {
|
||||
let mut rig = Rig::new();
|
||||
rig.tick(0.0, true);
|
||||
rig.finish(sizes(2));
|
||||
let first = rig.tick(0.1, true).unwrap_or_else(|| panic!("the densities"));
|
||||
rig.tick(0.1 + READ_AGAIN_AFTER - 1.0, true);
|
||||
assert_eq!(rig.reads.get(), 1, "not before the time is up");
|
||||
rig.tick(0.1 + READ_AGAIN_AFTER, true);
|
||||
assert_eq!(rig.reads.get(), 2, "read again");
|
||||
rig.finish(Ok(vec![Ok(Some(SIZES[1])), Ok(Some(SIZES[0]))]));
|
||||
let replaced = rig.tick(0.2 + READ_AGAIN_AFTER, true).unwrap_or_else(|| panic!("the densities"));
|
||||
assert!(replaced.main.ppi().is_some() && replaced.main != first.main, "the new panel's density: {first:?} then {replaced:?}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//! Windows: a monitor's raw density, the pixels per inch of the screen itself as Windows reads it
|
||||
//! from the monitor, for Display Print Size at 100% Zoom (`crate::screen_density`).
|
||||
//!
|
||||
//! `GetDpiForMonitor` is a C API with no safe binding, hence the scoped `unsafe_code` allowance.
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use windows::Win32::Graphics::Gdi::HMONITOR;
|
||||
use windows::Win32::UI::HiDpi::{GetDpiForMonitor, MDT_RAW_DPI};
|
||||
|
||||
/// The horizontal and vertical pixels per inch of the monitor winit's handle `monitor` names:
|
||||
/// `None` when Windows reports no density for it, an error when the call fails.
|
||||
pub(crate) fn raw_dpi(monitor: isize) -> Result<Option<[f64; 2]>, String> {
|
||||
let (mut x, mut y) = (0u32, 0u32);
|
||||
// SAFETY: `monitor` is a handle winit got from Windows for a connected monitor; a handle that
|
||||
// has gone stale makes the call fail, which returns an error. Both pointers point at live
|
||||
// `u32`s for the length of the call.
|
||||
unsafe { GetDpiForMonitor(HMONITOR(monitor as *mut core::ffi::c_void), MDT_RAW_DPI, &mut x, &mut y) }
|
||||
.map_err(|e| format!("couldn't read a monitor's density: {e}"))?;
|
||||
Ok((x > 0 && y > 0).then(|| [f64::from(x), f64::from(y)]))
|
||||
}
|
||||
@@ -93,6 +93,8 @@ pub struct Prefs {
|
||||
/// Artboard Options › Update While Dragging: the area outside the artboards stays darker while
|
||||
/// the Artboard tool moves or resizes an artboard; off, it draws as usual until the drag ends.
|
||||
pub artboard_update_while_dragging: bool,
|
||||
/// General › Display Print Size at 100% Zoom (on by default): 100% shows an inch of the
|
||||
/// document in an inch of the display. A preferences file without the key reads as on.
|
||||
pub display_print_size: bool,
|
||||
pub double_click_to_isolate: bool,
|
||||
pub transform_pattern_tiles: bool,
|
||||
@@ -503,7 +505,7 @@ impl Default for Prefs {
|
||||
type_glyph_bounds: false,
|
||||
fade_region_outside_artboard: true,
|
||||
artboard_update_while_dragging: true,
|
||||
display_print_size: false,
|
||||
display_print_size: true,
|
||||
double_click_to_isolate: true,
|
||||
transform_pattern_tiles: false,
|
||||
scale_corners: false,
|
||||
|
||||
@@ -197,3 +197,14 @@ fn hold_shortcut_preferences() {
|
||||
assert_eq!(restored.key_hold_delay(), 1.0);
|
||||
assert!(!restored.hold_shortcuts);
|
||||
}
|
||||
|
||||
/// Display Print Size at 100% Zoom is on by default, also for saved preferences that predate the
|
||||
/// key; a saved choice to turn it off stays off.
|
||||
#[test]
|
||||
fn display_print_size_is_on_unless_turned_off() {
|
||||
assert!(Session::new().prefs.display_print_size);
|
||||
let older: Prefs = serde_json::from_value(json!({"showToolTips": true})).unwrap();
|
||||
assert!(older.display_print_size);
|
||||
let off: Prefs = serde_json::from_value(json!({"displayPrintSize": false})).unwrap();
|
||||
assert!(!off.display_print_size);
|
||||
}
|
||||
|
||||
@@ -484,7 +484,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"view.actualSize",
|
||||
"Actual Size",
|
||||
"Cmd+1",
|
||||
"{} 100%: with Display Print Size at 100% Zoom off, one document point per screen point; on, one document inch fills 96 screen points (an inch at the system's reference density, whatever the display scaling); the same at every UI Scaling",
|
||||
"{} 100%: with Display Print Size at 100% Zoom off, one document point per screen point; on, one document inch fills an inch of the display that shows the window, measured from the physical size the system reports for it, or 96 screen points where it reports none or a size no display has; the same at every UI Scaling",
|
||||
),
|
||||
("view.setZoom", "Set Zoom", "", "{zoom: percent, center?: [x,y]}"),
|
||||
(
|
||||
|
||||
@@ -382,7 +382,8 @@ impl VectorcraftApp {
|
||||
self.host = Arc::new(self.host.with_lang(lang));
|
||||
}
|
||||
let native_ppp = self.ui_ctx.as_ref().map_or(1.0, |ctx| ctx.pixels_per_point() / ctx.zoom_factor());
|
||||
let root = root_env(&self.session.prefs, native_ppp);
|
||||
// The canvas steps through the zoom stops of the current window's display.
|
||||
let root = root_env(&self.session.prefs, native_ppp, self.print_ppi());
|
||||
FrameInput::new(root).commands(menus::model::command_input(self)).host(self.host.clone())
|
||||
}
|
||||
|
||||
@@ -441,6 +442,9 @@ impl VectorcraftApp {
|
||||
let now = self.now();
|
||||
self.perf.fps = self.frame_rate.frame(now, self.perf.frame_ms / 1000.0);
|
||||
self.sync_views();
|
||||
// A document that moved between the main window and a floating OS window, or opened, takes
|
||||
// the density of the display that shows it.
|
||||
self.settle_screen_ppi_if_changed();
|
||||
self.refresh_replace_font_warning(false);
|
||||
updates_ui::tick(self, ctx);
|
||||
// Read the system clipboard only when that alone decides whether Paste is enabled. A
|
||||
@@ -692,15 +696,16 @@ impl VectorcraftApp {
|
||||
}
|
||||
|
||||
/// The root values the preferences give every frame: the theme, the interface scale (UI Scaling
|
||||
/// over the display's `native_ppp`), Show Tool Tips, the zoom stops and which drags scrub a value
|
||||
/// (Scrub Numeric Fields: the side label only, or nothing).
|
||||
pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32) -> RootEnv {
|
||||
/// over the display's `native_ppp`), Show Tool Tips, the zoom stops (100% at `print` screen points
|
||||
/// to an inch, [`crate::state::print_ppi`]) and which drags scrub a value (Scrub Numeric Fields: the
|
||||
/// side label only, or nothing).
|
||||
pub(crate) fn root_env(prefs: &vectorcraft_engine::Prefs, native_ppp: f32, print: Option<f64>) -> RootEnv {
|
||||
let (theme, mode, accent) = theme::root_theme(prefs);
|
||||
// A hand-edited preferences file must not scale the interface to nothing.
|
||||
let scaling = if prefs.ui_scaling.is_finite() && prefs.ui_scaling > 0.0 { prefs.ui_scaling as f32 } else { 1.0 };
|
||||
let mut root = RootEnv::new().theme(theme).mode(mode).accent(accent).scale(Scale::new(scaling)).tooltips(prefs.show_tool_tips);
|
||||
root.sizes = theme::app_sizes();
|
||||
root.values.set(view::zoom_scheme(prefs, native_ppp));
|
||||
root.values.set(view::zoom_scheme(print, native_ppp));
|
||||
root.values.set(if prefs.scrub_numeric_fields { ScrubDrags::LabelOnly } else { ScrubDrags::Off });
|
||||
// Number fields as production drew them: the value and its unit one run at the start ("720 pt"), percentages
|
||||
// whole and lengths to a thousandth of a point (357.114 pt).
|
||||
|
||||
@@ -19,10 +19,21 @@ pub(crate) fn navigation(p: &Prefs) -> NavigationOptions {
|
||||
options
|
||||
}
|
||||
|
||||
/// The zoom rungs and range of the app, with 100 % at the device zoom Display Print Size at 100 %
|
||||
/// Zoom gives on a display of `native_ppp` pixels per point.
|
||||
pub(crate) fn zoom_scheme(p: &Prefs, native_ppp: f32) -> ZoomScheme {
|
||||
ZoomScheme::ILLUSTRATOR.with_hundred(crate::state::zoom_baseline(p.display_print_size) * f64::from(native_ppp))
|
||||
/// The zoom rungs and range of the app, with 100 % at the device zoom that shows a document inch in
|
||||
/// `print` screen points ([`crate::state::print_ppi`]; one document point per screen point when
|
||||
/// `None`) on a display of `native_ppp` pixels per point.
|
||||
pub(crate) fn zoom_scheme(print: Option<f64>, native_ppp: f32) -> ZoomScheme {
|
||||
ZoomScheme::ILLUSTRATOR.with_hundred(crate::state::zoom_baseline(print) * f64::from(native_ppp))
|
||||
}
|
||||
|
||||
/// Whether view command `command` fits the view to the window (`Some(true)`), sets a zoom
|
||||
/// percentage (`Some(false)`), or leaves the zoom alone (`None`).
|
||||
pub(crate) fn fits_window(command: ViewCommands) -> Option<bool> {
|
||||
match command {
|
||||
ViewCommands::FitOnScreen | ViewCommands::FillScreen | ViewCommands::FitArtboard | ViewCommands::FitLayers => Some(true),
|
||||
ViewCommands::RotateClockwise | ViewCommands::RotateCounterclockwise | ViewCommands::ResetRotation => None,
|
||||
_ => Some(false),
|
||||
}
|
||||
}
|
||||
|
||||
impl VectorcraftApp {
|
||||
@@ -47,8 +58,11 @@ impl VectorcraftApp {
|
||||
}
|
||||
self.views.truncate(docs.len());
|
||||
self.views.extend(docs.iter().skip(self.views.len()).map(View::of));
|
||||
// A new view counts its zoom from the main window's display, where it is first shown.
|
||||
let main = self.main_ppi();
|
||||
for (view, doc) in self.views.iter_mut().zip(docs) {
|
||||
view.artboard = view.artboard.min(doc.doc.artboards.len().saturating_sub(1));
|
||||
view.shown_ppi.get_or_insert(main);
|
||||
}
|
||||
let uids: Vec<u64> = docs.iter().map(|d| d.uid).collect();
|
||||
if let Some(ctx) = &self.ui_ctx {
|
||||
@@ -135,6 +149,169 @@ impl VectorcraftApp {
|
||||
self.session.active().map_or(vectorcraft_geom::Point::ZERO, |d| d.doc.ruler_origin_for(artboard))
|
||||
}
|
||||
|
||||
/// The screen points an inch takes at 100% zoom with Display Print Size at 100% Zoom on, for
|
||||
/// the current window's display; `None` with it off ([`crate::state::print_ppi`]).
|
||||
pub(crate) fn print_ppi(&self) -> Option<f64> {
|
||||
self.print_ppi_of(crate::doc_windows::current(self))
|
||||
}
|
||||
|
||||
/// [`Self::print_ppi`] for window `w`: the density its view's zoom counts from, which is the
|
||||
/// density of the display that shows it once [`Self::settle_screen_ppi`] has run.
|
||||
pub(crate) fn print_ppi_of(&self, w: Option<crate::doc_windows::Win>) -> Option<f64> {
|
||||
let counted = w.and_then(|w| crate::doc_windows::view(self, w)?.shown_ppi);
|
||||
let ppi = counted.unwrap_or_else(|| w.map_or(self.main_ppi(), |w| self.window_ppi(w)));
|
||||
crate::state::print_ppi(self.session.prefs.display_print_size, ppi.ppi())
|
||||
}
|
||||
|
||||
/// The density of the display that shows window `w`: its own OS window's when it floats in one
|
||||
/// that the host found on a display, else the main window's ([`Self::main_ppi`]).
|
||||
fn window_ppi(&self, w: crate::doc_windows::Win) -> crate::ScreenPpi {
|
||||
crate::doc_windows::screen_ppi(self, w).unwrap_or(self.main_ppi())
|
||||
}
|
||||
|
||||
/// The density the main window's views count from: the host's reading, or while the main
|
||||
/// window's display has not answered, the last reading, so every view there counts from the
|
||||
/// same density.
|
||||
fn main_ppi(&self) -> crate::ScreenPpi {
|
||||
match self.services.screen_ppi {
|
||||
crate::ScreenPpi::Unread => self.canvas.windows.main_read.unwrap_or(crate::ScreenPpi::Unread),
|
||||
read => read,
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes `ppi` as the density the host read for the main window's display, `None` for a
|
||||
/// display that reports no size ([`crate::Services::screen_ppi`]), and settles the views
|
||||
/// ([`Self::settle_screen_ppi`]). Returns whether the density changed.
|
||||
pub fn set_screen_ppi(&mut self, ppi: Option<f64>) -> bool {
|
||||
self.set_screen_reading(crate::ScreenPpi::Read(ppi))
|
||||
}
|
||||
|
||||
/// [`Self::set_screen_ppi`] with the host's reading, [`crate::ScreenPpi::Unread`] while the
|
||||
/// main window's display is unknown or has not answered.
|
||||
pub fn set_screen_reading(&mut self, ppi: crate::ScreenPpi) -> bool {
|
||||
if self.services.screen_ppi == ppi {
|
||||
return false;
|
||||
}
|
||||
// A switch of the preference made since the last frame applies before the reading does.
|
||||
self.follow_print_size_switch();
|
||||
self.services.screen_ppi = ppi;
|
||||
if ppi != crate::ScreenPpi::Unread && self.session.prefs.display_print_size {
|
||||
self.canvas.windows.main_read = Some(ppi);
|
||||
}
|
||||
self.settle_screen_ppi();
|
||||
true
|
||||
}
|
||||
|
||||
/// Gives each window's view the density of the display that shows it. With Display Print Size
|
||||
/// at 100% Zoom on, a view moved between two displays the host has read keeps its zoom
|
||||
/// percentage (a display that reports no size counts 96 points to an inch), so the art keeps
|
||||
/// its physical size on the new display; the views of other displays keep their zoom. At the
|
||||
/// first reading of a view's display, a view that still has the zoom a fit or the document's
|
||||
/// saved view gave it keeps that zoom, and any other view keeps its percentage, counted from
|
||||
/// 96 points to an inch until then.
|
||||
pub(crate) fn settle_screen_ppi(&mut self) {
|
||||
for w in crate::doc_windows::windows(self) {
|
||||
self.settle_window_ppi(w, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// [`Self::settle_screen_ppi`] for window `w` alone. With `keep` false (a fit made for the
|
||||
/// window), the view counts from the display's reading, without a change of zoom; while the
|
||||
/// display is being read, it counts from the last reading, and the reading still to come
|
||||
/// leaves its zoom alone.
|
||||
pub(crate) fn settle_window_ppi(&mut self, w: crate::doc_windows::Win, keep: bool) {
|
||||
let on = self.session.prefs.display_print_size;
|
||||
let now = self.window_ppi(w);
|
||||
let reading = crate::doc_windows::screen_ppi(self, w).unwrap_or(self.services.screen_ppi);
|
||||
let Some(v) = crate::doc_windows::view_mut(self, w) else { return };
|
||||
// Off, a view counts from no reading, so the first one after the preference is turned on
|
||||
// keeps the zoom chosen meanwhile.
|
||||
if !on {
|
||||
v.shown_ppi = Some(crate::ScreenPpi::Unread);
|
||||
v.fit_unread = false;
|
||||
return;
|
||||
}
|
||||
if !keep {
|
||||
// While the display is being read, the fit counts from the last reading, as the other
|
||||
// views there do, and the reading keeps its zoom. A floating window whose display has
|
||||
// not answered keeps counting from the density it was last shown at.
|
||||
match now {
|
||||
crate::ScreenPpi::Unread => {
|
||||
v.shown_ppi.get_or_insert(now);
|
||||
}
|
||||
read => v.shown_ppi = Some(read),
|
||||
}
|
||||
v.fit_unread = reading == crate::ScreenPpi::Unread;
|
||||
return;
|
||||
}
|
||||
// A fit made while its display is being read waits for that reading.
|
||||
if v.fit_unread && reading == crate::ScreenPpi::Unread {
|
||||
return;
|
||||
}
|
||||
// A display that has not answered yet leaves the view counting from the last one read, so
|
||||
// the answer, when it comes, keeps the zoom percentage.
|
||||
let crate::ScreenPpi::Read(after) = now else {
|
||||
v.shown_ppi.get_or_insert(now);
|
||||
return;
|
||||
};
|
||||
let fitted = v.fit_zoom == Some(v.zoom);
|
||||
let before = match v.shown_ppi {
|
||||
_ if fitted && v.fit_unread => None,
|
||||
Some(crate::ScreenPpi::Read(before)) => Some(before),
|
||||
_ if fitted => None,
|
||||
_ => Some(None),
|
||||
};
|
||||
v.fit_unread = false;
|
||||
if let Some(before) = before
|
||||
&& before != after
|
||||
&& let (Some(b), Some(a)) = (crate::state::print_ppi(on, before), crate::state::print_ppi(on, after))
|
||||
{
|
||||
v.zoom = (v.zoom * a / b).clamp(0.0313, 640.0);
|
||||
}
|
||||
v.shown_ppi = Some(now);
|
||||
}
|
||||
|
||||
/// [`Self::settle_screen_ppi`] when the main window's density or a floating window's changed
|
||||
/// since it last ran from here, or a window started or stopped floating, or Presentation Mode
|
||||
/// started or ended. With Display Print Size at 100% Zoom off, the desktop host does not read
|
||||
/// the displays: every density read before is forgotten, so the readings after the preference
|
||||
/// is turned on again count as first readings.
|
||||
pub(crate) fn settle_screen_ppi_if_changed(&mut self) {
|
||||
self.follow_print_size_switch();
|
||||
let key = (self.services.screen_ppi, crate::doc_windows::floating_ppi(self));
|
||||
if self.canvas.windows.settled.as_ref() != Some(&key) {
|
||||
self.settle_screen_ppi();
|
||||
self.canvas.windows.settled = Some(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes in a change of Display Print Size at 100% Zoom since this last ran: turned off, every
|
||||
/// density read before is forgotten; turned on, every view's zoom counts as the one its first
|
||||
/// reading keeps.
|
||||
fn follow_print_size_switch(&mut self) {
|
||||
let off = !self.session.prefs.display_print_size;
|
||||
let was_off = std::mem::replace(&mut self.canvas.windows.print_size_off, off);
|
||||
if off && !was_off {
|
||||
crate::doc_windows::forget_ppi(self);
|
||||
self.services.screen_ppi = crate::ScreenPpi::Unread;
|
||||
self.canvas.windows.main_read = None;
|
||||
self.services.screens.clear();
|
||||
for w in crate::doc_windows::windows(self) {
|
||||
if let Some(v) = crate::doc_windows::view_mut(self, w) {
|
||||
v.shown_ppi = Some(crate::ScreenPpi::Unread);
|
||||
}
|
||||
}
|
||||
}
|
||||
if was_off && !off {
|
||||
// The zoom chosen while it was off stays when the displays are read.
|
||||
for w in crate::doc_windows::windows(self) {
|
||||
if let Some(v) = crate::doc_windows::view_mut(self, w) {
|
||||
v.fit_zoom = Some(v.zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn view_mut(&mut self) -> Option<&mut View> {
|
||||
self.sync_views();
|
||||
let i = self.session.active_index()?;
|
||||
@@ -178,17 +355,38 @@ impl VectorcraftApp {
|
||||
};
|
||||
let target = crate::canvas::view_target(self, win);
|
||||
let (scaling, ppp) = (self.ui_scaling(), ctx.pixels_per_point());
|
||||
let scheme = zoom_scheme(&self.session.prefs, ppp / ctx.zoom_factor());
|
||||
self.before_view_command(win, command);
|
||||
let scheme = zoom_scheme(self.print_ppi_of(Some(win)), ppp / ctx.zoom_factor());
|
||||
let Some(v) = self.view_mut() else { return };
|
||||
let before = *v;
|
||||
let mut cv = v.canvas(scaling, v.rect);
|
||||
let layers = move || bounds;
|
||||
if command.apply(&mut cv, &target, Some(&layers), ppp, &scheme) {
|
||||
v.set_canvas(&cv, scaling);
|
||||
self.after_view_command(win, command);
|
||||
self.ease_view(before);
|
||||
}
|
||||
}
|
||||
|
||||
/// Before view command `command` runs on window `w`'s view: a fit to the window is made for the
|
||||
/// display the window is on now, and a zoom percentage (Actual Size) counts from the density the
|
||||
/// view counts from, which a reading still to come rescales (Display Print Size at 100% Zoom).
|
||||
pub(crate) fn before_view_command(&mut self, w: crate::doc_windows::Win, command: ViewCommands) {
|
||||
if let Some(fit) = fits_window(command) {
|
||||
self.settle_window_ppi(w, !fit);
|
||||
}
|
||||
}
|
||||
|
||||
/// After view command `command` ran on window `w`'s view: a fit to the window is kept at the
|
||||
/// first reading of its display; a zoom percentage keeps its percentage then.
|
||||
pub(crate) fn after_view_command(&mut self, w: crate::doc_windows::Win, command: ViewCommands) {
|
||||
if let Some(fit) = fits_window(command)
|
||||
&& let Some(v) = crate::doc_windows::view_mut(self, w)
|
||||
{
|
||||
v.fit_zoom = fit.then_some(v.zoom);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn view_info(&self) -> ViewInfo {
|
||||
ViewInfo {
|
||||
// The tools measure their tolerances and widgets in the interface's points.
|
||||
|
||||
@@ -147,9 +147,19 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
// A measuring run applies no view request: the view, its request and its fit wait for the pass
|
||||
// that shows the canvas.
|
||||
let measuring = craft::ui::runtime::measure::active(ui.ctx());
|
||||
let Some(view) = doc_windows::view_mut(app, win) else { return false };
|
||||
// Presentation Mode shows the active artboard on the whole screen: it fits again when the screen changes.
|
||||
let refit = !view.fitted || (presenting && view.rect != area);
|
||||
let refits = |v: &crate::state::View| !v.fitted || (presenting && v.rect != area);
|
||||
// The view command this pass runs, made for the display the window is on (Display Print Size at 100% Zoom).
|
||||
let command = doc_windows::view(app, win)
|
||||
.filter(|_| !measuring)
|
||||
.and_then(|v| v.request.map(|(r, _)| r.command()).or_else(|| refits(v).then_some(ViewCommands::FitArtboard)));
|
||||
if let Some(command) = command {
|
||||
app.before_view_command(win, command);
|
||||
}
|
||||
let ppp = ui.ctx().pixels_per_point();
|
||||
let scheme = crate::app::view::zoom_scheme(app.print_ppi_of(Some(win)), ppp / ui.ctx().zoom_factor());
|
||||
let Some(view) = doc_windows::view_mut(app, win) else { return false };
|
||||
let refit = refits(view);
|
||||
let (request, moved) = if measuring {
|
||||
(view.request, view.moved)
|
||||
} else {
|
||||
@@ -165,6 +175,16 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
}
|
||||
let mut cv = view.canvas(scaling, area);
|
||||
let given = cv;
|
||||
// A zoom percentage (Actual Size) counts from the density of the display that shows this
|
||||
// window: it runs here with that display's zoom stops, which the canvas's own may not be.
|
||||
let mut moved = moved;
|
||||
if let Some(request) = queued.first().copied().filter(|r| crate::app::view::fits_window(r.command()) == Some(false)) {
|
||||
let layers = move || bounds;
|
||||
if request.command().apply(&mut cv, &target, Some(&layers), ppp, &scheme) && matches!(request, ViewRequest::Command(_)) {
|
||||
moved = Some(ViewMove::Ease(given));
|
||||
}
|
||||
queued.clear();
|
||||
}
|
||||
let (x, y, zero) = rulers::texts(app, win);
|
||||
let strips = if app.ui.view.rulers && !presenting {
|
||||
Some(rulers::strips(zero, kind))
|
||||
@@ -223,6 +243,9 @@ pub(crate) fn show_document(app: &mut VectorcraftApp, ui: &mut Ui, win: Win, kin
|
||||
// An edit of the compass or a scroll bar reaches the next pass, which stops a running ease.
|
||||
view.moved = jumped.then_some(ViewMove::Jump);
|
||||
}
|
||||
if let Some(command) = command {
|
||||
app.after_view_command(win, command);
|
||||
}
|
||||
if kind == BodyKind::Pane || presenting {
|
||||
return pressed;
|
||||
}
|
||||
@@ -333,7 +356,7 @@ fn grids(app: &VectorcraftApp, ui: &mut Ui, space: &CanvasSpace, win: Win) {
|
||||
if let Some((grid, in_back)) = app.session.documents().get(win.0).and_then(|st| grid::document_grid(app, st)) {
|
||||
let _ = if in_back { grid.picture() } else { grid }.show_at(ui, space.view.rect);
|
||||
}
|
||||
if let Some(grid) = grid::pixel_grid(app) {
|
||||
if let Some(grid) = grid::pixel_grid(app, app.print_ppi_of(Some(win))) {
|
||||
let _ = grid.show_at(ui, space.view.rect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,13 +44,15 @@ pub(super) fn grid_look(prefs: &vectorcraft_engine::Prefs) -> (GridLine, Color32
|
||||
}
|
||||
|
||||
/// The pixel grid (Guides & Grid › Show Pixel Grid (Above 600% Zoom)): a line at every document
|
||||
/// pixel in Pixel Preview, which the control draws from [`PIXEL_GRID_ZOOM`] on (its `min_zoom` is
|
||||
/// the device zoom, as the view's).
|
||||
pub(super) fn pixel_grid(app: &VectorcraftApp) -> Option<CanvasGrid> {
|
||||
/// pixel in Pixel Preview, which the control draws from [`PIXEL_GRID_ZOOM`] on as the zoom field
|
||||
/// counts it, with `print` screen points to an inch at 100% ([`crate::state::print_ppi`]; its
|
||||
/// `min_zoom` is the device zoom, as the view's).
|
||||
pub(super) fn pixel_grid(app: &VectorcraftApp, print: Option<f64>) -> Option<CanvasGrid> {
|
||||
if app.ui.screen_mode >= 3 || !app.ui.view.pixel_preview || !app.session.prefs.show_pixel_grid {
|
||||
return None;
|
||||
}
|
||||
Some(CanvasGrid::new("Pixel grid").spacing((1.0, 1.0).into()).subdivisions(1).color(DataColor::new(PIXEL_GRID)).min_zoom(PIXEL_GRID_ZOOM))
|
||||
let min_zoom = PIXEL_GRID_ZOOM * crate::state::zoom_baseline(print);
|
||||
Some(CanvasGrid::new("Pixel grid").spacing((1.0, 1.0).into()).subdivisions(1).color(DataColor::new(PIXEL_GRID)).min_zoom(min_zoom))
|
||||
}
|
||||
|
||||
/// A `#rrggbb` colour preference, `fallback` when it doesn't parse.
|
||||
|
||||
@@ -105,9 +105,9 @@ fn trim_view_hides_the_guides_and_the_grid() {
|
||||
#[test]
|
||||
fn pixel_grid_shows_in_pixel_preview_from_600_percent() {
|
||||
let mut app = app();
|
||||
assert!(pixel_grid(&app).is_none(), "not in Pixel Preview");
|
||||
assert!(pixel_grid(&app, None).is_none(), "not in Pixel Preview");
|
||||
app.ui.view.pixel_preview = true;
|
||||
assert!(pixel_grid(&app).is_some());
|
||||
assert!(pixel_grid(&app, None).is_some());
|
||||
app.session.execute("prefs.set", &json!({"key": "showPixelGrid", "value": false})).unwrap();
|
||||
assert!(pixel_grid(&app).is_none(), "the preference is off");
|
||||
assert!(pixel_grid(&app, None).is_none(), "the preference is off");
|
||||
}
|
||||
|
||||
@@ -415,6 +415,36 @@ fn art_area(app: &VectorcraftApp, w: Win, cell: egui::Rect) -> egui::Rect {
|
||||
crate::doc_windows::view(app, w).map(|v| v.rect).filter(|r| r.is_positive()).unwrap_or(cell)
|
||||
}
|
||||
|
||||
/// Whether window `w`'s view is still where a pane fit left it, in a pane of `size`.
|
||||
pub(crate) fn follows_fit(app: &VectorcraftApp, w: Win, size: Option<egui::Vec2>) -> bool {
|
||||
let fit = slot(app, w).and_then(|s| app.canvas.panes.fits.get(&s).copied());
|
||||
crate::doc_windows::view(app, w).is_some_and(|v| v.fitted && fit.is_some_and(|(s, z, c)| Some(s) == size && z == v.zoom && c == v.center))
|
||||
}
|
||||
|
||||
/// Records window `w`'s view as fitted to a pane of `size` at its zoom and center now, as
|
||||
/// [`note_fits`] does after a fit.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn note_fit(app: &mut VectorcraftApp, w: Win, size: egui::Vec2) {
|
||||
if let (Some(s), Some(v)) = (slot(app, w), crate::doc_windows::view(app, w).copied()) {
|
||||
app.canvas.panes.fits.insert(s, (size, v.zoom, v.center));
|
||||
}
|
||||
}
|
||||
|
||||
/// The pane fit recorded for window `w` ([`note_fits`]).
|
||||
#[cfg(test)]
|
||||
pub(crate) fn fit_of(app: &VectorcraftApp, w: Win) -> Option<(egui::Vec2, f64, Point)> {
|
||||
slot(app, w).and_then(|s| app.canvas.panes.fits.get(&s).copied())
|
||||
}
|
||||
|
||||
/// Window `w`'s view, rescaled while it still fitted its pane ([`follows_fit`]), keeps fitting the
|
||||
/// pane at its new zoom and center.
|
||||
pub(crate) fn refollow_fit(app: &mut VectorcraftApp, w: Win) {
|
||||
let (Some(s), Some(v)) = (slot(app, w), crate::doc_windows::view(app, w).copied()) else { return };
|
||||
if let Some(fit) = app.canvas.panes.fits.get_mut(&s) {
|
||||
*fit = (fit.0, v.zoom, v.center);
|
||||
}
|
||||
}
|
||||
|
||||
/// Unfit each window whose view is still where a pane fit left it when its view's area (`areas`,
|
||||
/// by window) has changed size, as when the window or a panel is resized: it fits its pane again.
|
||||
/// A view zoomed or scrolled since keeps its place. → which of `areas`' views are unfitted now.
|
||||
@@ -454,16 +484,24 @@ fn fit_pane(v: &mut View, doc: &vectorcraft_doc::Document, area: egui::Rect, (ui
|
||||
craft::behavior::canvas::zoom::fit_rect(&mut view, target, target.size(), pixels_per_point, Vec2::new(FIT_MARGIN, FIT_MARGIN), scheme);
|
||||
v.set_canvas(&view, ui_zoom);
|
||||
v.fitted = true;
|
||||
v.fit_zoom = Some(v.zoom);
|
||||
}
|
||||
}
|
||||
|
||||
/// Fit window `w`'s view to its pane when it is unfitted, with the zoom stops of `ui`'s scope.
|
||||
/// Fit window `w`'s view to its pane when it is unfitted, with the zoom stops of the display that
|
||||
/// shows the pane (Display Print Size at 100% Zoom).
|
||||
fn fit_window(app: &mut VectorcraftApp, ui: &Ui, w: Win, cell: egui::Rect) {
|
||||
if !crate::doc_windows::view(app, w).is_some_and(|v| !v.fitted) {
|
||||
return;
|
||||
}
|
||||
let area = art_area(app, w, cell);
|
||||
let Some(doc) = app.session.documents().get(w.0).map(|st| st.doc.clone()) else { return };
|
||||
let scheme = Env::of(ui).get::<ZoomScheme>();
|
||||
let scaling = (app.ui_scaling(), ui.ctx().pixels_per_point());
|
||||
if let Some(v) = crate::doc_windows::view_mut(app, w).filter(|v| !v.fitted) {
|
||||
// The fit is made for the display the pane is on.
|
||||
app.settle_window_ppi(w, false);
|
||||
let ctx = ui.ctx();
|
||||
let scheme = crate::app::view::zoom_scheme(app.print_ppi_of(Some(w)), ctx.pixels_per_point() / ctx.zoom_factor());
|
||||
let scaling = (app.ui_scaling(), ctx.pixels_per_point());
|
||||
if let Some(v) = crate::doc_windows::view_mut(app, w) {
|
||||
fit_pane(v, &doc, area, scaling, &scheme);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2946,12 +2946,14 @@ fn hidden_characters_mark_no_space_at_a_bullet() {
|
||||
assert_eq!((plain, dots(&t)), (2, 2));
|
||||
}
|
||||
|
||||
/// General › Display Print Size at 100% Zoom (#394): Actual Size shows the document larger with it
|
||||
/// on (an inch at 96 screen points) than off (a point at a point), and reads 100% either way.
|
||||
/// General › Display Print Size at 100% Zoom (#394, #9051): Actual Size shows the document larger
|
||||
/// with it on (an inch at 96 screen points where no display was measured) than off (a point at a
|
||||
/// point), and reads 100% either way.
|
||||
#[test]
|
||||
fn view_actual_size_follows_display_print_size() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 200, "height": 100})).unwrap();
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": false})).unwrap();
|
||||
let ctx = crate::testing::ui_context();
|
||||
// Frames as the hosts run them: the zoom stops come from the preferences through the app's frame input.
|
||||
let frame = |app: &mut VectorcraftApp, ctx: &egui::Context, _: Vec<egui::Event>| {
|
||||
@@ -2966,7 +2968,7 @@ fn view_actual_size_follows_display_print_size() {
|
||||
app.run("view.actualSize", json!({})).unwrap();
|
||||
frame(app, &ctx, vec![]);
|
||||
let view = app.canvas_view().unwrap();
|
||||
let scheme = crate::app::view::zoom_scheme(&app.session.prefs, ctx.pixels_per_point() / ctx.zoom_factor());
|
||||
let scheme = crate::app::view::zoom_scheme(app.print_ppi(), ctx.pixels_per_point() / ctx.zoom_factor());
|
||||
(view.zoom, scheme.percent(craft::behavior::canvas::zoom::device(&view, ctx.pixels_per_point())))
|
||||
};
|
||||
let (off, off_percent) = actual(&mut app);
|
||||
@@ -2976,6 +2978,42 @@ fn view_actual_size_follows_display_print_size() {
|
||||
assert!((off_percent - 100.0).abs() < 1e-9 && (on_percent - 100.0).abs() < 1e-9, "both read 100%: {off_percent}, {on_percent}");
|
||||
}
|
||||
|
||||
/// #9051: with Display Print Size on, Actual Size shows a document inch in an inch of the display
|
||||
/// the window is on, from the density the host measured for it. When the window moves to a display
|
||||
/// of another density, the view keeps its zoom percentage, so the art keeps its physical size there.
|
||||
#[test]
|
||||
fn view_actual_size_fills_an_inch_of_the_measured_display() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 200, "height": 100})).unwrap();
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
let ctx = crate::testing::ui_context();
|
||||
let frame = |app: &mut VectorcraftApp, ctx: &egui::Context| {
|
||||
let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() };
|
||||
crate::testing::part_frame(app, ctx, raw, show);
|
||||
};
|
||||
let run = |app: &mut VectorcraftApp, id: &str| {
|
||||
app.run(id, json!({})).unwrap();
|
||||
frame(app, &ctx);
|
||||
};
|
||||
frame(&mut app, &ctx);
|
||||
run(&mut app, "view.fitArtboard");
|
||||
let fitted = app.view().unwrap().zoom;
|
||||
assert!(app.set_screen_ppi(Some(127.0)));
|
||||
assert_eq!(app.view().unwrap().zoom, fitted, "the first measurement leaves a fitted view alone");
|
||||
run(&mut app, "view.actualSize");
|
||||
assert!((app.view().unwrap().zoom * 72.0 - 127.0).abs() < 1e-6, "72 pt take the display's 127 points to an inch");
|
||||
assert!(app.set_screen_ppi(Some(91.0)), "the window moved to a sparser display");
|
||||
assert!(!app.set_screen_ppi(Some(91.0)), "the same reading changes nothing");
|
||||
assert!((app.view().unwrap().zoom * 72.0 - 91.0).abs() < 1e-6, "100% still fills an inch");
|
||||
assert_eq!(crate::state::zoom_label(app.view().unwrap().zoom, app.print_ppi()), "100%");
|
||||
assert!(app.set_screen_ppi(None), "the window moved to a display that reports no size");
|
||||
assert!((app.view().unwrap().zoom * 72.0 - 96.0).abs() < 1e-6, "100% there is 96 points to an inch");
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": false})).unwrap();
|
||||
let zoom = app.view().unwrap().zoom;
|
||||
assert!(app.set_screen_ppi(Some(110.0)));
|
||||
assert_eq!(app.view().unwrap().zoom, zoom, "off, a move leaves the zoom alone");
|
||||
}
|
||||
|
||||
/// Fit Artboard in Window fits the active artboard as a turned view shows it: with the second of
|
||||
/// two artboards active, at 45° all of it is on the canvas, and the two together are not.
|
||||
#[test]
|
||||
@@ -3030,11 +3068,7 @@ fn space_types_a_space_while_editing_text_and_does_not_pan() {
|
||||
assert_ne!(shown(&mut app), editing, "Cmd+Space shows the magnifier");
|
||||
typing_frame(&mut app, &ctx, vec![button(at, true, Modifiers::COMMAND)]);
|
||||
typing_frame(&mut app, &ctx, vec![button(at, false, Modifiers::COMMAND)]);
|
||||
assert_eq!(
|
||||
app.view().unwrap().zoom,
|
||||
crate::state::next_zoom(before.zoom, true, app.session.prefs.display_print_size),
|
||||
"Cmd+Space click zooms in"
|
||||
);
|
||||
assert_eq!(app.view().unwrap().zoom, crate::state::next_zoom(before.zoom, true, app.print_ppi()), "Cmd+Space click zooms in");
|
||||
typing_frame(&mut app, &ctx, vec![space(false, Modifiers::COMMAND), Event::ModifiersChanged(Modifiers::NONE)]);
|
||||
assert_eq!(plain(&app, id), "a ", "the text is as typed");
|
||||
}
|
||||
|
||||
@@ -27,10 +27,12 @@ fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, (native, ui_zoom): (f32,
|
||||
}
|
||||
|
||||
/// A 512 × 512 pt document shown at `native` device pixels a point and UI Scaling `ui_zoom`, with a
|
||||
/// controlled render worker, and the receiver of the frames it is asked to render.
|
||||
/// controlled render worker, and the receiver of the frames it is asked to render. Display Print
|
||||
/// Size at 100% Zoom is off, so 100% is one document point per screen point.
|
||||
fn shown(native: f32, ui_zoom: f32) -> (VectorcraftApp, egui::Context, std::sync::mpsc::Receiver<crate::render_worker::Job>) {
|
||||
let ctx = crate::testing::ui_context();
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": false})).unwrap();
|
||||
app.run("file.new", json!({"width": 512, "height": 512})).unwrap();
|
||||
// The app's frames zoom the interface by the preference.
|
||||
app.session.prefs.ui_scaling = f64::from(ui_zoom);
|
||||
|
||||
@@ -20,7 +20,7 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if let Some(secs) = next {
|
||||
ui.ctx().request_repaint_after(std::time::Duration::from_secs(secs));
|
||||
}
|
||||
let print = app.session.prefs.display_print_size;
|
||||
let print = app.print_ppi();
|
||||
let nab = app.session.active().map(|d| d.doc.artboards.len()).unwrap_or(0);
|
||||
let cur = crate::panels::artboards::selected(app, nab);
|
||||
// PLAN: assumed Artboard::rect has `width()` and `height()`.
|
||||
|
||||
@@ -9,22 +9,22 @@ use craft::ui::tabs::{DocumentTab, DocumentTabs, DocumentTabsEvent};
|
||||
|
||||
/// [`view_tab_title`] for a document with one view.
|
||||
#[cfg(test)]
|
||||
pub(super) fn tab_title(d: &vectorcraft_engine::DocState, zoom: f64, outline: bool, display_print_size: bool) -> String {
|
||||
view_tab_title(d, None, true, zoom, outline, display_print_size)
|
||||
pub(super) fn tab_title(d: &vectorcraft_engine::DocState, zoom: f64, outline: bool, print: Option<f64>) -> String {
|
||||
view_tab_title(d, None, true, zoom, outline, print)
|
||||
}
|
||||
|
||||
/// A document tab's title: "Name* @ 66.67 % (RGB/Preview)", or while an opacity mask is edited
|
||||
/// "Name* @ 66.67 % (<Opacity Mask>/Opacity Mask)". For a view of a document with more than one
|
||||
/// view, the view's `number` follows the name: "Name:2* @ 66.67 % (RGB/Preview)". The `*` of unsaved changes shows
|
||||
/// when `marked`; a document tab shows its own modified mark instead.
|
||||
fn view_tab_title(d: &vectorcraft_engine::DocState, number: Option<u32>, marked: bool, zoom: f64, outline: bool, display_print_size: bool) -> String {
|
||||
fn view_tab_title(d: &vectorcraft_engine::DocState, number: Option<u32>, marked: bool, zoom: f64, outline: bool, print: Option<f64>) -> String {
|
||||
let mode = if d.doc.mask_edit.is_some() {
|
||||
format!("<{0}>/{0}", tl!("Opacity Mask"))
|
||||
} else {
|
||||
let color = if d.doc.color_mode == vectorcraft_doc::ColorMode::Cmyk { "CMYK" } else { "RGB" };
|
||||
format!("{color}/{}", if outline { tl!("Outline") } else { tl!("Preview") })
|
||||
};
|
||||
format!("{} @ {} ({mode})", view_tab_name(d, number, marked), zoom_label(zoom, display_print_size).replace('%', " %"))
|
||||
format!("{} @ {} ({mode})", view_tab_name(d, number, marked), zoom_label(zoom, print).replace('%', " %"))
|
||||
}
|
||||
|
||||
/// The start of [`view_tab_title`], which an inactive document tab shows alone (#8582): "Name*",
|
||||
@@ -39,7 +39,7 @@ fn view_tab_name(d: &vectorcraft_engine::DocState, number: Option<u32>, marked:
|
||||
fn window_tab_title(app: &VectorcraftApp, w: crate::doc_windows::Win, d: &vectorcraft_engine::DocState, marked: bool) -> String {
|
||||
let view = crate::doc_windows::view(app, w);
|
||||
let zoom = view.map_or(1.0, |v| v.zoom);
|
||||
view_tab_title(d, crate::doc_windows::label(app, w), marked, zoom, view.is_some_and(|v| v.outline), app.session.prefs.display_print_size)
|
||||
view_tab_title(d, crate::doc_windows::label(app, w), marked, zoom, view.is_some_and(|v| v.outline), app.print_ppi_of(Some(w)))
|
||||
}
|
||||
|
||||
/// The title of window `w`'s tab and floating window ([`crate::doc_windows`]).
|
||||
|
||||
@@ -733,7 +733,8 @@ fn the_artboard_navigator_goes_to_artboards_and_fitting_shows_the_current_one()
|
||||
assert_eq!(at(&mut bar), (1, Point::new(320.0, 50.0)));
|
||||
bar.app().run("view.actualSize", json!({})).unwrap();
|
||||
let center = at(&mut bar).1;
|
||||
assert_eq!((center, bar.app().view().unwrap().zoom), (Point::new(320.0, 50.0), 1.0));
|
||||
let baseline = crate::state::zoom_baseline(bar.app().print_ppi());
|
||||
assert_eq!((center, bar.app().view().unwrap().zoom), (Point::new(320.0, 50.0), baseline));
|
||||
bar.click("First Artboard");
|
||||
assert_eq!(at(&mut bar), (0, Point::new(100.0, 50.0)), "first");
|
||||
// The command also takes an index, clamped to the last artboard.
|
||||
@@ -1085,7 +1086,7 @@ fn the_tab_title_names_the_opacity_mask_while_it_is_edited() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 50, "height": 50})).unwrap();
|
||||
let title = |s: &Session| super::tab_title(s.active().unwrap(), 1.0, false, false);
|
||||
let title = |s: &Session| super::tab_title(s.active().unwrap(), 1.0, false, None);
|
||||
assert!(title(&s).ends_with("(RGB/Preview)"), "{}", title(&s));
|
||||
s.execute("transparency.makeOpacityMask", &json!({})).unwrap();
|
||||
assert!(title(&s).ends_with("(<Opacity Mask>/Opacity Mask)"), "{}", title(&s));
|
||||
|
||||
@@ -171,6 +171,12 @@ pub fn inspect(app: &VectorcraftApp, ctx: &egui::Context) -> Value {
|
||||
// The display profile the canvas is drawn through, or why none (Preferences ›
|
||||
// Performance › Use Monitor Profile for Canvas).
|
||||
"displayProfile": app.display_profile.status(app.session.prefs.monitor_profile_display),
|
||||
// With Preferences › General › Display Print Size at 100% Zoom on, the measured density of
|
||||
// the main window's display in points per inch (null where none was measured), and the
|
||||
// points an inch takes at 100% in the current window. Both are null with it off, when the
|
||||
// desktop app does not measure the displays.
|
||||
"screenPpi": app.session.prefs.display_print_size.then(|| app.services.screen_ppi.ppi()).flatten(),
|
||||
"printPpi": app.print_ppi(),
|
||||
// Window › Arrange › Tile and its layout (not saved, so not in `ui`) and the panes the
|
||||
// last frame drew: each one's document index, view number (Window › New Window) and rect.
|
||||
// Canvas coordinates map to the current window's pane, inside its rulers and scroll bars
|
||||
|
||||
@@ -4,7 +4,7 @@ use vectorcraft_tools::{Mods, PointerEvent, PointerKind};
|
||||
|
||||
use craft::automation::{ControlRequest, Reply};
|
||||
|
||||
use super::handle;
|
||||
use super::{handle, inspect};
|
||||
use crate::{Services, VectorcraftApp};
|
||||
|
||||
/// Whether a dialog is open on the app's window.
|
||||
@@ -785,7 +785,24 @@ fn the_method_table_routes_each_method_and_checks_its_params() {
|
||||
assert_eq!(after, before, "{id} {params}: nothing changes");
|
||||
}
|
||||
app.run("view.setZoom", json!({"zoom": null, "center": null})).unwrap();
|
||||
assert_eq!(app.view().map(|v| v.zoom), Some(crate::state::zoom_from_display_percent(100.0, app.session.prefs.display_print_size)));
|
||||
assert_eq!(app.view().map(|v| v.zoom), Some(crate::state::zoom_from_display_percent(100.0, app.print_ppi())));
|
||||
}
|
||||
|
||||
/// `ui.inspect` gives the measured density of the main window's display and the points an inch
|
||||
/// takes at 100% while Display Print Size at 100% Zoom is on, and neither with it off (#9051).
|
||||
#[test]
|
||||
fn inspect_reports_the_display_density() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Services::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 400})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
let got = inspect(&app, &ctx);
|
||||
assert_eq!((got["screenPpi"].clone(), got["printPpi"].as_f64()), (Value::Null, Some(96.0)), "nothing measured: an inch is 96 points");
|
||||
app.set_screen_ppi(Some(127.0));
|
||||
let got = inspect(&app, &ctx);
|
||||
assert_eq!((got["screenPpi"].as_f64(), got["printPpi"].as_f64()), (Some(127.0), Some(127.0)));
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": false})).unwrap();
|
||||
let got = inspect(&app, &ctx);
|
||||
assert_eq!((got["screenPpi"].clone(), got["printPpi"].clone()), (Value::Null, Value::Null));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -57,11 +57,59 @@ pub struct DocWindow {
|
||||
generation: u32,
|
||||
/// Its OS window had the keyboard focus in the last frame.
|
||||
focused: bool,
|
||||
/// The density of the display that shows its OS window ([`crate::services::screen_ppi_at`]),
|
||||
/// while the window is on a display the host listed; `None` before that, while it is on none
|
||||
/// of them, and inside the main window, where the window counts the main window's density.
|
||||
ppi: Option<crate::ScreenPpi>,
|
||||
/// The last frame drew it as an OS window of its own.
|
||||
os: bool,
|
||||
/// A display that shows its OS window has been read since it opened.
|
||||
was_read: bool,
|
||||
}
|
||||
|
||||
impl DocWindow {
|
||||
fn new((uid, view): (u64, u32), place: egui::Rect) -> Self {
|
||||
Self { uid, view, place, number: 0, generation: 0, focused: false }
|
||||
Self { uid, view, place, number: 0, generation: 0, focused: false, ppi: None, os: false, was_read: false }
|
||||
}
|
||||
}
|
||||
|
||||
/// The density of the display that shows floating window `x`'s OS window: read once the window
|
||||
/// was found on a display, unread until then; `None` for a window inside the main window, which
|
||||
/// counts the main window's density, and for the window Presentation Mode shows there.
|
||||
fn window_ppi(app: &VectorcraftApp, x: &DocWindow) -> Option<crate::ScreenPpi> {
|
||||
if presenting(app) && current(app).and_then(|w| key(app, w)) == Some((x.uid, x.view)) {
|
||||
return None;
|
||||
}
|
||||
x.ppi.or(x.os.then_some(crate::ScreenPpi::Unread))
|
||||
}
|
||||
|
||||
/// [`window_ppi`] for window `w`; `None` for a window that does not float.
|
||||
pub(crate) fn screen_ppi(app: &VectorcraftApp, w: Win) -> Option<crate::ScreenPpi> {
|
||||
let (u, n) = key(app, w)?;
|
||||
window_ppi(app, app.ui.floating.iter().find(|x| x.uid == u && x.view == n)?)
|
||||
}
|
||||
|
||||
/// A floating window ([`views::key`]) with the density of the display that shows it
|
||||
/// ([`window_ppi`]).
|
||||
pub(crate) type FloatingPpi = ((u64, u32), Option<crate::ScreenPpi>);
|
||||
|
||||
/// Each floating window with the density of the display that shows it.
|
||||
pub(crate) fn floating_ppi(app: &VectorcraftApp) -> Vec<FloatingPpi> {
|
||||
app.ui.floating.iter().map(|x| ((x.uid, x.view), window_ppi(app, x))).collect()
|
||||
}
|
||||
|
||||
/// Forgets the densities found for the floating windows' displays.
|
||||
pub(crate) fn forget_ppi(app: &mut VectorcraftApp) {
|
||||
for x in &mut app.ui.floating {
|
||||
x.ppi = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the density of the display that shows floating window `key`'s ([`views::key`]) OS window.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn set_window_ppi(app: &mut VectorcraftApp, (uid, view): (u64, u32), ppi: Option<f64>) {
|
||||
if let Some(x) = app.ui.floating.iter_mut().find(|x| x.uid == uid && x.view == view) {
|
||||
x.ppi = Some(crate::ScreenPpi::Read(ppi));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +133,14 @@ pub struct Windows {
|
||||
/// window floats), back to front, with the art area each takes drops in; and those of the last frame.
|
||||
pub(crate) noted: Vec<(Win, egui::Rect)>,
|
||||
pub(crate) last_noted: Vec<(Win, egui::Rect)>,
|
||||
/// The main window's density and the floating windows' ([`floating_ppi`]) when the views were
|
||||
/// last settled each frame ([`VectorcraftApp::settle_screen_ppi_if_changed`]).
|
||||
pub(crate) settled: Option<(crate::ScreenPpi, Vec<FloatingPpi>)>,
|
||||
/// Display Print Size at 100% Zoom was off when the views were last settled each frame.
|
||||
pub(crate) print_size_off: bool,
|
||||
/// The last density the host read for the main window's display; the main window's views
|
||||
/// count from it while its display has not answered.
|
||||
pub(crate) main_read: Option<crate::ScreenPpi>,
|
||||
}
|
||||
|
||||
impl Windows {
|
||||
@@ -382,6 +438,7 @@ fn show_windows(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
let is_current = views::current(app) == Some(win);
|
||||
let live = is_current && !crate::menus::home_showing(app);
|
||||
let mut pressed = false;
|
||||
let mut found = (None, None, false);
|
||||
let window = DocumentWindow::new(title).id_salt((w.uid, w.number, w.generation)).first_placed(w.place.translate(origin));
|
||||
let window = if raise == Some((w.uid, w.view)) { window.raise() } else { window };
|
||||
let out = window.show(ui, |ui, _| {
|
||||
@@ -390,6 +447,9 @@ fn show_windows(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
crate::chrome::window_tab(app, ui, win);
|
||||
let areas = [(win, ui.available_rect_before_wrap())];
|
||||
let unfitted = crate::canvas::panes::refit_resized(app, &areas);
|
||||
// The display that shows the window, the size of its body and whether its view fits it in this frame.
|
||||
let ppi = if os_windows { crate::services::screen_ppi_at(&app.services.screens, ui.ctx()) } else { None };
|
||||
found = (ppi, Some(areas[0].1.size()), unfitted.first().copied().unwrap_or(false));
|
||||
if live {
|
||||
// The canvas fills the area below the tab, as a pane's does.
|
||||
let mut body = ui.new_child(egui::UiBuilder::new().max_rect(areas[0].1));
|
||||
@@ -399,6 +459,7 @@ fn show_windows(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
crate::canvas::panes::note_fits(app, &areas, &unfitted);
|
||||
});
|
||||
take_window_ppi(app, &ctx, ((w.uid, w.view), os_windows), win, found);
|
||||
if let Some(x) = app.ui.floating.iter_mut().find(|x| x.uid == w.uid && x.view == w.view) {
|
||||
x.focused = out.focused;
|
||||
// A move or resize of the fallback layer is where the window opens from now on.
|
||||
@@ -426,6 +487,57 @@ fn show_windows(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes `ppi`, the density of the display that floating window `key`'s ([`views::key`]) window
|
||||
/// `win` was found on (`None` when it was found on none), whether it is an OS window of its own
|
||||
/// (`os`), the size of its body and whether its view fitted the body in this frame, and settles
|
||||
/// the window's view when the density changed ([`VectorcraftApp::settle_window_ppi`]). A view that
|
||||
/// still has the zoom its window fitted it to at the window's present size keeps that zoom at its
|
||||
/// first reading, and keeps fitting the window.
|
||||
fn take_window_ppi(
|
||||
app: &mut VectorcraftApp,
|
||||
ctx: &egui::Context,
|
||||
((uid, number), os): ((u64, u32), bool),
|
||||
win: Win,
|
||||
(ppi, size, fitted_now): (Option<crate::ScreenPpi>, Option<egui::Vec2>, bool),
|
||||
) {
|
||||
let Some(x) = app.ui.floating.iter_mut().find(|x| x.uid == uid && x.view == number) else { return };
|
||||
x.os = os;
|
||||
// Drawn inside the main window, it counts the main window's density.
|
||||
if !os {
|
||||
if x.ppi.take().is_some() {
|
||||
app.settle_window_ppi(win, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// Off every display the host listed (moved past their edges, or its display went), it is
|
||||
// unread: its view counts from the density it was shown at until a display is found again.
|
||||
if ppi.is_none() {
|
||||
if x.ppi.take().is_some() {
|
||||
app.settle_window_ppi(win, true);
|
||||
ctx.request_repaint();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if x.ppi == ppi {
|
||||
return;
|
||||
}
|
||||
// Its first reading, or a fit made this frame, is a baseline; a move from a display read
|
||||
// before keeps the zoom percentage.
|
||||
let first = !x.was_read;
|
||||
x.ppi = ppi;
|
||||
x.was_read |= matches!(ppi, Some(crate::ScreenPpi::Read(_)));
|
||||
let following = crate::canvas::panes::follows_fit(app, win, size);
|
||||
// A zoom set as a percentage (View › Zoom, Actual Size) is not a fit, and the first reading
|
||||
// keeps its percentage.
|
||||
let fit = following && view(app, win).is_some_and(|v| v.fit_zoom == Some(v.zoom));
|
||||
app.settle_window_ppi(win, !(fit && (first || fitted_now)));
|
||||
// A view that still fits its window keeps fitting it at the zoom the new density gave it.
|
||||
if following {
|
||||
crate::canvas::panes::refollow_fit(app, win);
|
||||
}
|
||||
ctx.request_repaint();
|
||||
}
|
||||
|
||||
/// Whether the primary button went down over `ui`'s layer in this pass.
|
||||
fn pressed_on_layer(ui: &egui::Ui) -> bool {
|
||||
let at = ui.ctx().input(|i| i.pointer.primary_pressed().then_some(i.pointer.interact_pos()).flatten());
|
||||
|
||||
@@ -1199,3 +1199,197 @@ fn a_tab_transfer_whose_target_is_no_longer_current_drops_nothing_in_a_floating_
|
||||
assert_eq!(app.session.documents()[1].history.undo.len(), target_undo);
|
||||
assert_eq!(app.session.active_index(), Some(0), "the window does not become current");
|
||||
}
|
||||
|
||||
/// Runs view command `command` on window `win`'s view at once, in a 500 × 400 pt canvas at one
|
||||
/// pixel per point, as the canvas runs a queued one ([`crate::canvas::show_document`]).
|
||||
fn run_view(app: &mut VectorcraftApp, win: Win, command: craft::ui::canvas::ViewCommands) {
|
||||
app.before_view_command(win, command);
|
||||
let target = crate::canvas::view_target(app, win);
|
||||
let scheme = crate::app::view::zoom_scheme(app.print_ppi_of(Some(win)), 1.0);
|
||||
let scaling = app.ui_scaling();
|
||||
let Some(v) = view_mut(app, win) else { return };
|
||||
let mut cv = v.canvas(scaling, egui::Rect::from_min_size(Pos2::ZERO, vec2(500.0, 400.0)));
|
||||
if command.apply(&mut cv, &target, None, 1.0, &scheme) {
|
||||
v.set_canvas(&cv, scaling);
|
||||
}
|
||||
app.after_view_command(win, command);
|
||||
}
|
||||
|
||||
/// #9051: an OS window's display is the one at the window's scale factor that covers most of it. A
|
||||
/// 1× display to the right of a 2× one on macOS starts, in pixels, inside the 2× display's pixels.
|
||||
#[test]
|
||||
fn an_os_window_finds_the_display_at_its_own_scale() {
|
||||
use crate::ScreenPpi::Read;
|
||||
use crate::services::{ScreenDensity, screen_ppi_at};
|
||||
let screens = [
|
||||
ScreenDensity { rect: [0, 0, 3024, 1964], scale: 2.0, ppi: Read(Some(127.0)) },
|
||||
ScreenDensity { rect: [1512, 0, 1920, 1080], scale: 1.0, ppi: Read(Some(92.0)) },
|
||||
];
|
||||
let at = |center: Pos2, native: f32| {
|
||||
let ctx = egui::Context::default();
|
||||
let mut input = egui::RawInput::default();
|
||||
let info = input.viewports.entry(egui::ViewportId::ROOT).or_default();
|
||||
info.native_pixels_per_point = Some(native);
|
||||
info.outer_rect = Some(egui::Rect::from_center_size(center, vec2(200.0, 100.0)));
|
||||
let mut found = None;
|
||||
let mut out = ctx.run_ui(input, |ui| found = screen_ppi_at(&screens, ui.ctx()));
|
||||
out.textures_delta.clear();
|
||||
found
|
||||
};
|
||||
assert_eq!(at(pos2(1800.0, 300.0), 1.0), Some(Read(Some(92.0))), "on the 1× display");
|
||||
assert_eq!(at(pos2(700.0, 300.0), 2.0), Some(Read(Some(127.0))), "on the 2× display");
|
||||
assert_eq!(at(pos2(2000.0, 1100.0), 1.0), Some(Read(Some(92.0))), "partly below the 1× display, its center off it");
|
||||
assert_eq!(at(pos2(9000.0, 300.0), 1.0), None, "off every display");
|
||||
}
|
||||
|
||||
/// #9051: with Display Print Size at 100% Zoom on, a document floating in an OS window of its own
|
||||
/// counts 100% from the display that shows that window. A move of its window to a display of
|
||||
/// another density keeps its zoom percentage; a move of the main window leaves its zoom alone and
|
||||
/// keeps the percentage of the documents under the tabs.
|
||||
#[test]
|
||||
fn a_floating_window_counts_100_percent_from_its_own_display() {
|
||||
use craft::ui::canvas::ViewCommands;
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
app.set_screen_ppi(Some(127.0));
|
||||
run_view(&mut app, (1, 1), ViewCommands::ActualPixels);
|
||||
app.run("window.arrange.floatInWindow", json!({})).unwrap();
|
||||
let pct = |app: &VectorcraftApp, i: usize| crate::state::zoom_display_percent(app.views[i].zoom, app.print_ppi_of(Some((i, 1))));
|
||||
let uid = app.session.documents()[1].uid;
|
||||
set_window_ppi(&mut app, (uid, 1), Some(91.0));
|
||||
app.settle_screen_ppi();
|
||||
assert!((pct(&app, 1) - 100.0).abs() < 1e-9, "the floating document stays at 100%: {}", pct(&app, 1));
|
||||
assert!((app.views[1].zoom * 72.0 - 91.0).abs() < 1e-9, "an inch of the document fills an inch of its display");
|
||||
let (floating, tabbed, tabbed_pct) = (app.views[1].zoom, app.views[0].zoom, pct(&app, 0));
|
||||
assert!(app.set_screen_ppi(Some(150.0)), "the main window moved to a denser display");
|
||||
assert_eq!(app.views[1].zoom, floating, "the floating window did not move");
|
||||
assert!(app.views[0].zoom > tabbed, "the tabbed document zooms with the denser display");
|
||||
assert!((pct(&app, 0) - tabbed_pct).abs() < 1e-9, "and keeps its percentage");
|
||||
// Presentation Mode shows the floating document in the main window, on the main window's
|
||||
// display, and it keeps its 100% there.
|
||||
app.settle_screen_ppi_if_changed();
|
||||
app.ui.screen_mode = 3;
|
||||
app.settle_screen_ppi_if_changed();
|
||||
assert!((app.views[1].zoom * 72.0 - 150.0).abs() < 1e-9, "presented on the main window's display: {}", app.views[1].zoom * 72.0);
|
||||
assert!((pct(&app, 1) - 100.0).abs() < 1e-9);
|
||||
// Back from its own display under the tabs, a fit made there is kept.
|
||||
app.ui.screen_mode = 0;
|
||||
app.settle_screen_ppi_if_changed();
|
||||
app.run("window.arrange.consolidateAllWindows", json!({})).unwrap();
|
||||
run_view(&mut app, (1, 1), ViewCommands::FitArtboard);
|
||||
let fitted = app.views[1].zoom;
|
||||
app.settle_screen_ppi_if_changed();
|
||||
assert_eq!(app.views[1].zoom, fitted, "the fit is made for the main window's display");
|
||||
}
|
||||
|
||||
/// What the host found for a floating OS window's display reaches its view: its first display and
|
||||
/// a move to another keep 100%, a window off every display is unread and keeps its zoom, a fit made
|
||||
/// in the frame its window reached a new display stays the fit, and the window drawn in the main
|
||||
/// window again counts from the main window's display.
|
||||
#[test]
|
||||
fn a_floating_os_window_takes_the_density_of_the_display_it_is_found_on() {
|
||||
use crate::ScreenPpi::Read;
|
||||
use craft::ui::canvas::ViewCommands;
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
app.set_screen_ppi(Some(127.0));
|
||||
run_view(&mut app, (1, 1), ViewCommands::ActualPixels);
|
||||
app.run("window.arrange.floatInWindow", json!({})).unwrap();
|
||||
let uid = app.session.documents()[1].uid;
|
||||
let win = (1, 1);
|
||||
let body = vec2(500.0, 400.0);
|
||||
let inch = |app: &VectorcraftApp| app.views[1].zoom * 72.0;
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(91.0))), Some(body), false));
|
||||
assert!((inch(&app) - 91.0).abs() < 1e-9, "its first display keeps 100%: {}", inch(&app));
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(150.0))), Some(body), false));
|
||||
assert!((inch(&app) - 150.0).abs() < 1e-9, "and so does a move to a denser one: {}", inch(&app));
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (None, Some(body), false));
|
||||
assert_eq!(screen_ppi(&app, win), Some(crate::ScreenPpi::Unread), "off every display it is unread");
|
||||
assert!((inch(&app) - 150.0).abs() < 1e-9, "and keeps its zoom");
|
||||
// A fit made in the frame the window reaches a display of another density stays the fit.
|
||||
run_view(&mut app, win, ViewCommands::FitArtboard);
|
||||
crate::canvas::panes::note_fit(&mut app, win, body);
|
||||
let zoom = app.views[1].zoom;
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(110.0))), Some(body), true));
|
||||
assert_eq!(app.views[1].zoom, zoom, "the fit was made for that display");
|
||||
app.run("view.setZoom", json!({"zoom": 100})).unwrap();
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), false), win, (Some(Read(Some(110.0))), Some(body), false));
|
||||
assert!((inch(&app) - 127.0).abs() < 1e-9, "drawn in the main window, 100% counts from the main window's display: {}", inch(&app));
|
||||
}
|
||||
|
||||
/// A fit made while a floating OS window is off every display keeps counting from the density the
|
||||
/// window was last shown at, and the reading that follows leaves the fit's zoom alone.
|
||||
#[test]
|
||||
fn a_fit_made_while_a_floating_window_is_unread_counts_from_its_last_reading() {
|
||||
use crate::ScreenPpi::Read;
|
||||
use craft::ui::canvas::ViewCommands;
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
app.set_screen_ppi(Some(127.0));
|
||||
app.run("window.arrange.floatInWindow", json!({})).unwrap();
|
||||
let uid = app.session.documents()[1].uid;
|
||||
let win = (1, 1);
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(150.0))), None, false));
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (None, None, false));
|
||||
run_view(&mut app, win, ViewCommands::FitArtboard);
|
||||
let zoom = app.views[1].zoom;
|
||||
assert_eq!(app.print_ppi_of(Some(win)), Some(150.0), "the fit counts from the last reading");
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(110.0))), None, false));
|
||||
assert_eq!(app.views[1].zoom, zoom, "the reading leaves the fit alone");
|
||||
assert_eq!(app.print_ppi_of(Some(win)), Some(110.0));
|
||||
}
|
||||
|
||||
/// A zoom set as a percentage on a floating OS window that has not been read yet is not a fit,
|
||||
/// even when the window recorded that zoom and center as its fit: the first reading of its display
|
||||
/// keeps the percentage.
|
||||
#[test]
|
||||
fn a_zoom_set_before_a_floating_window_is_first_read_keeps_its_percentage() {
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
app.set_screen_ppi(Some(127.0));
|
||||
app.run("window.arrange.floatInWindow", json!({})).unwrap();
|
||||
let uid = app.session.documents()[1].uid;
|
||||
let win = (1, 1);
|
||||
let body = vec2(500.0, 400.0);
|
||||
app.run("view.setZoom", json!({"zoom": 100})).unwrap();
|
||||
crate::canvas::panes::note_fit(&mut app, win, body);
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(crate::ScreenPpi::Read(Some(91.0))), Some(body), true));
|
||||
let pct = crate::state::zoom_display_percent(app.views[1].zoom, app.print_ppi_of(Some(win)));
|
||||
assert!((pct - 100.0).abs() < 1e-9, "the first reading keeps 100%: {pct}");
|
||||
assert!((app.views[1].zoom * 72.0 - 91.0).abs() < 1e-9, "an inch of the document fills an inch of its display");
|
||||
}
|
||||
|
||||
/// A floating OS window whose view still fits it, moved between two displays read before, keeps
|
||||
/// fitting it at the zoom the new density gives: the fit kept is the settled one.
|
||||
#[test]
|
||||
fn a_fitted_floating_window_moved_to_another_density_keeps_fitting() {
|
||||
use crate::ScreenPpi::Read;
|
||||
use craft::ui::canvas::ViewCommands;
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": true})).unwrap();
|
||||
app.set_screen_ppi(Some(127.0));
|
||||
app.run("window.arrange.floatInWindow", json!({})).unwrap();
|
||||
let uid = app.session.documents()[1].uid;
|
||||
let win = (1, 1);
|
||||
let body = vec2(500.0, 400.0);
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(91.0))), Some(body), false));
|
||||
run_view(&mut app, win, ViewCommands::FitArtboard);
|
||||
// Fitted to its window's body, as the canvas leaves a view it fits.
|
||||
app.views[1].fitted = true;
|
||||
crate::canvas::panes::note_fit(&mut app, win, body);
|
||||
let zoom = app.views[1].zoom;
|
||||
take_window_ppi(&mut app, &ctx, ((uid, 1), true), win, (Some(Read(Some(150.0))), Some(body), false));
|
||||
let v = app.views[1];
|
||||
assert_ne!(v.zoom, zoom, "the move to a denser display keeps the zoom percentage");
|
||||
assert_eq!(crate::canvas::panes::fit_of(&app, win), Some((body, v.zoom, v.center)), "and the fit kept is the settled zoom");
|
||||
}
|
||||
|
||||
@@ -3362,7 +3362,7 @@ digits Malayalam Малаялам
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. „Селекция › Същото › Цвят на запълване“, „Цвят на щриха“ и „Запълване и щрих“ намират само същия нюанс на глобална или плътна мостра, а не всеки неин нюанс.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Показва началния екран, когато няма отворен документ; ако е изключено, прозорецът остава празен, докато не щракнете „Начало“.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Измерва обектите заедно с щрихите и ефектите, които променят формата, за размер, позиция и подравняване; сенките, сиянията и замъгляванията не се измерват.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. При мащаб 100 % един инч от документа заема 96 екранни точки вместо 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. При мащаб 100 % един инч от документа запълва един инч от дисплея или 96 екранни точки, когато системата не съобщава използваем размер на дисплея.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Двойно щракване върху група, контур или изображение с инструмента „Селекция“ ги отваря в режим на изолация.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Запълванията и щрихите с мостра се трансформират заедно с графиката, освен ако трансформацията или менюто на панела „Трансформиране“ не избере друго.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Радиусите на динамичните ъгли се мащабират заедно с графиката, освен ако мащабирането не избере друго.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4708,7 +4708,7 @@ font-technology Variable Varijabilni
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Odabir › Isto › Boja ispune, Boja poteza i Ispuna i potez pronalaze samo istu nijansu globalnog ili spot uzorka, a ne bilo koju njegovu nijansu.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Prikazuje početni ekran kada nijedan dokument nije otvoren; kada je isključeno, prozor ostaje prazan dok ne kliknete Početna.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mjeri objekte zajedno s potezima i efektima koji mijenjaju oblik za veličinu, položaj i poravnanje; sjene, sjaj i zamućenja se ne mjere.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Pri zumu od 100% jedan inč dokumenta zauzima 96 tačaka ekrana umjesto 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Pri zumu od 100% jedan inč dokumenta ispunjava jedan inč ekrana, ili 96 tačaka ekrana kada sistem ne javlja upotrebljivu veličinu ekrana.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Dvostruki klik na grupu, putanju ili sliku alatom Odabir otvara ih u načinu izolacije.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Ispune i potezi s uzorkom transformišu se zajedno s grafikom, osim ako transformacija ili meni panela Transformiši ne odabere drugačije.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Poluprečnici dinamičnih uglova skaliraju se zajedno s grafikom, osim ako skaliranje ne odabere drugačije.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -4079,7 +4079,7 @@ digits Malayalam Malaiàlam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Selecció › Igual › Color de farciment, Color del traç i Farciment i traç només coincideixen amb el mateix matís d’una mostra global o de tinta plana, no amb qualsevol matís seu.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Mostra la pantalla d’inici quan no hi ha cap document obert; desactivada, la finestra queda buida fins que feu clic a Inici.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mesura els objectes amb els traços i els efectes que en canvien la forma per a la mida, la posició i l’alineació; les ombres, les lluïsors i els desenfocaments no es mesuren.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Amb un zoom del 100 %, una polzada del document ocupa 96 punts de pantalla en lloc de 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Amb un zoom del 100 %, una polzada del document omple una polzada de la pantalla, o 96 punts de pantalla quan el sistema no n’indica una mida utilitzable.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Fer doble clic en un grup, traçat o imatge amb l’eina Selecció l’obre en mode d’aïllament.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Els farciments i traços de motiu es transformen amb la il·lustració, tret que una transformació o el menú del panell Transforma triï una altra cosa.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Els radis de cantonada dinàmics s’escalen amb la il·lustració, tret que l’escalat triï una altra cosa.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4817,7 +4817,7 @@ font-technology Variable Variabilní
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Výběr › Stejné › Barva výplně, Barva tahu a Výplň a tah najdou jen stejný odstín globálního nebo přímého vzorku, ne libovolný jeho odstín.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Zobrazí domovskou obrazovku, když není otevřený žádný dokument; když je vypnuto, okno zůstane prázdné, dokud neklepnete na Domů.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Měří objekty včetně tahů a efektů měnících tvar pro velikost, polohu a zarovnání; stíny, záře a rozostření se neměří.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Při zvětšení 100 % zabere jeden palec dokumentu 96 obrazovkových bodů místo 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Při zvětšení 100 % vyplní jeden palec dokumentu jeden palec displeje, nebo 96 obrazovkových bodů, pokud systém neudává použitelnou velikost displeje.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Poklepání na skupinu, cestu nebo obraz nástrojem Výběr je otevře v izolačním režimu.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Výplně a tahy se vzorkem se transformují s kresbou, pokud transformace nebo nabídka panelu Transformace nezvolí jinak.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Poloměry živých rohů se mění s velikostí kresby, pokud změna velikosti nezvolí jinak.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -7291,7 +7291,7 @@ font-technology Variable Variable
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Markér › Samme › Fyldfarve, Stregfarve og Fyld og streg finder kun samme nuance af en global farveprøve eller staffagefarve, ikke en hvilken som helst nuance af den.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Viser startskærmen, når intet dokument er åbent; når den er slået fra, forbliver vinduet tomt, indtil du klikker på Home.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Måler objekter med deres streger og formændrende effekter til størrelse, position og justering; skygger, glød og sløringer måles ikke.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Ved 100 % zoom fylder en tomme af dokumentet 96 skærmpunkter i stedet for 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Ved 100 % zoom fylder en tomme af dokumentet en tomme af skærmen, eller 96 skærmpunkter, hvis systemet ikke oplyser en brugbar skærmstørrelse.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Dobbeltklik på en gruppe, en sti eller et billede med værktøjet Markering åbner det i isolationstilstand.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Mønsterfyld og -streger transformeres med grafikken, medmindre en transformation eller menuen i panelet Transformér vælger andet.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Live-hjørneradier skaleres med grafikken, medmindre skaleringen vælger andet.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3294,7 +3294,7 @@ digits Malayalam Malayalam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. „Auswahl › Gleich › Flächenfarbe“, „Konturfarbe“ und „Fläche und Kontur“ finden nur denselben Farbton eines globalen oder Volltonfarbfelds, nicht jeden Farbton davon.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Zeigt den Startbildschirm, wenn kein Dokument geöffnet ist; ist die Option aus, bleibt das Fenster leer, bis Sie auf „Start“ klicken.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Misst Objekte für Größe, Position und Ausrichtung mit ihren Konturen und formverändernden Effekten; Schatten, Schein und Weichzeichnungen werden nicht gemessen.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Bei 100 % Zoom nimmt ein Zoll des Dokuments 96 statt 72 Bildschirmpunkte ein.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Bei 100 % Zoom füllt ein Zoll des Dokuments einen Zoll des Bildschirms, oder 96 Bildschirmpunkte, wenn das System keine verwendbare Bildschirmgröße meldet.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Ein Doppelklick mit dem Auswahl-Werkzeug auf eine Gruppe, einen Pfad oder ein Bild öffnet sie im Isolationsmodus.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Musterflächen und -konturen werden mit dem Bildmaterial transformiert, sofern die Transformation oder das Menü des Bedienfelds „Transformieren“ nichts anderes wählt.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Live-Eckenradien skalieren mit dem Bildmaterial, sofern die Skalierung nichts anderes wählt.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4147,7 +4147,7 @@ digits Malayalam Μαλαγιάλαμ
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Τα Επιλογή › Ίδιο › Χρώμα γεμίσματος, Χρώμα περιγράμματος και Γέμισμα και περίγραμμα βρίσκουν μόνο την ίδια απόχρωση ενός καθολικού ή σημειακού δείγματος, όχι οποιαδήποτε απόχρωσή του.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Εμφανίζει την αρχική οθόνη όταν δεν είναι ανοιχτό κανένα έγγραφο· όταν είναι ανενεργό, το παράθυρο μένει κενό μέχρι να κάνετε κλικ στην Αρχική οθόνη.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Μετρά τα αντικείμενα μαζί με τα περιγράμματα και τα εφέ που αλλάζουν το σχήμα τους για μέγεθος, θέση και στοίχιση· οι σκιές, οι λάμψεις και οι θολώσεις δεν μετρώνται.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Σε ζουμ 100%, μία ίντσα του εγγράφου καταλαμβάνει 96 στιγμές οθόνης αντί για 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Σε ζουμ 100%, μία ίντσα του εγγράφου γεμίζει μία ίντσα της οθόνης, ή 96 στιγμές οθόνης όταν το σύστημα δεν αναφέρει χρησιμοποιήσιμο μέγεθος οθόνης.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Το διπλό κλικ σε ομάδα, διαδρομή ή εικόνα με το εργαλείο Επιλογή την ανοίγει σε λειτουργία απομόνωσης.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Τα γεμίσματα και τα περιγράμματα μοτίβου μετασχηματίζονται μαζί με το γραφικό, εκτός αν ένας μετασχηματισμός ή το μενού του πλαισίου Μετασχηματισμός επιλέξει κάτι άλλο.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Οι ακτίνες των δυναμικών γωνιών κλιμακώνονται μαζί με το γραφικό, εκτός αν η κλιμάκωση επιλέξει κάτι άλλο.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3327,7 +3327,7 @@ digits Malayalam Malayálam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Selección › Igual › Color de relleno, Color de trazo y Relleno y trazo solo coinciden con el mismo matiz de una muestra global o de tinta plana, no con cualquier matiz de ella.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Muestra la pantalla de inicio cuando no hay ningún documento abierto; desactivada, la ventana queda vacía hasta que hace clic en Inicio.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mide los objetos con sus trazos y los efectos que cambian su forma para el tamaño, la posición y la alineación; las sombras, los resplandores y los desenfoques no se miden.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Con un zoom del 100 %, una pulgada del documento ocupa 96 puntos de pantalla en lugar de 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Con un zoom del 100 %, una pulgada del documento ocupa una pulgada de la pantalla, o 96 puntos de pantalla si el sistema no indica un tamaño utilizable.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Al hacer doble clic en un grupo, trazado o imagen con la herramienta Selección, se abre en modo de aislamiento.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Los rellenos y trazos de motivo se transforman con la ilustración, salvo que una transformación o el menú del panel Transformar indique otra cosa.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Los radios de esquina dinámicos se escalan con la ilustración, salvo que el escalado indique otra cosa.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4727,7 +4727,7 @@ font-technology Variable Muuttuvat
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Valinta › Sama › Täyttöväri, Viivan väri sekä Täyttö ja viiva löytävät vain globaalin tai spottivärimallin saman sävyn, eivät mitä tahansa sen sävyä.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Näyttää aloitusnäytön, kun yhtään asiakirjaa ei ole auki; kun asetus ei ole käytössä, ikkuna pysyy tyhjänä, kunnes napsautat Aloitus.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mittaa objektit viivoineen ja muotoa muuttavine tehosteineen kokoa, sijaintia ja tasausta varten; varjoja, hehkuja ja sumennuksia ei mitata.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100 %:n zoomauksella asiakirjan tuuma vie 96 näyttöpistettä 72:n sijaan.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100 %:n zoomauksella asiakirjan tuuma täyttää näytön tuuman, tai 96 näyttöpistettä, jos järjestelmä ei ilmoita käyttökelpoista näytön kokoa.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Ryhmän, polun tai kuvan kaksoisnapsautus Valinta-työkalulla avaa sen eristystilaan.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Kuviotäytöt ja -viivat muuntuvat grafiikan mukana, ellei muunnos tai Muunna-paneelin valikko valitse toisin.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Dynaamisten kulmien säteet skaalautuvat grafiikan mukana, ellei skaalaus valitse toisin.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3315,7 +3315,7 @@ digits Malayalam Malayalam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Sélection › Identique › Couleur de fond, Couleur du contour et Fond et contour ne retiennent que la même teinte d’une nuance globale ou d’une couleur d’accompagnement, et non toutes ses teintes.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Affiche l’écran d’accueil quand aucun document n’est ouvert. Désactivée, la fenêtre reste vide jusqu’à ce que vous cliquiez sur Accueil.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mesure les objets avec leurs contours et leurs effets qui modifient la forme pour la taille, la position et l’alignement. Les ombres, lueurs et flous ne sont pas mesurés.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. À 100 % de zoom, un pouce du document occupe 96 points d’écran au lieu de 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. À 100 % de zoom, un pouce du document occupe un pouce de l’écran, ou 96 points d’écran si le système n’indique pas de taille d’écran utilisable.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Un double-clic sur un groupe, un tracé ou une image avec l’outil Sélection l’ouvre en mode Isolation.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Les fonds et contours de motif se transforment avec l’illustration, sauf si une transformation ou le menu du panneau Transformation en décide autrement.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Les rayons d’angle dynamiques se mettent à l’échelle avec l’illustration, sauf si la mise à l’échelle en décide autrement.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3377,7 +3377,7 @@ arrowhead Feather પીંછું
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. પસંદ કરો › સમાન › ભરવાનો રંગ, સ્ટ્રોક રંગ અને ભરો અને સ્ટ્રોક ફક્ત ગ્લોબલ કે સ્પોટ સ્વૉચના એ જ ટિન્ટ સાથે મેળ ખાય છે, તેના કોઈપણ ટિન્ટ સાથે નહીં.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. કોઈ દસ્તાવેજ ખુલ્લો ન હોય ત્યારે હોમ સ્ક્રીન બતાવે છે; બંધ હોય ત્યારે તમે હોમ પર ક્લિક ન કરો ત્યાં સુધી વિન્ડો ખાલી રહે છે.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. કદ, સ્થાન અને ગોઠવણી માટે ઑબ્જેક્ટને તેમના સ્ટ્રોક અને આકાર બદલતી ઇફેક્ટ્સ સાથે માપે છે; છાયા, ગ્લો અને બ્લર માપવામાં આવતા નથી.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100% ઝૂમ પર દસ્તાવેજનો એક ઇંચ 72 ને બદલે 96 સ્ક્રીન પોઇન્ટ લે છે.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100% ઝૂમ પર દસ્તાવેજનો એક ઇંચ ડિસ્પ્લેનો એક ઇંચ ભરે છે, અથવા સિસ્ટમ ડિસ્પ્લેનું ઉપયોગી કદ ન જણાવે ત્યારે 96 સ્ક્રીન પોઇન્ટ લે છે.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. પસંદગી ટૂલથી ગ્રુપ, પાથ કે છબી પર ડબલ-ક્લિક કરવાથી તે આઇસોલેશન મોડમાં ખુલે છે.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. પૅટર્ન ભરણ અને સ્ટ્રોક આર્ટવર્ક સાથે ટ્રાન્સફોર્મ થાય છે, સિવાય કે કોઈ ટ્રાન્સફોર્મ કે ટ્રાન્સફોર્મ પેનલનું મેનૂ બીજું પસંદ કરે.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. લાઇવ ખૂણાઓની ત્રિજ્યાઓ આર્ટવર્ક સાથે સ્કેલ થાય છે, સિવાય કે સ્કેલિંગ બીજું પસંદ કરે.
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -4710,7 +4710,7 @@ arrowhead Feather पंख
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. सिलेक्ट › समान › फ़िल रंग, स्ट्रोक रंग और फ़िल व स्ट्रोक केवल ग्लोबल या स्पॉट स्वॉच के उसी टिंट से मेल खाते हैं, उसके किसी भी टिंट से नहीं।
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. कोई डॉक्यूमेंट खुला न होने पर होम स्क्रीन दिखाता है; बंद होने पर विंडो तब तक खाली रहती है जब तक आप होम पर क्लिक नहीं करते।
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. साइज़, स्थिति और संरेखण के लिए ऑब्जेक्ट को उनके स्ट्रोक और आकार बदलने वाले इफ़ेक्ट के साथ मापता है; छाया, ग्लो और ब्लर नहीं मापे जाते।
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100% ज़ूम पर डॉक्यूमेंट का एक इंच 72 की जगह 96 स्क्रीन पॉइंट लेता है।
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100% ज़ूम पर डॉक्यूमेंट का एक इंच डिस्प्ले का एक इंच घेरता है, या सिस्टम डिस्प्ले का उपयोग योग्य आकार न बताए तो 96 स्क्रीन पॉइंट लेता है।
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. सिलेक्शन टूल से किसी ग्रुप, पाथ या इमेज पर डबल-क्लिक करने से वह आइसोलेशन मोड में खुलता है।
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. पैटर्न वाले फ़िल और स्ट्रोक आर्टवर्क के साथ रूपांतरित होते हैं, जब तक कोई रूपांतरण या रूपांतरण पैनल का मेनू कुछ और न चुने।
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. लाइव कोनों की त्रिज्याएँ आर्टवर्क के साथ स्केल होती हैं, जब तक स्केलिंग कुछ और न चुने।
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3918,7 +3918,7 @@ mark-style Japanese Japán
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. A Kijelölés › Azonos › Kitöltőszín, Körvonalszín és Kitöltés és körvonal csak egy globális vagy direkt színminta azonos árnyalatát találja meg, nem bármely árnyalatát.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Megjeleníti a kezdőképernyőt, ha nincs megnyitott dokumentum; kikapcsolva az ablak üres marad, amíg a Kezdőképernyő gombra nem kattint.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Az objektumokat körvonalaikkal és alakmódosító effektusaikkal együtt méri a mérethez, a pozícióhoz és az igazításhoz; az árnyékokat, ragyogásokat és elmosásokat nem méri.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100%-os nagyításnál a dokumentum egy hüvelyke 72 helyett 96 képernyőpontot foglal el.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100%-os nagyításnál a dokumentum egy hüvelyke a kijelző egy hüvelykét tölti ki, vagy 96 képernyőpontot, ha a rendszer nem ad meg használható kijelzőméretet.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Ha a Kijelölés eszközzel duplán kattint egy csoportra, útvonalra vagy képre, az elkülönítő módban nyílik meg.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. A mintázatos kitöltések és körvonalak a grafikával együtt alakulnak át, hacsak egy átalakítás vagy az Átalakítás panel menüje mást nem választ.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Az élő sarkok sugara a grafikával együtt méreteződik, hacsak a méretezés mást nem választ.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5155,7 +5155,7 @@ font-technology Variable Variabel
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Seleksi › Sama › Warna isian, Warna stroke, dan Isian & stroke hanya mencocokkan tint yang sama dari swatch global atau spot, bukan sembarang tint-nya.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Menampilkan layar Home saat tidak ada dokumen yang terbuka; saat nonaktif, jendela tetap kosong sampai Anda mengklik Home.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mengukur objek beserta stroke dan efek yang mengubah bentuknya untuk ukuran, posisi, dan perataan; bayangan, cahaya, dan kekaburan tidak diukur.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Pada zum 100%, satu inci dokumen memakai 96 titik layar, bukan 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Pada zum 100%, satu inci dokumen mengisi satu inci layar, atau 96 titik layar bila sistem tidak melaporkan ukuran layar yang dapat dipakai.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Mengklik ganda grup, jalur, atau gambar dengan alat Seleksi membukanya dalam mode isolasi.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Isian dan stroke pola ikut bertransformasi dengan karya seni, kecuali transformasi atau menu panel Transformasi memilih lain.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Radius sudut dinamis ikut diskalakan dengan karya seni, kecuali penskalaan memilih lain.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3379,7 +3379,7 @@ digits Malayalam Malayalam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Selezione › Uguale › Colore riempimento, Colore traccia e Riempimento e traccia trovano solo la stessa tinta di un campione globale o di un colore spot, non qualsiasi sua tinta.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Mostra la schermata Home quando nessun documento è aperto; se disattivata, la finestra resta vuota finché non fai clic su Home.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Misura gli oggetti con le tracce e gli effetti che ne cambiano la forma per dimensioni, posizione e allineamento; ombre, bagliori e sfocature non vengono misurati.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Allo zoom del 100%, un pollice del documento occupa 96 punti dello schermo invece di 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Allo zoom del 100%, un pollice del documento occupa un pollice dello schermo, o 96 punti dello schermo se il sistema non ne indica dimensioni utilizzabili.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Un doppio clic su un gruppo, un tracciato o un'immagine con lo strumento Selezione lo apre in modalità isolamento.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. I riempimenti e le tracce con motivo si trasformano con la grafica, a meno che una trasformazione o il menu del pannello Trasforma scelga diversamente.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. I raggi degli angoli dinamici si ridimensionano con la grafica, a meno che il ridimensionamento scelga diversamente.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3344,7 +3344,7 @@ mark-style Japanese 日本式
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. 選択 › 共通 › カラー (塗り)、カラー (線)、塗りと線は、グローバルスウォッチまたは特色スウォッチの同じ濃度だけを選び、ほかの濃度は選びません。
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. ドキュメントが開いていないときにホーム画面を表示します。オフのときは、ホームをクリックするまでウィンドウは空のままです。
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. サイズ、位置、整列のために、線と形を変える効果を含めてオブジェクトを測ります。ドロップシャドウ、光彩、ぼかしは含めません。
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100% 表示のとき、ドキュメントの 1 インチを 72 ではなく 96 スクリーンポイントで表示します。
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100% 表示のとき、ドキュメントの 1 インチをディスプレイの 1 インチで表示します。システムが使用できるディスプレイのサイズを報告しない場合は 96 スクリーンポイントで表示します。
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. 選択ツールでグループ、パス、画像をダブルクリックすると、編集モードで開きます。
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. 変形コマンドや変形パネルのメニューで別の指定をしない限り、パターンの塗りと線をアートワークと一緒に変形します。
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. 拡大・縮小で別の指定をしない限り、ライブコーナーの半径をアートワークと一緒に拡大・縮小します。
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -6520,7 +6520,7 @@ font-technology Variable ცვლადი
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. მონიშვნა › იგივე › შევსების ფერი, კონტურის ფერი და შევსება და კონტური პოულობს გლობალური ან სპოტ-ფერის ნიმუშის მხოლოდ იმავე ტონირებას და არა მის ნებისმიერ ტონირებას.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. აჩვენებს საწყის ეკრანს, როცა არცერთი დოკუმენტი არ არის გახსნილი; გამორთვისას ფანჯარა ცარიელი რჩება, „საწყის ეკრანზე“ დაწკაპუნებამდე.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. ზომის, პოზიციისა და სწორების დროს ობიექტებს ზომავს კონტურებითა და ფორმის შემცვლელი ეფექტებით; ჩრდილები, ნათება და გაბუნდოვნება არ იზომება.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100%-იან მასშტაბზე დოკუმენტის ერთი დუიმი 72-ის ნაცვლად 96 ეკრანის პუნქტს იკავებს.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100%-იან მასშტაბზე დოკუმენტის ერთი დუიმი ეკრანის ერთ დუიმს ავსებს, ან 96 ეკრანის პუნქტს, როცა სისტემა ეკრანის გამოსადეგ ზომას არ აცნობებს.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. მონიშვნის ხელსაწყოთი ჯგუფზე, ტრაექტორიაზე ან გამოსახულებაზე ორჯერ დაწკაპუნება მას იზოლაციის რეჟიმში ხსნის.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. პატერნის შევსებები და კონტურები ნახატთან ერთად გარდაიქმნება, თუ გარდაქმნა ან გარდაქმნის პანელის მენიუ სხვას არ აირჩევს.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. ცოცხალი კუთხეების რადიუსები ნახატთან ერთად მასშტაბირდება, თუ მასშტაბირება სხვას არ აირჩევს.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3333,7 +3333,7 @@ mark-style Japanese 일본식
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. 선택 › 동일 › 칠 색상, 선 색상, 칠 및 선은 전역 또는 별색 견본의 같은 색조만 찾고, 다른 색조는 찾지 않습니다.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. 열린 문서가 없을 때 홈 화면을 표시합니다. 끄면 홈을 클릭할 때까지 창이 비어 있습니다.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. 크기, 위치, 정렬을 위해 선과 모양을 바꾸는 효과를 포함하여 개체를 측정합니다. 그림자, 광선, 흐림 효과는 측정하지 않습니다.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 100% 확대/축소에서 문서의 1인치가 72가 아닌 96 화면 포인트를 차지합니다.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 100% 확대/축소에서 문서의 1인치가 디스플레이의 1인치를 채우며, 시스템이 사용할 수 있는 디스플레이 크기를 알려 주지 않으면 96 화면 포인트를 차지합니다.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. 선택 도구로 그룹, 패스 또는 이미지를 두 번 클릭하면 격리 모드로 엽니다.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. 변형 명령이나 변형 패널의 메뉴에서 달리 선택하지 않는 한, 패턴 칠과 선이 아트웍과 함께 변형됩니다.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. 크기 조정에서 달리 선택하지 않는 한, 라이브 모퉁이 반지름이 아트웍과 함께 크기 조정됩니다.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5154,7 +5154,7 @@ font-technology Variable Variabel
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Selecteren › Zelfde › Vulkleur, Contourkleur en Vulling en contour vinden alleen dezelfde tint van een globaal of steunkleurstaal, niet elke tint ervan.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Toont het startscherm wanneer er geen document open is; uitgeschakeld blijft het venster leeg totdat u op Home klikt.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Meet objecten met hun contouren en vormveranderende effecten voor grootte, positie en uitlijning; schaduwen, gloed en vervagingen worden niet gemeten.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Bij 100% zoom neemt één inch van het document 96 schermpunten in beslag in plaats van 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Bij 100% zoom vult één inch van het document één inch van het scherm, of 96 schermpunten als het systeem geen bruikbare schermgrootte doorgeeft.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Dubbelklikken op een groep, pad of afbeelding met het gereedschap Selectie opent die in de isolatiemodus.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Patroonvullingen en -contouren transformeren mee met de illustratie, tenzij een transformatie of het menu van het deelvenster Transformeren anders kiest.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Dynamische hoekradii schalen mee met de illustratie, tenzij het schalen anders kiest.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4660,7 +4660,7 @@ font-technology Variable Zmienne
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Zaznacz › Taki sam › Kolor wypełnienia, Kolor obrysu oraz Wypełnienie i obrys dopasowują tylko ten sam odcień globalnej lub dodatkowej próbki, a nie dowolny jej odcień.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Pokazuje stronę startową, gdy nie jest otwarty żaden dokument; po wyłączeniu okno pozostaje puste, dopóki nie klikniesz Strona startowa.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mierzy obiekty razem z obrysami i efektami zmieniającymi kształt na potrzeby rozmiaru, położenia i wyrównania; cienie, poświaty i rozmycia nie są mierzone.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Przy powiększeniu 100% jeden cal dokumentu zajmuje 96 punktów ekranu zamiast 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Przy powiększeniu 100% jeden cal dokumentu wypełnia jeden cal ekranu albo 96 punktów ekranu, gdy system nie podaje użytecznego rozmiaru ekranu.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Dwukrotne kliknięcie grupy, ścieżki lub obrazu narzędziem Zaznaczanie otwiera je w trybie izolacji.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Wypełnienia i obrysy wzorkiem przekształcają się razem z kompozycją, chyba że przekształcenie lub menu panelu Przekształć wybierze inaczej.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Promienie narożników dynamicznych skalują się razem z kompozycją, chyba że skalowanie wybierze inaczej.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -2782,7 +2782,7 @@ digits Malayalam Malaiala
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Seleção › Igual › Cor de Preenchimento, Cor do Traçado e Preenchimento e Traçado encontram apenas o mesmo tom de uma amostra global ou de cor especial, não qualquer tom dela.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Mostra a tela Início quando nenhum documento está aberto; desativada, a janela fica vazia até você clicar em Início.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mede os objetos com seus traçados e efeitos que mudam a forma para tamanho, posição e alinhamento; sombras, brilhos e desfoques não são medidos.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Com zoom de 100%, uma polegada do documento ocupa 96 pontos de tela em vez de 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Com zoom de 100%, uma polegada do documento ocupa uma polegada da tela, ou 96 pontos de tela quando o sistema não informa um tamanho de tela utilizável.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Clicar duas vezes em um grupo, demarcador ou imagem com a ferramenta Seleção o abre no modo de isolamento.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Preenchimentos e traçados de padrão se transformam com a arte, a menos que uma transformação ou o menu do painel Transformar escolha outra coisa.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Os raios de canto dinâmicos mudam de escala com a arte, a menos que a escala escolha outra coisa.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3361,7 +3361,7 @@ digits Malayalam Малаялам
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. «Выделение › То же › Цвет заливки», «Цвет обводки» и «Заливка и обводка» находят только тот же оттенок глобального или плашечного образца, а не любой его оттенок.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Показывает начальный экран, когда нет открытых документов; если выключено, окно остаётся пустым, пока вы не нажмёте «Домой».
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Измеряет объекты с обводками и эффектами, меняющими форму, для размера, положения и выравнивания; тени, свечения и размытия не учитываются.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. При масштабе 100 % один дюйм документа занимает 96 экранных пунктов вместо 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. При масштабе 100 % один дюйм документа занимает один дюйм дисплея или 96 экранных пунктов, если система не сообщает пригодный размер дисплея.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Двойной щелчок по группе, контуру или изображению инструментом «Выделение» открывает их в режиме изоляции.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Заливки и обводки узором трансформируются вместе с графикой, если трансформирование или меню панели «Трансформировать» не задаёт иное.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Радиусы динамических углов масштабируются вместе с графикой, если масштабирование не задаёт иное.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3247,7 +3247,7 @@ digits Malayalam Malayalam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Markera › Samma › Fyllnadsfärg, Konturfärg och Fyllning och kontur hittar bara samma nyans av ett globalt färgprov eller en dekorfärg, inte vilken nyans som helst av det.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Visar startskärmen när inget dokument är öppet; när det är av förblir fönstret tomt tills du klickar på Start.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Mäter objekt med deras konturer och formändrande effekter för storlek, position och justering; skuggor, glöd och oskärpa mäts inte.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Vid 100 % zoom tar en tum av dokumentet upp 96 skärmpunkter i stället för 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Vid 100 % zoom fyller en tum av dokumentet en tum av skärmen, eller 96 skärmpunkter om systemet inte anger en användbar skärmstorlek.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Dubbelklick på en grupp, en bana eller en bild med verktyget Markering öppnar den i isoleringsläge.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Mönsterfyllningar och -konturer transformeras med grafiken, om inte en transformering eller menyn i panelen Transformera väljer annat.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Dynamiska hörnradier skalas med grafiken, om inte skalningen väljer annat.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3086,7 +3086,7 @@ digits Malayalam Malayalam
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Seçim › Aynı › Dolgu Rengi, Kontur Rengi ve Doldur ve Konturla yalnızca genel veya spot renk örneğinin aynı tonunu bulur, herhangi bir tonunu değil.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Hiçbir belge açık değilken Ana Sayfa ekranını gösterir; kapalıyken siz Ana Sayfa'ya tıklayana kadar pencere boş kalır.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Nesneleri boyut, konum ve hizalama için konturları ve şekil değiştiren efektleriyle birlikte ölçer; gölgeler, parlamalar ve bulanıklaştırmalar ölçülmez.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. %100 yakınlaştırmada belgenin bir inçi 72 yerine 96 ekran noktası kaplar.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. %100 yakınlaştırmada belgenin bir inçi ekranın bir inçini kaplar; sistem kullanılabilir bir ekran boyutu bildirmezse 96 ekran noktası kaplar.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Seçim aracıyla bir gruba, yola veya görüntüye çift tıklamak onu yalıtım modunda açar.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Desen dolguları ve konturları, bir dönüşüm veya Dönüştür panelinin menüsü başka bir seçim yapmadıkça resimle birlikte dönüşür.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Canlı köşe yarıçapları, ölçekleme başka bir seçim yapmadıkça resimle birlikte ölçeklenir.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3371,7 +3371,7 @@ digits Malayalam Малаялам
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. «Виділення › Те саме › Колір заливки», «Колір обведення» та «Заливка та обведення» знаходять лише той самий відтінок глобального або плашкового зразка, а не будь-який його відтінок.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Показує початковий екран, коли немає відкритих документів; якщо вимкнено, вікно лишається порожнім, доки ви не натиснете «Додому».
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Вимірює об’єкти з обведеннями та ефектами, що змінюють форму, для розміру, положення й вирівнювання; тіні, світіння та розмиття не враховуються.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. За масштабу 100 % один дюйм документа займає 96 екранних пунктів замість 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. За масштабу 100 % один дюйм документа займає один дюйм дисплея або 96 екранних пунктів, якщо система не повідомляє придатний розмір дисплея.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Подвійне клацання на групі, контурі або зображенні інструментом «Виділення» відкриває їх у режимі ізоляції.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Заливки й обведення візерунком трансформуються разом із графікою, якщо трансформування або меню панелі «Трансформувати» не задає іншого.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Радіуси динамічних кутів масштабуються разом із графікою, якщо масштабування не задає іншого.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3691,7 +3691,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. Vùng chọn › Giống nhau › Màu tô, Màu nét và Tô & Nét chỉ khớp với cùng sắc độ của một mẫu màu toàn cục hoặc màu pha, không phải mọi sắc độ của nó.
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. Hiển thị màn hình Trang chủ khi không có tài liệu nào mở; khi tắt, cửa sổ để trống cho đến khi bạn nhấp vào Trang chủ.
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. Đo đối tượng cùng với nét và các hiệu ứng thay đổi hình dạng cho kích thước, vị trí và căn chỉnh; bóng đổ, ánh sáng và làm mờ không được đo.
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. Ở mức thu phóng 100%, một inch của tài liệu chiếm 96 điểm màn hình thay vì 72.
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. Ở mức thu phóng 100%, một inch của tài liệu chiếm một inch trên màn hình, hoặc 96 điểm màn hình khi hệ thống không báo kích thước màn hình dùng được.
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. Nhấp đúp vào một nhóm, đường dẫn hoặc hình ảnh bằng công cụ Vùng chọn sẽ mở nó trong chế độ cô lập.
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. Phần tô và nét họa tiết biến đổi cùng hình minh họa, trừ khi phép biến đổi hoặc menu của bảng Biến đổi chọn khác.
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. Bán kính góc động co giãn cùng hình minh họa, trừ khi phép co giãn chọn khác.
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3220,7 +3220,7 @@ digits Malayalam 马拉雅拉姆数字
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. 选择 › 相同 › 填色、描边颜色和填色和描边只匹配全局色板或专色色板的相同色调,而不是其任意色调。
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. 没有打开文档时显示主页屏幕;关闭时,窗口保持空白,直到你点击主页。
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. 在尺寸、位置和对齐中按对象的描边和改变形状的效果测量对象;阴影、发光和模糊不计入测量。
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 缩放为 100% 时,文档的一英寸占 96 个屏幕点,而不是 72 个。
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 缩放为 100% 时,文档的一英寸占显示器上的一英寸;系统未报告可用的显示器尺寸时占 96 个屏幕点。
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. 用选择工具双击编组、路径或图像时,会在隔离模式中打开它。
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. 图案填色和描边随图稿一起变换,除非变换命令或变换面板的菜单另有选择。
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. 实时转角半径随图稿一起缩放,除非缩放命令另有选择。
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4669,7 +4669,7 @@ digits Malayalam 馬來亞拉姆數字
|
||||
Select › Same › Fill Color, Stroke Color and Fill & Stroke match only the same tint of a global or spot swatch, not any tint of it. 選取 › 相同 › 填色顏色、筆畫顏色和填色與筆畫只符合全域色票或特別色色票的相同色調,而不是其任意色調。
|
||||
Shows the Home screen when no document is open; off, the window stays empty until you click Home. 沒有開啟文件時顯示首頁畫面;關閉時,視窗保持空白,直到你按下首頁。
|
||||
Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured. 在尺寸、位置和對齊中依物件的筆畫和改變形狀的效果測量物件;陰影、光暈和模糊不計入測量。
|
||||
At 100% zoom, one inch of the document takes 96 screen points instead of 72. 縮放為 100% 時,文件的一英吋佔 96 個螢幕點,而不是 72 個。
|
||||
At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size. 縮放為 100% 時,文件的一英吋佔顯示器上的一英吋;系統未回報可用的顯示器尺寸時佔 96 個螢幕點。
|
||||
Double-clicking a group, path or image with the Selection tool opens it in isolation mode. 用選取工具按兩下群組、路徑或影像時,會在隔離模式中開啟它。
|
||||
Pattern fills and strokes transform with the art, unless a transform or the Transform panel's menu chooses otherwise. 圖樣填色和筆畫隨圖稿一起變形,除非變形指令或變形面板的選單另有選擇。
|
||||
Live corner radii scale with the art, unless the scale chooses otherwise. 即時轉角半徑隨圖稿一起縮放,除非縮放指令另有選擇。
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -127,7 +127,7 @@ pub use app::MAX_RECENT_FONTS;
|
||||
pub use caches::{CacheKey, CanvasCache, LivePaintGapsCache, Perf, PlacedKey, PrintTilingCache, SliceCache};
|
||||
#[cfg(test)]
|
||||
pub(crate) use services::browsable_url;
|
||||
pub use services::{DownloadFn, ExistsFn, Inbox, ReadFn, SaveStreamFn, SaveWriteFn, Services, WriteFn};
|
||||
pub use services::{DownloadFn, ExistsFn, Inbox, ReadFn, SaveStreamFn, SaveWriteFn, ScreenDensity, ScreenPpi, Services, WriteFn};
|
||||
pub use ui_fonts::ui_fonts;
|
||||
|
||||
pub struct VectorcraftApp {
|
||||
|
||||
@@ -469,12 +469,13 @@ fn run_ui_part5(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
"view.snapToPoint" => flag(&mut app.ui.view.snap_to_point),
|
||||
"view.zoomIn" | "view.zoomOut" => {
|
||||
let up = id == "view.zoomIn";
|
||||
let print = app.session.prefs.display_print_size;
|
||||
let print = app.print_ppi();
|
||||
// Selection & Anchor Display › Zoom to Selection: the selection comes to the middle.
|
||||
let focus = if app.session.prefs.zoom_to_selection { app.selection_box().map(|b| b.center()) } else { None };
|
||||
match app.view_mut() {
|
||||
Some(v) => {
|
||||
v.zoom = next_zoom(v.zoom, up, print);
|
||||
v.fit_zoom = None;
|
||||
if let Some(c) = focus {
|
||||
v.center = c;
|
||||
}
|
||||
@@ -484,7 +485,7 @@ fn run_ui_part5(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
}
|
||||
}
|
||||
"view.setZoom" => {
|
||||
let print = app.session.prefs.display_print_size;
|
||||
let print = app.print_ppi();
|
||||
let (zoom, center) = match opt_number(p, "zoom").and_then(|z| Ok((z, opt_point(p, "center")?))) {
|
||||
Ok(given) => given,
|
||||
Err(e) => return Some(Err(e)),
|
||||
@@ -493,6 +494,8 @@ fn run_ui_part5(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
|
||||
match app.view_mut() {
|
||||
Some(v) => {
|
||||
v.zoom = z.clamp(0.0313, 640.0);
|
||||
// A percentage, not a fit: the first reading of the display keeps it.
|
||||
v.fit_zoom = None;
|
||||
v.fitted = true;
|
||||
if let Some(c) = center {
|
||||
v.center = c;
|
||||
|
||||
@@ -485,7 +485,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"view.actualSize",
|
||||
"Actual Size",
|
||||
"Cmd+1",
|
||||
"{} 100%: with Display Print Size at 100% Zoom off, one document point per screen point; on, one document inch fills 96 screen points (an inch at the system's reference density, whatever the display scaling); the same at every UI Scaling",
|
||||
"{} 100%: with Display Print Size at 100% Zoom off, one document point per screen point; on, one document inch fills an inch of the display that shows the window, measured from the physical size the system reports for it, or 96 screen points where it reports none or a size no display has; the same at every UI Scaling",
|
||||
),
|
||||
("view.setZoom", "Set Zoom", "", "{zoom: percent, center?: [x,y]}"),
|
||||
(
|
||||
|
||||
@@ -208,8 +208,7 @@ pub(crate) fn lines(app: &mut VectorcraftApp, ctx: &egui::Context) -> InfoLines
|
||||
});
|
||||
let zoom = (app.session.tool_id() == "zoom").then(|| {
|
||||
let zoom = app.view().map_or(1.0, |v| v.zoom);
|
||||
// PLAN: assumed `crate::state::zoom_label(zoom: f64, print: bool) -> String`, kept by hub-w1.
|
||||
format!("{} {}", crate::i18n::colon(tl!("Zoom")), crate::state::zoom_label(zoom, app.session.prefs.display_print_size))
|
||||
format!("{} {}", crate::i18n::colon(tl!("Zoom")), crate::state::zoom_label(zoom, app.print_ppi()))
|
||||
});
|
||||
let brush = if let Some(Readout::Brush { name }) = readout { name } else { None };
|
||||
let (f, s) = current_paints(app);
|
||||
|
||||
@@ -87,7 +87,7 @@ fn target_circle_marks_follow_targeted_and_styled() {
|
||||
let thin = std::rc::Rc::new(std::cell::Cell::new(f32::INFINITY));
|
||||
let seen = std::rc::Rc::clone(&thin);
|
||||
let mut fixture = craft::ui::testing::Fixture::new(move |ui| seen.set(craft::ui::runtime::env::Env::of(ui).tokens.stroke.thin));
|
||||
fixture.root(crate::app::root_env(&vectorcraft_engine::Prefs::default(), 1.0)).frame(vec![]);
|
||||
fixture.root(crate::app::root_env(&vectorcraft_engine::Prefs::default(), 1.0, None)).frame(vec![]);
|
||||
assert!(TARGET_DOT_IN_RING + 0.5 < TARGET_RING - thin.get() / 2.0, "the dot covers the ring");
|
||||
}
|
||||
|
||||
|
||||
@@ -231,8 +231,9 @@ fn shifted(mut view: CanvasView, region: DRect) -> CanvasView {
|
||||
}
|
||||
|
||||
/// The `view.setZoom` params for `edited`, a view of the region's frame: the zoom as the status bar
|
||||
/// shows it (in print size with `print`), and the centre back in document units.
|
||||
fn view_params(edited: &CanvasView, region: DRect, print: bool) -> Value {
|
||||
/// shows it (with `print` screen points to an inch at 100%, [`crate::state::print_ppi`]), and the
|
||||
/// centre back in document units.
|
||||
fn view_params(edited: &CanvasView, region: DRect, print: Option<f64>) -> Value {
|
||||
json!({"zoom": crate::state::zoom_display_percent(edited.zoom, print), "center": [edited.center.x + region.x0, edited.center.y + region.y0]})
|
||||
}
|
||||
|
||||
@@ -278,7 +279,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if let Some(edited) = out.view.value()
|
||||
&& *edited != given
|
||||
{
|
||||
let print = app.session.prefs.display_print_size;
|
||||
let print = app.print_ppi();
|
||||
app.run("view.setZoom", view_params(edited, region, print)).ok();
|
||||
}
|
||||
}
|
||||
@@ -298,7 +299,7 @@ mod tests {
|
||||
assert_eq!((given.center.x, given.center.y), (210.0, 170.0), "the centre minus the region's corner");
|
||||
let mut edited = given;
|
||||
edited.center = (100.0, 100.0).into();
|
||||
assert_eq!(view_params(&edited, region, false)["center"], json!([90.0, 80.0]), "the edit plus the region's corner");
|
||||
assert_eq!(view_params(&edited, region, None)["center"], json!([90.0, 80.0]), "the edit plus the region's corner");
|
||||
}
|
||||
|
||||
/// The panel menu's rows are titled, checked and enabled as the option says, and each row's
|
||||
|
||||
@@ -28,7 +28,10 @@ pub(crate) const DESCRIPTIONS: &[(&str, &str)] = &[
|
||||
"usePreviewBounds",
|
||||
"Measures objects with their strokes and shape-changing effects for size, position and alignment; shadows, glows and blurs are not measured.",
|
||||
),
|
||||
("displayPrintSize", "At 100% zoom, one inch of the document takes 96 screen points instead of 72."),
|
||||
(
|
||||
"displayPrintSize",
|
||||
"At 100% zoom, one inch of the document fills an inch of the display, or 96 screen points where the system reports no usable display size.",
|
||||
),
|
||||
("doubleClickToIsolate", "Double-clicking a group, path or image with the Selection tool opens it in isolation mode."),
|
||||
(
|
||||
"transformPatternTiles",
|
||||
|
||||
@@ -114,8 +114,74 @@ pub struct Services {
|
||||
pub print: Option<Box<dyn print::PrintService>>,
|
||||
/// The macOS menu bar, when the desktop app installed one: the in-window menus are hidden then.
|
||||
pub native_menu: Option<craft::menu::NativeMenu>,
|
||||
/// The density of the display that shows most of the main window, in the window's points
|
||||
/// (before UI Scaling) per inch, from the physical size the system reports for that display.
|
||||
/// The desktop host keeps it current as the window moves between displays. With Display Print
|
||||
/// Size at 100% Zoom, 100% shows one document inch in this many points ([`crate::state::print_ppi`]).
|
||||
/// [`ScreenPpi::Unread`] on the web and until the host's first reading; a display that
|
||||
/// reports no size reads as `Read(None)`. Either way an inch then takes 96 points. The views
|
||||
/// the main window shows count from it; a document floating in an OS window of its own counts
|
||||
/// from the display that shows that window ([`Self::screens`]).
|
||||
pub screen_ppi: ScreenPpi,
|
||||
/// The connected displays with their densities, kept current by the desktop host while
|
||||
/// Display Print Size at 100% Zoom is on, for the document windows floating in OS windows of
|
||||
/// their own ([`screen_ppi_at`]). Empty on the web.
|
||||
pub screens: Vec<ScreenDensity>,
|
||||
/// The text Help › Copy Troubleshooting Info copies (desktop: the platform, the graphics
|
||||
/// processor, recent commands and frame times, and the hang reports of this session and the
|
||||
/// one before). Without it the command copies the version only ([`crate::troubleshooting`]).
|
||||
pub troubleshooting: Option<Box<dyn Fn() -> String>>,
|
||||
}
|
||||
|
||||
/// The density of a display as far as the host has read it ([`Services::screen_ppi`]).
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
pub enum ScreenPpi {
|
||||
/// Not read yet.
|
||||
#[default]
|
||||
Unread,
|
||||
/// Read: its points to an inch, `None` for a display that reports no physical size.
|
||||
Read(Option<f64>),
|
||||
}
|
||||
|
||||
impl ScreenPpi {
|
||||
/// The points to an inch, when the display was read and reports a size.
|
||||
pub fn ppi(self) -> Option<f64> {
|
||||
match self {
|
||||
Self::Read(ppi) => ppi,
|
||||
Self::Unread => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A connected display ([`Services::screens`]): where it is on the desktop, in the physical pixels
|
||||
/// winit gives its position and size in, its scale factor, and its density in points (at that
|
||||
/// scale factor) per inch: `Read(None)` where the system reports no physical size for it, and
|
||||
/// unread while it has not answered.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct ScreenDensity {
|
||||
/// Left, top, width and height in physical pixels.
|
||||
pub rect: [i32; 4],
|
||||
pub scale: f64,
|
||||
pub ppi: ScreenPpi,
|
||||
}
|
||||
|
||||
/// The density of the display that shows most of the viewport `ctx` draws, from `screens`: of the
|
||||
/// displays at the viewport's scale factor, the one whose rect covers the largest part of the
|
||||
/// viewport, in the physical pixels of that scale factor. On macOS each display's pixels are its
|
||||
/// points times its own scale factor, so displays of different scales can overlap in those pixels
|
||||
/// and the scale tells them apart. `None` when the viewport reports no position (Wayland, the web)
|
||||
/// or covers no display.
|
||||
pub fn screen_ppi_at(screens: &[ScreenDensity], ctx: &egui::Context) -> Option<ScreenPpi> {
|
||||
let (rect, ppp, native) = ctx.input(|i| (i.viewport().outer_rect, i.pixels_per_point(), i.viewport().native_pixels_per_point));
|
||||
let (rect, ppp, native) = (rect?, f64::from(ppp), f64::from(native?));
|
||||
let [l, t, r, b] = [rect.left(), rect.top(), rect.right(), rect.bottom()].map(|v| f64::from(v) * ppp);
|
||||
if ![l, t, r, b].iter().all(|v| v.is_finite()) {
|
||||
return None;
|
||||
}
|
||||
let covered = |s: &ScreenDensity| {
|
||||
let [x, y, w, h] = s.rect.map(f64::from);
|
||||
((r.min(x + w) - l.max(x)).max(0.0)) * ((b.min(y + h) - t.max(y)).max(0.0))
|
||||
};
|
||||
let best = screens.iter().filter(|s| (s.scale - native).abs() < 1e-3).map(|s| (covered(s), s)).max_by(|a, b| a.0.total_cmp(&b.0))?;
|
||||
(best.0 > 0.0).then_some(best.1.ppi)
|
||||
}
|
||||
|
||||
+88
-22
@@ -76,6 +76,21 @@ pub struct View {
|
||||
/// document opens in Preview.
|
||||
#[serde(default)]
|
||||
pub outline: bool,
|
||||
/// The density of the display the view was last shown on ([`crate::Services::screen_ppi`]),
|
||||
/// which its zoom percentage counts from with Display Print Size at 100% Zoom; `None` until
|
||||
/// the view was first shown ([`crate::VectorcraftApp::settle_screen_ppi`]).
|
||||
#[serde(skip)]
|
||||
pub(crate) shown_ppi: Option<crate::ScreenPpi>,
|
||||
/// The zoom a fit to the window, or the document's saved view, gave the view. While the view
|
||||
/// still has it, the first reading of its display leaves the zoom alone; a zoom chosen as a
|
||||
/// percentage keeps its percentage then ([`crate::VectorcraftApp::settle_screen_ppi`]).
|
||||
#[serde(skip)]
|
||||
pub(crate) fit_zoom: Option<f64>,
|
||||
/// The fit that gave [`Self::fit_zoom`] was made while the view's display was being read: the
|
||||
/// view counts from the last reading meanwhile, and the reading, when it comes, leaves the zoom
|
||||
/// alone while the view still has it.
|
||||
#[serde(skip)]
|
||||
pub(crate) fit_unread: bool,
|
||||
/// The canvas on screen, inside the rulers, as the last pass laid it out (screen points).
|
||||
#[serde(skip, default = "no_rect")]
|
||||
pub rect: egui::Rect,
|
||||
@@ -97,6 +112,9 @@ impl Default for View {
|
||||
rotation: 0.0,
|
||||
artboard: 0,
|
||||
outline: false,
|
||||
shown_ppi: None,
|
||||
fit_zoom: None,
|
||||
fit_unread: false,
|
||||
rect: egui::Rect::NOTHING,
|
||||
request: None,
|
||||
moved: None,
|
||||
@@ -117,8 +135,10 @@ impl View {
|
||||
/// the zoom range; `None` when the canvas can't show it (a zoom or centre that isn't finite, a
|
||||
/// zoom of 0 or less).
|
||||
pub fn saved(v: &vectorcraft_engine::doc::SavedView) -> Option<Self> {
|
||||
let zoom = v.zoom.clamp(0.0313, 640.0);
|
||||
v.is_usable().then(|| Self {
|
||||
zoom: v.zoom.clamp(0.0313, 640.0),
|
||||
zoom,
|
||||
fit_zoom: Some(zoom),
|
||||
center: v.center,
|
||||
fitted: true,
|
||||
rotation: if v.rotation.is_finite() { v.rotation } else { 0.0 },
|
||||
@@ -159,37 +179,59 @@ pub const ROTATE_VIEW_ANGLES: [(&str, f64); 12] = [
|
||||
("-90°", -90.0),
|
||||
];
|
||||
|
||||
/// Screen points in an inch when the system reports no physical size for the display: the
|
||||
/// reference density that display scaling is set against (a CSS inch).
|
||||
pub const REFERENCE_PPI: f64 = 96.0;
|
||||
|
||||
/// The pixel densities a measured display may have, in pixels per inch, before the display scale
|
||||
/// divides them into screen points. A size outside them is a wrong report (a projector or
|
||||
/// television that gives its aspect ratio as its size, or none).
|
||||
pub const SCREEN_PPI_RANGE: std::ops::RangeInclusive<f64> = 30.0..=1000.0;
|
||||
|
||||
/// The screen points one inch takes at 100% zoom: `None` with Preferences › General › Display
|
||||
/// Print Size at 100% Zoom off, else the measured density of the display (`screen_ppi`,
|
||||
/// [`crate::Services::screen_ppi`]), or [`REFERENCE_PPI`] when the display has none. A measured
|
||||
/// density is taken when it is finite and positive: the host checks the display's pixels against
|
||||
/// [`SCREEN_PPI_RANGE`] before the display scale divides them into points, so a point density can
|
||||
/// fall outside that range.
|
||||
pub fn print_ppi(display_print_size: bool, screen_ppi: Option<f64>) -> Option<f64> {
|
||||
display_print_size.then(|| screen_ppi.filter(|p| p.is_finite() && *p > 0.0).unwrap_or(REFERENCE_PPI))
|
||||
}
|
||||
|
||||
/// Document zoom at 100% in the status bar: one screen point per document point, or with
|
||||
/// Preferences › General › Display Print Size at 100% Zoom, one document inch in 96 screen points.
|
||||
pub fn zoom_baseline(display_print_size: bool) -> f64 {
|
||||
if display_print_size { 96.0 / 72.0 } else { 1.0 }
|
||||
/// Preferences › General › Display Print Size at 100% Zoom ([`print_ppi`] `Some`), one document
|
||||
/// inch (72 pt) in an inch of the screen, `print` screen points.
|
||||
pub fn zoom_baseline(print: Option<f64>) -> f64 {
|
||||
print.map_or(1.0, |ppi| ppi / 72.0)
|
||||
}
|
||||
|
||||
/// The zoom stops with 100% at [`zoom_baseline`]: the one scheme the status bar, the zoom
|
||||
/// commands and the canvas step through.
|
||||
fn zoom_stops(display_print_size: bool) -> ZoomScheme {
|
||||
ZoomScheme::ILLUSTRATOR.with_hundred(zoom_baseline(display_print_size))
|
||||
fn zoom_stops(print: Option<f64>) -> ZoomScheme {
|
||||
ZoomScheme::ILLUSTRATOR.with_hundred(zoom_baseline(print))
|
||||
}
|
||||
|
||||
/// The zoom `z` as the status bar shows it, in percent of [`zoom_baseline`].
|
||||
pub fn zoom_display_percent(z: f64, display_print_size: bool) -> f64 {
|
||||
zoom_stops(display_print_size).percent(z)
|
||||
pub fn zoom_display_percent(z: f64, print: Option<f64>) -> f64 {
|
||||
zoom_stops(print).percent(z)
|
||||
}
|
||||
|
||||
/// The zoom the status bar's `pct` stands for.
|
||||
pub fn zoom_from_display_percent(pct: f64, display_print_size: bool) -> f64 {
|
||||
zoom_stops(display_print_size).device(pct)
|
||||
pub fn zoom_from_display_percent(pct: f64, print: Option<f64>) -> f64 {
|
||||
zoom_stops(print).device(pct)
|
||||
}
|
||||
|
||||
/// The zoom stop after `z`, up or down, within the zoom range. The range has a fixed floor, so
|
||||
/// the document's size does not enter.
|
||||
pub fn next_zoom(z: f64, up: bool, display_print_size: bool) -> f64 {
|
||||
zoom_stops(display_print_size).step(z, if up { 1 } else { -1 }, vectorcraft_geom::Size::ZERO)
|
||||
/// the document's size does not enter. The stops count from [`zoom_baseline`]`(print)`; past the
|
||||
/// last stop in that direction, the zoom stays where it is.
|
||||
pub fn next_zoom(z: f64, up: bool, print: Option<f64>) -> f64 {
|
||||
let stop = zoom_stops(print).step(z, if up { 1 } else { -1 }, vectorcraft_geom::Size::ZERO).clamp(0.0313, 640.0);
|
||||
if up { stop.max(z) } else { stop.min(z) }
|
||||
}
|
||||
|
||||
/// Format for the tab/zoom field: up to 2 decimals, no trailing zeros.
|
||||
pub fn zoom_label(z: f64, display_print_size: bool) -> String {
|
||||
let s = format!("{:.2}", zoom_display_percent(z, display_print_size));
|
||||
pub fn zoom_label(z: f64, print: Option<f64>) -> String {
|
||||
let s = format!("{:.2}", zoom_display_percent(z, print));
|
||||
let s = s.trim_end_matches('0').trim_end_matches('.');
|
||||
format!("{s}%")
|
||||
}
|
||||
@@ -1566,19 +1608,43 @@ mod tests {
|
||||
/// storytold/vectorcraft#2719: 100% in the zoom field matches Actual Size when Display Print Size is on.
|
||||
#[test]
|
||||
fn zoom_percent_honors_display_print_size_baseline() {
|
||||
let print = zoom_baseline(true);
|
||||
assert!(print > zoom_baseline(false), "an inch in 96 points zooms in past one point per point");
|
||||
for display_print_size in [false, true] {
|
||||
let print = zoom_baseline(print_ppi(true, None));
|
||||
assert!(print > zoom_baseline(None), "an inch in 96 points zooms in past one point per point");
|
||||
for display_print_size in [None, print_ppi(true, None)] {
|
||||
let baseline = zoom_baseline(display_print_size);
|
||||
assert!((zoom_display_percent(baseline, display_print_size) - 100.0).abs() < 1e-9, "{display_print_size}");
|
||||
assert!((zoom_from_display_percent(100.0, display_print_size) - baseline).abs() < 1e-9, "{display_print_size}");
|
||||
assert!((zoom_display_percent(baseline, display_print_size) - 100.0).abs() < 1e-9, "{display_print_size:?}");
|
||||
assert!((zoom_from_display_percent(100.0, display_print_size) - baseline).abs() < 1e-9, "{display_print_size:?}");
|
||||
let up = next_zoom(baseline, true, display_print_size);
|
||||
let down = next_zoom(baseline, false, display_print_size);
|
||||
assert!(up > baseline && down < baseline, "{display_print_size}: {down} < {baseline} < {up}");
|
||||
assert!(zoom_display_percent(up, display_print_size) > 100.0, "{display_print_size}");
|
||||
assert!(up > baseline && down < baseline, "{display_print_size:?}: {down} < {baseline} < {up}");
|
||||
assert!(zoom_display_percent(up, display_print_size) > 100.0, "{display_print_size:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// #9051: with Display Print Size on, 100% follows the measured density of the display, so an
|
||||
/// inch of the document takes as many screen points as an inch of that display holds. A
|
||||
/// density that is not finite and positive counts as no measurement.
|
||||
#[test]
|
||||
fn print_size_follows_the_displays_measured_density() {
|
||||
assert_eq!(print_ppi(false, Some(127.0)), None, "the preference off ignores the display");
|
||||
let (dense, sparse) = (print_ppi(true, Some(127.0)), print_ppi(true, Some(91.0)));
|
||||
assert!(zoom_baseline(dense) > zoom_baseline(print_ppi(true, None)), "a denser display than the reference zooms 100% further in");
|
||||
assert!(zoom_baseline(sparse) < zoom_baseline(print_ppi(true, None)), "a sparser one zooms it out");
|
||||
assert!((zoom_baseline(dense) * 72.0 - 127.0).abs() < 1e-9, "an inch of the document fills an inch of the display");
|
||||
for wrong in [Some(0.0), Some(-5.0), Some(f64::NAN), Some(f64::INFINITY), Some(f64::NEG_INFINITY), None] {
|
||||
assert_eq!(print_ppi(true, wrong), print_ppi(true, None), "{wrong:?} is no measurement");
|
||||
}
|
||||
assert_eq!(print_ppi(true, Some(23.15)), Some(23.15), "a display at a large scale factor has few points to an inch");
|
||||
assert_eq!(print_ppi(true, Some(1600.0)), Some(1600.0), "and one at a scale below 1 many");
|
||||
assert_eq!(zoom_label(zoom_from_display_percent(100.0, dense), dense), "100%");
|
||||
let thin = print_ppi(true, Some(40.0));
|
||||
assert!(next_zoom(0.0313, false, thin) >= 0.0313, "the last stop down stays in the zoom range");
|
||||
assert!(next_zoom(600.0, true, print_ppi(true, Some(900.0))) <= 640.0, "and the last stop up");
|
||||
let reference = print_ppi(true, None);
|
||||
assert!(next_zoom(0.0313, false, reference) <= 0.0313, "past the last stop, zooming out does not zoom in");
|
||||
assert!(next_zoom(640.0, true, thin) >= 640.0, "nor zooming in out");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_document_opens_on_the_artboard_its_file_names_as_active() {
|
||||
let mut doc = vectorcraft_doc::Document::new(100.0, 100.0);
|
||||
|
||||
@@ -14,7 +14,9 @@ pub(crate) fn install(ctx: &egui::Context) {
|
||||
if embed::install(ctx, craft::ui::testing::install_spec(), &fonts).is_err() {
|
||||
fonts.install(ctx);
|
||||
}
|
||||
set_input(ctx, FrameInput::new(crate::app::root_env(&vectorcraft_engine::Prefs::default(), 1.0)));
|
||||
let prefs = vectorcraft_engine::Prefs::default();
|
||||
let print = crate::state::print_ppi(prefs.display_print_size, None);
|
||||
set_input(ctx, FrameInput::new(crate::app::root_env(&prefs, 1.0, print)));
|
||||
}
|
||||
|
||||
/// `app` shown in a window of its own: its context is the one every frame of the test runs on, so its dialogs open on
|
||||
|
||||
@@ -175,7 +175,7 @@ fn tools_open_their_options() {
|
||||
assert_eq!((v.center.x, v.center.y, v.zoom), (150.0, 100.0, 2.0));
|
||||
open_options(&mut app, "zoom").unwrap();
|
||||
canvas_pass(&mut app);
|
||||
assert_eq!(app.view().unwrap().zoom, 1.0);
|
||||
assert_eq!(app.view().unwrap().zoom, crate::state::zoom_baseline(app.print_ppi()));
|
||||
// With an object selected, the transform tools open their dialogs and the selection tools open Move.
|
||||
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 40, "height": 20})).unwrap();
|
||||
for (tool, dialog) in [
|
||||
|
||||
+15
-4
@@ -8627,10 +8627,21 @@ their own Anti-aliasing option),
|
||||
`scrubNumericFields` (on: a horizontal drag on a numeric field's label steps the field, one undo step per drag; the
|
||||
control channel's `ui.drag` scrubs), `showHomeScreen` (on by default: the Home screen while no document is open;
|
||||
off, an empty window, and the Home button or `app.home` still shows the screen), `autoCollapseIconPanels` (off by
|
||||
default: on, a click away from a panel popped out of the icon column puts it away), `displayPrintSize` (off by
|
||||
default: View › Actual Size / `view.actualSize` is one document point per screen point; on, one document inch fills
|
||||
96 screen points, an inch at the system's reference density whatever the display scaling). `uiScaling` scales the
|
||||
interface and not the art: a zoom shows the art at the same size at every UI Scaling. The tool shortcut
|
||||
default: on, a click away from a panel popped out of the icon column puts it away), `displayPrintSize` (on by
|
||||
default, also for saved preferences without the key: View › Actual Size / `view.actualSize` shows one document inch
|
||||
in an inch of the display that shows the document's window, measured from the physical size macOS, Windows, or on
|
||||
Linux X11 or the Wayland compositor reports for that display. A document under the tabs counts from the main
|
||||
window's display, and a document floating in an OS window of its own counts from that window's display. It also
|
||||
applies in Pixel Preview. A window that moves to a display of another density keeps its zoom percentage. Where no
|
||||
display is measured (the web build, the headless backend, `vectorcraft-cli`, and the desktop app on other systems),
|
||||
where the system reports no size, or where it reports a size no display has, an inch is 96 screen points, so Actual
|
||||
Size there shows 4/3 screen points per document point. When the first measurement of a display
|
||||
arrives, a view that still has the zoom a fit or the document's saved view gave it keeps that zoom, and any other
|
||||
view keeps its zoom percentage. Off, 100% is one document point per screen point, and the desktop app does not
|
||||
measure the displays. While it is on, `ui.inspect` gives `screenPpi`, the measured density of the main window's
|
||||
display, and
|
||||
`printPpi`, the points an inch takes at 100% in the current window; both are null while it is off). `uiScaling`
|
||||
scales the interface and not the art: a zoom shows the art at the same size at every UI Scaling. The tool shortcut
|
||||
preference `holdToolKeys` also needs the desktop app. It is on by default: a single-key tool shortcut held for 0.25 s
|
||||
or more, or held while its tool is used, chooses the tool until the key is let go and then returns to the tool active
|
||||
before, after any drag in progress; a quicker press chooses the tool for good. With it off, every press and every key
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user