Skip to content

Commit

Permalink
Update for piet 0.4.0 and kurbo 0.8.0
Browse files Browse the repository at this point in the history
Not a lot of breakage here, although there might be a bit more
upstream.
  • Loading branch information
cmyr committed Mar 28, 2021
1 parent 6b8b9fd commit 762af70
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
8 changes: 4 additions & 4 deletions druid-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ default-target = "x86_64-pc-windows-msvc"
default = ["gtk"]
gtk = ["gio", "gdk", "gdk-sys", "glib", "glib-sys", "gtk-sys", "gtk-rs", "gdk-pixbuf"]
x11 = ["x11rb", "nix", "cairo-sys-rs"]
# Implement HasRawWindowHandle for WindowHandle
# Implement HasRawWindowHandle for WindowHandle
raw-win-handle = ["raw-window-handle"]

# passing on all the image features. AVIF is not supported because it does not
Expand All @@ -40,8 +40,8 @@ hdr = ["piet-common/hdr"]
[dependencies]
# NOTE: When changing the piet or kurbo versions, ensure that
# the kurbo version included in piet is compatible with the kurbo version specified here.
piet-common = "=0.3.2"
kurbo = "0.7.1"
piet-common = "=0.4.0"
kurbo = "0.8.1"

tracing = "0.1.22"
lazy_static = "1.4.0"
Expand Down Expand Up @@ -99,7 +99,7 @@ version = "0.3.44"
features = ["Window", "MouseEvent", "CssStyleDeclaration", "WheelEvent", "KeyEvent", "KeyboardEvent"]

[dev-dependencies]
piet-common = { version = "=0.3.2", features = ["png"] }
piet-common = { version = "=0.4.0", features = ["png"] }
static_assertions = "1.1.0"
test-env-log = { version = "0.2.5", features = ["trace"], default-features = false }
tracing-subscriber = "0.2.15"
Expand Down
2 changes: 1 addition & 1 deletion druid/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ console_error_panic_hook = { version = "0.1.6" }
float-cmp = { version = "0.8.0", features = ["std"], default-features = false }
# tempfile 3.2.0 broke wasm; I assume it will be yanked (Jan 12, 2021)
tempfile = "=3.1.0"
piet-common = { version = "=0.3.2", features = ["png"] }
piet-common = { version = "=0.4.0", features = ["png"] }
pulldown-cmark = { version = "0.8", default-features = false }
test-env-log = { version = "0.2.5", features = ["trace"], default-features = false }

Expand Down
11 changes: 10 additions & 1 deletion druid/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,18 @@ impl Data for kurbo::Rect {
}
}

impl Data for kurbo::RoundedRectRadii {
fn same(&self, other: &Self) -> bool {
self.top_left.same(&other.top_left)
&& self.top_right.same(&other.top_right)
&& self.bottom_left.same(&other.bottom_left)
&& self.bottom_right.same(&other.bottom_right)
}
}

impl Data for kurbo::RoundedRect {
fn same(&self, other: &Self) -> bool {
self.rect().same(&other.rect()) && self.radius().same(&other.radius())
self.rect().same(&other.rect()) && self.radii().same(&other.radii())
}
}

Expand Down
2 changes: 1 addition & 1 deletion druid/src/widget/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ impl<T: Data> Widget<T> for Flex<T> {
let color = env.get_debug_color(ctx.widget_id().to_raw());
let my_baseline = ctx.size().height - ctx.widget_state.baseline_offset;
let line = crate::kurbo::Line::new((0.0, my_baseline), (ctx.size().width, my_baseline));
let stroke_style = crate::piet::StrokeStyle::new().dash(vec![4.0, 4.0], 0.0);
let stroke_style = crate::piet::StrokeStyle::new().dash_pattern(&[4.0, 4.0]);
ctx.stroke_styled(line, &color, 1.0, &stroke_style);
}
}
Expand Down
10 changes: 6 additions & 4 deletions druid/src/widget/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,18 +311,20 @@ impl SvgRenderer {
let brush = self.brush_from_usvg(&stroke.paint, stroke.opacity, ctx);
let mut stroke_style = StrokeStyle::new()
.line_join(match stroke.linejoin {
usvg::LineJoin::Miter => LineJoin::Miter,
usvg::LineJoin::Miter => LineJoin::Miter {
limit: stroke.miterlimit.value(),
},
usvg::LineJoin::Round => LineJoin::Round,
usvg::LineJoin::Bevel => LineJoin::Bevel,
})
.line_cap(match stroke.linecap {
usvg::LineCap::Butt => LineCap::Butt,
usvg::LineCap::Round => LineCap::Round,
usvg::LineCap::Square => LineCap::Square,
})
.miter_limit(stroke.miterlimit.value());
});
if let Some(dash_array) = &stroke.dasharray {
stroke_style.set_dash(dash_array.clone(), stroke.dashoffset as f64);
stroke_style.set_dash_pattern(dash_array.clone());
stroke_style.set_dash_offset(stroke.dashoffset as f64);
}
ctx.stroke_styled(path, &*brush, stroke.width.value(), &stroke_style);
}
Expand Down

0 comments on commit 762af70

Please sign in to comment.