Commit graph

59 commits

Author SHA1 Message Date
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
Olivier Goffart
c0473a7c94 Forgot to implement intercept_set_binding in the rust case 2020-09-28 14:36:03 +02:00
Olivier Goffart
3b6679ed4b Two ways binding works also work as three ways binding and more
A side effect is that the order of calling set_binding and link_two_ways is no longer relevant
2020-09-28 10:42:27 +02:00
Olivier Goffart
60cf022b69 Fix the two ways binding being flacky in the interpreter
The two way binding must be set at the end.
It is flacky because the order currently depends on the order in the Hashmap
2020-09-25 17:07:22 +02:00
Olivier Goffart
abe24e2e9e C++ two way bindings 2020-09-25 15:21:37 +02:00
Olivier Goffart
20430566c1 Implement two ways binding in the runtime. 2020-09-25 12:46:21 +02:00
Olivier Goffart
cfa172f5c9 Add an explaining comment for properties 2020-09-23 14:06:08 +02:00