Commit graph

59 commits

Author SHA1 Message Date
Simon Hausmann
bf84bb2ab6 Make floating point operations compile with no_std
Use num_traits and libm instead, also for euclid.
2021-11-30 15:33:50 +01:00
Olivier Goffart
a5ea6dd087 Models: re-implement the internal of model tracking
Don't rely on the weak-table that does not work with no_std,
instead, use the same data structure as for the property dependency
tracking
2021-11-29 17:15:56 +01:00
Olivier Goffart
80c0602277 WIP: start making the corelib crate a no_std crate
Does not compile yet with no_std because of the lack of
alternative for thread_local
2021-11-25 12:02:16 +01:00
Olivier Goffart
973964c2e3 Fix warning in documentation because of a typo 2021-11-09 17:00:43 +01:00
Simon Hausmann
7b687d020c Fix compatibility of attach_peer on ModelHandle for older models
If the model doesn't implement `model_tracker` then we must
forward `attach_peer`.
2021-10-21 13:39:38 +02:00
Simon Hausmann
2ba469cf2a Fix vector model example docs
Re-implement model_tracker instead of attach_peer.
2021-10-20 15:33:37 +02:00
Simon Hausmann
d420d5efd7 internal cleanup: Rename Property::set_dirty() to mark_dirty() 2021-10-20 15:25:28 +02:00
Simon Hausmann
63bf1af093 Add support for tracking the length of a model in Rust
This is done by exposing the ModelNotify to the caller via the new
ModelTracker trait, which has a function that allows "hooking" into the
dirty tracking of the size.

By extension, this also works in JavaScript.

