Skip to content

Commit 8e83678

Browse files
authored
Merge branch 'master' into 2504-fix-auto-panning
2 parents 53d4c3e + 3e6021f commit 8e83678

4 files changed

Lines changed: 9 additions & 6 deletions

File tree

editor/src/messages/portfolio/document/utility_types/document_metadata.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,17 @@ impl DocumentMetadata {
142142
///
143143
/// If the layer bounds are `0` in either axis then they are changed to be `1`.
144144
pub fn nonzero_bounding_box(&self, layer: LayerNodeIdentifier) -> [DVec2; 2] {
145-
let [bounds_min, mut bounds_max] = self.bounding_box_with_transform(layer, DAffine2::IDENTITY).unwrap_or_default();
145+
let [mut bounds_min, mut bounds_max] = self.bounding_box_with_transform(layer, DAffine2::IDENTITY).unwrap_or_default();
146146

147147
let bounds_size = bounds_max - bounds_min;
148+
let bounds_midpoint = bounds_min.midpoint(bounds_max);
148149
if bounds_size.x < 1e-10 {
149-
bounds_max.x = bounds_min.x + 1.;
150+
bounds_max.x = bounds_midpoint.x + 0.5;
151+
bounds_min.x = bounds_midpoint.x - 0.5;
150152
}
151153
if bounds_size.y < 1e-10 {
152-
bounds_max.y = bounds_min.y + 1.;
154+
bounds_max.y = bounds_midpoint.y + 0.5;
155+
bounds_min.y = bounds_midpoint.y - 0.5;
153156
}
154157

155158
[bounds_min, bounds_max]

editor/src/messages/tool/common_functionality/pivot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl Default for Pivot {
3535
impl Pivot {
3636
/// Calculates the transform that gets from normalized pivot to viewspace.
3737
fn get_layer_pivot_transform(layer: LayerNodeIdentifier, document: &DocumentMessageHandler) -> DAffine2 {
38-
let [min, max] = document.metadata().nonzero_bounding_box(layer);
38+
let [min, max] = document.metadata().bounding_box_with_transform(layer, DAffine2::IDENTITY).unwrap_or_default();
3939

4040
let bounds_transform = DAffine2::from_translation(min) * DAffine2::from_scale(max - min);
4141
let layer_transform = document.metadata().transform_to_viewport(layer);

editor/src/messages/tool/common_functionality/transformation_cage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ impl BoundingBoxManager {
794794
}
795795

796796
match edges {
797-
Some((top, bottom, left, right)) if !self.is_bounds_flat() => match (top, bottom, left, right) {
797+
Some((top, bottom, left, right)) => match (top, bottom, left, right) {
798798
(true, _, false, false) | (_, true, false, false) => MouseCursorIcon::NSResize,
799799
(false, false, true, _) | (false, false, _, true) => MouseCursorIcon::EWResize,
800800
(true, _, true, _) | (_, true, _, true) => MouseCursorIcon::NWSEResize,

node-graph/gcore/src/graphic_element/renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl ClickTarget {
8888
// This bounding box is not very accurate as it is the axis aligned version of the transformed bounding box. However it is fast.
8989
if !self
9090
.bounding_box
91-
.is_some_and(|loose| (loose[0] - loose[1]).abs().cmpgt(DVec2::splat(1e-4)).all() && intersects((layer_transform * Quad::from_box(loose)).bounding_box(), target_bounds))
91+
.is_some_and(|loose| (loose[0] - loose[1]).abs().cmpgt(DVec2::splat(1e-4)).any() && intersects((layer_transform * Quad::from_box(loose)).bounding_box(), target_bounds))
9292
{
9393
return false;
9494
}

0 commit comments

Comments
 (0)