mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-08 03:18:12 +08:00
fixed rectangular spacing
This commit is contained in:
-6
@@ -91,12 +91,6 @@ impl RowColumnGizmo {
|
|||||||
let line = self.gizmo_type.line(grid_type, columns, rows, spacing, angles, viewport);
|
let line = self.gizmo_type.line(grid_type, columns, rows, spacing, angles, viewport);
|
||||||
let (p0, p1) = get_line_endpoints(line);
|
let (p0, p1) = get_line_endpoints(line);
|
||||||
overlay_context.dashed_line(p0, p1, None, None, Some(5.), Some(5.), Some(0.5));
|
overlay_context.dashed_line(p0, p1, None, None, Some(5.), Some(5.), Some(0.5));
|
||||||
|
|
||||||
if matches!(self.gizmo_state, RowColumnGizmoState::Hover) {
|
|
||||||
let line = self.gizmo_type.opposite(grid_type, columns, rows, spacing, angles, viewport);
|
|
||||||
let (p0, p1) = get_line_endpoints(line);
|
|
||||||
overlay_context.dashed_line(p0, p1, None, None, Some(5.), Some(5.), Some(0.5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+50
-17
@@ -90,12 +90,6 @@ impl GridSpacingGizmo {
|
|||||||
let line = gizmo_type.line(self.column_index, self.row_index, spacing, viewport, stroke_width);
|
let line = gizmo_type.line(self.column_index, self.row_index, spacing, viewport, stroke_width);
|
||||||
let (p0, p1) = get_line_endpoints(line);
|
let (p0, p1) = get_line_endpoints(line);
|
||||||
overlay_context.dashed_line(p0, p1, None, None, Some(5.), Some(5.), Some(0.5));
|
overlay_context.dashed_line(p0, p1, None, None, Some(5.), Some(5.), Some(0.5));
|
||||||
|
|
||||||
if matches!(self.gizmo_state, GridSpacingGizmoState::Hover) {
|
|
||||||
let line = gizmo_type.opposite_gizmo_type().line(self.column_index, self.row_index, spacing, viewport, stroke_width);
|
|
||||||
let (p0, p1) = get_line_endpoints(line);
|
|
||||||
overlay_context.dashed_line(p0, p1, None, None, Some(5.), Some(5.), Some(0.5));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +104,7 @@ impl GridSpacingGizmo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let Some(gizmo_type) = &self.gizmo_type else { return };
|
let Some(gizmo_type) = &self.gizmo_type else { return };
|
||||||
let direction = gizmo_type.direction(spacing, viewport);
|
let direction = gizmo_type.direction(self.initial_spacing, viewport);
|
||||||
let delta_vector = input.mouse.position - drag_start;
|
let delta_vector = input.mouse.position - drag_start;
|
||||||
|
|
||||||
let delta = delta_vector.dot(direction);
|
let delta = delta_vector.dot(direction);
|
||||||
@@ -120,22 +114,23 @@ impl GridSpacingGizmo {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let new_spacing = gizmo_type.new_spacing(delta, self.initial_spacing);
|
let new_spacing = gizmo_type.new_spacing(delta, self.initial_spacing);
|
||||||
let delta_spacing = new_spacing - spacing;
|
let spacing_delta = new_spacing - spacing;
|
||||||
|
|
||||||
// let transform = self.transform_grid(dimensions_delta, grid_type, viewport_spacing, angles, viewport);
|
|
||||||
|
|
||||||
responses.add(NodeGraphMessage::SetInput {
|
responses.add(NodeGraphMessage::SetInput {
|
||||||
input_connector: InputConnector::node(node_id, GRID_SPACING_INDEX),
|
input_connector: InputConnector::node(node_id, GRID_SPACING_INDEX),
|
||||||
input: NodeInput::value(TaggedValue::DVec2(new_spacing), false),
|
input: NodeInput::value(TaggedValue::DVec2(new_spacing), false),
|
||||||
});
|
});
|
||||||
|
|
||||||
// responses.add(GraphOperationMessage::TransformChange {
|
let transform = self.transform_grid(spacing_delta, direction);
|
||||||
// layer,
|
|
||||||
// transform: DAffine2::from_translation(-delta_spacing * direction),
|
|
||||||
// transform_in: TransformIn::Viewport,
|
|
||||||
// skip_rerender: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
responses.add(GraphOperationMessage::TransformChange {
|
||||||
|
layer,
|
||||||
|
transform,
|
||||||
|
transform_in: TransformIn::Viewport,
|
||||||
|
skip_rerender: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
log::info!("{:?}", (self.row_index, self.column_index));
|
||||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||||
|
|
||||||
// if self.initial_dimension() as i32 + dimensions_to_add < 1 {
|
// if self.initial_dimension() as i32 + dimensions_to_add < 1 {
|
||||||
@@ -146,7 +141,45 @@ impl GridSpacingGizmo {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transform_grid(&self, dimensions_delta: i32, grid_type: GridType, spacing: DVec2, angles: DVec2, viewport: DAffine2) {}
|
fn transform_grid(&self, spacing_delta: DVec2, direction: DVec2) -> DAffine2 {
|
||||||
|
if let Some(gizmo_type) = &self.gizmo_type {
|
||||||
|
match gizmo_type {
|
||||||
|
GridSpacingGizmoType::Right => {
|
||||||
|
if self.column_index == 0 {
|
||||||
|
DAffine2::IDENTITY
|
||||||
|
} else {
|
||||||
|
DAffine2::from_translation(-spacing_delta * direction * (self.column_index) as f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GridSpacingGizmoType::Down => {
|
||||||
|
if self.row_index == 0 {
|
||||||
|
DAffine2::IDENTITY
|
||||||
|
} else {
|
||||||
|
DAffine2::from_translation(-spacing_delta * direction * (self.row_index) as f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GridSpacingGizmoType::Left => {
|
||||||
|
if self.column_index == 0 {
|
||||||
|
DAffine2::from_translation(spacing_delta * direction)
|
||||||
|
} else {
|
||||||
|
DAffine2::from_translation(spacing_delta * direction * (self.column_index + 1) as f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GridSpacingGizmoType::Top => {
|
||||||
|
if self.row_index == 0 {
|
||||||
|
DAffine2::from_translation(spacing_delta * direction)
|
||||||
|
} else {
|
||||||
|
DAffine2::from_translation(spacing_delta * direction * (self.row_index + 1) as f64)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GridSpacingGizmoType::None => DAffine2::IDENTITY,
|
||||||
|
_ => DAffine2::from_translation(spacing_delta * direction),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
DAffine2::IDENTITY
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_if_over_gizmo(grid_type: GridType, columns: u32, rows: u32, spacing: DVec2, mouse_position: DVec2, viewport: DAffine2) -> Option<(u32, u32)> {
|
fn check_if_over_gizmo(grid_type: GridType, columns: u32, rows: u32, spacing: DVec2, mouse_position: DVec2, viewport: DAffine2) -> Option<(u32, u32)> {
|
||||||
|
|||||||
Reference in New Issue
Block a user