Commit graph

1368 commits

Author SHA1 Message Date
Olivier Goffart
6b4c822a4a MenuBar: C++/Rust native menubar implementation
introduce a SetupMenuBar builtin function to ease C++/Rust lowering
2025-01-08 21:16:17 +01:00
Olivier Goffart
846664ad45 WIP: native menubar using muda
Only the interpreter is implemented so far

MacOs won't work yet because we don't disable the default winit menubar

The viewer don't support removing the MenuBar yet
2025-01-08 14:05:35 +01:00
Simon Hausmann
2ec0522151 Fix panic in FemtoVG and Skia renderers with certain drop shadows
If the effectively drop shadow size would be zero, the FemtoVG and Skia item renderers would panic. The following test-case reproduces this:

```slint
export component Test inherits Window {
    Rectangle {
        drop-shadow-color: black;
        drop-shadow-offset-x: 1px;
        drop-shadow-blur: -0.5px;
        width: 0.5px;
        height: 0.5px;
        background: blue;
    }
}
```

ChangeLog: [Renderers] Fix panic with FemtoVG and Skia renderers for certain drop shadows.
2025-01-06 12:40:44 +01:00
Simon Hausmann
c31389dd14 AccessKit: expose popups in the accessibility tree
This is the plumbing, where a `PopupWindow` directly becomes a child of wherever it's declared in, when show() is called. Further changes may be necessary to make this really useful, such as new roles or improved dialog handling. (see ticket for comments)

Fixes #7209
2025-01-03 12:59:31 +01:00
Olivier Goffart
e0c6800946 Fix flickable hard to scroll when starting slow
We shouldn't ungrab the mouse when the mouse distance is smaller than the threshold

Fixes #7152

ChangeLog: Fixed Flickable hard to scroll when starting slow
2025-01-02 18:07:22 +01:00
autofix-ci[bot]
a715fb9fa0 [autofix.ci] apply automated fixes 2024-12-19 15:26:29 +01:00
Simon Hausmann
e69bbef5e6 On Linux, react to dark/light color scheme changes 2024-12-17 16:06:21 +01:00
Olivier Goffart
243262cbdf Keep focus of child of clipped item that are themselves not clipped
If a clipped item has a child outside of its bounds that is not clipped,
we shouldn't remove the focus.

Fixes #7058
2024-12-16 19:06:08 +01:00
Olivier Goffart
c0b2a7bab7 Fix TextInput decimal entry to add the minus in the middle
Fixes #7079
2024-12-16 15:14:50 +01:00
Simon Hausmann
0d36f88152 Revamp BackendSelector API
Based on API review, PlatformBuilder becomes BackendSelector with
a slightly smaller API surface but more options, such as selecting
Metal or Vulkan rendering.
2024-12-16 13:06:05 +01:00
Benny Sjoestrand
5ef4aace4c Implement full-screen property for slint Window item
Make it possible to programatically to switch to full-screen mode
via a new property in the Windows item.
The SLINT_FULLSCREEN environment variable will default set this
property to true. However settings this property in the slint code
will override the SLINT_FULLSCREEN.

