Commit graph

236 commits

Author SHA1 Message Date
Simon Hausmann
15b517a554 Emit a warning to stderr (debug_log) when using the ElementHandle API but there's no debug info present 2024-06-05 01:29:58 -07:00
Simon Hausmann
1a8ce3c659 Add support for optimized rectangles in ElementHandle
Keep merging elements, but remember the boundaries in the debug info, separated by a slash.

Also fixed tests that rely on accessible-label being set only once. For example

```
Button { text: "foo"; }
```

will certainly have "foo" as accessible-label on `Button`, but its internal `Text` element has
an implicit "accessible-label" set to the same
value.

So don't rely on that for now but search by id instead.
2024-06-05 01:29:58 -07:00
Simon Hausmann
4eef2d4936 WIP: Add find_by_element_type_name 2024-06-05 01:29:58 -07:00
Simon Hausmann
a52fe6bbfc Make element debug information configurable
The `SLINT_EMIT_DEBUG_INFO` environment variable needs to be set for Rust and C++ builds. For the interpreter it's always enabled, since ... we have it.
2024-06-05 01:29:58 -07:00
Olivier Goffart
43a336b534 C++ part of element_ids
Simplify a bit the llr generation so that there is less code duplication
between Rust and C++
2024-06-05 01:29:58 -07:00
Olivier Goffart
8add2e4ebd element_ids: Can't return a SharedString by value from the vtable
also compile the LSP
2024-06-05 01:29:58 -07:00
Simon Hausmann
73b5136f98 WIP: Search by qualified element id 2024-06-05 01:29:58 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Olivier Goffart
1040946d7f Fix rust warnings in generated code with changed callbacks
We sometimes generate dead code or unused variables for our expressions.
Most code is already covered with the `#[allow]`, so we need to also
allow it for callbaks
2024-05-27 17:51:02 +02:00
Olivier Goffart
5c3732c74e C++: fix string to float so that it doesn't depends on the current locale 2024-05-07 14:58:07 +02:00
Olivier Goffart
80f37a3acf C++ ChangeTracker implementation 2024-05-02 22:25:53 +02:00
Olivier Goffart
cadcd4caf4 Change callback: rust code generation 2024-05-02 22:25:53 +02:00
Simon Hausmann
31767eb6ab Add a clear-focus()function on all elements that have a focus() function
This is the counter-part, which removes focus from the element if it's currently focused. The window - if focused - may still be focused towards the windowing system.
2024-04-26 11:09:11 +02:00
Olivier Goffart
5a4713aa17 C++: add #pragma once to generated file 2024-04-22 13:06:05 +02:00
Olivier Goffart
64404ceca2 accessibility: return an Option for accessible string values
So we can know whether the item had the property set at all or not
2024-04-19 11:23:26 +02:00
Olivier Goffart
13127dc71c Accessibility: Add support for accessibility-action-* callback (#5073)
Merge branch 'feature/accessibility'

 Conflicts:
	internal/compiler/widgets/cosmic-base/button.slint
	internal/compiler/widgets/cupertino-base/button.slint
	internal/compiler/widgets/fluent-base/button.slint
	internal/compiler/widgets/material-base/button.slint

Also updated license header in actions.slint
2024-04-16 15:02:25 +02:00
Olivier Goffart
bd112a3021 C++: fix code generation of functions that don't return anything
and whose expression return something. Otherwise we get an error:
`return-statement with a value, in function returning ‘void’`
2024-04-16 14:50:55 +02:00
Olivier Goffart
0f05089d5e Polish the C++ and Rust HSV API 2024-04-15 18:18:00 +02:00
Luke D. Jones
0b1ec5e4c9 Convert to struct field access and make HsvColor public 2024-04-15 18:18:00 +02:00
Luke D. Jones
d4a3f77877 feat: color: add HSV methods to slint 2024-04-15 18:18:00 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +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
Olivier Goffart
028d075199 Fix code generation when the if branch has a value and there is no else branch
Fixes #4942
2024-03-27 08:30:32 +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
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
28b96ca6f6 janitor: manual cargo clippy fixes
Semi-random selection of clippy topics that were
uncontroversial before:-).

