Rust nightly removed this:
```
error[E0557]: feature has been removed
--> internal/interpreter/lib.rs:4:38
|
4 | #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
| ^^^^^^^^^^^^ feature has been removed
|
= note: removed in CURRENT_RUSTC_VERSION; see <https://github.com/rust-lang/rust/pull/138907> for more information
= note: merged into `doc_cfg`
```
* Tools: Remove the unecessary 'FF' from generated colors
When colors in most UI tools are 100% alpha the extra 'FF' is auto cut
off for readability. e.g. #000000FF becomes #000000. Since introducing
the new color pickers this has been the case on the UI side. However the
code generator for gradients was inconsistent and would still add in the
unnecessary 'FF'. This fixes that and makes generated gradient code
tidier.
* Fix correct tests
* Fix
* [autofix.ci] apply automated fixes
* Fix
* Fix
* Fix
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
* Add scale method to backends
* Rename Rotate to Transform
* Add scaling to Transform
* Fix tests
* Insert Transform if any of scale-x, scale-y or rotation-angle are set
* Add scaling to child_transform and handle events as a result
* Cargo fmt
* Femtovg clipping
* Fix femotovg clipping
* Add newline to actual_render.scale
* Cargo fmt tools/lsp changes
* Modify docs
* Change type to a float instead of percent and fix defaults
* Add note about software renderer
* Add basic event scaling test
The notify API has its own mutex that is being held when the callback is
called on Windows, causing a deadlock.
Also match for ModifyKind::Any as this is what we get on Windows
For the implementation of BuiltinFunction::GetWindowDefaultFontSize, instead of going to the window adapter's window item rc (which will be the outermost window item), start at the first item of the current component and work the way up from there.
Fixes#4298
After commit e04f028c91, the
default-font-size property on WindowItem isn't set anymore by default,
so BuiltinFunction::GetWindowDefaultFontSize, which reads it, would
return zero.
Instead, delegate to a run-time function where we can fall back to the
default from the renderer.
This patch changes rem.slint to use the newer syntax. The main change to
the test case though is to removal of the explicit default-font-size
property setting, so that we fall back to the value provided by the
renderer. This test relies on being run with the testing backend.
Fixes#8961
... so that `debug(...)` used anywhere in a popup will
show up in the live-preview's console, next to the debug
messages from all the other components.
Previously there were two kinds of Menu:
1. "Simple" menu that don't have any `if` or `for`
2. "Complex" menu that have `if` and `for`
For the first kind, we were generating in the compiler the `entries` and
`sub-menu` callback. This lead to more efficient and simple code at
runtime.
For the second kind, we generate an item tree so we can dynamically
produce them at runtime.
The issue is that as we added feature, the code became complex to
handle, even in the simple case as we need to create a `VRc<MenuVTable>`
also for the context menu so we can have native context menu.
We still need the "Simple" case for the internal though.
So for that I added a ShowPopupMenuInternal builtin function although it
only differ from ShowPopupMenu by the type of its second argument.
Since the generated code has lots in common, they are still handled
together.
The proof that the two different codepath were harmful is that removing
it showed a bug with contextmenu within repeated element.
the `contextmenu_delete.slint` started failling. It worked before
because it was only a problem with "Complex" menu and the test used a
"Simple" menu.
The change in the interpreter should also solve the issue #9031 which
were using the wrong item tree as the menu.
- Implement @conic-gradient(color angle, ...) syntax
- Center is always at rectangle center (no center_x/center_y parameters)
- 0 degrees starts at north (12 o'clock position)
- Support Slint angle units: deg, rad, turn
- Software renderer: Full native implementation
- Qt backend: Native support with angle offset correction
- Skia backend: Native support with angle offset correction
- FemtoVG backend: Fallback to solid color (first gradient stop)
ChangeLog: Added support for `@conic-gradient`
Fixes#3957
Missing feature:
- conversion between Value and enums
- conversion from value to Model
- Compatibility with the testing framework (get the `VRc<ItemTreeTable>` from an instance)
This fixes the test on tests/cases/model/models when using the rust
interpreter, as the second test has a "broken" model, the data is left
uninitialized, and this causes a data of the wrong type which causes
panic when it is being used.
This broke the build on zephyr
```
/usr/bin/ld: /home/runner/work/slint/slint/build/zephyr/NSI/home/runner/work/slint/slint/build/zephyr/zephyr.elf.loc_cpusw.o:(.data.DW.ref.rust_eh_personality[DW.ref.rust_eh_personality]+0x0): undefined reference to `rust_eh_personality'
```
When using rust, allow panics to cross the boundaries of our vtable traits.
This avoids panic producing two backtrace with panic=unwind
This patch doesn't touch the ABI of out FFI interface, they stay extern "C", because
if a panic or exception crosses these boundaries, we are in trouble.
(Also, we have a panic=abort in our Cargo.toml anyway)
Previously to see errors or debug info using debug(...) required the output panel of a speperate IDE or for Slintpad to open the browser developer tools.
This PR adds a dedicated panel to the live-preview. Log messages include a link back to the source file and line number for fast finding where the message was generated. Syntax errors also now show in the logs.
By default the panel is minimised and logs will clear themselves on UI recompile. The last log message does show as a preview on the minimised bar meaning in many cases you never need to open the panel.
---------
Co-authored-by: Tobias Hunger <tobias.hunger@slint.dev>
This fixes the contents of the `n`-th repeater inside the
`ComponentContainer` to also show up in the `n`-th repeater *after*
the `ComponentContainer`.
The ComponentContainer is lowered to a Comonent Container and a
dynamic tree node. The tree node is managed manually and I messed
up the repeater indices since there were no entries in the repeater
array for the embedded components. That mad things hard to keep
consistent as components get merged.
This chnages that: It lowers a Component Container to Something like this:
```slint
ComponentContainer {
if false: Emtpy {}
}
```
This way the standard mechanismns make sure we have something to put into
the repeater list and that unscrews the indices, saving a bit of code along
the way.
The inserted repeated node is still marked as `is_component_placeholder`, so
that we can wire it up as needed.
This exposes FocusReason to .slint, and adds it as an argument to focus-event-changed callback on FocusScope to close#8387. It also adds two new callbacks, focus-gained and focus-lost, which are identical to focus-event-changed but are only invoked on focus gain or loss respectively.
In addition to this, it removes the FocusEventReason::AccessKit variant, replacing it with the mouse variant to hopefully make AccessKit more compatible with any Slint code that will use FocusEventReason.
Finally, I added two tests based on focus_change_event.slint, one for testing the FocusEventReason argument and another for testing the new callbacks.
close#8387
ChangeLog: Added `focus-gained` and `focus-lost` callback to FocusScope. Pass an `FocusReason` enum to the FocusScope callbacks
When converting a ModelRc<T> to a Value, the resulting model did not
implement set_row_data and therefore would not allow changing the model
from the code.
By adding a `TryFrom` bound, we can make sure set_row_data is
implemented.
This is technically a breaking change to add this bound, but most type
that implement From for value also implement TryFrom<Value>
These conversion function were added in
20443ec0df for Slint 1.9
ChangeLog: interpreter: The `From<ModelRc> for slint_interpreter::Value` now gives a model that supports `set_row_data`.
Once upon a time, the enum were written in snake case in the .rs file,
but since ac4f3e97ad, they are written
in camel case, and the strenum crate takes care of moving that to kebab
case, which match our normalization, so there is no need to normalize
more.
The de-normalization was actually broken since
63f7533dc9 which changed a
denormalization into a normalization for the TryFrom<Value>
Closes#5992
Adds the enum FocusEventReason and makes it an argument for FocusEvent. This reason could eventually be exposed in Slint to solve #8387.
Using the focus reason tracking, I also added a select all on keyboard focus for TextInputs (except on macOS), which should close#5992.
ChangeLog: TextInput selects its content when focused with the keyboard on Windows and Linux
To be compatible with the 2024 edition, we need to wrap the
`no_mangle` attribute in `unsafe()`.
The parsing for that in cbindgen was only added in the version 0.28,
but we couldn't upgrade cbindgen before because of a regression in
cbindgen 0.27 that prevented us from upgrading.
Now that cbindgen 0.29 is released with a fix, we can prepare for the
2024 edition
`__1` is a valid identifier, which we normalized to
`--1`, which is invalid.
This changes the nromalization function to leave a `_` in the first position.
```
warning: implicit autoref creates a reference to the dereference of a raw pointer
--> internal/interpreter/dynamic_type.rs:170:26
|
170 | let mem_layout = (*instance).type_info.mem_layout;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: creating a reference requires the pointer target to be valid and imposes aliasing requirements
= note: `#[warn(dangerous_implicit_autorefs)]` on by default
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
|
170 | let mem_layout = (&(*instance).type_info).mem_layout;
| ++ +
```
Taking a reference to the type_info is valid because the instance is a
valid instance in that function