Fixes #6665
2024-12-16 09:52:40 +01:00
FloVanGH
e0ad561c86
widgets: added key-pressed and key-released callbacks to all text input components (#7081)
* widgets: removed rejected event
* widgets: added key-pressed, key-released callbacks to text input components
* Update docs/astro/src/content/docs/reference/std-widgets/lineedit.mdx
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-12-12 16:20:45 +00:00
Olivier Goffart
c0f346fdf7 Rust docs: have a macro to make link to the Slint doc 2024-12-12 16:44:31 +01:00
Simon Hausmann
8d85c54a6f Fix up Window::take_snapshot docs
Clarify the "performance" as discussed in the API review.
2024-12-11 17:07:23 +01:00
Olivier Goffart
e03e812984 Fix Focus in PopupWindow
Fix https://github.com/slint-ui/slint/issues/2911
2024-12-09 15:58:16 +01:00
Olivier Goffart
34152611b3 PopupWindow: fix absolute-position property within a PopupWindow
We were actually skipping two element (the popup and the popup parent)
Also this broke the positioning of sub-popup.

The "fix" is to not get a parent for popup window.
This will also have the side effect of fixing the focus issue
2024-12-09 15:58:16 +01:00
Olivier Goffart
44df136c4f Translation API: a few renaming for API review 2024-12-07 09:33:58 +01:00
Olivier Goffart
a3dad45f0b Accessibility: rename a few properties after API review:
- Rename `accessible-selectable` and `accessible-selected` to `accessible-item-{selectable,selected}`.
   Because the property is for items in list rather than eg Text
 - Rename `accessible-position-in-set` to `accessible-item-index`.
 - Rename `accessible-size-of-set` to `accessible-item-count` and move
   the property to the container element rather than the item itself
2024-12-07 08:25:42 +01:00
Olivier Goffart
ff8aff6ab4 swrenderer: Fix drawing of tiled svg
This fixes drawing the background of the live preview with the software
renderer.

The problem was that when a svg image is tiled (and the svg is not
pre-rendered), we would render the svg in a duffer the size of the
target. But that's not the size at which it should be rendered as it is
going to be tiled over this surface.

Too big images are not supported by the software renderer, it would
panic in overflows in diverse places. So this also fixes panics
2024-12-05 16:57:54 +01:00
crai0
ffd079b870
core: Improve forward/backward cursor movement in TextInput (#6990)
When a TextInput has a selection and a forward or backward movement
is performed (i.e. pressing Left or Right) without keeping the anchor
(i.e. Shift is not pressed), the selection collapses either to the
beginning or end of the selection based on the movement direction.

ChangeLog: Improved deselection behavior when pressing Left/Right in TextInput

Fixes #6511
2024-12-04 10:02:44 +01:00
FloVanGH
0bd242cb1b
popup: close popup on escape press. (#6978)
* Update internal/common/enums.rs

Co-authored-by: Arnold Loubriat <datatriny@gmail.com>

---------

Co-authored-by: Arnold Loubriat <datatriny@gmail.com>
2024-12-03 13:46:32 +00:00
FloVanGH
0d1412afc5
removed skip-taskbar property from window (#6982) 2024-12-03 10:07:36 +00:00
Olivier Goffart
4e7bbcf2ba
Try to improve rendering (positioning) of signed field distance font. (#6868)
* WIP: swrenderer: use fixed point for the pixmap font coordinate

* swrenderer: signed distance field: move the glyph to the middle

* swrenderer: round the advance instead of truncating it in distance field

* swrenderer: actually align the gplyph on the sub-pixel precision

sub-pixel within the source.

* swrenderer: adapt the threshold for signed distance field

sqrt(2) is the distance to the diagonal, seems like this gives sharper fonts

* Fix bug in the elision, and re-upload the screenshort

the screenshot changed because the afvanced is now rounded intead of
truncated
2024-11-30 23:03:31 +01:00
Olivier Goffart
9683b67576 swrenderer: intersect the dirty region with the screen rectangle
When rounded out, the dirty region might end up bigger than the size
of the screen, which would then result in panic while trying to draw a
pixel out of the screen.

Fixes #6932
2024-11-28 17:35:26 +01:00
FloVanGH
712f930897
windows: added skip_taskbar (#6911)
* Update internal/backends/winit/winitwindowadapter.rs

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

* Update internal/backends/winit/winitwindowadapter.rs

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

* Update docs/src/content/docs/reference/window/window.mdx

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

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-11-27 09:55:11 +00:00
Simon Hausmann
1888e58735 Add API to set the XDG app id
ChangeLog: Added function to set the XDG app id on Wayland/X11. This needs to be added with respective function names in the language sections.

Fixes #1332
2024-11-22 11:24:06 +01:00
FloVanGH
6ebce7e5f4
cpp: added to_lowercase and to_uppercase to SharedString (#6869)
* cpp: added to_lowercase and to_uppercase to SharedString

* Update api/cpp/include/slint_string.h

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

* Update api/cpp/include/slint_string.h

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

* Update api/cpp/include/slint_string.h

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

* Update api/cpp/include/slint_string.h

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

* Update internal/core/string.rs

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

* Update internal/core/string.rs

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

* Update internal/core/string.rs

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

* Update internal/core/string.rs

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

* code review feedback

* Update api/cpp/tests/datastructures.cpp

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

* code review feedback

* Update api/cpp/include/slint_string.h

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

* Update api/cpp/include/slint_string.h

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

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simon Hausmann <simon.hausmann@slint.dev>
2024-11-21 18:53:02 +00:00
Olivier Goffart
eeaf1ba70f Bundled translation: pick the translation from the locale 2024-11-20 17:26:13 +01:00
Olivier Goffart
f195892376 Fix calling init to all the items on a ListView
This also fix changed event not working as they rely on the init to the setup

Fixes #6836

ChangeLog: fix init and changed callback not always being called in ListView
2024-11-20 14:24:58 +01:00
FloVanGH
bad71b7a13
rust: added ToSharedString trait (#6845) 2024-11-20 13:17:26 +00:00
Olivier Goffart
5bd20def0e Experimental support for MenuBar
Introduces `MenuBar{ ... }` that can be put in a Window
2024-11-20 09:25:37 +01:00
Simon Hausmann
a7e04b7d59 Move the partial rendering state into core
... and use from skia as well as the software renderer.
2024-11-19 21:31:04 +01:00
Simon Hausmann
d706f81773 Add support for partial rendering with Skia behind an environment variable 2024-11-19 21:31:04 +01:00
SuchAFuriousDeath
1b112c9cfc
Implements AsRef<Path>, AsRef<OsStr> for SharedString
Closes #6810
2024-11-19 08:08:09 +01:00
Olivier Goffart
d68b84a3f1
Change API to set the language with bundle translation
* Change API to set the language with bundle translation

Part of #6793
2024-11-17 11:40:02 +01:00
Simon Hausmann
5ecc0f0b47
Fix panic when code in init callback of conditional/repeater re-triggers repeater traversal (#3215)
Don't call init() while mutably borrowing the repeater's inner.

Fixes #3214
2024-11-15 14:25:36 +01:00
Olivier Goffart
f8f6282a05 swrenderer: Fix drawing of clipped VectorFont
That code was touched recently while doing the signed distance field
rendering. The offset is now within the source rectangle.
So the SharedBufferCommand's source_rect must include the whole pixmap.

Unfortunately, VectorFont are not covered by the screenshot tests
2024-11-13 22:14:31 +01:00
Simon Hausmann
a7a3b3f9ee Changelog: C++: Add slint::Window::take_snapshot()
Corresponds to the Rust API.
2024-11-13 12:38:36 +01:00
Olivier Goffart
b0c7ac41f0 Add debug statements
to help debugging #6432
2024-11-07 17:24:06 +01:00
Olivier Goffart
1941b8a40b SwipeGestureHandler: currectly grab the mouse
Fixes #6543
Fixes #6542
2024-11-05 15:49:32 +01:00
Brandon Fowler
6da0f55b05
Associate PopupWindows with an ID for their active popup (#6693)
Popups are stored in a HashMap and are assigned an ID so popup.close(); closes the correct popup and so a single PopupWindow cannot be opened multiple times
2024-11-04 09:17:55 +01:00
Olivier Goffart
2d944b242c Support multiple PopupWindow
Fixes #4356

Still not perfect:
 - Calling several times `popup.show()` on the same popup, will open
   that popup multiple times (instead of being a noop once opened)
 - Calling `some-popup.close()` will always close the top of the stack,
   without considering if it is the `some-popup` or another popup.

Both problems are because we don't remember whether a particular popup
is open and we don't associate `close()` with a particular popup
2024-10-31 22:27:56 +01:00
Olivier Goffart
446bb4a6bf
swrenderer: signed distance field: properly round the x and y glyph coordinate (#6687) 2024-10-30 18:12:52 +01:00
Olivier Goffart
45976bcf2b
Small polish of the appearence of small glyph with sdf
The trick is that we should have a constant delta, regardless of the
size of the individual glyphs.
2024-10-30 10:43:32 +01:00
Arnold Loubriat
97219c21bf Add the accessible-size-of-set property 2024-10-30 15:54:01 +08:00
Arnold Loubriat
67166fcc2d Add the accessible-position-in-set property 2024-10-30 15:54:01 +08:00
Olivier Goffart
7b1e8b4e12 Fix division by zero in distance field rendering
if the width or hight is one pixel, then the delta don't matter since we
will just draw one pixel anyway
2024-10-29 15:54:48 +01:00
Olivier Goffart
95f5685789
Bundle translations (#6661)
This currently doesn't have public API to enable it yet.

TODO:
 - Error handling in the compiler
 - Public API in the compiler configuration
 - Documentation
2024-10-29 15:07:15 +01:00
Olivier Goffart
1340a4902e
swrenderer: Always use an offset in the image when rednering glyphs (#6673)
Instead of using the trick of taking a sub-slice and pretending the
image was smaller than it is.
Then this is more uniform with all the other rendering path.
And this should prevent the panic in #6643

Fixes #6643
2024-10-28 14:37:00 +01:00
Ryan Naddy
58efd5312b
Added rejected to TextInput (#6649) 2024-10-25 17:24:47 +02:00