-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add option to take screenshot #43
Conversation
@@ -18,8 +18,11 @@ eframe = { version = "0.22.0", default-features = false, features = [ | |||
"default_fonts", # Embed the default egui fonts. | |||
"glow", # Use the glow rendering backend. Alternative: "wgpu". | |||
"persistence", # Enable restoring app state when restarting the app. | |||
"__screenshot", # __screenshot is so we can dump a screenshot using EFRAME_SCREENSHOT_TO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what all the official egui
screenshot examples require 🤷
if let Some(screenshot) = frame.screenshot() { | ||
self.screenshot = Some(screenshot); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit clunky to me, but ref:
/// Request the current frame's pixel data. Needs to be retrieved by calling [`Frame::screenshot`]
/// during [`App::post_rendering`].
src/app.rs
Outdated
} | ||
|
||
if let Some(screenshot) = self.screenshot.take() { | ||
if let Some(mut path) = rfd::FileDialog::new().save_file() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently always defaults to "Untitled" (.png) but we could set a a different default filename if desired
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe default to the name-of-the-profile.png?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or Screenshot_YYYY-MM-DD-HH-MM-SS.png
, or something like that.
I agree a more informative default name is helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giver there can be an arbitrary number of source locators I opted for something like @elliottslaughter's datetime suggestion 3be2ff1
I actually wanted Legion Prof 2024-01-11 12:41:27
but annoyingly rfd
converts colons to forward slashes 🤷)
Is there a reason not to use the print screen key? 😉 |
There is no print screen key on Mac keyboards, e.g. and also no |
On MAC: print-screen == Ctrl+Cmd+3
That's unfortunate. |
Also Shift Command 4, Shift Command 4 + Space, Shift Command 5... We could make any of them work, but I am not sure there is one obvious choice |
Definitely do not overload the Mac print screen keys. They will work fine as long as we don't mess with them. I assume Seshu is not on a Mac, so what he needs is for this to be available on other platforms. |
@elliottslaughter CI issues seem to be a version incompat
|
@elliottslaughter any thoughts on the CI issue? |
I bumped the Rust version, can you merge and try again? (Note: please throw away your |
Unfortunately after merge |
Something you're doing seems to depend on GTK:
I'm not sure we want to add additional (non-Rust) dependencies? Is there a way to avoid pulling this in? |
no idea offhand, this PR just follows the short and simple official Edit: That isn't the build error I am seeing, though, FWIW (or maybe they are downstream errors, I have not looked into yet)
|
@syamajala had asked about a screenshot capability in StanfordLegion/legion#1551 (comment)
This PR adds a screenshot feature to the profiler frontend. Currently it is activated by
<ctrl>+Space
but open to any alternative suggestions (personally prefer keyboard option to a button, but it would be simple to add one). This approach borrows liberally from the egui plot screenshot example.Currently just saves the entire window (I think the added context is nice) but image region could be clipped as desired.
cc @manopapad @elliottslaughter