cc #98
2021-10-20 15:25:28 +02:00
Olivier Goffart
e3d9abb1f7 ListView: Attempt to account for ListView with different item height
As an attempt to fix part of https://github.com/sixtyfpsui/cargo-ui/issues/10
2021-10-20 14:10:19 +02:00
Olivier Goffart
b74ab8969e Implement Model::set_row_data for ModelHandle 2021-10-12 14:05:33 +02:00
Olivier Goffart
8150bb027b Fix ListView not always making the window to be redrawn when a model change
Example: expending or collapsing the cargo-ui dependency tree after scrolling.
2021-10-04 16:15:36 +02:00
Olivier Goffart
94f55ba29e Janitor: Make sure the variable means what it says
The variable "geometry_changed" was true when the geometry was not updated.
Rename the variable and make it sure it has a proper meaning.
(Doesn't change the logic of the program)
2021-10-04 15:53:51 +02:00
Simon Hausmann
5fc5563c99 Minor cleanup: Replace expect() with unwrap() and comment
That's the more common pattern we use currently.
2021-09-15 08:49:27 +02:00
Simon Hausmann
5742a122ed Fix listview not updating its geometry in Rust when the entire model is changed
The geometry tracker did not track the model property itself, so it did not become dirty.

Fixes #500
2021-09-15 08:49:27 +02:00
Olivier Goffart
e1be599bc0 Print an warning in stderr when modifying read-only model
... and improve the documentation of Model
2021-08-31 10:36:22 +02:00
Olivier Goffart
073447a47d Fix the clippy error about comparing address of virtual table
Fix one vtable_address_comparisons clippy link.
It is fine to only compare the data pointer.
Two different model with the same data pointer in a Rc could only be obtained
with tricks like transmute because each model is allocated on a different Rc.
2021-08-16 10:53:28 +02:00
Tobias Hunger
ff76aa8953 Janitor: Fix clippy::blocks_in_if_conditions 2021-08-05 23:41:56 +02:00
Tobias Hunger
60ef093aaa Janitor: Fix clippy::len_without_is_empty 2021-08-04 22:50:35 +02:00
Tobias Hunger
aeebbb1d96 Janitor: Fix remaining clippy::option_map_unit_fn 2021-07-21 19:44:57 +02:00
Olivier Goffart
673c0ce81c Add a as_any to the Model trait to allow getting a reference to the original model 2021-07-20 15:38:10 +02:00
Tobias Hunger
9608825eb2 Janitor: Use if let over Option::map returning () 2021-07-12 15:01:19 +02:00
Tobias Hunger
925afb2ba4 Janitor: Remove unnecessary lifetimes 2021-07-12 15:01:19 +02:00
Tobias Hunger
f24df0f94f Janitor: Typo fixes 2021-07-08 20:43:38 +02:00
Tobias Hunger
3f5ad42683 Janitor: Fix typo in comment 2021-07-08 06:47:05 +02:00
Tobias Hunger
9b929b287d Janitor: slice.iter().cloned().collect::<Vec<T>>() == slice.to_vec() 2021-07-05 09:48:29 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Olivier Goffart
deaa0fddb0 WIP layout: split vertical and horizontal cache
Split the vertical and horizontal pass into different property cache
This will allow to implement "height for with"

This patch does not port the Rust or C++ binding yet
2021-06-16 15:14:07 +02:00
Olivier Goffart
ee00c9eb92 Rename maximum- and minimum- properties to max- and min-
Issue #259
2021-06-14 10:28:30 +02:00
Olivier Goffart
e7b75a2f2d ListView: Attempt to be a bit better as filling the element
Be sure to always instentiate at least enought element.
This is a problem if the items don't have the same height.

This only covers Rust and the interpreter
(The C++ code logic for the Listview currently instentiate all elements anyway)

Should help for issue #228
2021-06-01 17:27:09 +02:00
Olivier Goffart
76a42cd757 Added support for static constant z ordering
Just re-order the children at compile time
2021-05-14 16:17:34 +02:00
Olivier Goffart
720001a223 Remove the solve_layout from the component vtable
no longer required
2021-05-11 14:59:57 +02:00
Olivier Goffart
b463e3cca4 WIP refactor layout
This commit add support for the box layout
2021-05-11 14:59:57 +02:00
Olivier Goffart
9e6970abfe ListView: Fix panic when removing item that are not visible 2021-04-27 16:37:17 +02:00
Olivier Goffart
576eb116e8 Make the is_dirty flag a property so that changing it will force a repaint 2021-04-27 11:05:35 +02:00
Olivier Goffart
76befb63a3 Fix the dependency tracker not registering a dependency if it was not dirty
Also fix opening/closing the popup should refresh the window
2021-04-26 15:24:48 +02:00
Olivier Goffart
81b63c3b3f Small reformating fix 2021-02-12 09:56:37 +01:00
Simon Hausmann
d5e72b255a Fix build when structures contain models
The generated code for structs includes #[derive(Debug)],
which requires Debug for all fields. When the field is a ModelHandle
it's up to us to provide an implementation.
2021-01-25 14:20:13 +01:00
Olivier Goffart
dfa25b96f7 Rename SharedArray to SharedVector 2020-12-18 10:26:07 +01:00
Simon Hausmann
bdebb77f14 Implement Iterator for the Model in Rust 2020-12-02 12:04:32 +01:00
Simon Hausmann
276bcd6574 Implement Model for ModelHandle
This makes extracting model data out of .60 files a little easier
2020-12-01 16:14:43 +01:00
Olivier Goffart
8a64f10e84 Remove ComponentVtable::input_event
And the custom handling of the mouse grabber
2020-11-24 16:23:37 +01:00
Olivier Goffart
3f111ecd30 Fix a few doc typo 2020-11-23 11:47:16 +01:00
Simon Hausmann
89e0b57627 Rework and simplify the focus handling
Instead of determining the focus item through item tree traversal and
pointer comparison and storing the intermediate indices in the
components in the tree, remember the focus item by a pair of
VWeak<ComponentVTable, Dyn> and item_index: usize.

This speeds up determining the focus item as well as delivering events,
which can now be done directly after retrieving an ItemRef with
get_item_ref.

This also fixes the duplicate line edit focus in the 7gui cells
test case.
2020-11-20 15:33:15 +01:00
Olivier Goffart
af801b9879 Use the new get_item_ref function instead of visiting the root 2020-11-11 15:04:49 +01:00
Olivier Goffart
a1f1fcb3a6 Use VRc<ComponentVTable> in the rust generated code 2020-11-09 14:58:37 +01:00
Olivier Goffart
2ece3817cc Make ModelHandle a struct
Last commit broke for structures containing models, because models are not PartialEq.
So we need to implement PartialEq for ModelHandle. Which means a struct needs to
be created
2020-10-31 13:32:19 +01:00
Olivier Goffart
d2255327fe Properties: make sure that the falue is different before marking all dependencies dirty
Fix the animation of the gauge in the printer demo
2020-10-31 12:58:11 +01:00
Olivier Goffart
d339ead5dd support for within box layouts
Only rust implementation for now
2020-10-30 19:12:48 +01:00
Olivier Goffart
5face45c51 Rename Component::compute_layout to apply_layout
And pass the expected rectangle.
This is currently not used yet but will be needed when we can have
repeated elements within a box layout
2020-10-29 19:08:52 +01:00
Olivier Goffart
9f08492258 Make sure that the ListView is not scrolled when there is enough room for all contents
Fixes #93
2020-10-21 09:47:33 +02:00