Commit graph

68 commits

Author SHA1 Message Date
Tobias Hunger
39d215bee0 docs: Rename "Slint language Reference" to "Slint Language Documentation" 2023-02-22 21:13:47 +01:00
Tobias Hunger
78892cdf1f docs: Fix broken links in our docs. 2023-02-22 17:08:30 +01:00
Olivier Goffart
6889dfa5f5 Rust: Make new(), run() and show() report errors from the backend
Fixes #2198
2023-02-10 05:00:03 +01:00
Florian Blasius
d84de623b4
TextEdit select text with double and dribble click (#2088)
* Select word in `TextEdit` by double click
* Select paragraph in `TextEdit` by dribble click
2023-01-31 15:04:19 +01:00
Simon Hausmann
52fb1ab9fe Fix signature of get_proc_address in Rust GraphicsAPI
Use a CStr instead of str, to avoid an extra CString allocation. The underlying operating system API for
this expects a zero terminated C String.

Fixes #1943
2023-01-26 11:55:10 +01:00
Simon Hausmann
7122d22c88 janitor: use the new default attribute for enums 2022-12-05 10:20:39 +01:00
Simon Hausmann
247772104a Move WindowEvent, PointerEventButton and Key to the platform module
For `Key` this is a move, as it is a new type. For `WindowEvent` and `PointerEventButton` deprecated aliases
are provided.
2022-11-24 11:34:28 +01:00
Simon Hausmann
66871da47b doc: remove stray triple slash 2022-11-24 09:15:05 +01:00
Florian Blasius
61c39b5fa1 Add support for dispatching key events through the public platform API
This change adds `KeyPress` and `KeyRelease` variants to the
`WindowEvent` enum, along with the new `slint::Key` enum, that allows
encoding keys.
2022-11-15 10:34:17 +01:00
Simon Hausmann
e9db914fb1
Add is_visible to NodeJS and C++ Window types (#1816)
Amends commit 82278a5742
2022-11-04 16:24:24 +01:00
David John
82278a5742 api: add Window::is_visible 2022-10-29 09:21:26 +02:00
Simon Hausmann
38a55f87a4 Change internal MouseEvent to use logical points 2022-10-13 17:02:18 +02:00
Simon Hausmann
299325370d Change generated accessor functions for Property<Coord> getters to return LogicalLength 2022-10-13 17:02:18 +02:00
Simon Hausmann
dba137e3ba
Rename RequestedSize to WindowSize and RequestedPosition to WindowPosition (#1640) 2022-09-14 12:59:53 +02:00
Tobias Hunger
53a3c72b57
api: Change logical/physical position and size on window (#1620)
* Add `RequestedSize` and `RequestedPosition` enum to enable asking for
  logical or physical size/position.
* Rename `Window::size()` to `Window::physical_size()`
* Make `Window::set_size(...)` take an `Into<RequestedSize>`
* Rename `Window::position()` to `Window::physical_position()`
* Make `Window::set_position(...)` take an `Into<RequestedPosition>`
* Change `WindowAdapter` and related classes to be able to handle
  requests being made in the either physical or logical units.

Implement this for C++, Rust and node.
2022-09-13 08:55:31 +02:00
Simon Hausmann
e444aa1c4e
Some doc fixes to the new types/functions (#1618)
Various edits and enhancements.
2022-09-09 11:30:37 +02:00
Simon Hausmann
372e6b0ffc winit: Work around request_redraw() not always resulting in a Event::RedrawRequested
The old workaround doesn't work anymore (commit
575665994a removed the
redraw_all_windows() but that was correct as well). Instead we take an
approach that is hopefully more idiomatic to winit:

The winit documention suggests two methods: For continuously repainting
windows, we can just draw in MainEventsCleared. Otherwise call
request_redraw() and wait for Event::RedrawRequested(id).

In practice sometimes a call to request_redraw() from within the input
event processing results right away in a Event::RedrawRequested
(observed on Windows). Sometimes a request_redraw() results in waking up
with NewEvents() but no Event::RedrawRequested, and then in the next
iteration a new request_redraw() is included (observed on Windows).

We will continue to issue request_redraw() but for any windows that
haven't received Event::RedrawRequested() we will just draw. This still
allows the windowing system to compress / combine paint events.

If during draw() request_redraw() is called, we assume that the
application wants to redraw ASAP and we fall back to Poll. This was
previously the workaround in corelib that's now only in the winit code.

Fixes #1574
2022-09-08 11:35:34 +02:00
Olivier Goffart
096103b472 Rename EventLoopError::NoEventLoopProvider 2022-09-07 10:13:58 +02:00
Olivier Goffart
6ede77436b api: Return an error from invoke_from_event_loop and quit_event_loop 2022-09-07 10:13:58 +02:00
Simon Hausmann
3649390d85 doc: Remove the mention of euclid in the scale_factor function
We don't depend on euclid anymore in the public API

cc #1502
2022-09-06 16:19:27 +02:00
Simon Hausmann
7967bf1ab0 Replace the internal WindowHandleAccess trait with a helper function on WindowInner
The reversal of ownership removes the need for the glue trait in the
publicly visible API.
2022-09-06 16:17:06 +02:00
Olivier Goffart
f715a0c214 Try to fix the way the window is resized
- We must first set change the constraints before changing the size
   otherwise the new size might not be in the old constraint and the
   change might not take effect.

 - We must update the WindowItem's size even if the size of the window
   doesn't change. This happens when a component is set on a window that
   that doesn't change it size (eg, preview) but for which we need to
   set the geometry on the window
2022-09-05 16:19:27 +02:00
Simon Hausmann
7e5de3d5d3 Remove use of euclid types and tags for logical/physical position and size in the public API
Instead provide our own types.
2022-09-02 11:05:53 +02:00
Simon Hausmann
85461d380d Remove euclid from the public re-export of the Slint crate 2022-09-02 11:05:53 +02:00
Olivier Goffart
b9c2dec922 API: seal the WindowAdaptor trait
And hide most of its functions in the sealed trait.
2022-08-30 22:21:24 +02:00
Tobias Hunger
0daa2513af API cleanup: Rename PointerEvent to WindowEvent
Also rename members and related functions as specified in #1543.

Fixes: #1543
2022-08-30 16:47:55 +02:00
Tobias Hunger
88cf874d03 API cleanup: Rename create_window to create_window_adapter 2022-08-29 16:53:47 +02:00
Tobias Hunger
1e6ffeaa0f API cleanup: Rename PlatformWindow to WindowAdapter 2022-08-29 16:53:47 +02:00
Tobias Hunger
53053683a1 API cleanup: Rename PlatformAbstraction to Platform 2022-08-29 13:26:36 +02:00
Tobias Hunger
3557e92a84 API cleanup: Fix typos in comments/documentation 2022-08-29 13:26:36 +02:00
Olivier Goffart
13c9c3bbab Re-export the platform module as public api in slint::platform
Tweek some documentation
2022-08-24 14:28:51 +02:00
Olivier Goffart
dbd9f00c71 Don't call invoke_from_event_loop in doctests
The test backend can no longer support this.

Because Tests might be called from different thread and the backend with
an event loop can only be set on one thread. So the test backend can't
implement new_event_loop_proxy()
2022-08-24 11:32:21 +02:00
Olivier Goffart
7417422e3c Make the PlatformAbstraction not Send using a EventLoopProxy trait
This changes the way the platform abstraction is initialized
2022-08-24 11:32:21 +02:00
Olivier Goffart
2e5ab86bea Rename backend module to platform
and the Backend trait into PlatfromAbstraction trait
2022-08-23 19:39:49 +02:00
Olivier Goffart
a326844948 Move the has_active_animation to the window 2022-08-22 14:41:50 +02:00
Simon Hausmann
af86f36157 Invert slint:🪟:WindowInner and PlatformWindow ownership
Previously: Window is an Rc<WindowInner>, which has an Rc<dyn
PLatformWindow> - and weak references the other way around.

Now: Rc<dyn PlatformWindow> is the root of window ownership. The impl
PlatformWindow has a slint::api::Window, which just holds a WindowInner.

This change is incomplete on a few levels, mainly that neither of the
code generators nor the interpreter is ported.
2022-08-19 15:07:27 +02:00
Olivier Goffart
02c60e5389 Refactor the way the backend sets the window size 2022-08-18 09:39:25 +02:00
Olivier Goffart
16985a349d Add dispatch_pointer_event to the public API 2022-08-17 18:28:12 +02:00
Simon Hausmann
351a1b6448 Move set_rendering_notifier from the (to be public) PlatformWindow to the (private) Renderer trait 2022-08-10 13:07:07 +02:00
Simon Hausmann
0ee361d994 winit: Remove unused existing_size field
This field duplicates the winit window's inner size. It is set on a
WindowEvent::Resized(), after which
`winit:🪟:Window::inner_size()` returns the same value.
2022-08-09 13:16:52 +02:00
Olivier Goffart
29404e3f2c Rename i_slint_core:🪟:Window into WindowInner
We already have `api::Window` and also the Window element (`WindowItem`),
So rename the inner part to avoid confusion
2022-07-22 18:12:00 +02:00
Simon Hausmann
937c37677e Add API for setting and getting the size of a Window in Rust and C++ 2022-07-08 18:37:01 +02:00
Simon Hausmann
3ce9977f0a Add slint::Window::(set_)position
Fixes #323
2022-07-08 18:37:01 +02:00
Olivier Goffart
ca5151de11 C++: implement Window::on_close_requested 2022-03-17 14:49:12 +01:00
Lukas Jung
9a0f67575b remove redundant sentence in doc for on_close_requested()
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
2022-03-17 08:51:00 +01:00
Lukas Jung
e6b39aea40 remove unnecessary derive macros from CloseRequestResponse 2022-03-17 08:51:00 +01:00
Lukas Jung
0046c1a754 run rustfmt on api.rs and window.rs 2022-03-17 08:51:00 +01:00
Lukas Jung
17066615bb remove mut from on_close_requested() to remove warning 2022-03-17 08:51:00 +01:00
Lukas Jung
3ce937f4df Add documentation to functions for close callback handling 2022-03-17 08:51:00 +01:00
Lukas Jung
a7e798842a add close_requested() closure and request_close() function to Window 2022-03-17 08:51:00 +01:00