Fix druid dependency
This commit is contained in:
parent
0f8c318bb6
commit
9f1db67d23
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
|
|
@ -4,24 +4,25 @@ version = "0.1.0"
|
||||||
authors = ["Enrico Lumetti <enrico.lumetti@gmail.com>"]
|
authors = ["Enrico Lumetti <enrico.lumetti@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
udev = "0.2"
|
udev = "0.2"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
errno = "0.2"
|
errno = "0.2"
|
||||||
csv = "1.1"
|
csv = "1.1"
|
||||||
druid = { git = "https://github.com/doppioandante/druid", branch = "stylus_events", features = ["im"] }
|
druid = { version = "0.6.0", features = ["im"] }
|
||||||
im = { version = "*" }
|
im = { version = "*" }
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
druid = { git = "https://github.com/doppioandante/druid", branch = "stylus_events_0.6.0", features = ["im"] }
|
||||||
|
|
||||||
[dependencies.gtk]
|
[dependencies.gtk]
|
||||||
version = "0.9.2"
|
version = "0.8.1"
|
||||||
features = ["v3_22"]
|
features = ["v3_22"]
|
||||||
|
|
||||||
[dependencies.gio]
|
[dependencies.gio]
|
||||||
version = ""
|
version = "0.8.1"
|
||||||
features = ["v2_56"]
|
features = ["v2_56"]
|
||||||
|
|
||||||
[dependencies.gdk]
|
[dependencies.gdk]
|
||||||
version = ""
|
version = "0.12.1"
|
||||||
features = ["v3_22"]
|
features = ["v3_22"]
|
||||||
|
|
|
||||||
11
src/lib.rs
11
src/lib.rs
|
|
@ -5,10 +5,7 @@ pub struct Path {
|
||||||
|
|
||||||
#[derive(Clone, druid::Data)]
|
#[derive(Clone, druid::Data)]
|
||||||
pub enum CanvasElement {
|
pub enum CanvasElement {
|
||||||
Freehand {
|
Freehand { path: Path, thickness: f64 },
|
||||||
path: Path,
|
|
||||||
thickness: f64,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CanvasElement {
|
impl CanvasElement {
|
||||||
|
|
@ -16,7 +13,9 @@ impl CanvasElement {
|
||||||
match self {
|
match self {
|
||||||
CanvasElement::Freehand { path, thickness } => {
|
CanvasElement::Freehand { path, thickness } => {
|
||||||
use druid::kurbo::Shape;
|
use druid::kurbo::Shape;
|
||||||
path.kurbo_path.bounding_box().inflate(*thickness, *thickness)
|
path.kurbo_path
|
||||||
|
.bounding_box()
|
||||||
|
.inflate(*thickness, *thickness)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -36,3 +35,5 @@ impl CanvasElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
14
src/main.rs
14
src/main.rs
|
|
@ -117,15 +117,13 @@ impl Widget<CanvasData> for CanvasWidget {
|
||||||
// It goes event -> update -> layout -> paint, and each method can influence the next.
|
// It goes event -> update -> layout -> paint, and each method can influence the next.
|
||||||
// Basically, anything that changes the appearance of a widget causes a paint.
|
// Basically, anything that changes the appearance of a widget causes a paint.
|
||||||
fn paint(&mut self, ctx: &mut PaintCtx, data: &CanvasData, _env: &Env) {
|
fn paint(&mut self, ctx: &mut PaintCtx, data: &CanvasData, _env: &Env) {
|
||||||
// Let's draw a picture with Piet!
|
|
||||||
|
|
||||||
// Clear the whole widget with the color of your choice
|
|
||||||
// (ctx.size() returns the size of the layout rect we're painting in)
|
// (ctx.size() returns the size of the layout rect we're painting in)
|
||||||
let size = ctx.size();
|
let size = ctx.size();
|
||||||
let rect = size.to_rect();
|
let rect = size.to_rect();
|
||||||
ctx.fill(rect, &Color::WHITE);
|
|
||||||
// Note: ctx also has a `clear` method, but that clears the whole context,
|
// Note: ctx also has a `clear` method, but that clears the whole context,
|
||||||
// and we only want to clear this widget's area.
|
// and we only want to clear this widget's area.
|
||||||
|
ctx.fill(rect, &Color::WHITE);
|
||||||
|
|
||||||
for element in &data.elements {
|
for element in &data.elements {
|
||||||
element.draw(ctx);
|
element.draw(ctx);
|
||||||
}
|
}
|
||||||
|
|
@ -136,14 +134,12 @@ impl Widget<CanvasData> for CanvasWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_ui() -> impl Widget<CanvasData> {
|
fn build_ui() -> impl Widget<CanvasData> {
|
||||||
use druid::widget::{Align, Button, Flex, CrossAxisAlignment, SizedBox};
|
use druid::widget::{Align, Button, CrossAxisAlignment, Flex, SizedBox};
|
||||||
let toolbar = Flex::row()
|
let toolbar = Flex::row()
|
||||||
.cross_axis_alignment(CrossAxisAlignment::Center)
|
.cross_axis_alignment(CrossAxisAlignment::Center)
|
||||||
.with_spacer(30.0)
|
.with_spacer(30.0)
|
||||||
.with_child(
|
.with_child(Button::new("Undo"))
|
||||||
Button::new("Undo"))
|
.with_child(Button::new("Redo"));
|
||||||
.with_child(
|
|
||||||
Button::new("Redo"));
|
|
||||||
|
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.cross_axis_alignment(CrossAxisAlignment::Center)
|
.cross_axis_alignment(CrossAxisAlignment::Center)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue