Commit graph

97 commits

Author SHA1 Message Date
Simon Hausmann
97ecbb3338 CI: Fix lifetime annotation warnings in model types
Amends de81fa1dba
2025-06-06 12:09:09 +02:00
Tobias Hunger
c25d15c3d2 live-preview: Remember recent colors
... for the duration of the session. How can we save those
colors?

Recent colors change a lot, we probably do not want that stored
inside the git repository hosting the slint files... and this is
probably "personal data" and nor "project data" in the first place.
2025-05-22 15:30:30 +02:00
Simon Hausmann
98fbdb99b5
doc: Extend Model::as_any() docs with a hint how to debug downcast fa… (#8451)
Co-authored-by: Olivier Goffart <olivier.goffart@slint.dev>
2025-05-19 09:40:13 +02:00
Olivier Goffart
a9a9e23e48
Document how to update a model from a thread
Part of #3945
2025-04-02 18:47:43 +02:00
Olivier Goffart
a80f14e7d8 Fix re-instentiating if elements when the condition is dirty
Fixes #3953
2025-03-27 15:37:07 +01:00
Yuri Astrakhan
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +01:00
Arnold Loubriat
42773eca64 Don't instanciate ListView items that are just above the viewport when scrolling down 2025-02-05 10:00:49 +01:00
Simon Hausmann
9961a6f44d VecModel<T>: Don't require that T implements Default
ChangeLog: Rust: Removed the requirement that for VecModel<T> T has to implement Default.
2025-02-04 14:49:58 +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
2df0b8bf20 ListView: adapt the viewport's width based on the minimum-width of delegate
(Instead of their `width` property)
2025-01-21 14:31:55 +01:00
Olivier Goffart
7e37f19e2c ListView: fix continuous redraw with fluent style
Because we set the viewport-width several time to different value during
the layouting of the ListView, it will cause this property to always be
dirty. In particular, this causes permanent restart of the fluent's
scrollbar animation on the size of the handle, causing continous
repaints.
2025-01-21 14:31:55 +01:00
Olivier Goffart
e11ef5cca6 Fix infinite loop with very large ListView 2025-01-20 17:41:38 +01:00
Olivier Goffart
4da79ac69a Fix layouting of huge ListView with millions of items
The problem is that the precision of f32 for coordinate wouldn't be
accurate enough with such big viewport to put the elements so that they
are next to eachother.
So put the elements relative to the Flickable instead of relative to the
created moving viewport Rectangle.

Fixes #3700

Note that the ListView still use f32 for the scrollbar value, meaning
that at some point, the wheel stops working as the wheel increment is
smaller than the f32 increment, and scrolling becomes somehow fuzzy.
But this only happens after one more billions pixels now, so one can
have more than 50 millions of elements without much problems
2025-01-20 17:41:38 +01:00
Olivier Goffart
36381c579b ListView focus fixes
- Fix StandardListView not always getting the focus. Because the
   geometry of the FocusScope might be empty but its position is still
   in the non-clipped area, but not its center.

 - Fix panic when accessing "negative" items if there are hidden
   elements in the ListView (#7341)

Fixes #7341
2025-01-13 21:08:32 +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
Olivier Goffart
f195892376 Fix calling init to all the items on a ListView
This also fix changed event not working as they rely on the init to the setup

Fixes #6836

ChangeLog: fix init and changed callback not always being called in ListView
2024-11-20 14:24:58 +01:00
Simon Hausmann
5ecc0f0b47
Fix panic when code in init callback of conditional/repeater re-triggers repeater traversal (#3215)
Don't call init() while mutably borrowing the repeater's inner.

Fixes #3214
2024-11-15 14:25:36 +01:00
Simon Hausmann
be2af11a08 Rust: Stop ModelIterator from calling row_data() with out of bounds row
While technically allowed and sort of serving as a test to see if the model is well implemented, this is unnecessary behaviour. The model iterator should not serve as a testing ground :)
2024-10-10 11:40:12 +02:00
crai0
a0e20a0b51
core: implement FromIterator for VecModel (#6140)
Closes #5879
2024-09-16 08:26:59 +02:00
FloVanGH
f6ec79c76a
Added missing tests for VecModel (#5975) 2024-08-28 11:17:17 +00:00
FloVanGH
13692e2647
Added swap to VecModel (#5965) 2024-08-27 11:08:55 +00:00
FloVanGH
a5bb83c6b9
Added clear to VecModel (#5960) 2024-08-27 09:09:25 +00:00
Enyium
f82a785b81 Extended VecModel docs regarding interior mutability. 2024-08-20 21:56:21 +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
d4741efac0 testing: rename the init function 2024-04-18 18:45:31 +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
ba3a1af167 Fix panic when the model row_data returns None
Closes #4839
2024-04-15 10:48:54 +02:00
Tobias Hunger
9873cfd7c0 janitor: Run cargo clippy --fix
Only the hand-picked sensible things, not all of it ;-)

Also fix a few typos that cspell complained about when I
tried to commit and some formatting changes that cargo fmt
insisted on when commiting.
2024-03-14 13:42:38 +01:00
Olivier Goffart
09a5c724bf ListView: Fix redraw when model changes
Amend 48180919da
That commit added the dependency, but did not reset the dirty flag, so
it only worked once.

Fixes: #4538
2024-02-05 15:02:44 +01:00
Olivier Goffart
48180919da ListView: ensure that we track change to the model
Fixes #3125
2024-01-05 09:17:19 +01:00
Olivier Goffart
d55803d290 Models: fix writing data doesn't update ListView model data property
This fixes a couple of bug:
 - Bug #3740 happens because `Repeater::model_set_row_data` did not use
   the inner.offset to get the instance (So that's the `val == 106` part
   of the test)
 - But I went ahead and also tested what happenned if you changed the
   model from the "outside" using the `model[i] = `, and that was not
   implemented, hence the move of the code from
   `Repeater::model_set_row_data` to `RepeaterTracker::row_changed`,
   That does need Pin though, so Pin was added everywhere
 - C++ is not affected by bug #3740, because because the C++ listview
   don't do the "allocate only visible" optimization. But the
   "val == 1106" part of the test would fail so this patch also moces
   the update from  `model_set_row_data` to `row_changed`.
   But following that we don't set the state as Dirty in `row_changed`,
   the write_to_model test started filling  because the `row_added`
   function was missing an update of the index on every further items

The change in the interpreter prevent a borrow_mut from causing trouble.
The Value really don't need to be in a RefCell anyway

Fix #3740
2023-10-31 13:41:31 +01:00
Olivier Goffart
78d273e599 Revert "Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)"
This reverts commit 1162ebbb79.

Because otherwise if we keep the elements, their internal state is kept
and this causes bug #2598

Fixes #2598
2023-10-23 16:52:03 +02:00
Olivier Goffart
a5488d6285 Rename RepeatedComponent -> RepeatedItemTree
And some more cleanups
2023-10-09 11:01:56 +02:00
Olivier Goffart
852b4d906d Rename ComponentVTable to ItemTreeVTable
and their related name.
Also move the component module in the item_Tree module
register_component -> register_item_tree
ComponentItemTree -> ItemTreeNodeArray

For #3323

Rationale from that issue:

Right now, we use the term `component` in the Slint language and in the compiler to be a a tree of elements that can be used as an element in a .slint file.

The term is also currently used in the runtime as a tree of runtime Items that are allocated together. (declared in ComponentVTable)

But there are no 1 to 1 mapping between a `component` in the slint language, and a runtime Component.
(for example, the items behind a `if` or `for` or `PopupMenu` are in a different runtime component. And `component` declared in Slint are often inlined)

So we should rename the internal runtime `Component` to  `ItemTree`

The currently public `slint::ComponentHandle` wraps the "root" of the ItemTree, but that's ok because it is generated from a .slint `component`,  so it doesn't change name
2023-10-09 11:01:56 +02:00
Olivier Goffart
083023866d Use the item_geometry from ComponentVTable 2023-09-13 16:08:37 +02:00
Simon Hausmann
3652f58a3f Change item indices from usize to u32
So that the compiler and run-time can never disagree on the
number of bytes the item index can use.
2023-09-12 08:53:58 +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
Guilhem Vallat
49b3e15bc8 Add ReverseModel 2023-07-20 16:18:37 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +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
Tobias Hunger
9c50da9bde
janitor: Fix a few typos 2023-06-08 18:12:52 +02:00
Simon Hausmann
0eab14139e Add convenience implementations of From for ModelRc from slices and arrays
Fixes #2787
2023-06-06 14:38:52 +02:00
Olivier Goffart
bef2e3617d Fix ListView panic when setting a new model
.. that has less items and the ListView is scrolled.

We should not have an offset that is higher than the current count
otherwise we're going to access invalid item in the model

Fix #2780
2023-06-05 15:52:06 +02:00
Simon Hausmann
439b0c09d8
Try to improve the documentation for ModelRc (#2791)
- Mention in the type mapping table as well as in ModelRc that ModelRc is also used for array struct fields.
- Use an itemized list for the different ways of constructing, with the from_slice variant being listed second.

cc #2787
2023-05-31 17:16:06 +02:00
Olivier Goffart
f746ed5908
docs: Improved Model and ModelRc documentation (#2698) 2023-05-07 08:07:04 +02:00
Olivier Goffart
75f0c3cc83 Fix resizing a ListView to empty height would make all items invisible even if resized back
The problem is that we would end up with a division by zero and the NaN
value would be cached as the average item height

Fixes #2545
2023-04-13 19:23:20 +02:00
Olivier Goffart
4cf44ea69d Mark StandardListViewItem and TableColumn as #[non_exhaustive]
Closes #2330
2023-03-18 09:04:48 +01:00