Commit graph

1507 commits

Author SHA1 Message Date
Olivier Goffart
fa6be65a04 Revert "Rename the free_graphics_resources to component_destroyed"
This reverts commit 1b9fee96c16f7a660ed2c14bb3287fceedc72ba7.

The MCU backend still need the array of item, so it's too realy for this change
2022-05-31 10:48:24 +02:00
Olivier Goffart
ad2d19165a Rename the free_graphics_resources to component_destroyed
And do not iterate over the items anymore
2022-05-31 10:48:24 +02:00
Olivier Goffart
6cbf2c0609 Put the new cache in corelib and use it in the GL backend 2022-05-31 10:48:24 +02:00
Olivier Goffart
615c7635ee Qt: use a HashMap for the cache
And not the cache dirrectly within the item, because it is already in use
for the partial rendering
2022-05-31 10:48:24 +02:00
Olivier Goffart
d2186593c0 Pass the ItemRc to each draw_function
So that it can be used as a key to the cache
2022-05-31 10:48:24 +02:00
Olivier Goffart
80830bbece MCU: Refactor the renderer in a LineRenderer
The LineRenderer is going to be a public type which can be used
by the MCU board support to draw.
Right now, it is used by the old code
2022-05-23 16:40:34 +02:00
Simon Hausmann
cf47d3919c Replace femtovg patch with new release 2022-05-23 09:32:25 +02:00
Tobias Hunger
18cbda0269 janitor: Run cargo clippy --fix 2022-05-22 11:59:00 +02:00
Olivier Goffart
9ae6d71619 Qt: fix gradient that have stop at the same position
Qt implementation only keep one stop if two are at the same location.
So mangle the stop position to be sure they are all at sligntly different position
2022-05-21 11:43:53 +02:00
Olivier Goffart
b4ebd88d35 Implements @radial-gradient(circle, ...)
Only the circle is implemented so far.

Part of #263
2022-05-19 14:07:20 +02:00
Jocelyn Turcotte
041238708f wasm: Prevent wasted redraws with multiple post_events
The previous approach of calling send_event on a timer has the disadvantage
or re-entering the event loop for every queued event. Any requested redraw
after one of those events will end up actually drawing, even if that frame could be
replaced by the next event's redraw without being shown to the user.

winit also doesn't expose publicly its web Runner send_events method that would
allow us to queue the events outside and pass them all together.

We can however queue the events inside winit by putting the event loop in
ControlFlow::Poll mode so that winit batches them itself.
This has the side effect of processing and painting those events using
requestAnimationFrame.

To achieve this we take advantage of winit processing send_event calls
synchronously, possibly while on a native event handler, by entering the
event loop just to send WakeEventLoopWorkaround, set the event loop in
Poll mode, exit, and call send_events again with our event which then
ends up being queue in the web event loop's Runner until the next animation
frame where all queued events are processed and redrawn together.
2022-05-16 11:02:28 +02:00
Simon Hausmann
08fb9a9336 Fix instructions on how to build the mcu printer demo for the simulator
With the simulator this still requires a regular main() entry point.
For some reason a feature test for i-slint-backend-mcu/simulator doesn't work,
but it works with the local feature.
2022-05-16 08:29:33 +02:00
Simon Hausmann
77445e9dc5 text handling: simplify text_size signature
We can calculate the line height in the common code, that doesn't need to be done in the backends.
2022-05-16 08:21:14 +02:00
Simon Hausmann
38abeaec41 text handling: clean up font traits
Separate the text shaping functionality from font metrics by having a
FontMetrics trait next to the TextShaper. AbstractFont is the combining
super trait. This allows eliminating the font height member from
TextParagraphLayout and improving the overall naming of fields and
types.

