Commit graph

60 commits

Author SHA1 Message Date
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
Olivier Goffart
2760d96b79 Make VecModel::remove() return the removed value like Vec
Fixes #1221
2022-09-06 05:42:56 +02:00
Olivier Goffart
4d05688730 ListView: try the best to keep the listview elements consistant when scrolling
Even when the average height changes
2022-07-11 19:33:05 +02:00
Olivier Goffart
55155915d2 Fixt listview jumping when scrolling and element have different size
The test test one particular case where we want to expand an item to
the size of the listview when clicking
2022-07-11 19:33:05 +02:00
Tobias Hunger
4da7588af4 Fix component_at in repeaters 2022-07-05 14:27:19 +02:00
Simon Hausmann
cdff68da17 Revert "Fixt listview jumping when scrolling and element have different size"
This reverts commit 1ae0e8f760.

Oops, this was not intended to be pushed to master.
2022-07-04 13:53:39 +02:00
Olivier Goffart
1ae0e8f760 Fixt listview jumping when scrolling and element have different size
The test test one particular case where we want to expand an item to
the size of the listview when clicking
2022-06-30 14:46:34 +02:00
Lukas Jung
ff036d41ec Add model adapters
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-05-11 15:50:43 +02:00
Lukas Jung
a36ac901db Add nth() implementation to ModelIterator to improve skip() performance 2022-05-11 15:50:43 +02:00
Olivier Goffart
696ce933f7
Refactor the Model tracking in a module (#1223)
Contain the unsafe code in a smaller module.
Add an abstraction to make it easier to create change listener other
than the repeater.
2022-05-05 10:25:15 +02:00
Olivier Goffart
525e9982d8 Re-export and document ModelExt 2022-05-04 11:08:14 +02:00
Lukas Jung
7c45be97cd Move row_data_tracked to ModelExt trait 2022-05-04 11:08:14 +02:00
Olivier Goffart
86d893245e Model: When items are inserted, sets the components after that as dirty
Because their index property needs to be updated
2022-05-02 11:47:17 +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
67e9a59398 Add a Model::row_data_tracked function
Closes #1177
2022-04-19 15:12:15 +02:00
Simon Hausmann
5a270313d2 Improve VecModel::set_vec test
Verify the values reported by `row_count()` in the rows added/remove
callbacks.
2022-04-14 14:20:27 +02:00
Olivier Goffart
f5030cff06
Add a reset function to the model notifier 2022-04-14 14:06:34 +02:00
Olivier Goffart
1b91158b46 corelib: allow to use i32 for coordinate instead of f32 2022-04-11 17:46:50 +02:00
Tobias Hunger
ee68716d07 Component: Add information to stich together ItemTrees
Add accessors to the information necessary to stitch together the
Component-wide ItemTrees (which include DynamicNodes) into one logical
tree of Items.
2022-03-28 14:13:36 +02:00
Simon Hausmann
3a3ce15970 Add a unit test that verifies that VecModel::set_vec notifies the view correctly 2022-03-17 09:47:10 +01:00
Ray Redondo
b265f721f2 add a test 2022-03-17 09:15:58 +01:00
Ray Redondo
94cbaa55d7 add VecModel::set_vec 2022-03-17 09:15:58 +01:00
Lukas Jung
4c61a16c08 add From<&str> and From<SharedString> to StandardListViewItem 2022-03-11 15:45:59 +01:00