Commit graph

51 commits

Author SHA1 Message Date
Tobias Hunger
e7994b589a core: Fix doc comment 2025-04-02 15:14:02 +02:00
Yuri Astrakhan
bcb2953f00 Auto-fixed clippy::unnecessary_map_or
This is a hacky approach, but does help a lot with the tedious fixes.

See https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_map_or

```
__CARGO_FIX_YOLO=1 cargo clippy --fix  --all-targets --workspace --exclude gstreamer-player --exclude i-slint-backend-linuxkms --exclude uefi-demo --exclude ffmpeg -- -A clippy::all -W clippy::unnecessary_map_or

cargo fmt --all
```
2025-02-07 09:02:31 +01:00
Yuri Astrakhan
61de4d56b0 Fix all format arg inlining
Ran this command:

```shell
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2025-02-06 10:16:20 +01:00
Olivier Goffart
c98d234b9e Janitor: Always use `#![no_std] for runtime lib
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
2025-01-27 19:22:00 +01:00
Olivier Goffart
87d86ae7d2 Only re-create elements if the model actually changed
Being dirty is not enough

Fixes #7245

ChangeLog: Elements of a `for` now only get re-created if the model is
changed, not if it is only dirty
2025-01-13 12:11:21 +01:00
Tasuku Suzuki
346d1c2df3 Fix typos
Ran `typos .` and fixed all typos that do make sense.
https://crates.io/crates/typos
2025-01-13 08:35:20 +01:00
Tobias Hunger
e14e296734 janitor: Fix clippy "casting raw pointers to the same type and constness is unnecessary" 2024-06-24 14:59:47 +02: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
ab53b1db2f More work on ChangeTracker 2024-05-02 22:25:53 +02:00
Olivier Goffart
b5b00fdf9f WIP: some runtime support for the change tracker
Introduce a ChangeTracker type, but it is not of any use now
2024-05-02 22:25:53 +02:00
Olivier Goffart
5e634fda9f PropertyTracker: Pin the DirtyHandler 2024-05-02 22:25:53 +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
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Tobias Hunger
23f3e61227
core: Make debug print of PropertyHandle more useful (#3780)
core: Make debug print of `PropertyHandle` more useful

Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2023-10-30 09:18:45 +01:00
Tobias Hunger
962d70a357 core: Fix two-way-bindings of two-way-bindings
Fix binding a two-way bound property to another property: The value of
the first bproperty was used here, while it is documented to use the
value of the second.

Add test cases for two-way bindings in first, second an in both places
when creating another two-way binding to make sure everything works and
stays that way :-)
2023-10-17 13:00:52 +02:00
darknight
37488f015d Refactoring: define macro rules to group builtin structs
apply new macro for struct declaration, type register,
doc generation, cpp header generation, struct-value conversion.
2023-08-03 11:01:18 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Tobias Hunger
66cf903d70 janitor: Fix some typos in properties.rs 2023-07-04 20:04:28 +02:00
Olivier Goffart
530e6783ab
Fix crash when evaluating two_way_link too early
two_way_link shouldn't force the evaluation of the property
2023-06-30 17:06:29 +02:00
Tobias Hunger
e81a3d40f0 Get rid of more clippy warnings
* Configure clippy to not report about type complexity until *much*
  later
* Configure clippy to only complain about more than 10 function
  arguments
* Properly format safety sections
* Allow unnecessary main functions in doctests in the slint API crate
* AccessKit: Move big block of code before if condition
2023-06-28 14:22:30 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Jocelyn Turcotte
16c9a14fe7 Don't recurse mark_dependencies_dirty if it was already marked
When updating multiple models between frames, it's possible
that multiple bindings will be marked dirty many times.
In diamond dependencies, marking one binding could also
end up affecting another binding through multiple intermediate
dependencies.
The process can then be quite expensive even for medium scenes.

If a binding is already marked dirty we can however assume
that all of its dependencies are already marked dirty.
This reduces the complexity of marking large dependency
branches multiple times.
2023-05-15 17:09:46 +02:00
Olivier Goffart
a89c5db8db Fix crash when a state condition is detected as constant
States are never constant because the generated state binding depend on
the time as it register the time it was set for the pottential animation

Also adjust the assert so it assert correctly which the right message

Fixes: #2274
2023-02-24 16:43:48 +01:00
Olivier Goffart
dddfcf572d Fix const detection with two ways binding
The const detection for two way binding was not detecting change if one
of the property was set to a const value in a component using it.

This would cause the compiler to generate call set_content on one of the
property in a two way bindings, and later, the "const sentinel" be
present in the dependency list, causing crash.

To avoid segfault for similar bug in the future, added added an assert!
in the property system to detect that.

Fixes #2185
2023-02-07 10:27:37 +01:00
Olivier Goffart
27347de92b Properties: fix extra dependency when making a two way binding
This can be reproduced with this example:

```
import { TabWidget } from "std-widgets.slint";
App := Window {
    preferred-width: 700px;
    preferred-height: 500px;
    HorizontalLayout {
        side-bar := TouchArea {
            property <int> current-item: 1;
            clicked => { current-item =  current-item == 0 ? 1 : 0 ; }
        }
        if(side-bar.current-item == 0) :  TabWidget {  }
    }
}
```