Finally, this prepares the API for composability of TextShaper for font
fallback handling.
2022-05-16 08:21:14 +02:00
Simon Hausmann
3ce142344a text handling: cleanup
Rename "byte_offset" in the Glyph structure to "text_byte_offset" to make
it clearer that this refers to the original text. Also added docs.
2022-05-16 08:21:14 +02:00
Simon Hausmann
93b5eda82e text handling: simplify glyph data structure handling
Replace the abstract glyph trait with a glyph struct. That way the text
layout code can operate properly on a struct with fields, instead of on
functions on a trait (some of which returning a mutable reference). The
input is a glyph with offset, advance, etc. - everything needed for the
layout and the output is a position along with the platform specific
glyph data.
2022-05-15 12:03:29 +02:00
Simon Hausmann
99ea6db9d4 text handling: simplify shaper <> glyph relation
Use the Glyph trait also for the byte offset handling, to avoid the use of
tuples.
2022-05-15 12:03:29 +02:00
Simon Hausmann
5f52f18df4 mcu text handling: Add support for letter spacing
This is implemented generically by adjusting the advances on the shape buffer, so that we can
use the same in the future in the GL backend.
2022-05-15 12:03:29 +02:00
Simon Hausmann
a7fb45365d text handling: remove unused advance getter on TextShaper
This is available via GlyphMetrics now.
2022-05-15 11:50:54 +02:00
Simon Hausmann
08e27fef4a text handling: move function from TextShaper to glyph trait
This will avoid the need to keep a reference to the TextShaper
around.
2022-05-15 11:50:14 +02:00
Simon Hausmann
b6e7db0221 Minor cleanup in the MCU text handling
Replace the use of Option for the associated glyph type with a
struct that can later implement a trait.
2022-05-15 11:50:00 +02:00
Olivier Goffart
877934f1f1 GL backend: process timing event before processing input events
Otherwise the timing code might think at the time of an event (eg key press)
that the starting point of an animation that starts in this event is
earlier in time than it really is. Causing the animation to appear as it
had started earlier or literaly be finished before it starts.

Fixes #1255
2022-05-12 11:43:07 +02:00
ogoffart
3709ded44d Bump version number to 0.2.5 2022-05-09 16:16:00 +00:00
Olivier Goffart
226ceca58d Native style: Fix crash when opening a combobox
Bug introduced by https://github.com/slint-ui/slint/pull/1231
2022-05-09 17:27:32 +02:00
ogoffart
c160ec2aef Bump version number to 0.2.4 2022-05-09 13:49:25 +00:00
Simon Hausmann
6e18513c12 GL backend: fix locating the default font in slightly atypical environments
Enable fontdb's fontconfig feature to parse fontconfig files to locate
the directories where truetype fonts are located. This helps in system
setups that differ from the defaults that fontdb uses otherwise.

Fixes #1240
2022-05-07 21:59:16 +08:00
Olivier Goffart
0c19751a1e Qt: do not wrap QPainter directly, but use a unique_ptr instead
Because QPainter can't be relocated.

