Commit graph

249 commits

Author SHA1 Message Date
Simon Hausmann
7ff7c2f875 Fix let-else formatting
Nightly now supports it and thus `cargo +nightly fmt` yields a
difference.
2023-07-28 13:43:21 +02:00
Olivier Goffart
d43d24ec7e Un-hide the renderer() function from the WindowAdapter
Now that the SoftwareRenderer can be constructed, it is
finally possible to have your own WindowAdapter

Revert "Hide the `renderer()` function from the public API"

This reverts commit ff6653c77e.
2023-07-27 14:44:28 +02:00
Olivier Goffart
49485dbf7d SoftwareRenderer: add API to construct and change the buffer type 2023-07-27 14:44:28 +02:00
Simon Hausmann
af97435463 Replace show()/hide() in the WindowAdapter with set_visible(bool)
This makes for a smaller interface.
2023-07-26 13:53:45 +02:00
Simon Hausmann
c05ee8b87d Fix empty window test
When render() is called on an renderer that's not associated with a component yet,
then just return a default constructed region.
2023-07-25 17:28:08 +02:00
Simon Hausmann
7d136b6568 Remove the window parameter from the render() function of all the renderers
This makes for a slimmer API and instead we can create the renderer <-> window association
behind the scenes ourselves,
in set_component.
2023-07-25 17:28:08 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +02:00
Simon Hausmann
279c143d31 Clarify request_redraw() docs in the WindowAdapter 2023-06-22 22:31:51 +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
Olivier Goffart
4dd10f4a78 Make WindowAdaptor::request_redraw public 2023-06-13 20:29:52 +02:00
Olivier Goffart
ff6653c77e Hide the renderer() function from the public API 2023-06-13 17:44:04 +02:00
Olivier Goffart
0e31f097a4 Un-seal the WindowAdapter trait 2023-06-13 17:44:04 +02:00
Olivier Goffart
23b910725f Rename WindowAdapterSealed to WindowAdapterInternal 2023-06-13 17:44:04 +02:00
Olivier Goffart
6341769cbd WindowAdaptor: move a few function to the public trait
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
2023-06-13 17:44:04 +02:00
Olivier Goffart
5f84cd5a90 Change the return type of WindowAdapterSealed::position to be an Option 2023-06-12 19:25:33 +02:00
Olivier Goffart
facb471d9b Update a comment 2023-06-12 19:25:33 +02:00
Simon Hausmann
0f54b9599b Add support for manually closing PopupWindows
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.
2023-06-02 18:07:49 +02:00
Simon Hausmann
e3e9131dc3
Fix panic when attempting to render window contents without a component (#2800)
With Qt and eglfs it may happen that when creating a popup, Qt delivers
a paint event via show() before we've had a chance to set the component
on the slint::Window. In that case unwrapping the component in
draw_contents() panics.

This fix is covered by reproducing the same scenario using public
MinimalSoftwareWindow API.

Fixes #2799

Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2023-06-01 12:40:01 +02:00
Olivier Goffart
dd5ef9993f
Platform: Add a Resized event and use that to convey the changes in size (#2759) 2023-05-21 12:12:30 +02:00
Simon Hausmann
846c48b81d Add public API to allow platforms to report the window scale factor
Add WindowEvent::ScaleFactorChanged and made set_scale_factor on
WindowInner private.

This achieves what #2486 tried to do, but using the clean platform
window event interface.
2023-05-19 17:06:38 +02:00
Olivier Goffart
a68df6eb70
WindowAdaptor: change the 3 ime call into one single ime request enum (#2747) 2023-05-17 17:50:19 +02:00
Olivier Goffart
e3ecb5979c Simplify the way the window properties are applied 2023-05-17 10:22:54 +02:00
Simon Hausmann
7df902b53c winit: Create a winit window at renderer creation time
This simplifies the logic for how to apply window related requests as
they can be applied to the winit window immediately.

It also simplifies the state handling in the WinitWindowAdapter, as
there's no more distinction between mapped and unmapped. We always map
now (winit does).

One related change in core is that the window properties are now sent to
the backend before calling show(), instead of after.
2023-05-11 10:42:09 +02:00
Amirhossein Akhlaghpour
2e8708be87
Feature: Add copy/paste listener on Wasm (#2703) 2023-05-09 15:55:35 +02:00
Simon Hausmann
da7748c518 Add some internal comments to WindowAdapterSealed
These are the result of a discussion on how to make it public in the future.
2023-04-26 15:30:11 +02:00
Simon Hausmann
4d502a9f96 Add a C++ version of the Virtual Keyboard example 2023-04-14 11:39:02 +02:00
Florian Blasius
bcb9d1ef83
virtual keyboard example (#2490)
* Update examples/virtual_keyboard/rust/Cargo.toml

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update internal/core/window.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update internal/core/api.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update internal/core/api.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update internal/core/api.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* Update internal/core/api.rs

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>

* code review fixes

---------

Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2023-04-13 08:36:40 +02:00
Olivier Goffart
a57c7eb6bc Added TextInputInterface.text-input-focused 2023-04-12 14:49:08 +02:00
Olivier Goffart
b565eb8820 Merge all the pinned field of the window in a common allocation 2023-04-12 14:49:08 +02:00
Simon Hausmann
8ffb5131c7
Introduce error handling in the FemtoVG and Skia renderers (#2402)
Avoid unwrap() and expect() and instead propagate errors all the way
down to run_event_loop(), show(), and hide() in the Slint AIP.
2023-03-24 14:18:11 +01:00
Tobias Hunger
3ac01c3f07 clippy: Fix clippy warnings 2023-03-09 09:35:29 +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
Olivier Goffart
96c17e9563 TextImput: Shift+Click selects 2023-02-06 09:14:29 +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
33d68687c2 Fix key input not working after loss of focus due to global shortcut
When a global shortcut, like ^-Cmd-Q on macOS to lock the screen, causes
a loss of window focus, we'll receive a key event from the windowing
system for the modifier, but we'll never receive the "Q" in this example
(as press or release). So later, when we regain focus, we'd assume that
our keyboard modifier state is still "pressed ^/Cmd", which is
incorrect. Therefore assume that a loss of window focus implies a reset
keyboard of keyboard modifier state.

Fixes #2098
2023-01-23 14:07:57 +01:00
Olivier Goffart
8d686637f4
Experimental platform API from C++ 2022-12-12 12:54:31 +01:00
Simon Hausmann
b2ebac63c2 Remove component_destroyed from winit's internal renderer interface
The default impl of unregister_component in WindowAdapterSealed would call free_graphics_resources
on the rendere. Any re-implementation would have to do the same,
which the winit backend forwarded through
the winit backend specific internal renderer interface.

Instead, the original call site for unregister_component now calls
free_graphics_resources and unregister_component (for accessibility tree dirty notification).
2022-12-09 09:03:27 +01:00
Simon Hausmann
f5bbca9fce Remove default_font_size() from internal winit renderer interface
Replace register_root_component in the WindowAdapterSealed altogether with
a default font size getter on the renderer.

This is overall simpler and allows removing the doc-hidden getter in the software renderer.
2022-12-09 09:03:27 +01:00
Tobias Hunger
47300a7495
janitor: Fix clippy errors (#1895)
* janitor: Fix clippy error drop_copy

Clippy says cache_entry is Copy, so calling drop on it is useless since
it will drop a copied value.

* janitor: Fix clippy error

... about cloning a double ref.

Co-authored-by: Olivier Goffart <olivier@woboq.com>
2022-11-23 15:06:07 +01:00
Olivier Goffart
0d39e6f721 Make use of ItemRc::map_to_window 2022-11-17 12:23:23 +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
Simon Hausmann
39121994ca Always set Window.default-font-size
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
2022-11-03 17:15:44 +01:00
Simon Hausmann
a95504ad4f Remove stray and duplicated call to request_window_properties() 2022-11-03 17:15:44 +01:00
Simon Hausmann
63cd49fb46 Use LogicalPoint for the internal popup location 2022-11-01 12:15:51 +01:00
Simon Hausmann
64588c70f1 Make popup related data structures internal to the window module 2022-11-01 12:15:51 +01:00
Simon Hausmann
b835290f83 Use LogicalRect for the geometry of popups in WindowAdapterSealed 2022-11-01 12:15:51 +01:00
David John
82278a5742 api: add Window::is_visible 2022-10-29 09:21:26 +02:00