With the native style. (click on the window, then resize)
This will result in a stack overflow, because we have a cycle in the
dependency graph and they are marked dirty forever.
The NativeTabWidget will create two way binding internally. And it will
be crated as a result of the layout cache property because that's when
the model will be evaluated and created.  This will inatvertently create
a dependency between the layout cache property, and the two way link.
2022-11-09 12:57:11 +01:00
Simon Hausmann
27fea8b9f3 Fix rustdoc warnings with nightly
Use backticks as recommended by rustdoc for items that could be interpreted as HTML tags.
2022-10-12 17:29:46 +02:00
Olivier Goffart
6b88fc634d Fix partial renderer not rendering some dirty area that were clipped
During the rendering, if an area is clipped, it will not be rendered and
therefore will not be rendered as a dependency.

Consider this example:

```
    HorizontalBox {
        Rectangle {
           TouchArea{
              Rectangle { background: parent.pressed ? red : blue; }
           }
        }

        Rectangle {
           clip: true;
           TouchArea{
              Rectangle { background: parent.pressed ? red: blue; }
           }
        }
    }
}

```

Clicking on the first rectangle will make that area dirty and it will be
redrawn, but since the second one is clipped away, the renderer will not
visit the child items. And clicking on the second rectangle will not
make it re-drawn.

This patch makes sure we rejuster ad dependency of the window tracker
the non-dirty areas

This fix the printerdemo_mcu stopping to render in some cases
2022-09-08 16:22:13 +02:00
Olivier Goffart
8fba65a282 Rename and expose the unsafe-single-threaded feature 2022-08-25 16:47:53 +02:00
Olivier Goffart
c28c527e0e Split the properties.rs files in modules 2022-07-21 14:07:15 +02:00
Olivier Goffart
c41749fc12 Rename PropertyChangeHandler to PropertyDirtyHandler
The handler is called whenever the properties it depends on becomes dirty,
not when it changes.

This has caused confusion before, so rename it
2022-07-21 13:16:40 +02:00
Olivier Goffart
ced9504635 Fix warning in nightly rust
```
warning: unused return value of `alloc::boxed::Box::<T>::from_raw` that must be used
Warning:    --> internal/core/properties.rs:382:9
    |
382 |         Box::from_raw(_self as *mut BindingHolder<B>);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: call `drop(from_raw(ptr))` if you intend to drop the `Box`
```

Just do what the note says
2022-07-18 16:21:27 +02:00
Olivier Goffart
30f95e3aca Fix animation-tick() to register that there are running animation 2022-07-12 17:36:04 +02:00
Olivier Goffart
d48c590346 Add animation-tick() builtin function
Low level primitive allowing to build always running animations
2022-07-11 17:49:28 +02:00
Olivier Goffart
d89d62b6de Properties: Try to re-use the shared property if more than two property are linked
... via two ways bindings

Otherwise we could be in a case where we have an unbounded number of "shared" property
which might not be shared anymore if the original property goes out of scope
2022-07-08 19:05:54 +02:00
Olivier Goffart
fd44b2e651 Model: Do not register row data tracker if not needed
Make track_row_data_changes not register a dependency to the row
if there is currently no binding being evaluated.
2022-04-19 15:12:15 +02:00
Olivier Goffart
6c59cefa9d Property system: setting a binding must mark all dependent property as dirty
When resetting the binding, we need to mark dependent property as dirty.
It just hapenned that the current implementation always set all bindings
before starting to query the properties, so this problem was not seen
before. But there is an exception when setting the two_way bindings,
then we may set the binding after the property was querried because
setting a two way binding actually queries the property
2022-04-13 21:16:32 +02:00
Olivier Goffart
fa1fad931b Properties: Save one usize for each binding
Use a Cell instead of a RefCell
2022-03-18 09:23:52 +01:00
Olivier Goffart
24237377cf Don't register dependencies when computing the dirty geometry 2022-03-07 19:06:23 +01:00
Olivier Goffart
2fd4b4ccfb Print what property was marked as constant when we assert because of modifying non-const 2022-03-04 11:11:40 +01:00
Olivier Goffart
c941946f49 Debug: make sure that more properties have debug_name
The global properties, and base properties were not named

This adds a Property::new_named regardless if debug is enabled or not
2022-02-18 17:40:17 +01:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Tobias Hunger
de4e195280
Rename internal crates and add a README.md to them
The README.md contains the warning that used to be in lib.rs.

Add README.md files to all internal crates

... pointing to the official public crate to use instead.

Rename internal crates

fixup: README files

fixup rename
2022-02-07 13:12:48 +01:00
Simon Hausmann
125b90a64b Merge remote-tracking branch 'origin/master' into wip/rename
Conflicts:
	api/cpp/cbindgen.rs
	api/cpp/include/slint.h
	examples/CMakeLists.txt
	examples/imagefilter/Cargo.toml
	examples/plotter/main.rs
	internal/backends/mcu/lib.rs
2022-02-04 16:47:20 +01:00
Tobias Hunger
b348d1af44 PropertyAnimation: Make iteration-count: n run animations n times
Side-effect: The code handles invalid inputs to duration/delay better.
2022-02-04 10:42:25 +01:00
Olivier Goffart
d2d6a5cc6a Rename sixtyfps_ 2022-02-02 14:25:56 +01:00
Simon Hausmann
c846633708 Rename C ffi functions 2022-02-02 11:12:34 +01:00
Simon Hausmann
ad0c020aa4 Rename the sixtyfps-corelib crate 2022-02-01 18:04:30 +01:00