Skip to content

Commit 73c277f

Browse files
committed
reset
1 parent 5887e2d commit 73c277f

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -236,24 +236,12 @@ pub fn overlay_options(grid: &GridSnapping) -> Vec<LayoutGroup> {
236236
TextLabel::new("Type").table_align(true).widget_holder(),
237237
Separator::new(SeparatorType::Unrelated).widget_holder(),
238238
RadioInput::new(vec![
239-
RadioEntryData::new("rectangular").label("Rectangular").on_update(update_val(grid, |grid, _| {
240-
if let GridType::Isometric { y_axis_spacing, angle_a, angle_b } = grid.grid_type {
241-
grid.isometric_y_spacing = y_axis_spacing;
242-
grid.isometric_angle_a = angle_a;
243-
grid.isometric_angle_b = angle_b;
244-
}
245-
grid.grid_type = GridType::Rectangular { spacing: grid.rectangular_spacing };
246-
})),
247-
RadioEntryData::new("isometric").label("Isometric").on_update(update_val(grid, |grid, _| {
248-
if let GridType::Rectangular { spacing } = grid.grid_type {
249-
grid.rectangular_spacing = spacing;
250-
}
251-
grid.grid_type = GridType::Isometric {
252-
y_axis_spacing: grid.isometric_y_spacing,
253-
angle_a: grid.isometric_angle_a,
254-
angle_b: grid.isometric_angle_b,
255-
};
256-
})),
239+
RadioEntryData::new("rectangular")
240+
.label("Rectangular")
241+
.on_update(update_val(grid, |grid, _| grid.grid_type = GridType::RECTANGULAR)),
242+
RadioEntryData::new("isometric")
243+
.label("Isometric")
244+
.on_update(update_val(grid, |grid, _| grid.grid_type = GridType::ISOMETRIC)),
257245
])
258246
.min_width(200)
259247
.selected_index(Some(match grid.grid_type {

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,17 @@ pub enum GridType {
176176

177177
impl Default for GridType {
178178
fn default() -> Self {
179-
Self::Rectangular { spacing: DVec2::ONE }
179+
Self::RECTANGULAR
180180
}
181181
}
182182

183183
impl GridType {
184+
pub const RECTANGULAR: Self = GridType::Rectangular { spacing: DVec2::ONE };
185+
pub const ISOMETRIC: Self = GridType::Isometric {
186+
y_axis_spacing: 1.,
187+
angle_a: 30.,
188+
angle_b: 30.,
189+
};
184190
pub fn rectangular_spacing(&mut self) -> Option<&mut DVec2> {
185191
match self {
186192
Self::Rectangular { spacing } => Some(spacing),
@@ -212,10 +218,6 @@ impl GridType {
212218
pub struct GridSnapping {
213219
pub origin: DVec2,
214220
pub grid_type: GridType,
215-
pub rectangular_spacing: DVec2,
216-
pub isometric_y_spacing: f64,
217-
pub isometric_angle_a: f64,
218-
pub isometric_angle_b: f64,
219221
pub grid_color: Color,
220222
pub dot_display: bool,
221223
}
@@ -225,10 +227,6 @@ impl Default for GridSnapping {
225227
Self {
226228
origin: DVec2::ZERO,
227229
grid_type: Default::default(),
228-
rectangular_spacing: DVec2::ONE,
229-
isometric_y_spacing: 1.0,
230-
isometric_angle_a: 30.0,
231-
isometric_angle_b: 30.0,
232230
grid_color: Color::from_rgb_str(COLOR_OVERLAY_GRAY.strip_prefix('#').unwrap()).unwrap(),
233231
dot_display: false,
234232
}

0 commit comments

Comments
 (0)