Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new Image API from egui #11

Merged
merged 8 commits into from
Sep 13, 2023
Merged

Conversation

jprochazk
Copy link
Contributor

@jprochazk jprochazk commented Sep 13, 2023

Sorry for the noise! Continued from #9.

@jprochazk jprochazk marked this pull request as ready for review September 13, 2023 14:42
examples/hello_world.rs Outdated Show resolved Hide resolved
/// A cache used for storing content such as images.
pub struct CommonMarkCache {
// Everything stored here must take into account that the cache is for multiple
// CommonMarkviewers with different source_ids.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is for the entire struct and not for the image field. It's just badly placed by me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it back in

pub fn reload_images(&mut self) {
self.images.lock().clear();
pub fn reload_images(&mut self, ui: &Ui) {
ui.ctx().forget_all_images();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a different meaning now. Before it removed only egui_commonmark's images, now it removes all images. The extra tracking of images required just for this function does not seem worth it to me, so I'm tempted to have the entire method removed. I added this method originally just because I could...

src/lib.rs Show resolved Hide resolved
@lampsitter lampsitter merged commit 22fa289 into lampsitter:master Sep 13, 2023
1 check passed
@lampsitter
Copy link
Owner

Thanks!

let url = if url.starts_with("http://") || url.starts_with("https://") {
url.to_string()
} else {
format!("file://{url}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a mistake. I think we should pass the uri unchanged to egui.

For instance, the user might specify their uri using something like bytes:// to indicate it should come from the BytesLoader. Or they specify it using file:// and now egui_commonmark adds another file:// prefix to it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect ![](image.png) to just point to the file at {cwd}/image.png. Maybe we could detect if the URI begins with a protocol of any kind, and if it doesn't, only then append file://?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants