Commit graph

82 commits

Author SHA1 Message Date
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
Tobias Hunger
f7de5d4602
docs: Go over builtin_elements.md (#2280)
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2023-02-24 11:03:56 +01:00
Olivier Goffart
473103dc95 Add a lifetime to ModelPeer
ModelPeer is a short lived object which is just used to register a view
to a ModelNotify.
Using a life time allow to save a heap allocation.

closes #1953
2023-01-26 11:02:32 +01:00
Olivier Goffart
a0fdf94fb1 StandardTableView: Remove the editable feature for now
This commit can be reverted when we want to introduce it again.
There is a few bugs with the editable property:
 - The text is not in sync with the model if the model changes after an
   edit. (can be seen by making an edit and then sort)
 - The highlight of the current row doesn't work properly
 - We should probably only edit on double click or some shortcut instead
   of just clicking
 - The editable field exist but does nothing for the StandardListView
2023-01-24 07:31:29 +01:00
Olivier Goffart
48ce61f740 TableViewColumn: document that the widths are in logical pixel 2023-01-23 16:26:49 +01:00
Olivier Goffart
66b848227b StandardTableView resizable columns 2023-01-23 16:26:49 +01:00
Olivier Goffart
5e7f6bd363 Fix panic when resetting the model to a smaller model in a ListView
Regresison in 1162ebbb79:
Before that commit, the vew would never have more items than the model
since the model would communicate what items to remove.
But now, it is possible that the model has less elements than the view
currently displays from the previous model, so we need to account for
that.
2023-01-17 11:14:04 +01:00
Florian Blasius
ac5eaf495f
move cpp StandardListViewItem from private to public namespace (#2062)
* move cpp StandardListViewItem to public namespace
* Fix missing C++ docs for StandardListViewItem

The struct is originally defined in Rust in model.rs and cbindgen creates the
compatible C++ declaration. For doxygen
to see it, it needs to be emitted into slint_generated_public.h.

* Improve the StandardListViewItem docs a little bit
* move cpp StandardListViewItem to public namespace

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-01-16 09:06:36 +01:00
Florian Blasius
f2aab576f4
Add StandardTableView widget (#2032)
* Text only StandardTableView with column and rows
* Text editing of cells
* Sort by column ascending and descending
* Variants of the TableView for native, fluent and material
2023-01-12 19:41:12 +01:00
Simon Hausmann
1162ebbb79
Reduce the amount of re-creation of cells in repeaters when the model changes (#1954)
Re-use the cells but mark them as dirty, instead of re-creating them every time.
In the included test-case that provides behavior that's
more intuitive.
2022-12-06 18:43:55 +01:00
Olivier Goffart
39aebc1f4e Use the std::ops::Range as range in the repeater
And fix the preview highlight to use that
2022-11-17 12:23:23 +01:00
Simon Hausmann
907b58161c Add support for invoking an init callback on component and element construction
This enables imperative code to be run. To be used sparingly :-)
2022-11-17 10:12:08 +01:00
Simon Hausmann
c16253d29f Use Property<LogicalLength> instead of Property<Coord>
This removes the special code for the generated property getters and
ensures type safety in the run-time library for property value setting.

In the Rust generated code we continue to do arithmetic on the scalar
values, that means we immediately extract the scalar, do arithmetic and
rely on the compiler to only allow compatible units.

Danger zone alert: In the interpreter Value::Number can now be converted
to LogicalLength as-is.
2022-10-24 12:49:37 +02:00
Olivier Goffart
7d90a3673f Add VecModel::extend, tests, and changelog entry for last commit
CC #1678  #1647
2022-10-17 14:40:48 +02:00
David John
a049d72ac5 add VecModel::extend_from_slice 2022-10-17 14:04:49 +02:00
Florian Blasius
5fb31ace02
Florian/rust sorting model (#1712)
Add Rust version of SortModel
2022-10-07 16:24:48 +02:00