Fixes #1230
2022-05-05 13:50:26 +02:00
ogoffart
6395cdfc09 Bump version number to 0.2.3 2022-05-04 12:32:58 +00:00
Lukas Jung
d648862589 Make window.hide() respect the set EventLoopQuitBehavior 2022-05-04 09:16:13 +02:00
Tobias Hunger
11f23cbbdb
Hack to make Qt not close newly opened popups when running on Windows (#1227)
* Hack to make Qt not close newly opened popups when running on Windows

Windows sends a mouse release event after the close event when running
on windows. This confuses our hack to close popups!

So hack around the problem by ignoring any mouse button release event
that does not follow a mouse button press event. I hope this will
not couse too many side effects.

Fixes: #1211

* Update internal/backends/qt/qt_window.rs

Co-authored-by: Olivier Goffart <olivier@woboq.com>

Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-05-03 18:46:53 +02:00
Olivier Goffart
931838e2ce Qt: quit the application when calling hide() on the last window
Fixes the todo example not exiting when clicking on "yes" in
the close popup

cc #1212
2022-05-03 17:20:41 +02:00
Olivier Goffart
1b9917db37 Fix PopupMenu showing in a wrong place from qt_viewer
qt_viewer reparent the window so we need to use mapToGlobal to compute
the popup position

Fixes #1219
2022-05-03 11:54:53 +02:00
Olivier Goffart
723f89d342 Fix changing the size of contrained window on x11
Changing the constraint doesn't work on non-rezsizable window.
So first set the window as resizeable, then change the constraints, then
maybe remove the resizable flag
2022-04-29 11:54:31 +02:00
Olivier Goffart
1104ab73a0 Fix compilation with integer coordinate 2022-04-28 18:58:11 +02:00
Olivier Goffart
5a9c70307a MCU: properly round the image source rect
to avoid artifacts with different (frational) clipping
2022-04-28 17:45:47 +02:00
Olivier Goffart
ad1936d2d2 Remove new_scene_rectangle indirection 2022-04-27 09:23:10 +02:00
Olivier Goffart
fc65809b9d stm32h735: cleanup after review 2022-04-27 09:00:52 +02:00
Olivier Goffart
c658792c1e stm32h735g: cleanup 2022-04-27 09:00:52 +02:00
Olivier Goffart
846ae7cd43 stm32h735g: Instructions in readme 2022-04-27 09:00:52 +02:00
Olivier Goffart
5c507ab86c stm32h735g: Touch support 2022-04-27 09:00:52 +02:00
Olivier Goffart
199dc1fb18 upgrade stm32h7xx-hal 2022-04-27 09:00:52 +02:00
Olivier Goffart
e41c15aef9 stm32h735g: Add support for double frame buffer and timing 2022-04-27 09:00:52 +02:00
Olivier Goffart
a81d8b7ba4 stm32h735g: The screen actually show the UI now 2022-04-27 09:00:52 +02:00
Olivier Goffart
4755f57fb2 stm32h735g: The screen now show something 2022-04-27 09:00:52 +02:00
Olivier Goffart
0e0526912d WIP: attempt to get the display working on stm32h735g
(doesn't work, the screen is plain white)
2022-04-27 09:00:52 +02:00
Olivier Goffart
df95ee79ba WIP: setup OCTOSPI2 ram 2022-04-27 09:00:52 +02:00
Olivier Goffart
cc98d53b28 WIP: more work on stm32h735g 2022-04-27 09:00:52 +02:00
Olivier Goffart
703cffd444 WIP: STM32H735G support 2022-04-27 09:00:52 +02:00
Olivier Goffart
9ec6ed0406 wasm: fix tab and back tab
The situation differs depending if the widget show the virtual keyboard or not:
For widget that don't show the virtual keyboard, we rely on the winit events,
but for some reason we don't recieve WindowEvent::ModifiersChanged events with
wasm. Since the event handling in winit is about to be rewriten, I did not
bother reporting the bug upstream, but just work around by using the deprecated
API. So that way shift + tab will no longer be understood as just tab.

For widget using the virtual keyboard, then the event handling is in
wasm_input_helper.rs.  There is a couple of issues:

 - We must map shift+tab to backtab.
 - We need to prevent the default events to trigger, so that tab and other
   shortcuts don't take effect on the browser. Winit already inhibit these
   events so we must do the same otherwise tab and shift+tab would change the
   html focus.
 - By luck, tab used to give the focus back to the canvas before (see previous
   point) and that's why it worked. But now that we don't do that anymore,
   hiding the virtual keyboard should actually re-focus the canvas
 - That will cause the focus event to be intercepted by winit, and will cause
   recursions and borrow error, so we make sure that we do not recurse when
   getting the focus event
2022-04-22 13:58:37 +02:00
Simon Hausmann
eb3ceb54bd janitor: Move the GL renderer into a separate module 2022-04-20 17:41:53 +02:00