Skip to content

Commit

Permalink
Rename to scene
Browse files Browse the repository at this point in the history
  • Loading branch information
grtlr committed Jan 22, 2025
1 parent 4809160 commit 76c23dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion crates/egui/src/containers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ pub mod modal;
pub mod panel;
pub mod popup;
pub(crate) mod resize;
pub mod scene;
pub mod scroll_area;
mod sides;
pub(crate) mod window;
pub mod zoom_pan_area;

pub use {
area::{Area, AreaState},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ fn fit_to_rect_in_scene(rect_in_ui: Rect, rect_in_scene: Rect) -> TSTransform {

#[derive(Clone, Debug)]
#[must_use = "You should call .show()"]
pub struct ZoomPanArea {
pub struct Scene {
min_scaling: Option<f32>,
max_scaling: f32,
fit_rect: Option<Rect>,
}

impl Default for ZoomPanArea {
impl Default for Scene {
fn default() -> Self {
Self {
min_scaling: None,
Expand All @@ -47,30 +47,30 @@ impl Default for ZoomPanArea {
}
}

impl ZoomPanArea {
impl Scene {
pub fn new() -> Self {
Default::default()
}

/// Provides a zoom-pan area for a given view.
///
/// Will fill the entire `max_rect` of the `parent_ui`.
fn show_zoom_pan_area(
fn show_scene(
&self,
parent_ui: &mut Ui,
to_global: &mut TSTransform,
draw_contents: impl FnOnce(&mut Ui),
) -> Response {
// Create a new egui paint layer, where we can draw our contents:
let zoom_pan_layer_id = LayerId::new(
let scene_layer_id = LayerId::new(
parent_ui.layer_id().order,
parent_ui.id().with("zoom_pan_area"),
parent_ui.id().with("scene_area"),
);

// Put the layer directly on-top of the main layer of the ui:
parent_ui
.ctx()
.set_sublayer(parent_ui.layer_id(), zoom_pan_layer_id);
.set_sublayer(parent_ui.layer_id(), scene_layer_id);

let global_view_bounds = parent_ui.max_rect();

Expand All @@ -82,7 +82,7 @@ impl ZoomPanArea {

let mut local_ui = parent_ui.new_child(
UiBuilder::new()
.layer_id(zoom_pan_layer_id)
.layer_id(scene_layer_id)
.max_rect(to_global.inverse() * global_view_bounds)
.sense(Sense::click_and_drag()),
);
Expand All @@ -105,7 +105,7 @@ impl ZoomPanArea {
// Tell egui to apply the transform on the layer:
local_ui
.ctx()
.set_transform_layer(zoom_pan_layer_id, *to_global);
.set_transform_layer(scene_layer_id, *to_global);

pan_response
}
Expand Down Expand Up @@ -159,6 +159,6 @@ impl ZoomPanArea {
to_global: &mut TSTransform,
add_contents: impl FnOnce(&mut Ui),
) -> Response {
self.show_zoom_pan_area(ui, to_global, add_contents)
self.show_scene(ui, to_global, add_contents)
}
}

0 comments on commit 76c23dd

Please sign in to comment.