Skip to content

Commit 489ca95

Browse files
committed
fmt
1 parent db1bac7 commit 489ca95

File tree

3 files changed

+25
-33
lines changed

3 files changed

+25
-33
lines changed

editor/src/messages/portfolio/document/overlays/grid_overlays.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::messages::layout::utility_types::widget_prelude::*;
22
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
33
use crate::messages::portfolio::document::utility_types::misc::{GridSnapping, GridType};
44
use crate::messages::prelude::*;
5-
use glam::{DVec2,UVec2};
5+
use glam::{DVec2, UVec2};
66
use graphene_std::raster::color::Color;
77
use graphene_std::renderer::Quad;
88
use graphene_std::vector::style::FillChoice;
@@ -48,18 +48,10 @@ fn grid_overlay_rectangular(document: &DocumentMessageHandler, overlay_context:
4848
DVec2::new(secondary_pos, primary_end)
4949
};
5050
overlay_context.line(
51-
document_to_viewport.transform_point2(start),
51+
document_to_viewport.transform_point2(start),
5252
document_to_viewport.transform_point2(end),
53-
if is_major {
54-
Some(&grid_color)
55-
} else {
56-
Some(&grid_color_minor)
57-
},
58-
if is_major && document.snapping_state.grid.major_is_thick {
59-
Some(3.)
60-
} else {
61-
Some(1.)
62-
},
53+
if is_major { Some(&grid_color) } else { Some(&grid_color_minor) },
54+
if is_major && document.snapping_state.grid.major_is_thick { Some(3.) } else { Some(1.) },
6355
);
6456
}
6557
}
@@ -74,7 +66,7 @@ fn grid_overlay_rectangular_dot(document: &DocumentMessageHandler, overlay_conte
7466
let origin = document.snapping_state.grid.origin;
7567
let grid_color = "#".to_string() + &document.snapping_state.grid.grid_color.to_rgba_hex_srgb();
7668
let grid_color_minor = "#".to_string() + &document.snapping_state.grid.grid_color_minor.to_rgba_hex_srgb();
77-
let Some(spacing) = GridSnapping::compute_rectangle_spacing(spacing, &document.snapping_state.grid.rectangular_major_interval, &document.document_ptz) else {
69+
let Some(spacing) = GridSnapping::compute_rectangle_spacing(spacing, &document.snapping_state.grid.rectangular_major_interval, &document.document_ptz) else {
7870
return;
7971
};
8072
let document_to_viewport = document.navigation_handler.calculate_offset_transform(overlay_context.size / 2., &document.document_ptz);

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::consts::COLOR_OVERLAY_GRAY_DARK;
2-
use glam::{DVec2,UVec2, UVec3};
2+
use glam::{DVec2, UVec2, UVec3};
33
use graphene_std::raster::Color;
44
use std::fmt;
55

@@ -247,22 +247,22 @@ impl Default for GridSnapping {
247247
impl GridSnapping {
248248
// Double grid size until it takes up at least 10px.
249249
pub fn compute_rectangle_spacing(mut size: DVec2, major_interval: &UVec2, navigation: &PTZ) -> Option<DVec2> {
250-
let mut iterations = 0;
251-
size = size.abs();
252-
while (size.x * navigation.zoom() < 10.) || (size.y * navigation.zoom() < 10.) {
253-
if iterations > 100 {
254-
return None;
255-
}
256-
if size.x * navigation.zoom() < 10. {
257-
size.x *= if major_interval.x != 1 {major_interval.x as f64} else {2.};
258-
}
259-
if size.y * navigation.zoom() < 10. {
260-
size.y *= if major_interval.y != 1 {major_interval.y as f64} else {2.};
261-
}
262-
iterations += 1;
250+
let mut iterations = 0;
251+
size = size.abs();
252+
while (size.x * navigation.zoom() < 10.) || (size.y * navigation.zoom() < 10.) {
253+
if iterations > 100 {
254+
return None;
255+
}
256+
if size.x * navigation.zoom() < 10. {
257+
size.x *= if major_interval.x != 1 { major_interval.x as f64 } else { 2. };
258+
}
259+
if size.y * navigation.zoom() < 10. {
260+
size.y *= if major_interval.y != 1 { major_interval.y as f64 } else { 2. };
263261
}
264-
Some(size)
262+
iterations += 1;
265263
}
264+
Some(size)
265+
}
266266

267267
// Double grid size until it takes up at least 10px.
268268
pub fn compute_isometric_multiplier(length: f64, divisor: f64, navigation: &PTZ) -> Option<f64> {
@@ -280,11 +280,11 @@ impl GridSnapping {
280280
}
281281

282282
pub fn has_minor_lines(&self) -> bool {
283-
match self.grid_type {
284-
GridType::Rectangular { .. } => self.rectangular_major_interval.x > 1 || self.rectangular_major_interval.y > 1,
285-
GridType::Isometric { .. } => self.isometric_major_interval.x > 1 || self.isometric_major_interval.z > 1 || self.isometric_major_interval.y > 1,
286-
}
283+
match self.grid_type {
284+
GridType::Rectangular { .. } => self.rectangular_major_interval.x > 1 || self.rectangular_major_interval.y > 1,
285+
GridType::Isometric { .. } => self.isometric_major_interval.x > 1 || self.isometric_major_interval.z > 1 || self.isometric_major_interval.y > 1,
287286
}
287+
}
288288
}
289289

290290
#[derive(Debug, Clone, Copy, PartialEq, Eq)]

editor/src/messages/tool/common_functionality/snapping/grid_snapper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::*;
22
use crate::messages::portfolio::document::utility_types::misc::{GridSnapTarget, GridSnapping, GridType, SnapTarget};
3-
use glam::{DVec2,UVec2};
3+
use glam::{DVec2, UVec2};
44
use graphene_std::renderer::Quad;
55

66
struct Line {

0 commit comments

Comments
 (0)