* Refactor ProgressIndicator api according to api review.
* Update docs/language/src/builtins/widgets.md
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
* Capping progress also for native.
---------
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
The action requests on Windows typically come in from a non-main thread,
so we'd try to clone the send wrapper in `do_action`
in a non-main thread. That panics unfortunately - send-wrapper
requires the clone to be done in the original thread.
To work around this, wrap the send-wrapper in an Arc, which we can
safely clone. Then inside the closure invoked from within the main thread,
we can clone the send wrapper safely and then take out the Weak
from it (safely as well).
Note: the addition of MinimalSoftwareWindow::set_size is there because
it would be a breaking change for user who called set_size on the
MinimalSoftwareWindow while also using the WindowAdapter trait.
This was the case of a test.
The same problem theorically exist with set_position and position, but
is unlikely to be a problem because i don't think people would use the
position with a MinimalSoftwareWindow
The renderer() is now public as well. That's because I want to make sure
that the scealed trait don't have non-provided method
With just the Qt accessibility support, this is not impactful.
But with accesskit it'll be useful to avoid the intermediate vector of ItemRcs
and map directly to a different data structure.
Otherwise, this is a trade-off between the stack allocation of the recursion and
instead allocating the stack of pending itemrs
on the heap.
This will be needed for embedding - to avoid creating two window
adapters - and it will be needed for the API to allow creating a
component from an existing window.
When the TextInput item is read-only, it should not report availability
or any other status to the input method via the window adapter.
This also fixes the order of events when clicking on a TextInput: We
would send the ime position update request before enabling the ime,
because we set the focus _after_ setting the cursor pos.
Fixes#2812
This patch adds a `close()` function that can be called to close a popup
window, and a `close-to-click` boolean that can be set to false to
disable the default behavior.
After creating the winit window we end up issuing a request_redraw() on
the window adapter after setting the component. This is before show().
With regular windowing systems the redraw event will be delivered when
the window is actually shown, but winit delivers it right away.
In our draw() implementation we don't do anything before show() is
called, as the size won't be correct.
Therefore content is never rendered.
To work around this behavior, we can use the redraw_requested state and
draw right away in show() on wasm.
After commit 7df902b53c, the winit window
is not created when calling show() anymore but it's now created at
component creation time. That means the event loop workaround removed
in 459f810bd8 is now needed at
construction time.
Since this is a winit and wasm specific issue, it's now dealt with in
the wasm interpreter implementation, by invoking the creation from the
event loop from there and returning a promise in the API.
This changes the API therefore: create() can only be called after the
event loop is running.
We would pass `physical_size_to_slint(&self.winit_window().inner_size())`, which is
identical to `slint::Window::size()`, which
calls `size()` on the WindowAdapter, which
returns the above.
show() used to create the window, which required access to the event
loop (target), which in turn required workarounds like in #1603. Since
the winit window exists now in show(), we don't need this workaround
anymore.
The same applies to hide(), we don't need an event loop target, all we
need is the event loop proxy to dispatch a WindowHidden event.