Skip to content
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
"files.insertFinalNewline": true,
"files.associations": {
"*.graphite": "json"
}
},
"rust-analyzer.checkOnSave": true
}
19 changes: 19 additions & 0 deletions editor/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub const POINT_RADIUS_HANDLE_SEGMENT_THRESHOLD: f64 = 7.9;
pub const NUMBER_OF_POINTS_DIAL_SPOKE_EXTENSION: f64 = 1.2;
pub const NUMBER_OF_POINTS_DIAL_SPOKE_LENGTH: f64 = 10.;
pub const GIZMO_HIDE_THRESHOLD: f64 = 20.;
pub const GRID_ROW_COLUMN_GIZMO_OFFSET: f64 = 15.;

// SCROLLBARS
pub const SCROLLBAR_SPACING: f64 = 0.1;
Expand All @@ -153,3 +154,21 @@ pub const AUTO_SAVE_TIMEOUT_SECONDS: u64 = 15;

// INPUT
pub const DOUBLE_CLICK_MILLISECONDS: u64 = 500;

// GRID INPUT INDICES

// grid_type: GridType,
// #[unit(" px")]
// #[hard_min(0.)]
// #[default(10)]
// #[implementations(f64, DVec2)]
// spacing: T,
// #[default(10)] columns: u32,
// #[default(10)] rows: u32,
// #[default(30., 30.)] angles: DVec2,

pub const GRID_TYPE_INDEX: usize = 1;
pub const GRID_SPACING_INDEX: usize = 2;
pub const GRID_COLUMNS_INDEX: usize = 3;
pub const GRID_ROW_INDEX: usize = 4;
pub const GRID_ANGLE_INDEX: usize = 5;
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ impl<'a> Selected<'a> {
pen_handle: Option<&'a mut DVec2>,
) -> Self {
// If user is using the Select tool then use the original layer transforms
if (*tool_type == ToolType::Select) && (*original_transforms == OriginalTransforms::Path(HashMap::new())) {
if (*tool_type == ToolType::Select || *tool_type == ToolType::Shape) && (*original_transforms == OriginalTransforms::Path(HashMap::new())) {
*original_transforms = OriginalTransforms::Layer(HashMap::new());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::messages::portfolio::document::utility_types::document_metadata::Laye
use crate::messages::prelude::{DocumentMessageHandler, InputPreprocessorMessageHandler};
use crate::messages::tool::common_functionality::graph_modification_utils;
use crate::messages::tool::common_functionality::shape_editor::ShapeState;
use crate::messages::tool::common_functionality::shapes::grid_shape::GridGizmoHandler;
use crate::messages::tool::common_functionality::shapes::polygon_shape::PolygonGizmoHandler;
use crate::messages::tool::common_functionality::shapes::shape_utility::ShapeGizmoHandler;
use crate::messages::tool::common_functionality::shapes::star_shape::StarGizmoHandler;
Expand All @@ -23,6 +24,7 @@ pub enum ShapeGizmoHandlers {
None,
Star(StarGizmoHandler),
Polygon(PolygonGizmoHandler),
Grid(GridGizmoHandler),
}

impl ShapeGizmoHandlers {
Expand All @@ -32,6 +34,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(_) => "star",
Self::Polygon(_) => "polygon",
Self::Grid(_) => "grid",
Self::None => "none",
}
}
Expand All @@ -41,6 +44,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.handle_state(layer, mouse_position, document, responses),
Self::Polygon(h) => h.handle_state(layer, mouse_position, document, responses),
Self::Grid(h) => h.handle_state(layer, mouse_position, document, responses),
Self::None => {}
}
}
Expand All @@ -50,6 +54,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.is_any_gizmo_hovered(),
Self::Polygon(h) => h.is_any_gizmo_hovered(),
Self::Grid(h) => h.is_any_gizmo_hovered(),
Self::None => false,
}
}
Expand All @@ -59,6 +64,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.handle_click(),
Self::Polygon(h) => h.handle_click(),
Self::Grid(h) => h.handle_click(),
Self::None => {}
}
}
Expand All @@ -68,6 +74,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.handle_update(drag_start, document, input, responses),
Self::Polygon(h) => h.handle_update(drag_start, document, input, responses),
Self::Grid(h) => h.handle_update(drag_start, document, input, responses),
Self::None => {}
}
}
Expand All @@ -77,6 +84,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.cleanup(),
Self::Polygon(h) => h.cleanup(),
Self::Grid(h) => h.cleanup(),
Self::None => {}
}
}
Expand All @@ -94,6 +102,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.overlays(document, layer, input, shape_editor, mouse_position, overlay_context),
Self::Polygon(h) => h.overlays(document, layer, input, shape_editor, mouse_position, overlay_context),
Self::Grid(h) => h.overlays(document, layer, input, shape_editor, mouse_position, overlay_context),
Self::None => {}
}
}
Expand All @@ -110,6 +119,7 @@ impl ShapeGizmoHandlers {
match self {
Self::Star(h) => h.dragging_overlays(document, input, shape_editor, mouse_position, overlay_context),
Self::Polygon(h) => h.dragging_overlays(document, input, shape_editor, mouse_position, overlay_context),
Self::Grid(h) => h.dragging_overlays(document, input, shape_editor, mouse_position, overlay_context),
Self::None => {}
}
}
Expand Down Expand Up @@ -147,6 +157,11 @@ impl GizmoManager {
return Some(ShapeGizmoHandlers::Polygon(PolygonGizmoHandler::default()));
}

// Grid
if graph_modification_utils::get_grid_id(layer, &document.network_interface).is_some() {
return Some(ShapeGizmoHandlers::Grid(GridGizmoHandler::default()));
}

None
}

Expand Down
Loading