Commit graph

65 commits

Author SHA1 Message Date
Olivier Goffart
cd47ef1100 Mark properties that we know are never modified as constant,
so that we don't need to register dependencies when accessing them
2021-12-04 22:00:12 +01:00
Olivier Goffart
a90013983b Add a way to debug the properties behind a configuration flag
I used a `#[cfg(..)]` instead of a feature flag because then it is enabled
for both the compiler and the lib at the same time, and since it is only a debug stuff
it does not need to be enabled within the project. So one must enable it with
`RUSTFLAGS='--cfg sixtyfps_debug_property'`
2021-12-04 22:00:12 +01:00
Simon Hausmann
855ef6375e Minor no_std build fix
Use core::time::Duration instead of std::time
2021-11-30 12:57:45 +01:00
Olivier Goffart
e8271b8f1d Make corelib work without thread_local in no_std 2021-11-29 21:00:35 +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
d8e4c6a887 Properties: Refactor the Dependency tracking in a module
So it will be re-used by the models
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
Simon Hausmann
d420d5efd7 internal cleanup: Rename Property::set_dirty() to mark_dirty() 2021-10-20 15:25:28 +02:00
Simon Hausmann
a494eafa9c Make Property::set_dirty public
Property is not public API yet, there's not much value in playing hide and seek.

Co-authored-by: Olivier Goffart <ogoffart@sixtyfps.io>
2021-10-20 15:25:28 +02:00
Simon Hausmann
7d12fd7b4e Add support for tracking the length of a model in C++
Similar to the parent commit, the model tracks changes to the rows and
marks an internal property dirty. Since we have a base class this is a
little less intrusive.

cc #98
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
bb4e5d8b55 Fix animation not starting when set from a callback
Two problems:
 - We were not marking the property as dirty, so dependent property would not
   update themselves
 - In the generated rust/c++ code, we would not call set_animated_value
2021-10-13 14:33:40 +02:00
Tobias Hunger
ff76aa8953 Janitor: Fix clippy::blocks_in_if_conditions 2021-08-05 23:41:56 +02:00
Tobias Hunger
5b37521e0a Janitor: Allow warning about unnecessary closures 2021-07-12 15:01:19 +02:00
Tobias Hunger
b29360dc5c Janitor: a = a % b is a %= b 2021-07-12 15:01:19 +02:00
Tobias Hunger
a5f4645640 Janitor: Spelling fixes
Work around cspell not liking words ending in `'s` :-)
2021-07-12 15:01:19 +02:00
Tobias Hunger
58cbfa780d Janitor: Spell out argument 2021-07-12 15:01:19 +02:00
Tobias Hunger
9608825eb2 Janitor: Use if let over Option::map returning () 2021-07-12 15:01:19 +02:00
Tobias Hunger
35dd3ed282 Janitor: Remove redundant clone() calls 2021-07-08 20:43:38 +02:00
Tobias Hunger
8b3eda8a49 Janitor: Remove some useless 'static that clippy does not like 2021-07-05 09:48:29 +02:00
Tobias Hunger
96c792d7fc Janitor: self: &Self is not canonical. Use &self instead 2021-07-05 09:48:29 +02:00
Olivier Goffart
13bd828b96 Update license date 2021-07-02 15:55:54 +02:00
Tobias Hunger
13d7f5e7bd Janitor: Fix typos in comments and user-facing strings
Also adapt tests for error messages containing the fixed strings.

No behavior change is intended!
2021-06-28 08:32:25 +02:00
Simon Hausmann
3c0cf6390d Fix loop handling of animations on bindings
For regularly animated values, the loop count was always applied. For animations
triggered through bindings, the iteration count wasn't reset when the
animation restarted and therefore it looked like the loop count was only
applied once.

