Skip to main content

egui_rotate/
lib.rs

1//! # egui-rotate
2//!
3//! Viewport rotation (0° / 90° / 180° / 270°) for [egui](https://github.com/emilk/egui).
4//!
5//! Use cases: virtual pinball cabinets, kiosks, embedded displays, industrial
6//! panels — any setup where the physical screen is mounted rotated and the OS
7//! cannot (or should not) rotate the whole desktop.
8//!
9//! This crate **does not modify egui**: it ships [`RotationPlugin`], a
10//! self-contained [`egui::Plugin`]. Register it once and rotation becomes
11//! transparent for input, rendering and the OS cursor — on any backend
12//! (`egui_glow`, `egui_wgpu`, eframe, custom), with no other integration code.
13//!
14//! ## Quick start
15//!
16//! ```no_run
17//! use egui_rotate::{Rotation, RotationPlugin};
18//!
19//! # let ctx = egui::Context::default();
20//! ctx.add_plugin(RotationPlugin::new(Rotation::CW90));
21//! ```
22//!
23//! That's it: pointer/touch input is remapped into the rotated space, the whole
24//! UI is rendered rotated, and directional OS cursor icons are remapped.
25//!
26//! ## Multiple windows
27//!
28//! Rotation is **per-viewport and opt-in**. [`RotationPlugin::new`] configures the
29//! root window; child windows pass through untouched unless you configure them
30//! with [`RotationPlugin::set_viewport_rotation`]. So a rotated cabinet window can
31//! coexist with upright settings dialogs.
32//!
33//! ## Software cursor (feature `software-cursor`, opt-in)
34//!
35//! Enable with `egui-rotate = { version = "…", features = ["software-cursor"] }`.
36//! See [`SoftwareCursor`] for the rotated virtual cursor used by pinball cabinets
37//! and kiosks where the OS cursor cannot be rotated; attach it with
38//! [`RotationPlugin::with_software_cursor`].
39//!
40//! ## Custom integration (without the plugin)
41//!
42//! If you cannot use the plugin, the building blocks are public: [`Rotation`]'s
43//! transform methods for input, and [`rotate_clipped_shapes`] / [`rotate_shape`]
44//! to rotate pre-tessellation shapes. The older manual helpers
45//! [`transform_raw_input`] and [`transform_clipped_primitives`] are **deprecated
46//! since 1.0** — prefer the plugin.
47
48mod input;
49mod output;
50mod plugin;
51mod rotation;
52mod shape_rotate;
53
54#[allow(deprecated)]
55pub use input::transform_raw_input;
56#[allow(deprecated)]
57pub use output::transform_clipped_primitives;
58pub use plugin::RotationPlugin;
59pub use rotation::Rotation;
60pub use shape_rotate::{rotate_clipped_shapes, rotate_shape};
61
62mod cursor_icon;
63pub use cursor_icon::CursorIconExt;
64
65#[cfg(feature = "software-cursor")]
66mod cursor;
67#[cfg(feature = "software-cursor")]
68pub use cursor::{SoftwareCursor, SoftwareCursorOutput};