Commit graph

1368 commits

Author SHA1 Message Date
Olivier Goffart
02775f7783
swrenderer: Fix rendering of SVG when SLINT_SCALE_FACTOR is defined at compile time (#5013)
We call fit_to with the source size (which is not scaled by the scale
factor) while the actual image is already scaled, so we need to adjust
for the difference between the texture size and the original size.

Also pass the scale_factor at compile time to the screenshot test
2024-04-04 13:19:17 +02:00
Olivier Goffart
523e1a161c WIP: More on support for accessibility actions
Continue with the core library support and the compiler support.

This hasn't been tested yet and is missing implementation in the
backends
2024-03-28 11:28:56 +01:00
Florian Blasius
b0549b50c6 (wip) Added accessibility_action and supported_accessibility_action to ItemTreeVTable 2024-03-28 11:28:56 +01:00
Florian Blasius
6326705831 Acessibility: added AccessibilityAction and SupportedAccessibilityAction (#4824) 2024-03-28 10:02:46 +01:00
Simon Hausmann
68083243b2
Add an in-out boolean color-scheme property to Palette (#4701)
This allows applications to force dark/light mode, as well as determine
which mode is active.
2024-03-26 15:44:22 +01:00
Olivier Goffart
8c2a798630 Android: long press select word 2024-03-26 14:50:55 +01:00
Simon Hausmann
ed2816331e
Add support for raw-window-handle (#4918)
Add a `raw-window-handle-06` feature to the Rust API crates, which adds support for version 0.6 of rwh to slint::Window, by delegation adding a `window_handle()` function that returns a struct that implements the corresponding traits from rwh.

HasDisplayHandle could also be provided on the backend, but that can be
done separately if needed.

This is only implemented for the winit backend right now.

cc #877
2024-03-22 14:25:05 +01:00
Olivier Goffart
b46effe65c Android: selection handle
Have two selection handle when there is selected text
2024-03-22 09:19:53 +01:00
Olivier Goffart
881da94737 Move the condition to render the text cursor in TextVisualRepresentation
And add a hack to make the screenshot test pass on Mac
2024-03-21 09:34:52 +01:00
Olivier Goffart
5e66fe9dc8 Fixup cursor color and appearence
On mobile and macOs, the cursor is the selection color.
Also don't show the cursor when there is a selection (all platforms)
2024-03-21 09:34:52 +01:00
Olivier Goffart
528f85509b android: Moving cursor handle 2024-03-20 12:46:10 +01:00
Olivier Goffart
9c3ce701ba Fix cursor geometry: we need to account for the TextInput's own geometry 2024-03-20 12:46:10 +01:00
Olivier Goffart
5c381fd73e Fix clipping and border-radius
Fix #4854
2024-03-14 23:48:16 +01:00
Simon Hausmann
78771e0e37 Fix panic when loading unsupported images in Rust
The call to load the image already prints a message to stderr, so don't
panic but return a null image instead - neither when calling load_from_path
nor when decoding embedded image data.

cc #4846
2024-03-14 23:04:43 +01:00
Tobias Hunger
77c85aa703 janitor: fix clippy warnings about "bound is defined in more than one place" 2024-03-14 13:42:38 +01:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Simon Hausmann
b1f408f683 Fix build of generated C++ code when using transitions on int properties with esp-idf
The energy monitor declares a transition on an animated int property,
for which Property<int>::set_animated_binding_for_transition is called,
which in turn calls slint_property_set_animated_binding_helper. The
latter is overloaded for various property types, such as float, Color,
or Brush, and then calls specialized functions from ffi, such as

slint_property_set_animated_binding_(int|float|etc.).

slint_property_set_animated_binding_int uses i32 in Rust, which cbindgen
maps to int32_t, so the
slint_property_set_animated_binding_helper overload also uses int32_t.

Unfortunately, with esp-idf, int32_t is a distinct type from int, and
the overload resolution fails.

As remedy, this change uses c_int instead of i32 in the Rust ffi, which
maps to int.

This seems easier than changing Property<int> to Property<int32_t> :-)
2024-03-12 20:25:00 +01:00
Olivier Goffart
255dc59ef4 Rename @image-url(..., 9slice(...)) to @image-url(..., nine-slice(...))
As per API review:
 - In the Rust and C++ API we use `set_nine_slice_edges` because the getter couldn't start with 9
 - in english we spell number less than 10 with letters and this is a name
2024-03-07 17:01:57 +01:00
Olivier Goffart
5a4e24529b swrenderer: Fix rendering of the first glyph if it has negative bearing
`src_rect.origin.x` can be negative and when casted to usize it becomes zero
2024-03-07 11:29:05 +01:00
Olivier Goffart
43266f7f76 Fix some issues with image 9slice
- Don't panic if the image is smaller then the borders
 - Some height and witdh cooredinate were inversed (should have tried
   with non-squared image before
 - Fix offset when there is no tiling
2024-03-06 19:31:13 +01:00
Olivier Goffart
c71b58e556 Fix rust nightly warnings about unused import in tests 2024-02-28 11:19:26 +01:00
Olivier Goffart
1fb162936e Android: simplify the text input with SpannableStringBuilder
Also needed some change on the Text item to avoid sending ime callback
for intermediate states
2024-02-27 18:29:36 +01:00
Olivier Goffart
8bc4c4e053 vtable: increase version number to account for breaking change in vtable::Dyn 2024-02-26 14:45:47 +01:00
Paul Zinselmeyer
73e05aebdb Added flicked-Callback on Flickable
As requested in #1462, I've added a `flicked`-Callback that gets
triggered when the `viewport_x`- or `viewport_y` -Properties are changed
by a mouse drag or mouse wheel movement.
2024-02-26 12:17:31 +01:00
Olivier Goffart
3910095e4d Tiling for the nine slice images 2024-02-26 12:16:41 +01:00
Olivier Goffart
5e7ddf3a19 Image Tiling
(Doesn't work yet with 9slice)
2024-02-26 12:16:41 +01:00
Olivier Goffart
9f0c3c94a9 C++: minimize/maximize/fullscreen API on Window 2024-02-22 13:17:50 +01:00
Ralph Minderhoud
9cb1a4a4e0
Add API for minimize/maximize on Window component (#4581)
Closes #4400
2024-02-22 10:40:36 +01:00
Olivier Goffart
2ab71db4f7 Update deps, including resvg 2024-02-21 12:30:33 +01:00
Olivier Goffart
7b2ff89f1c Fix nightly warnings
eg:
```
warning: the item `Box` is imported redundantly
```
2024-02-21 10:52:04 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
424f046416 swrenderer: refactor image drawing algorithm
For tiling, we will need to know the actual source size in addition to
the scaling factor that can be different. So store the scaling factors
in the scene command, as well as an offset where to start.

This is more accurate in case of clipping and rotation.
For rotation that doesn't matter (appart from the fact that the testing
can now be more strict)
But for clipping this prevent glitches with partial rendering where it
would seem like the image are moving a bit by a pixel when it is redrawn
with a different clip
2024-02-15 18:25:47 +01:00
Olivier Goffart
3f27e62e75
SharedVector: use const generics for array conversion 2024-02-15 07:33:13 +01:00
Olivier Goffart
49b89f03f5 Fix C++ no_std build
(ammend previous commit)
2024-02-14 10:52:24 +01:00
Olivier Goffart
dab4ea44cd Fix C++ compilation with nightly rust
```
error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused
    --> internal/core/item_tree.rs:1035:32
     |
1035 |             Pin::new_unchecked(&*(&**component as *const Dyn as *const u8)),
     |                                ^^^^-----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |                                    |
     |                                    backing allocation comes from here
     |
     = note: casting from `vtable::Dyn` (0 bytes) to `u8` (1 bytes)
     = note: `#[deny(invalid_reference_casting)]` on by default
```
2024-02-14 10:15:07 +01:00
Olivier Goffart
b2920b1714 Software renderer: use 16 bit precision when drawing image
This is important when zooming, and still allow images of 65535 pixel
width or height
2024-02-13 14:46:27 +01:00
Olivier Goffart
2a63df6ed6 Implementation of border image in the software renderer 2024-02-13 14:46:27 +01:00
Olivier Goffart
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Olivier Goffart
926786fb59 Remove ImageHorizontalAlignement::Start/End
Since RTL language are not yet implemented, let's leave that out for now
2024-02-08 18:59:26 +01:00
Olivier Goffart
ce6c7f5527 Image: add horizontal and vertical alignment 2024-02-08 18:59:26 +01:00
Waqar Ahmed
d47b50d5af Make UndoItem repr(C)
The code is more classic style now because the fancy enum can't contain
a non-trivial type
2024-02-08 14:51:14 +01:00
Waqar Ahmed
08ac33aab2 SharedVector: Add pop method 2024-02-08 14:51:14 +01:00
Waqar Ahmed
8c6ff74a6e TextInput: Add undo/redo support
#474
2024-02-08 14:51:14 +01:00
Olivier Goffart
cb92ba1132 Add ImageFit.preserve and de-duplicate the fitting code 2024-02-08 10:10:56 +01:00
Waqar Ahmed
07efb6a816 Fix typo 2024-02-07 19:19:58 +01:00
Olivier Goffart
e43f4d4c0c Fix a panic in the software renderer when rendering text
To reproduce, run the slide_puzzle with a SLINT_SCALE_FACTOR of 1.5 with
the software renderer.

The bug is that some text are rendered at some location, with an offset
of, say, 400.499999. And then the left and right side of the bounding
rectangle may be rounded differently and we may get to draw images that
are bigger than the glyph which cause panic. Fix that by ensuring we
never do that.
2024-02-07 15:51:55 +01:00
Olivier Goffart
b23c605ac1
Refactoring: Use a trait for Item being Images 2024-02-07 13:28:47 +01:00
Simon Hausmann
367af4fdf4 Align rotation between software renderer and LinuxKMS backend
As discussed a few days ago, let's define rotation to be always
clockwise, as it is done in other graphics frameworks as well as our
own image rotation. This means changing the definition for the
software renderer. Also fixed docs for the enum in the linuxkms backend
that was wrong.
2024-02-07 11:21:59 +01:00
J-P Nurmi
cc5d2b24e5 Add BasicBorderRectangle to avoid unnecessary xxx-border-radius bindings 2024-02-06 18:01:35 +01:00
J-P Nurmi
5e086971c9 Add RenderBorderRectangle trait 2024-02-06 18:01:35 +01:00