mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 20:28:12 +08:00
Add snapping to endpoints and stops in the Gradient tool (#3732)
* snapping * Cleanup * fix * Fix snapping failing sometimes on newly drawn gradient lines * Code cleanup --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
691d965bcf
commit
3b91d02fff
@@ -484,6 +484,7 @@ impl OverlayContext {
|
||||
self.render_context.set_line_width(width);
|
||||
self.render_context.set_stroke_style_str(color);
|
||||
self.render_context.stroke();
|
||||
self.render_context.set_line_width(1.);
|
||||
} else {
|
||||
self.render_context.set_fill_style_str(color);
|
||||
self.render_context.fill();
|
||||
|
||||
@@ -307,6 +307,19 @@ pub enum PathSnapSource {
|
||||
IntersectionPoint,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GradientSnapSource {
|
||||
Endpoint,
|
||||
}
|
||||
|
||||
impl fmt::Display for GradientSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
GradientSnapSource::Endpoint => write!(f, "Gradient: Endpoint"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for PathSnapSource {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
@@ -347,6 +360,7 @@ pub enum SnapSource {
|
||||
Artboard(ArtboardSnapSource),
|
||||
Path(PathSnapSource),
|
||||
Alignment(AlignmentSnapSource),
|
||||
Gradient(GradientSnapSource),
|
||||
}
|
||||
|
||||
impl SnapSource {
|
||||
@@ -377,6 +391,7 @@ impl fmt::Display for SnapSource {
|
||||
SnapSource::Artboard(artboard_snap_source) => write!(f, "{artboard_snap_source}"),
|
||||
SnapSource::Path(path_snap_source) => write!(f, "{path_snap_source}"),
|
||||
SnapSource::Alignment(alignment_snap_source) => write!(f, "{alignment_snap_source}"),
|
||||
SnapSource::Gradient(gradient_snap_source) => write!(f, "{gradient_snap_source}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user