Leaves about 84 deduplicated issues in the code base
according to clippy from nightly.
2024-03-14 13:42:38 +01:00
Olivier Goffart
b844f76842 Add test and fixup color red/green/blue fields 2024-03-12 11:36:30 +01:00
Luke D. Jones
8c60cc74be feat: color: add channel properties to color
Add extra properties to the `color` type.
- `red`
- `green`
- `blue`
- `alpha`
2024-03-12 09:42:30 +01:00
Wilston Oreo
bef532b5fc
Optional C++ namespaces (#4759)
Co-authored-by: Michael Winkelmann <michael@winkelmann.site>
2024-03-06 19:43:11 +01:00
Olivier Goffart
5fe68e1746 Fix animation when started from a different item tree
Fixes #4741

This commit move the property_binding_and_analysis from the inlining
pass to an associated funciton in the context.
Then re-use that from the rust and c++ generator to actually get the
right animation
2024-03-05 12:27:11 +01:00
Olivier Goffart
100123901a Rust: move the call to ItemTreeVTable_static at mod level
... instead of having it in the drop implementation.
This is required to fix the `non_local_definitions` warning in nightly rust.

Part of #4706
2024-02-28 11:19:26 +01:00
Olivier Goffart
190273d293 C++: fix enum with dashes 2024-02-22 10:41:45 +01:00
Olivier Goffart
b5abee6c8d C++: fix compilation when class name has an underscore
Fixes: #4659
2024-02-22 10:41:45 +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
97067c3d65 Add 9slice information at runtime 2024-02-13 14:46:27 +01:00
Olivier Goffart
da9fb9fa1b Fix warning in Rust 1.77 with unused exported globals 2024-02-05 12:50:44 +01:00
Olivier Goffart
1e19e0a754 Rust codegen: fix compile if slint names matches internal names
Fixes #4419
2024-01-24 22:47:58 +01:00
Simon Hausmann
0e53b1529c Fix compilation of Rust generated code when calling builtin item member function through child component 2024-01-23 09:56:38 +01:00
Tobias Hunger
382b5486ca
Component container subcomponent (#4355)
This changes the component containers away from using a "MAGIC" index in the
placeholder dynamic item tree node it creates. These are hard to
integrate across sub-components.

Use index numbers right after the index numbers used by repeaters and
"extend" the repeater offset by the number of component containers in
the sub-component. This way we can piggy-back on the forwarding of
repeaters.

This has one annoying side-effect: We do have indices in our item tree
that are out of range for a repeater. But I think that is acceptable
considering that we never materialize that array anyway.
2024-01-17 11:26:08 +01:00
Brandon Fowler
3e8940660b
Add set-selection-offsets function to TextInput, TextEdit, and LineEdit (#4197)
The function accepts two arguments that specify the start and the end of the text to select.

Fixes #4164
2024-01-06 11:12:53 +01:00
Olivier Goffart
01e6429bfa Janitor: fix warning about unused import in Rust 1.75
Prospective fix for the CI breaking with Rust 1.75
2023-12-29 14:40:02 +01:00
Olivier Goffart
6ebfad14db Fix panic in the interpreter when using visible in a ListView
This doesn't solve the issue #2537, but at least prevent the panic

Drive by change to fix compile when a struct is named `Box`
2023-12-12 14:01:55 +01:00
Olivier Goffart
6195fc8567 Fix compilation when dividing by zero at compile time
Rust would have panicked and C++ generated wrong code.

CC #3982
2023-11-27 17:09:57 +01:00
Olivier Goffart
f043234890 C++: fix (private) properties of type EasingCurve
tests/cases/properties/animation_props_depends.slint in previous commit
added a property<easing> and that didn't work with C++
2023-11-03 15:11:06 +01:00
Olivier Goffart
89c80f3b6d Fix animation expression not being visited for use count of property
resulting in properties being optimized when they shouldn't
2023-11-03 15:11:06 +01:00
Ken Carpenter
b20536131f
Add more easing formulas (#3812)
Closes #2655
2023-11-03 09:20:44 +01:00
Tobias Hunger
c2056075c0 janitor: Disable clippy::overly_complex_bool_expr in generated rust code
This makes clippy error out in our users code (using a nightly compiler).
2023-11-02 16:33:19 +01:00
Tobias Hunger
2adc3713fa janitor: Do not warn about unused imports in generated rust code
When testing, we have `deny(wanrings)` set, so this actully makes the
tests error out.
2023-11-02 10:17:59 +01:00