Skip to content

Commit

Permalink
Use new Image API from egui (#11)
Browse files Browse the repository at this point in the history
* use new `Image` caching API from egui

* update to latest rev

* handle `https`

* update rev

* update rev

* update `fit_to_original_size` usage

* Remove commented code

* revert removed comment

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
jprochazk and emilk authored Sep 13, 2023
1 parent db79ec0 commit 22fa289
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 238 deletions.
26 changes: 8 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,27 @@ documentation = "https://docs.rs/egui_commonmark"
include = ["src/*.rs", "LICENSE-MIT", "LICENSE-APACHE", "Cargo.toml"]

[dependencies]
egui = { git = "https://github.com/emilk/egui", rev = "2c7c598" }
image = { version = "0.24", default-features = false, features = ["png"] }
parking_lot = "0.12"
poll-promise = "0.3"
egui = { git = "https://github.com/emilk/egui", rev = "67a3fcae383044def7450b311ddc1f79e36eaae0" }
pulldown-cmark = { version = "0.9.3", default-features = false }

egui_extras = { git = "https://github.com/emilk/egui", rev = "67a3fcae383044def7450b311ddc1f79e36eaae0" }

syntect = { version = "5.0.0", optional = true, default-features = false, features = [
"default-fancy",
] }

resvg = { version = "0.35.0", optional = true }
usvg = { version = "0.35.0", optional = true }

url = { version = "2.4", optional = true }
ehttp = { version = "0.3.0", optional = true }

document-features = { version = "0.2", optional = true }

[features]
## Syntax highlighting for code blocks
syntax_highlighting = ["syntect"]

## Support loading svg images
svg = ["resvg", "usvg"]

## Images with urls will be downloaded and displayed
fetch = ["ehttp", "url", "image/jpeg"]

[dev-dependencies]
eframe = { git = "https://github.com/emilk/egui", rev = "2c7c598" }
egui_extras = { git = "https://github.com/emilk/egui", rev = "67a3fcae383044def7450b311ddc1f79e36eaae0", features = [
"all-loaders",
"log",
] }
eframe = { git = "https://github.com/emilk/egui", rev = "67a3fcae383044def7450b311ddc1f79e36eaae0" }
image = { version = "0.24", default-features = false, features = ["png"] }

[package.metadata.docs.rs]
# docs.rs build can fail with the fetch feature enabled
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn main() {
});

Box::new(App {
cache: CommonMarkCache::default(),
cache: CommonMarkCache::new(&cc.egui_ctx),
})
}),
)
Expand Down
8 changes: 4 additions & 4 deletions examples/link_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Check out the [previous](#prev) page."#;
}

fn main() {
let mut cache = CommonMarkCache::default();
cache.add_link_hook("#next");
cache.add_link_hook("#prev");
eframe::run_native(
"Markdown link hooks",
eframe::NativeOptions::default(),
Box::new(|_| {
Box::new(|cc| {
let mut cache = CommonMarkCache::new(&cc.egui_ctx);
cache.add_link_hook("#next");
cache.add_link_hook("#prev");
Box::new(App {
cache,
curr_page: 0,
Expand Down
2 changes: 1 addition & 1 deletion examples/scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn main() {
});

Box::new(App {
cache: CommonMarkCache::default(),
cache: CommonMarkCache::new(&cc.egui_ctx),
})
}),
)
Expand Down
29 changes: 0 additions & 29 deletions src/fetch_data.rs

This file was deleted.

51 changes: 0 additions & 51 deletions src/image_loading.rs

This file was deleted.

Loading

0 comments on commit 22fa289

Please sign in to comment.