Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
Tweoss committed Jan 27, 2024
1 parent 24143f4 commit 0f6f82c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions crates/egui/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub struct Memory {
// Per-viewport:
areas: ViewportIdMap<Areas>,
layer_transforms: HashMap<LayerId, LayerTransform>,

#[cfg_attr(feature = "persistence", serde(skip))]
pub(crate) interactions: ViewportIdMap<Interaction>,

Expand Down Expand Up @@ -154,7 +155,9 @@ impl FocusDirection {
}
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "persistence", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "persistence", serde(default))]
pub struct LayerTransform {
pub translation: Vec2,
pub scale: f32,
Expand Down Expand Up @@ -632,10 +635,12 @@ impl Memory {
self.areas.entry(self.viewport_id).or_default()
}

/// Access layer transformations.
pub fn layer_transforms(&self) -> &HashMap<LayerId, LayerTransform> {
&self.layer_transforms
}

/// Access layer transformations.
pub fn layer_transforms_mut(&mut self) -> &mut HashMap<LayerId, LayerTransform> {
&mut self.layer_transforms
}
Expand Down Expand Up @@ -935,7 +940,7 @@ impl Areas {
rect = rect.expand(resize_interact_radius_side);
}

if let Some(transform) = layer_transforms.get(&layer) {
if let Some(transform) = layer_transforms.get(layer) {
rect = transform.apply(rect);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/egui_demo_lib/src/demo/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn drag_source(ui: &mut Ui, id: Id, body: impl FnOnce(&mut Ui)) {

if let Some(pointer_pos) = ui.ctx().pointer_interact_pos() {
let delta = pointer_pos - response.rect.center();
ui.ctx().transform_layer(layer_id, delta);
ui.ctx().transform_layer(layer_id, delta, 1.0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/epaint/src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl Shape {
Self::Text(text_shape) => {
transform_point(&mut text_shape.pos);
let mut galley = (*text_shape.galley).clone();
for row in galley.rows.iter_mut() {
for row in &mut galley.rows {
row.visuals.mesh.transform(Vec2::ZERO, scale);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/test_viewports/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ fn drag_source<R>(

if let Some(pointer_pos) = ui.ctx().pointer_interact_pos() {
let delta = pointer_pos - res.response.rect.center();
ui.ctx().transform_layer(layer_id, delta);
ui.ctx().transform_layer(layer_id, delta, 1.0);
}

res
Expand Down

0 comments on commit 0f6f82c

Please sign in to comment.