slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.94k stars 568 forks source link

Ability to snapshot part/all of the screen via a Slint element #6095

Open NigelBreslaw opened 1 week ago

NigelBreslaw commented 1 week ago

The issue here is to snapshot, as in screenshot part or all of the screen. Show that while changes are done underneath it. Then fade it away. This could be controlled in the following way, but it's just a suggestion. Whatever solves the problem is the main thing.

In one tool I have used the API is as follows...

Shader as downScale {
                    opaque: true // optimises things if you know it can be opaque

                    property Shader.Source source: Shader.Source { 
                        sourceItem: <id of Slint element> 
                        options: Shader.Source.Option.CaptureUnderSourceItem // This captures what is under the element. Not the element itself which is the default
                        live: false; // live means it keeps updating. So if the element or what is under it changes it gets resampled. But often that isn't what you want.
                        enabled: true;
                    }
                }
Enyium commented 1 week ago

In an imagined app of mine, I would need this. The app would present a view into a diagram that you can scroll. But because the exported diagram image should be able to have a greater size (data-wise) than what's displayed, and since the scroll surface is quasi-infinite and a virtual scroller would need to be implemented, which wouldn't render much of what currently isn't in view, I'd need a way to let Slint render the diagram image off-screen using a second diagram tree that of course can't scroll and could - just for the image export - have any large size.

It would be useful, if such off-screen rendering wouldn't be bound by the monitor's scale factor, allowing you to specify the scale factor.