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

Provide per-platform screenshots for each widget #2103

Merged
merged 43 commits into from
Nov 3, 2023

Conversation

freakboy3742
Copy link
Member

@freakboy3742 freakboy3742 commented Aug 28, 2023

The widget screenshots are currently all macOS widgets. This PR modifies the documentation to provide a tabview so that you can see what the widget will look like on each platform.

To ensure the screenshots remain consistent, a new demo app has been added that automatically generates all the screenshots. The only exceptions are WebView (web content isn't reliably included in screenshots on macOS, presumably for security reasons?), Window and MainWindow (which will require manual screenshots until #1930 lands, adding a full-screen capture API).

When this app runs, it generates a sample of each widget, takes a screenshot, crops the screenshot so that it only includes the widget, and saves the cropped screenshot in the app data folder.

Also adds:

  • An API to capture windows as an image has been added (Add API to capture screenshots of windows. #2062). This is required to capture the images of each demo widget.
  • The ability to extract the raw data of a toga.Image has been added. This is needed so that a toga.Image can be easily loaded into a PIL.Image.

Builds off #2160.

Fixes #2062.

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@freakboy3742
Copy link
Member Author

This is currently failing RTD, plus Windows and Android testbed tests because the Windows and Android screenshots (and relative APIs) are missing.

To get those, an implementation of Window.get_image_data() and Image.get_data() is needed; once those are in place, running the screenshot app should generate all the screenshots, except for Window and MainWindow which need to be taken manually (there's a prompt in the app to do this).

In the process, I've noticed that tutorial4 isn't producing the right output on Windows; not sure where that regressed.

@mhsmith
Copy link
Member

mhsmith commented Oct 31, 2023

In the process, I've noticed that tutorial4 isn't producing the right output on Windows; not sure where that regressed.

There are two separate problems:

  • The window size wasn't taking the invisible resize borders into account, causing the window to be too narrow for the image. This is fixed by #2180.
  • Elliptical arcs are not connected to the rest of their containing path. I'll look at this tomorrow, and add a testbed test that would have caught it.

Copy link
Member

@mhsmith mhsmith left a comment

Choose a reason for hiding this comment

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

The WinForms Canvas will be fixed by #2184, and there's also a small change to the drawing instructions which will have to be copied from tutorial4.

I'm not sure what's happening on Android – maybe something to do with the Box not being big enough to hold the Canvas plus its padding?

@freakboy3742 freakboy3742 merged commit 6085478 into beeware:main Nov 3, 2023
34 of 35 checks passed
@freakboy3742 freakboy3742 deleted the screenshots branch November 3, 2023 01:37
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.

Add API to capture screenshots of windows.
2 participants