Commit graph

1458 commits

Author SHA1 Message Date
Olivier Goffart
70c7fd1b49 Fix @children next to Timer or PopupWindow
Fixes #7887
2025-03-21 15:58:55 +01:00
Olivier Goffart
51523e981f Compiler: Fix when one branch of a void condition is not void
Fix panic or warning in the generated code

Fixes #7864
2025-03-21 14:37:10 +01:00
Olivier Goffart
d63168d51b Fix change handler with callback
Don't merge a property with a global property if it has a change handler
as we can't mobe the change handler in the global
Fixes #7784

If two property are merged that each have a change handler, we must
merge the change handler. (Note that the order in which they are being
called is not deterministic)
Fixes #7747
2025-03-20 21:34:52 +01:00
Olivier Goffart
bcd8c5d7be Fix compiler warning with nightly rust
```
error: unused `ControlFlow` that must be used
   --> internal/compiler/passes/infer_aliases_types.rs:185:5
    |
185 |     recurse(&root, element, &mut scope);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
```
2025-03-19 13:00:42 +01:00
Simon Hausmann
cc932fceb9
Improve font embedding for MCUs when bundling translations (#7875)
Include messages from bundled translations into the character set used for deciding which glyphs to embed.
2025-03-18 11:54:28 +01:00
crai0
a8eb44b739 Promote float to double in cpp code gen 2025-03-18 11:44:28 +01:00
crai0
e6e7b4e3df Fix cpp code gen 2025-03-18 11:44:28 +01:00
crai0
4bb7412460 ChangeLog: Add float.to-fixed and float.to-precision
Add two new float to string conversion methods that mimic
JavaScript's Number.toFixed() and Number.toPrecision().

They are implemented as no_mangle functions similar to the already
existing float to shared string conversion.

Closes #5822
2025-03-18 11:44:28 +01:00
ogoffart
178cf21c2e Bump version number to 1.11.0 2025-03-18 09:48:22 +00:00
Arnold Loubriat
615be362b2 Disable built-in TextInput accessibility for Spinbox 2025-03-17 14:27:08 +01:00
Olivier Goffart
a3ab90d4fc compiler: Fix infinite recursion trying to inline function argument
We can't use `body.visit_recursive_mut` because it will recurse on the
newly replaced argument. Implement recursion manually instead.
2025-03-06 23:24:08 +01:00
FloVanGH
390f8aaf50
scrollview: fixed scrollthumb size on small sizes (#7809)
* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-03-05 16:46:45 +01:00
Olivier Goffart
a6a142f9c8 C++: fix a bug in which a substraction could overflow
There was an image like this:
```slint
height: 40px
Image {
     width: parent.width;
     height: self.source.height * 1px;
     source: @image-url("....");
}
```

The `y` propery ended inlined like so:
`(40 - the_image.source.get().size().height)/float(2)`
but since height was `unsigned` the C++ rules means that the operation
happens as unsigned and we have an overflow. and `y` turned out to be
very big instead of slightly negative (for image whose height was larger
than 40)
2025-03-05 08:25:45 +01:00
FloVanGH
5cfac949d9 material: fix horizontal tab stretch 2025-03-04 12:37:06 +01:00
FloVanGH
ac1a0f9f76 material: cleanup tabwidget.slint code 2025-03-04 12:37:06 +01:00
Olivier Goffart
5ab791416b Implement Property::set_constant in C++ 2025-03-03 00:50:09 +01:00
Olivier Goffart
79b31153c5 C++: implement the ItemTreeVTable::window_adapter
This is required to fix closing popup with the Qt backend, as we use the
window_adapter as a hack to get the root window_adapter (as opposed to
the popup one)

(That function was only used for the ComponentContainer and was not
implemented for C++ before)

Note that this reinterpret a
`Option<slint::private_api::WindowAdapterRc>` to just a `WindowAdapterRc`
This is because `Option` is only forward declared in C++ as it is not
generaly `#[repr(C)]`,  but we assume (and assert) the usage of a niche.

As reported in https://chat.slint.dev/public/pl/ihnwtdgp7fb75k4aj5ou3p4idc
2025-02-28 00:34:14 +01:00
autofix-ci[bot]
617aa386bc [autofix.ci] apply automated fixes 2025-02-27 12:13:44 +01:00
FloVanGH
f6cec29fed menu: finished cupertino style 2025-02-27 12:13:44 +01:00
Olivier Goffart
185d49e238
Fix possible panic when ContextMenuArea gets destroyed when the menu is visible 2025-02-25 21:38:13 +01:00
FloVanGH
dcb7c065d6 menu: cosmic style 2025-02-25 16:31:31 +01:00
FloVanGH
5019ff7df4
menu: adjusted for material style (#7731) 2025-02-25 07:25:31 +00:00
Olivier Goffart
11accc190a Fix panic when inlining into clip during the second phase of inlining
During the second phase, anything that involve @children should already
have been processed, so there shouldn't be anything left to inline.
But the children insertion point may be pointing to the wrong location
if some items were moved around (eg because of the `clip`).
So work it around by not accessing the children array at that indax that
might be out of range.

Fixes #7724
2025-02-24 19:15:39 +01:00
Simon Hausmann
dde0ebe201 Fix build for C++ generated code for embedded textures 2025-02-24 17:02:10 +01:00
Simon Hausmann
df6c99871d Change TargetPixelBuffer's draw_texture function to take a data structure instead of many arguments 2025-02-24 17:02:10 +01:00
FloVanGH
be7c125726
menus: fluent style and refactoring (#7723)
* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-24 17:01:22 +01:00
Olivier Goffart
fe333049ea Fix Menu highlight on hover
Regressed in 5cccfda36f
2025-02-24 09:37:37 +01:00
FloVanGH
5cccfda36f
menu: cleanup code, extract MenuItemImpl (#7696)
* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-02-22 08:10:54 +01:00
Olivier Goffart
1a2aff8b57
Revert "compiler: inline components that are used only once" (#7697)
This reverts commit bf716ff8c5.
(And also revert the test part of 259756c0fd)

This exposed the bug #7693 and more issues mentined in
https://github.com/slint-ui/slint/issues/7693#issuecomment-2675077008

Fixes #7693
CC #7680
2025-02-21 19:11:11 +01:00
Olivier Goffart
39191e5acd
Menu API changes
`ContextMenu` -> `ContextMenuArea`

`ContextMenu` must have a `Menu` child.
`MenuItem` can no longer be put dirrectly in `MenuBar` and can no longer
have children
`Menu` is used now for sub menus
2025-02-21 16:03:47 +01:00
Alex Badics
337282373f compiler: add more complicated const propagation unit test 2025-02-21 11:16:00 +01:00
Alex Badics
7128097b94 compiler: add handling for < and > in const propagation 2025-02-21 11:16:00 +01:00
Alex Badics
d173fa0ba9 compiler: Fix function constness marking 2025-02-21 11:16:00 +01:00
Alex Badics
848e54a9ac compiler: fix func constness propagation 2025-02-21 11:16:00 +01:00
Alex Badics
61df727c48 compiler: fix materialize_fake_properties change 2025-02-21 11:16:00 +01:00
Alex Badics
3e67c93097 compiler: fix pretty print crash on wrong parent references 2025-02-21 11:16:00 +01:00
Alex Badics
68dd67244b compiler: emit optimized fake properties for Images 2025-02-21 11:16:00 +01:00
Alex Badics
bf716ff8c5 compiler: inline components that are used only once 2025-02-21 11:16:00 +01:00
Alex Badics
259756c0fd compiler: don't inline repeater components
They don't need to be inlined, and a lot of the times inlining them incur
a significant overhead (e.g. in case of conditional complex components)
2025-02-21 11:16:00 +01:00
Alex Badics
65bcca1082 compiler: inline functions if possible 2025-02-21 11:16:00 +01:00
Alex Badics
38ddb4d2b7 compiler: improve return elimination 2025-02-21 11:16:00 +01:00
Alex Badics
c2e9fa9f66 compiler: enhance const propagation 2025-02-21 11:16:00 +01:00
Simon Hausmann
368ec3459b
Improve default accessibility of TextInput elements
Apply similar logic as to LineEdit and TextEdit, so that when folks build their own text input widgets, they're accessible by default. Also fixed the docs while at it to mention default applications.

Amends #7669
2025-02-20 13:44:16 +01:00
Olivier Goffart
1e814c9bdc
Stabilize the sdf-fonts feature
Enable the SDF feature by default in our compiler binaries

(Still disabled by default for other users because it takes up compile
time for something they probably don't need)
2025-02-19 21:24:53 +01:00
Arnold Loubriat
cc91de2d38 Add the accessible-read-only property 2025-02-19 09:16:41 +01:00
Arnold Loubriat
90c337f1d1
Add AccessibleRole::Image and use it in the AboutSlint widget (#7593)
* Add `AccessibleRole::Image`

* Improve accessibility of the `AboutSlint` widget

* Filter out some images from the accessibility tree
2025-02-18 09:43:53 +01:00
Olivier Goffart
7c75720c9a Compiler: remove more indeterminism in the order of statements 2025-02-15 18:53:44 +01:00
Olivier Goffart
b2e7b0ec7d compiler: Use BTreeMap at a few more place to help with determinism of the output
CC #7642
2025-02-15 18:53:44 +01:00
Simon Hausmann
fc26666a0e Attempt to provide better diagnostics when the translation bundle directory path can't be read 2025-02-11 19:26:37 +01:00
Olivier Goffart
c85b20d431 ContextMenu on the LineEdit and TextEdit
With usual copy/paste entries

We need to make sure that showing the popup window don't clear the
selection in the TextInput which happens if the TextInput gets a
FocusOut event.
2025-02-11 10:30:11 +01:00