Commit graph

1368 commits

Author SHA1 Message Date
Simon Hausmann
a98d4709be Move printer demo and energy-monitor into new top-level demos/ folder
These are showing off use-cases for Slint, but they're not examples showing individual Slint features.

Also removed the old printerdemo while at it.
2024-10-25 12:09:32 +02:00
DataTriny
2de3b9d455 Add the accessible-enabled property 2024-10-25 10:20:09 +02:00
FloVanGH
14c7910d49
PopupWindow: added close-policy property (#6614)
* Update api/cpp/include/slint_window.h

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update docs/reference/src/language/builtins/elements.md

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update internal/core/window.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/interpreter/eval.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

* Update internal/backends/qt/qt_window.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/interpreter/dynamic_item_tree.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update internal/compiler/passes/materialize_fake_properties.rs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-10-24 09:27:39 +00:00
Olivier Goffart
9e2576bc5c swrenderer: Small fixup in distance field
- include the ' ' char that doesn't have a bounding box but need to be
   included for the advance_x
 - Fix an off by one in rendering where the last pixel was missing
2024-10-24 08:12:13 +02:00
Olivier Goffart
cbc28b1f1b Android: handle properly the Destroy event
Destroy means we need to exit the event loop.
And android_main will be called again from another thread, so we need to
support reseting the proxy

There is also a bug in the timer when exiting the app that this worked
around

Fix #6626
2024-10-23 14:30:55 +02:00
Simon Hausmann
a2eacd77f4 Minor cleanup: femtovg -> FemtoVG 2024-10-23 13:25:05 +02:00
Ian Hattendorf
e2c9b4a743 Fix wording in SlintRenderer comment
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2024-10-23 11:13:49 +02:00
Ian Hattendorf
3cc44dc670 Add version to OpenGLAPI 2024-10-23 11:13:49 +02:00
Ian Hattendorf
dedd396093 Allow choosing renderer via PlatformBuilder 2024-10-23 11:13:49 +02:00
Ian Hattendorf
ac9b85049a Add PlatformBuilder API to allow selecting OpenGL API
Right now this just allows selecting between OpenGL and OpenGL ES.
2024-10-23 11:13:49 +02:00
Simon Hausmann
2a4024fdcb Bump various dependencies 2024-10-23 10:06:12 +02:00
Olivier Goffart
d8ab4e4600 Signed DistanceField font rendering in swrenderer
Note that this is still disabled in the compiler with no way to enable
it with public API
2024-10-23 09:12:30 +02:00
Simon Hausmann
20cf304936 Enable support for WASM builds with the software renderer
Everything is already working, just had to play around with a few cfgs. The sharedfontdb module already takes care of including DejaVuSans as default fallback font.
2024-10-17 08:50:25 +02:00
Arnold Loubriat
19f09950c2 Changelog: Add accessible-selectable and accessible-selected properties 2024-10-16 15:38:46 +02:00
Tobias Hunger
df4f9b38ee femtovg: Fix warning about deprecated web_sys::set_fill_style
Use set_fill_style_str insterad, it avoids constructing a JSValue
from a str.
2024-10-16 13:25:00 +02:00
Simon Hausmann
07a833a2e3 Clarify Timer::set_interval Rust docs with regards to running timer behaviour
Fixes #6515
2024-10-15 16:49:35 +02:00
Simon Hausmann
0cf40b08bc
Fix two issues with the timer handling (#6549)
- When stopping a running but not yet expired timer from within the activation callback of an expired timer, the stopping would fail to find the timer in the active_timers list because it was built on the fly. Similarly, restarting a future timer form within the same kind of callback would end up registering the active timer twice. Fix this by doing all the active_timer re-setup before activating any callbacks, so that by the time of activation the data structure is in a good state.
- When two timers expire at the same time and from the callback of the first, the second timer would be dropped/deleted, the timer's `being_activated` was overwritten and the timer was deleted too early, causing a panic. Fix this by preserving the removal state.

Fixes #6187
Fixes #6505
2024-10-14 15:02:35 +02:00
Olivier Goffart
80dfaf8c2c Derive serde for PhysicalPosition, LogicalSize etc.
Fixes #6534

ChangeLog: [Rust] Derive serde traits for `PhysicalPosition`,
`LogicalPosition`, `PhysicalSize` and `LogicalSize`
2024-10-14 14:31:40 +02:00
Olivier Goffart
a6ff642da5
refactor: split sofware_renderer.rs in modules 2024-10-11 11:56:46 +02:00
FloVanGH
52afd18650
macos: enable gettext (#6508) 2024-10-10 13:37:16 +00:00
Simon Hausmann
be2af11a08 Rust: Stop ModelIterator from calling row_data() with out of bounds row
While technically allowed and sort of serving as a test to see if the model is well implemented, this is unnecessary behaviour. The model iterator should not serve as a testing ground :)
2024-10-10 11:40:12 +02:00
Olivier Goffart
9734bfdd8e
SwipeGestureRecognizer: fix cancel() function
It was implemented in the compiler, but not in the runtime
2024-10-09 18:06:32 +02:00
Olivier Goffart
9f9306ac95
TextInput: don't reset mouse cursor when left-clicking
ChangeLog: Fixed TextInput mouse cursor after left click

Fixes #6444
2024-10-07 13:38:41 +02:00
Olivier Goffart
d7e76c36cb Software renderer: Don't panic when rotation is used
Instead, just ignore the rotation.

(Rotation is currently used in the live-preview to show the collapsed
items. It shouldn't cause a panic even if rotation is not showning)

CC: #3068
2024-10-07 12:25:40 +02:00
Simon Hausmann
0b028bfb6f
Add support for a font-metrics property to Text/TextInput. (#6452)
The struct held provides access to the design metrics of the font scaled
to the font pixel size used by the element.

ChangeLog: Slint Language: Added font-metrics property to `Text` and `TextInput`.

Closes #6047
2024-10-05 17:00:46 +02:00
Olivier Goffart
43b05074e0
Software renderer: fix drawing partialy clipped texture with rotation (#6445)
We were assuming that the extra clip was always on a unrotated image,
the rendering code didn't account for rotated screens

ChangeLog: Software renderer: fix artifact with partial drawing and rotation
2024-10-04 15:16:41 +02:00
Tobias Hunger
0723743d14 core: Improve popup window positioning
This is the most stupid policy for popup placement
that we can possibly implement: If we render the
popup as a subsurface in our own window, then just
make sure we move to popup so that it does stay fuilly
within our own window surface.
2024-10-02 18:14:17 +02:00
Tobias Hunger
364007a2f2 core: Add a popup module with a basic test 2024-10-02 18:14:17 +02:00
Tobias Hunger
8c25d44a49 core: Fix some clippy warnings
Just disable the clippy warning about unnecessary cast:
All current occurances are due to Coord being an alias to f32
almost all the time and the cast is necessary when it is not.
2024-10-02 17:05:05 +02:00
Olivier Goffart
fd299302ef
TouchArea: send cancel event when disabled while pressed (#6424)
ChangeLog: TouchArea: Send cancel event and update `pressed` and `has-hover`
property when `enabled` is set to false while pressed.

Fixes: #6422
2024-10-01 17:07:47 +02:00
Olivier Goffart
c5954f61c0
SwipeGestureHandler: improve behavior
- Remove the duration threshold
 - Always register the swipe even if the pointer went in another
   direction before
 - set the current position on the release event (in case there was no
   mouve to that position before)

ChangeLog: adjusted threshold in the SwipeGestureHandler

Closes #6344
Probably also helps for #6350
2024-10-01 13:39:01 +02:00
Simon Hausmann
e52ef5cfe1 Calling focus() on a focusable item that's already focused should be a no-op
Fixes #6403
2024-10-01 12:31:32 +02:00
Simon Hausmann
7db5024c52
Generate bindings of Image::to_rgb8/to_rgba8/to_rgba8_premultiplied f… (#6405)
ChangeLog: [C++] Add `Image::to_rgb8/to_rgba8/to_rgba8_premultiplied` pixel buffer accessors.

Fixes #6399
2024-10-01 10:55:11 +02:00
Olivier Goffart
7afec3a1c5 Text layout: fix char-wrap doesn't wrap between lines
Fixes #6346

ChangeLog: Software renderer: fixed `char-wrap` not braking between lines
2024-09-27 13:29:45 +02:00
Olivier Goffart
b9175072c7 Fix warning in nightly rust (non_local_definitions) 2024-09-26 08:42:59 +02:00
Josh Wood
6a131e2648
Added PropertyAnimation.direction property for controlling animation direction (#6261)
Closes #6260

ChangeLog: Added property for controlling animation direction
2024-09-24 19:55:24 +02:00
Simon Hausmann
f772cb8e11
live-preview: Bring the window to the front and focus it when the use… (#6295)
Fixes #196


Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2024-09-24 17:05:03 +02:00
Simon Hausmann
cd2b738c7a Rename SwipeGestureRecognizer to SwipeGestureHandler
The origin of this proposal is the name of the `swipe-left`, etc.
directional, boolean properties. They're missing another verb in their
name. In principle the right choice would be "recognize". That is what
the type name suggests, that's the term the documentation uses, so the
code should read `recognize-swipe-left: true;`. However that is a long
word. "Handle" is a verb that's simpler. It's also more generic (that's
a downside), but it's otherwise short enough to make things look
"right":

```
SwipeGestureHandler {
    handle-swipe-left: true;
    swiped => { something.naviate-left(); }
}
```

Therefore this patch proposes to rename the type to SwipeGestureHandler
and prefixes the boolean directional properties with "handle".
2024-09-18 16:37:27 +02:00
Olivier Goffart
e67f55f884 Fixed Timer::set_interval() doesn't work in timer callback
Fixes: #6141
ChangeLog: Fixed Timer::set_interval() doesn't work in timer callback (#6141)
2024-09-18 11:25:52 +02:00
Olivier Goffart
d2bd5366f4 Timer::set_interval
Don't return an Option, just return 0 when the timer is not started.
As discussed in the API review, the rational is that the interval is
just like a field in a struct and when the struct is default
constructed, it is initialized to 0
2024-09-18 09:24:39 +02:00
Olivier Goffart
c623df62b5 GridLayout: fix panic when rowspan or colspan is 0
Fixes #6181

ChangeLog: Fixed panic when rowspan or colspan is 0. (#6181)
2024-09-17 12:06:06 +02:00
Wannes Van Leemput
58fcd80f69
Add is_finished to JoinHandle (#6034) 2024-09-16 15:17:47 +02:00
crai0
a0e20a0b51
core: implement FromIterator for VecModel (#6140)
Closes #5879
2024-09-16 08:26:59 +02:00
Olivier Goffart
5663ddd9cc
SwipeGestureRecognizer (#6005) 2024-09-09 14:40:55 +02:00
Simon Hausmann
386710cd6d Fix repeated loading of an image by path if the file was changed since last time
Fixes #6030
2024-09-04 17:19:42 +02:00
Olivier Goffart
80c497b319 refactor: move FocusScope and TouchArea to a new input_items.rs module
items.rs is getting big and i'm about to add another item there
2024-08-29 09:38:26 +02:00
Olivier Goffart
eb2a2ba106 Reference slint::spawn_local from the invoke_from_event_loop docs
Unfortunately, we can't link because it is defined in a different crate

Fixes #5988
2024-08-29 09:30:26 +02:00
FloVanGH
f6ec79c76a
Added missing tests for VecModel (#5975) 2024-08-28 11:17:17 +00:00
FloVanGH
13692e2647
Added swap to VecModel (#5965) 2024-08-27 11:08:55 +00:00
FloVanGH
a5bb83c6b9
Added clear to VecModel (#5960) 2024-08-27 09:09:25 +00:00