Commit graph

44 commits

Author SHA1 Message Date
Olivier Goffart
23962b3e25
Upgrade cbindgen and use unsafe(no_mangle) attributes (#8539)
To be compatible with the 2024 edition, we need to wrap the
`no_mangle` attribute in `unsafe()`.

The parsing for that in cbindgen was only added in the version 0.28,
but we couldn't upgrade cbindgen before because of a regression in
cbindgen 0.27 that prevented us from upgrading.
Now that cbindgen 0.29 is released with a fix, we can prepare for the
2024 edition
2025-05-26 11:21:33 +02:00
Simon Hausmann
6aff60b38f
doc: minor polish to the timer docs (#7905) 2025-03-21 12:34:40 +01:00
Yuri Astrakhan
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +01:00
Olivier Goffart
c98d234b9e Janitor: Always use `#![no_std] for runtime lib
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
2025-01-27 19:22:00 +01:00
Olivier Goffart
12fe2bb36d Extra tests for Timer::stop
Just in case (CC #5885)
2025-01-14 18:02:41 +01:00
Olivier Goffart
cbc28b1f1b Android: handle properly the Destroy event
Destroy means we need to exit the event loop.
And android_main will be called again from another thread, so we need to
support reseting the proxy

There is also a bug in the timer when exiting the app that this worked
around

Fix #6626
2024-10-23 14:30:55 +02:00
Simon Hausmann
07a833a2e3 Clarify Timer::set_interval Rust docs with regards to running timer behaviour
Fixes #6515
2024-10-15 16:49:35 +02:00
Simon Hausmann
0cf40b08bc
Fix two issues with the timer handling (#6549)
- When stopping a running but not yet expired timer from within the activation callback of an expired timer, the stopping would fail to find the timer in the active_timers list because it was built on the fly. Similarly, restarting a future timer form within the same kind of callback would end up registering the active timer twice. Fix this by doing all the active_timer re-setup before activating any callbacks, so that by the time of activation the data structure is in a good state.
- When two timers expire at the same time and from the callback of the first, the second timer would be dropped/deleted, the timer's `being_activated` was overwritten and the timer was deleted too early, causing a panic. Fix this by preserving the removal state.

Fixes #6187
Fixes #6505
2024-10-14 15:02:35 +02:00
Olivier Goffart
e67f55f884 Fixed Timer::set_interval() doesn't work in timer callback
Fixes: #6141
ChangeLog: Fixed Timer::set_interval() doesn't work in timer callback (#6141)
2024-09-18 11:25:52 +02:00
Olivier Goffart
d2bd5366f4 Timer::set_interval
Don't return an Option, just return 0 when the timer is not started.
As discussed in the API review, the rational is that the interval is
just like a field in a struct and when the struct is default
constructed, it is initialized to 0
2024-09-18 09:24:39 +02:00
Simon Hausmann
d978a856fc Fix bug reference 2024-08-21 12:55:35 +02:00
Olivier Goffart
a9f526491a Timer Element
Closes #5724
2024-08-16 16:36:38 +02:00
Simon Hausmann
7d270812a3
Fix panic in slint::Timer due to double mutable borrow (#5525)
When stopping a timer, the removal from the timer list requires a mutable borrow.
If during that borrow the timer's closure is dropped and a `Drop` impl starts another time, then the attempt of
acquiring a mutable borrow for the timers list to insert the new timer fails.
2024-07-02 11:20:30 +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
f302142cd7 Rust Timer: Mark as !Send
The Timer cannot be moved between threads because the id is only valid
as part of the thread local of timers.

This is a breaking change. But if one had move timer between thread
before, it would have caused a bug.
2024-04-24 10:00:52 +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
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Tobias Hunger
3b7e79958a cpp: Make Timer available to other FFI-exported types
We have a nice FFI-compatible wrapper areound rust timers in C++, so
allow to use that in other types exported to C++.

This also makes sure the rust and C++ side agree on the size of the
type, with the nice side effect that the rust Timer now uses half as
much space now as it did before.
2023-12-01 18:47:00 +01:00
Tobias Hunger
471bef422d core: Do not report singleshot timers set up via start() as running
... after firing once. `running()` will now return `true` for such timers
till just before the callback is run and `false` after that point.

Add test a new test and update existing C++ tests to make them comply
with the changed behavior.
2023-11-30 20:14:45 +01:00
Olivier Goffart
8f16b519a2 use #repr(uX) instead of repr(C) for fieldless enums
Otherwise the ABI may differ between the C++ and the Rust
2023-08-31 10:22:03 +02:00
asuper0
5268aeb676 Add set_interval function to Timer, which could change the interval of timer without re-invoking a start function. 2023-07-24 09:37:53 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
5e5c0c4fb7 Fix timer corruption if a Timer ids Drop'ed in the event handler of another Timer
Fixes #3019
2023-07-04 10:54:33 +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
Simon Hausmann
c813e80b48 Fix rendering of links in data structures where docs are shared between C++ and Rust
- in SetRenderingNotifierError using a rustdoc link breaks the C++ docs. Using a qualified backtick'ed slint::Window works perfect with both.
- In TimerMode, the same track unfortunately doesn't work with a function,
  but we can use [`Foo::bar()`] to make the link work with rustdoc and myst-parser.
  The look isn't perfect in C++, the square brackets are visible.
2023-06-08 10:02:15 +02:00
Olivier Goffart
22fc23a5db Document that timers stop on drop
Closes #2482
2023-04-20 12:59:47 +02:00
Olivier Goffart
adb1b24c28 Fix the slint_mock_elapsed_time when not using the testing backend
The nodejs tests don't use the testing backend, as a result, calling
`platform::update_timers_and_animations` would use the real time instead
of the fake time.
So call `maybe_activate_timers` with the fake time instead
2022-09-16 19:14:15 +02:00
Olivier Goffart
f954cb4ced Add a 100ms delay before forwarding the event in a Flickable
It was reported an annoying visual bug when flicking over a listview
with item that has a special effect on pressed, that the items would
show "pressed" for a brief instant.  This patch add a small delay before
sending the press event to the children.

The FIXME in the test is not a regression. (This happens because we send
Exited event to the children when flicking, despite the mouse is still in
the area)

Added a update_timers_and_animations from slint_mock_elapsed_time so we
don't have to call update_timers_and_animations ourselves in the test
anymore to fire the timers (it was previously only touching the
animation property)
2022-09-16 19:14:15 +02:00
Olivier Goffart
d1e3ce4acf Tests for the timers
Tests that timer fires, but also that stopping them within a timer event work
(Test for #1532 and #1533)
2022-08-26 10:16:18 +02:00
tay64
0b1be0316e Fix #1532: Timer::{start,stop} in the timer's own callback
Before the change:

- calling the_timer.start(...) in the_timer's callback resulted in the_timer
keeping the old callback;

- calling the_timer.stop() in the_timer's callback was ignored.
2022-08-26 09:19:10 +02:00
Olivier Goffart
8fba65a282 Rename and expose the unsafe-single-threaded feature 2022-08-25 16:47:53 +02:00
Olivier Goffart
00e9fcc9dd backend API: polish and move the timer functions to the backend module 2022-08-22 14:41:50 +02:00
Olivier Goffart
793974ce9f Make just one function to fire both timers and animations
Also simplify the Qt backend since only the paint event will
query the animated properties that should then cause a refresh
one frame later
2022-07-26 15:13:07 +02:00
Tobias Hunger
4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00
Tobias Hunger
de4e195280
Rename internal crates and add a README.md to them
The README.md contains the warning that used to be in lib.rs.

Add README.md files to all internal crates

... pointing to the official public crate to use instead.

Rename internal crates

fixup: README files

fixup rename
2022-02-07 13:12:48 +01:00
Tobias Hunger
2b55c488ca
Rename sixtyfps to slint in internal 2022-02-02 16:16:55 +01:00
Olivier Goffart
d2d6a5cc6a Rename sixtyfps_ 2022-02-02 14:25:56 +01:00
Tobias Hunger
cc3994b58d
Rename rust API 2022-02-02 13:26:35 +01:00
Simon Hausmann
c846633708 Rename C ffi functions 2022-02-02 11:12:34 +01:00
Simon Hausmann
9494068201 Rename the sixtyfps-rendering-backend-selector crate 2022-02-01 18:06:49 +01:00
Tobias Hunger
e6b24bceec [reorg]: Set up and populate the internal directory
Move "internal" crates into the `internal` directory. This first batch
includes most of sixtyfps_runtime but leaves the rendering backends
alone for now.

pre-commit applied some cleanups to the moved files:
 - Consistent newline at end of file policy
 - trimming trailing whitespace
 - Formatting Cargo.toml files.
2022-01-31 16:00:50 +01:00
Renamed from sixtyfps_runtime/corelib/timers.rs (Browse further)