1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Add egui::Scene for panning/zooming a Ui (#5505)

This is similar to `ScrollArea`, but:
* Supports zooming
* Has no scroll bars
* Has no limits on the scrolling

## TODO
* [x] Automatic sizing of `Scene`s outer bounds
* [x] Fix text selection in scenes
* [x] Implement `fit_rect`
* [x] Document / improve API

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Jochen Görtler
2025-01-28 20:06:10 +01:00
committed by GitHub
parent 37c564be2c
commit e8f351b729
13 changed files with 391 additions and 189 deletions

View File

@@ -33,7 +33,7 @@ impl TSTransform {
#[inline]
/// Creates a new translation that first scales points around
/// `(0, 0)`, then translates them.
/// `(0, 0)`, then translates them.
pub fn new(translation: Vec2, scaling: f32) -> Self {
Self {
translation,
@@ -51,6 +51,11 @@ impl TSTransform {
Self::new(Vec2::ZERO, scaling)
}
/// Is this a valid, invertible transform?
pub fn is_valid(&self) -> bool {
self.scaling.is_finite() && self.translation.x.is_finite() && self.scaling != 0.0
}
/// Inverts the transform.
///
/// ```