mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-29 09:28:12 +08:00
Add a stroke width option to the Line Tool (#355)
* Add a stroke width option to the Line Tool * Fix title case for line options * Add px unit to line stroke width * Add stroke width to pen tool * Rename stroke width to weight * Change number input width to min-width * Remove the word "stroke" from "stroke weight"
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::input::InputPreprocessor;
|
||||
use crate::tool::{DocumentToolData, Fsm, ToolActionHandlerData};
|
||||
use crate::tool::{DocumentToolData, Fsm, ToolActionHandlerData, ToolOptions, ToolType};
|
||||
use crate::{document::DocumentMessageHandler, message_prelude::*};
|
||||
use glam::DAffine2;
|
||||
use graphene::{layers::style, Operation};
|
||||
@@ -49,6 +49,7 @@ impl Default for PenToolFsmState {
|
||||
struct PenToolData {
|
||||
points: Vec<DAffine2>,
|
||||
next_point: DAffine2,
|
||||
weight: u32,
|
||||
path: Option<Vec<LayerId>>,
|
||||
}
|
||||
|
||||
@@ -79,6 +80,11 @@ impl Fsm for PenToolFsmState {
|
||||
data.points.push(pos);
|
||||
data.next_point = pos;
|
||||
|
||||
data.weight = match tool_data.tool_options.get(&ToolType::Pen) {
|
||||
Some(&ToolOptions::Pen { weight }) => weight,
|
||||
_ => 5,
|
||||
};
|
||||
|
||||
Dragging
|
||||
}
|
||||
(Dragging, DragStop) => {
|
||||
@@ -140,7 +146,7 @@ fn make_operation(data: &PenToolData, tool_data: &DocumentToolData, show_preview
|
||||
insert_index: -1,
|
||||
transform: DAffine2::IDENTITY.to_cols_array(),
|
||||
points,
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, 5.)), Some(style::Fill::none())),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight as f32)), Some(style::Fill::none())),
|
||||
}
|
||||
.into(),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user