Commit graph

1488 commits

Author SHA1 Message Date
Laurent Montel
eafa9bae12 Disable cut/paste action when textedit is disabled
(Too bad that we can't hide these actions)
2025-04-19 10:14:58 +02:00
Laurent Montel
706bd3e984 Disable cut/paste action in lineedit when disabled 2025-04-19 10:12:45 +02:00
Olivier Goffart
9058456fbf
live-preview: don't replace the native menu bar with the previewed one
Always use the non-native one for the previewed component
2025-04-17 17:12:23 +02:00
Olivier Goffart
691039b7ea typeloader: Cache parse error for loaded document
We will need these if loading from cache

Fixes #8064
2025-04-15 19:22:57 +02:00
Olivier Goffart
25b2829052 LSP: do not clear error in dependency when reloading a dependent file
In the test, `reexport.slint` depends on `bar.slint`
When parsing `reexport.slint` we shouldn't clear previously reported
error from previously parsed `bar.slint`. The errors are still there.
2025-04-15 19:22:57 +02:00
Olivier Goffart
f669df913c Fix miscompilation because of too-agressive optimization
We try to only visit the bindings of used property.
The problem is that when we visit the element, not all properties have
been marked as used, yet. We have a chicken and egg problem.

So just visit all bindings even for property we haven't reached.
This is unfortunate that we have to do that, and we'd need a much
deeper analysis to do this properly.

Fixes #8144
2025-04-15 11:47:06 +02:00
Joshua Goins
d1f2fef430
Menu: Add enabled property (#8145)
By default it's enabled, of course. This property is not only added to
MenuItem, but Menu as well - since they can be nested. It's also
possible to select a disabled item, but it's hard to modify that since
it's logic is written in Slint. You should be prevented from activating
it with a tap or key press at least.

See #7791
2025-04-15 08:08:11 +02:00
Tobias Hunger
7a1bc6f6d7 live-preview: Add gradient support to the property editor
Parse the gradient data from source code and pass it on to the
UI side to do its magic.

SQUASH ME
2025-04-11 13:34:18 +02:00
Olivier Goffart
82adeb47b2
Fix accessing properties within the MenuItem
We were not visiting properly the MenuItem from
`recurse_elem_including_sub_components_no_borrow`
(`recurse_elem_including_sub_components` was correctly modified before)

Fixes #8090



The tree-sitter test fails because the output contained `ERROR` as it matched this string
2025-04-09 15:06:32 +02:00
Olivier Goffart
78a3757b7f
Remormat all the toml file again to fix npm upload
Commit cd6f2e2 reformated the .toml, but the 80 char width column is
judged too small to be practical

Add a .taplo.toml file

Also do not split feature array
2025-04-09 15:06:00 +02:00
Tobias Hunger
9942afd183 SQUASH: Rework the element id to be a hash based on filename
and position iof the LBrace token.
2025-04-09 13:52:29 +02:00
Tobias Hunger
aaeb4a0df5 compiler: Add a DebugHook expression
You can not create this expression manually, but there
is a pass in the compiler that adds it to all set
properties in a compilation run.

All it does is basically associate an id with an expression,
so that we can then in a later step have the interpreter do
something with that information. Apart from that, it tries to
be as transparent as possible.

The LLR lowering removes that expression again, just so we can
be sure it does not end up in the generated live code.
2025-04-09 13:52:29 +02:00
Tobias Hunger
e1b85bbb93 component-container: Accept focus
So that we can pass the focus into the container when it first
shows.

I thought this would be super complex to do property! What a
nice surprise:-)

Fixes: #4055
2025-04-09 09:37:28 +02:00
Olivier Goffart
ca0c75bfe1 Menu: don't remove the title properties
Let further pass materialize them, and most likely remove them anyway.
That way, they can be properly set and read from the rest of the .slint
code.

Fixes #8080
2025-04-08 13:30:01 +02:00
Nigel Breslaw
538f8bde19
Allow checking at runtime about the current theme (#8049)
Although std-widgets provides many properties that adapt to the current theme users who would like to go beyond these properties and do theme dependent changes are limited. One option would be to add even more properties to the Palette, however this would potentially bloat the object, it's not obvious what properties users care about and this approach doesn't scale. In many cases developers could simply create their own properties if they knew what the current runtime theme was.

This simple change allows an app to know what the current theme is and present theme appropriate UI's.
2025-04-04 14:44:14 +03:00
Nigel Breslaw
ffce61ca97
HSV should wrap hue values otherwise it outputs an invalid hue of black (#8024)
Fix by wrapping around at 360.
Added tests.
Updated the docs.
2025-04-03 12:33:40 +03:00
FloVanGH
4d754b7ddf
StandardButton improvements (#8035)
* StandardButton improvements
* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-04-03 07:29:49 +00:00
Olivier Goffart
e5289af154 Introduce MenuSeparator
Fixes #7790
2025-04-02 11:50:45 +02:00
Tobias Hunger
cd6f2e2cf2 ci: Format toml files
... using taplo with default settings

I tried this with 4 spaces indentation, but the patch is almost as
big as this one, so I went with default settings instead as that
is just easier:-)
2025-04-02 11:03:41 +02:00
Olivier Goffart
7b8ef71ddd link_section needs unsafe with edition 2024
Second part of #7998
2025-03-31 17:35:22 +02:00
Olivier Goffart
6010cf724c Hover on MenuBar should activate menu if a menu is already open
Fixes #7822
2025-03-31 14:06:24 +02:00
Olivier Goffart
fa650ed5ec Allow to have builtin item function to return a value
This does some refactoring to allow builtin item functions to return a
value:
 - builtin member functions are no longer BuiltinFunction, but they are
   just normal NamedReference
 - Move special case for them in the LLR/eval
2025-03-31 14:06:24 +02:00
Olivier Goffart
aca30901be C++: put the parent in a weak pointer
Right now we always `lock().value()` it which is the equivalent of
`upgrade().unwrap()` in rust, this helps because it keeps the parent
alive when we are calling function in it.

Ideally we should also check that it wasn't deleted, but that's another
issue.

Fixes #7880
2025-03-28 17:24:14 +01:00
Olivier Goffart
a80f14e7d8 Fix re-instentiating if elements when the condition is dirty
Fixes #3953
2025-03-27 15:37:07 +01:00
Olivier Goffart
3621fbcbd3
C++: fix mod with negative number again
`mod(-42, 2)` would return 2 instead of 0
2025-03-27 13:41:29 +01:00
Olivier Goffart
1efe8c8d5f
swrenderer: Don't overflow for font bigger than 256px
Fixes #7936
2025-03-25 15:51:18 +01:00
crai0
c103d37828
Add string.to-lowercase and string.to-uppercase (#7922)
Adds methods to change a `string`'s case to lowercase or uppercase.
They use Rust's `to_lowercase` and `to_uppercase` `String` methods.

ChangeLog: Added string.to-lowercase and string.to-uppercase

Closes #7860
2025-03-25 09:53:54 +01:00
Olivier Goffart
92e5cef55f
Deprecate alias to global callback and error out when setting such callback
Also properly error out when the number of arguments to a callback alias
is not correct

Fixes #7806
2025-03-24 15:17:20 +01:00
Olivier Goffart
286bdc9ce5
Interpreter: Fix panic when animating a % property
Should register the Type::Percent as animated

Also avoid duplicating the binding for both min and max, and just make
one use the other.

Fixes #7761
2025-03-24 14:54:08 +01:00
Olivier Goffart
4015288080 Compiler: fix const propagation in condition
We should simplify the false branch even if the true branch can't be
inlined

Fixes #7827
2025-03-21 18:00:34 +01:00
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