diff --git a/crates/fj-viewer/src/camera.rs b/crates/fj-viewer/src/camera.rs index dcfb6e6bc..566375432 100644 --- a/crates/fj-viewer/src/camera.rs +++ b/crates/fj-viewer/src/camera.rs @@ -4,7 +4,7 @@ use std::f64::consts::FRAC_PI_2; use fj_interop::TriMesh; use fj_math::{Aabb, Point, Scalar, Transform, Vector}; -use crate::screen::NormalizedScreenPosition; +use crate::window::NormalizedScreenPosition; /// The camera abstraction /// diff --git a/crates/fj-viewer/src/display.rs b/crates/fj-viewer/src/display.rs index 1abd696a8..0bc42b3d1 100644 --- a/crates/fj-viewer/src/display.rs +++ b/crates/fj-viewer/src/display.rs @@ -15,9 +15,8 @@ use winit::{ use crate::{ RendererInitError, input::{DEFAULT_CAMERA_TUNING_CONFIG, InputEvent}, - screen::ScreenSize, viewer::ViewerWindow, - window::{self, Window}, + window::{self, ScreenSize, Window}, }; /// # Display the provided mesh in a window that processes input diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index 83bbee506..ec23ccf5b 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -4,7 +4,10 @@ use thiserror::Error; use tracing::{error, trace}; use wgpu::util::DeviceExt as _; -use crate::{camera::Camera, screen::ScreenSize, window::Window}; +use crate::{ + camera::Camera, + window::{ScreenSize, Window}, +}; use super::{ DEPTH_FORMAT, DeviceError, SAMPLE_COUNT, device::Device, diff --git a/crates/fj-viewer/src/lib.rs b/crates/fj-viewer/src/lib.rs index 77b99abc1..b9faa755f 100644 --- a/crates/fj-viewer/src/lib.rs +++ b/crates/fj-viewer/src/lib.rs @@ -13,7 +13,6 @@ mod camera; mod display; mod graphics; mod input; -mod screen; mod viewer; mod window; diff --git a/crates/fj-viewer/src/screen.rs b/crates/fj-viewer/src/screen.rs deleted file mode 100644 index 669f15c51..000000000 --- a/crates/fj-viewer/src/screen.rs +++ /dev/null @@ -1,39 +0,0 @@ -//! Types that describe aspects of the screen - -/// Cursor position in normalized coordinates (-1 to +1) -/// -/// The center of the screen is at (0, 0). The aspect ratio is taken into -/// account. -#[derive(Clone, Copy, Debug)] -pub struct NormalizedScreenPosition { - /// The x coordinate of the position [-1, 1] - pub x: f64, - - /// The y coordinate of the position [-1, 1] - pub y: f64, -} - -/// The size of the screen -#[derive(Clone, Copy, Debug)] -pub struct ScreenSize { - /// The width of the screen - pub width: u32, - - /// The height of the screen - pub height: u32, -} - -impl ScreenSize { - /// # Indicate whether the screen size is valid - /// - /// A screen size is valid, if neither of its dimensions is zero. But it can - /// be reported as zero by spurious screen resize events. - pub fn is_valid(&self) -> bool { - self.width > 0 && self.height > 0 - } - - /// Convert size to `f64` - pub fn as_f64(&self) -> [f64; 2] { - [self.width, self.height].map(Into::into) - } -} diff --git a/crates/fj-viewer/src/viewer.rs b/crates/fj-viewer/src/viewer.rs index 651b28bd4..a92a5ff98 100644 --- a/crates/fj-viewer/src/viewer.rs +++ b/crates/fj-viewer/src/viewer.rs @@ -10,8 +10,7 @@ use crate::{ CameraTuningConfig, DEFAULT_CAMERA_TUNING_CONFIG, InputEvent, MouseButton, }, - screen::{NormalizedScreenPosition, ScreenSize}, - window::Window, + window::{NormalizedScreenPosition, ScreenSize, Window}, }; pub struct ViewerWindow { diff --git a/crates/fj-viewer/src/window.rs b/crates/fj-viewer/src/window.rs index d78a6a458..626e07b0c 100644 --- a/crates/fj-viewer/src/window.rs +++ b/crates/fj-viewer/src/window.rs @@ -2,8 +2,6 @@ use std::sync::Arc; use winit::event_loop::ActiveEventLoop; -use crate::screen::ScreenSize; - /// A window that can be used with `fj-viewer` pub struct Window { inner: Arc, @@ -63,3 +61,41 @@ impl Window { #[derive(Debug, thiserror::Error)] #[error("Error initializing window")] pub struct WindowError(#[from] pub winit::error::OsError); + +/// Cursor position in normalized coordinates (-1 to +1) +/// +/// The center of the screen is at (0, 0). The aspect ratio is taken into +/// account. +#[derive(Clone, Copy, Debug)] +pub struct NormalizedScreenPosition { + /// The x coordinate of the position [-1, 1] + pub x: f64, + + /// The y coordinate of the position [-1, 1] + pub y: f64, +} + +/// The size of the screen +#[derive(Clone, Copy, Debug)] +pub struct ScreenSize { + /// The width of the screen + pub width: u32, + + /// The height of the screen + pub height: u32, +} + +impl ScreenSize { + /// # Indicate whether the screen size is valid + /// + /// A screen size is valid, if neither of its dimensions is zero. But it can + /// be reported as zero by spurious screen resize events. + pub fn is_valid(&self) -> bool { + self.width > 0 && self.height > 0 + } + + /// Convert size to `f64` + pub fn as_f64(&self) -> [f64; 2] { + [self.width, self.height].map(Into::into) + } +}