slint-ui / slint

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

Request for Canvas API Support #3734

Closed chonwhite closed 1 year ago

chonwhite commented 1 year ago

I recently discovered Slint and was impressed by its capabilities. However, upon further investigation, I noticed that it lacks support for the Canvas API. I would like to inquire about any plans to add support for the Canvas API in Slint.

Currently, the absence of Canvas API support poses limitations on creating complex custom widgets. Without access to the low-level canvas API, it becomes challenging to achieve highly customized widgets and implement advanced visual effects.

I kindly request the inclusion of Canvas API support in Slint. By integrating the Canvas API, developers would gain the ability to create intricate custom widgets and leverage low-level canvas operations for advanced visual effects. This enhancement would greatly enhance the flexibility and versatility of Slint as a GUI library.

tronical commented 1 year ago

duplicate of #432

I agree, an imperative "painting" API that operates on a Canvas, that itself is blended into the UI is desirable to have.

chonwhite commented 1 year ago

Thank you for the reply, I can go with the sixtyfps::Image solution at the moment, can you point me to any example or documentation, A C++ example would be preferable.

tronical commented 1 year ago

Thank you for the reply, I can go with the sixtyfps::Image solution at the moment, can you point me to any example or documentation, A C++ example would be preferable.

The C++ documentation of slint::Image has a small snippet. Once you have that slint::Image, you can set it on an in property<image> that's exposed in your Slint code, for example in the root component or in a global.

chonwhite commented 1 year ago

Cool!, just tried it, and works perfectly, another question is should I update the whole window when I want to redraw the image content? Seems inefficient to me, but can't find a partial redraw request API in the Image class.

tronical commented 1 year ago

Indeed, there's no support for partial updates on slint::Image yet.