all_is_cubes_desktop/lib.rs
1//! Components for creating a desktop application that renders interactive [`all_is_cubes`]
2//! content.
3//!
4//! ## Warning: Unstable! Dubiously designed!
5//!
6//! This is not a good general-purpose library. It is primarily used
7//! by the `all-is-cubes` binary target in this package; it currently only exists as a library
8//! so that additional development tools can reuse the same UI code. Use at your own risk.
9//! Documentation is lacking.
10
11// Increase recursion limit for deeply nested wgpu types
12#![recursion_limit = "256"]
13// Crate-specific lint settings. (General settings can be found in the workspace manifest.)
14#![forbid(unsafe_code)]
15
16use all_is_cubes::euclid::{Size2D, size2};
17use all_is_cubes_render::camera;
18
19#[cfg(feature = "audio")]
20mod audio;
21mod config_files;
22pub use config_files::SettingsArgs;
23mod glue;
24pub mod logging;
25#[cfg(feature = "record")]
26pub mod record;
27mod session;
28mod startup;
29#[cfg(feature = "terminal")]
30pub mod terminal;
31mod universe_source;
32pub mod winit;
33
34pub use config_files::load_config;
35pub use glue::{Executor, Renderer, Window};
36pub use session::{ClockSource, DesktopSession};
37pub use startup::*;
38pub use universe_source::UniverseSource;
39
40/// Our concrete session type.
41///
42/// Usually wrapped in a [`DesktopSession`].
43pub type Session = all_is_cubes_ui::apps::Session;
44
45/// Choose a window size (in terms of viewport size) when the user did not request one.
46///
47/// The given dimensions are of the maximum possible viewport size, if known.
48pub fn choose_graphical_window_size(
49 maximum_size: Option<Size2D<u32, camera::NominalPixel>>,
50) -> Size2D<u32, camera::NominalPixel> {
51 match maximum_size {
52 Some(maximum_size) => {
53 // TODO: consider constraining the aspect ratio, setting a maximum size, and other caveats
54 maximum_size * 7 / 10
55 }
56 None => size2(800, 600),
57 }
58}