mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 16:58:11 +08:00
Change stroke weight from ints to floats (#601)
Also rename stroke "width" to "weight" in some places. Closes #587 * Change stroke weight from ints to floats * "miter_limit" -> "line_join_miter_limit" * Bump file format version
This commit is contained in:
@@ -21,18 +21,18 @@ pub struct FreehandTool {
|
||||
}
|
||||
|
||||
pub struct FreehandOptions {
|
||||
line_weight: u32,
|
||||
line_weight: f64,
|
||||
}
|
||||
|
||||
impl Default for FreehandOptions {
|
||||
fn default() -> Self {
|
||||
Self { line_weight: 5 }
|
||||
Self { line_weight: 5. }
|
||||
}
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[impl_message(Message, ToolMessage, Freehand)]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum FreehandToolMessage {
|
||||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
@@ -46,9 +46,9 @@ pub enum FreehandToolMessage {
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum FreehandToolMessageOptionsUpdate {
|
||||
LineWeight(u32),
|
||||
LineWeight(f64),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -64,9 +64,9 @@ impl PropertyHolder for FreehandTool {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
value: self.options.line_weight as f64,
|
||||
is_integer: true,
|
||||
is_integer: false,
|
||||
min: Some(1.),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| FreehandToolMessage::UpdateOptions(FreehandToolMessageOptionsUpdate::LineWeight(number_input.value as u32)).into()),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| FreehandToolMessage::UpdateOptions(FreehandToolMessageOptionsUpdate::LineWeight(number_input.value)).into()),
|
||||
..NumberInput::default()
|
||||
}))],
|
||||
}])
|
||||
@@ -119,7 +119,7 @@ impl Default for FreehandToolFsmState {
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct FreehandToolData {
|
||||
points: Vec<DVec2>,
|
||||
weight: u32,
|
||||
weight: f64,
|
||||
path: Option<Vec<LayerId>>,
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ fn add_polyline(data: &FreehandToolData, tool_data: &DocumentToolData) -> Messag
|
||||
insert_index: -1,
|
||||
transform: DAffine2::IDENTITY.to_cols_array(),
|
||||
points,
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight as f32)), style::Fill::None),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight)), style::Fill::None),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -24,18 +24,18 @@ pub struct LineTool {
|
||||
}
|
||||
|
||||
pub struct LineOptions {
|
||||
line_weight: u32,
|
||||
line_weight: f64,
|
||||
}
|
||||
|
||||
impl Default for LineOptions {
|
||||
fn default() -> Self {
|
||||
Self { line_weight: 5 }
|
||||
Self { line_weight: 5. }
|
||||
}
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[impl_message(Message, ToolMessage, Line)]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum LineToolMessage {
|
||||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
@@ -53,9 +53,9 @@ pub enum LineToolMessage {
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum LineOptionsUpdate {
|
||||
LineWeight(u32),
|
||||
LineWeight(f64),
|
||||
}
|
||||
|
||||
impl PropertyHolder for LineTool {
|
||||
@@ -65,9 +65,9 @@ impl PropertyHolder for LineTool {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
value: self.options.line_weight as f64,
|
||||
is_integer: true,
|
||||
is_integer: false,
|
||||
min: Some(0.),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| LineToolMessage::UpdateOptions(LineOptionsUpdate::LineWeight(number_input.value as u32)).into()),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| LineToolMessage::UpdateOptions(LineOptionsUpdate::LineWeight(number_input.value)).into()),
|
||||
..NumberInput::default()
|
||||
}))],
|
||||
}])
|
||||
@@ -129,7 +129,7 @@ struct LineToolData {
|
||||
drag_start: ViewportPosition,
|
||||
drag_current: ViewportPosition,
|
||||
angle: f64,
|
||||
weight: u32,
|
||||
weight: f64,
|
||||
path: Option<Vec<LayerId>>,
|
||||
snap_handler: SnapHandler,
|
||||
}
|
||||
@@ -168,7 +168,7 @@ impl Fsm for LineToolFsmState {
|
||||
path: data.path.clone().unwrap(),
|
||||
insert_index: -1,
|
||||
transform: DAffine2::ZERO.to_cols_array(),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight as f32)), style::Fill::None),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight)), style::Fill::None),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
|
||||
@@ -27,18 +27,18 @@ pub struct PenTool {
|
||||
}
|
||||
|
||||
pub struct PenOptions {
|
||||
line_weight: u32,
|
||||
line_weight: f64,
|
||||
}
|
||||
|
||||
impl Default for PenOptions {
|
||||
fn default() -> Self {
|
||||
Self { line_weight: 5 }
|
||||
Self { line_weight: 5. }
|
||||
}
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[impl_message(Message, ToolMessage, Pen)]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum PenToolMessage {
|
||||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
@@ -62,9 +62,9 @@ enum PenToolFsmState {
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum PenOptionsUpdate {
|
||||
LineWeight(u32),
|
||||
LineWeight(f64),
|
||||
}
|
||||
|
||||
impl PropertyHolder for PenTool {
|
||||
@@ -73,10 +73,10 @@ impl PropertyHolder for PenTool {
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
value: self.options.line_weight as f64,
|
||||
is_integer: true,
|
||||
value: self.options.line_weight,
|
||||
is_integer: false,
|
||||
min: Some(0.),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| PenToolMessage::UpdateOptions(PenOptionsUpdate::LineWeight(number_input.value as u32)).into()),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| PenToolMessage::UpdateOptions(PenOptionsUpdate::LineWeight(number_input.value)).into()),
|
||||
..NumberInput::default()
|
||||
}))],
|
||||
}])
|
||||
@@ -128,7 +128,7 @@ impl Default for PenToolFsmState {
|
||||
}
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct PenToolData {
|
||||
weight: u32,
|
||||
weight: f64,
|
||||
path: Option<Vec<LayerId>>,
|
||||
curve_shape: VectorShape,
|
||||
bez_path: Vec<PathEl>,
|
||||
@@ -184,7 +184,7 @@ impl Fsm for PenToolFsmState {
|
||||
transform: transform.to_cols_array(),
|
||||
insert_index: -1,
|
||||
bez_path: data.bez_path.clone().into_iter().collect(),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight as f32)), style::Fill::None),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight)), style::Fill::None),
|
||||
closed: false,
|
||||
}
|
||||
.into(),
|
||||
|
||||
@@ -23,18 +23,18 @@ pub struct SplineTool {
|
||||
}
|
||||
|
||||
pub struct SplineOptions {
|
||||
line_weight: u32,
|
||||
line_weight: f64,
|
||||
}
|
||||
|
||||
impl Default for SplineOptions {
|
||||
fn default() -> Self {
|
||||
Self { line_weight: 5 }
|
||||
Self { line_weight: 5. }
|
||||
}
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[impl_message(Message, ToolMessage, Spline)]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum SplineToolMessage {
|
||||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
@@ -56,9 +56,9 @@ enum SplineToolFsmState {
|
||||
}
|
||||
|
||||
#[remain::sorted]
|
||||
#[derive(PartialEq, Clone, Debug, Hash, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
|
||||
pub enum SplineOptionsUpdate {
|
||||
LineWeight(u32),
|
||||
LineWeight(f64),
|
||||
}
|
||||
|
||||
impl PropertyHolder for SplineTool {
|
||||
@@ -67,10 +67,10 @@ impl PropertyHolder for SplineTool {
|
||||
widgets: vec![WidgetHolder::new(Widget::NumberInput(NumberInput {
|
||||
unit: " px".into(),
|
||||
label: "Weight".into(),
|
||||
value: self.options.line_weight as f64,
|
||||
is_integer: true,
|
||||
value: self.options.line_weight,
|
||||
is_integer: false,
|
||||
min: Some(0.),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| SplineToolMessage::UpdateOptions(SplineOptionsUpdate::LineWeight(number_input.value as u32)).into()),
|
||||
on_update: WidgetCallback::new(|number_input: &NumberInput| SplineToolMessage::UpdateOptions(SplineOptionsUpdate::LineWeight(number_input.value)).into()),
|
||||
..NumberInput::default()
|
||||
}))],
|
||||
}])
|
||||
@@ -124,7 +124,7 @@ impl Default for SplineToolFsmState {
|
||||
struct SplineToolData {
|
||||
points: Vec<DVec2>,
|
||||
next_point: DVec2,
|
||||
weight: u32,
|
||||
weight: f64,
|
||||
path: Option<Vec<LayerId>>,
|
||||
snap_handler: SnapHandler,
|
||||
}
|
||||
@@ -265,7 +265,7 @@ fn add_spline(data: &SplineToolData, 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, data.weight as f32)), style::Fill::None),
|
||||
style: style::PathStyle::new(Some(style::Stroke::new(tool_data.primary_color, data.weight)), style::Fill::None),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user