Fixes #250
2021-06-01 15:49:14 +02:00
Olivier Goffart
b5b715651d More replacement from ptr::read to drop_in_place
Should fix the asserts in C++.
2021-05-31 21:25:41 +02:00
Olivier Goffart
dc1cf645db Interpreter: Fix crash when dropping
the ptr::read will move the object in memory, which is not
allowed for our items which contains Pin'ed property.
2021-05-31 18:48:03 +02:00
Olivier Goffart
56a2225238 Make explicit that a the PropertyTracker need to be Pin
Even if it is a private function, it need to be pined as it register pointers
2021-05-31 18:48:03 +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
Simon Hausmann
ac0d15da6a Fix PropertyTracker::set_dirty() when nesting 2021-04-06 19:14:30 +02:00
Simon Hausmann
b818fd6761 Fix crash with nested property trackers
After commit 3bd5b0eadf the trackers register themselves,
so on Drop they also need to unregister.
2021-04-06 19:07:54 +02:00
Simon Hausmann
a05bcc206a Add support for property change handlers in PropertyTracker
A Property tracker can now be constructed with a callback that's invoked
when a property accessed during evaluate is changed.

The callback is guarded to be called only once until the tracker has
been evaluated. This is implemented by passing the information about
whether the property/tracker was already dirty before through the
mark_dirty() vtable call.
2021-03-25 12:29:19 +01:00
Simon Hausmann
3bd5b0eadf Add support for recursive dependency tracking across PropertyTracker instances
By default PropertyTracker::evaluate() registers the currently
evaluating binding/tracker as a dependency. This should help with
repeaters and other scenarios where in the run-time we use property
trackers but want to track the overall "dirtyness" in the window with
regards to whether a redraw is needed or not.

The new evaluate_as_dependency_root() function allows skipping this
mechanism and is used for the two trackers in the window.
2021-03-25 12:29:19 +01:00
Olivier Goffart
35cce45cbc Add a fii feature so that we don't compile in the ffi code if not required 2021-03-16 18:09:57 +01:00
Olivier Goffart
89bbdce88e Polish a bit the Brush API 2021-03-10 16:54:33 +01:00
Simon Hausmann
f087cc18bc Remove extern "C" functions from wasm module
We don't need these functions and their export. They account for ~20kb in
the optimized .wasm - plus JS glue code.
2021-02-26 17:04:49 +01:00
Olivier Goffart
90fd7b1403 Manual implementation of Debug for Property
Helps with debugging. It is too verbose with useless info otherwise
2021-02-18 10:30:59 +01:00
Simon Hausmann
7982325da4 Change Rectangle::background's type to be a brush
This also introduces the brush type in the compiler and generators. At the
moment only conversion from Color is implemented.
2021-02-03 12:49:44 +01:00
Simon Hausmann
bc194241fd Prepare for Brush becoming a property type
We're going to need support for InterpolatedValue, which at the moment
has trait requirements that are a bit too tight.

It's sufficient if it takes references to values and doesn't require Copy or Clone.
The latter can go into the bounds where it's actually used.
2021-02-03 11:04:52 +01:00
Olivier Goffart
3606717172 Make sure to unlock the Property in cse of panic
This way we don't have another panic while unwinding if a panic
occurs while evaluating a property binding
2021-01-27 16:46:22 +01:00
Olivier Goffart
d5c4885955 Transitions in C++ 2020-11-20 11:38:03 +01:00
Olivier Goffart
091a0834d3 Transitions in rust (C++ and interpreter not implemented yet) 2020-11-20 10:30:17 +01:00
Olivier Goffart
4d4c73925c Some refactoring to prepare for transitions on properties 2020-11-20 09:39:06 +01:00
Olivier Goffart
c50fc6f51c More work on state properties with transitions
C++ set the proper binding for StateInfo state binding
2020-11-19 13:31:18 +01:00
Olivier Goffart
cfa9413861 More work on the state binding for transition:
When there is a transition, turn the state property into a property of StateInfo

Not yet implemented for C++
2020-11-19 12:43:28 +01:00
Olivier Goffart
05924da620 Create a StateInfo object and a special binding for it 2020-11-18 17:29:04 +01:00
Olivier Goffart
103c7cf9a5 Use a custom Instant that is repr(C) 2020-11-18 16:37:22 +01:00
Olivier Goffart
4bbe3362a0 Properties: use a loop instead of a recursion when deleting dependency nodes
to avoid stack overflow
2020-11-05 11:34:26 +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
dec06be70c WIP ListView 2020-10-02 18:07:39 +02:00