API cleanup: Rename PlatformWindow to WindowAdapter

This commit is contained in:
Tobias Hunger 2022-08-29 12:17:41 +02:00 committed by Tobias Hunger
parent 344f5c437b
commit 1e6ffeaa0f
50 changed files with 600 additions and 604 deletions

View file

@ -135,7 +135,7 @@ fn gen_corelib(
config.export.include = [ config.export.include = [
"ComponentVTable", "ComponentVTable",
"Slice", "Slice",
"PlatformWindowRcOpaque", "WindowAdapterRcOpaque",
"PropertyAnimation", "PropertyAnimation",
"EasingCurve", "EasingCurve",
"TextHorizontalAlignment", "TextHorizontalAlignment",
@ -189,7 +189,7 @@ fn gen_corelib(
"slint_property_listener_scope_is_dirty", "slint_property_listener_scope_is_dirty",
"PropertyTrackerOpaque", "PropertyTrackerOpaque",
"CallbackOpaque", "CallbackOpaque",
"PlatformWindowRc", "WindowAdapterRc",
"VoidArg", "VoidArg",
"KeyEventArg", "KeyEventArg",
"PointerEventArg", "PointerEventArg",
@ -453,9 +453,9 @@ fn gen_corelib(
.with_after_include( .with_after_include(
r" r"
namespace slint { namespace slint {
namespace private_api { class PlatformWindowRc; } namespace private_api { class WindowAdapterRc; }
namespace cbindgen_private { namespace cbindgen_private {
using slint::private_api::PlatformWindowRc; using slint::private_api::WindowAdapterRc;
using namespace vtable; using namespace vtable;
struct KeyEvent; struct PointerEvent; struct KeyEvent; struct PointerEvent;
using private_api::Property; using private_api::Property;

View file

@ -83,23 +83,23 @@ inline void assert_main_thread()
#endif #endif
} }
class PlatformWindowRc class WindowAdapterRc
{ {
public: public:
explicit PlatformWindowRc(cbindgen_private::PlatformWindowRcOpaque adopted_inner) explicit WindowAdapterRc(cbindgen_private::WindowAdapterRcOpaque adopted_inner)
: inner(adopted_inner) : inner(adopted_inner)
{ {
} }
PlatformWindowRc() { cbindgen_private::slint_windowrc_init(&inner); } WindowAdapterRc() { cbindgen_private::slint_windowrc_init(&inner); }
~PlatformWindowRc() { cbindgen_private::slint_windowrc_drop(&inner); } ~WindowAdapterRc() { cbindgen_private::slint_windowrc_drop(&inner); }
PlatformWindowRc(const PlatformWindowRc &other) WindowAdapterRc(const WindowAdapterRc &other)
{ {
assert_main_thread(); assert_main_thread();
cbindgen_private::slint_windowrc_clone(&other.inner, &inner); cbindgen_private::slint_windowrc_clone(&other.inner, &inner);
} }
PlatformWindowRc(PlatformWindowRc &&) = delete; WindowAdapterRc(WindowAdapterRc &&) = delete;
PlatformWindowRc &operator=(PlatformWindowRc &&) = delete; WindowAdapterRc &operator=(WindowAdapterRc &&) = delete;
PlatformWindowRc &operator=(const PlatformWindowRc &other) WindowAdapterRc &operator=(const WindowAdapterRc &other)
{ {
assert_main_thread(); assert_main_thread();
if (this != &other) { if (this != &other) {
@ -226,7 +226,7 @@ public:
} }
private: private:
cbindgen_private::PlatformWindowRcOpaque inner; cbindgen_private::WindowAdapterRcOpaque inner;
}; };
constexpr inline ItemTreeNode make_item_node(uint32_t child_count, uint32_t child_index, constexpr inline ItemTreeNode make_item_node(uint32_t child_count, uint32_t child_index,
@ -374,7 +374,7 @@ public:
/// \private /// \private
/// Internal function used by the generated code to construct a new instance of this /// Internal function used by the generated code to construct a new instance of this
/// public API wrapper. /// public API wrapper.
explicit Window(const private_api::PlatformWindowRc &windowrc) : inner(windowrc) { } explicit Window(const private_api::WindowAdapterRc &windowrc) : inner(windowrc) { }
Window(const Window &other) = delete; Window(const Window &other) = delete;
Window &operator=(const Window &other) = delete; Window &operator=(const Window &other) = delete;
Window(Window &&other) = delete; Window(Window &&other) = delete;
@ -432,12 +432,12 @@ public:
void set_size(const slint::Size<unsigned int> &size) { inner.set_size(size); } void set_size(const slint::Size<unsigned int> &size) { inner.set_size(size); }
/// \private /// \private
private_api::PlatformWindowRc &window_handle() { return inner; } private_api::WindowAdapterRc &window_handle() { return inner; }
/// \private /// \private
const private_api::PlatformWindowRc &window_handle() const { return inner; } const private_api::WindowAdapterRc &window_handle() const { return inner; }
private: private:
private_api::PlatformWindowRc inner; private_api::WindowAdapterRc inner;
}; };
/// A Timer that can call a callback at repeated interval /// A Timer that can call a callback at repeated interval

View file

@ -564,7 +564,7 @@ public:
/// such as the position on the screen. /// such as the position on the screen.
const slint::Window &window() const slint::Window &window()
{ {
const cbindgen_private::PlatformWindowRcOpaque *win_ptr = nullptr; const cbindgen_private::WindowAdapterRcOpaque *win_ptr = nullptr;
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr); cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
return *reinterpret_cast<const slint::Window *>(win_ptr); return *reinterpret_cast<const slint::Window *>(win_ptr);
} }
@ -582,10 +582,10 @@ public:
/// it may return nullptr if the Qt backend is not used at runtime. /// it may return nullptr if the Qt backend is not used at runtime.
QWidget *qwidget() const QWidget *qwidget() const
{ {
const cbindgen_private::PlatformWindowRcOpaque *win_ptr = nullptr; const cbindgen_private::WindowAdapterRcOpaque *win_ptr = nullptr;
cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr); cbindgen_private::slint_interpreter_component_instance_window(inner(), &win_ptr);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::slint_qt_get_widget( auto wid = reinterpret_cast<QWidget *>(cbindgen_private::slint_qt_get_widget(
reinterpret_cast<const cbindgen_private::PlatformWindowRc *>(win_ptr))); reinterpret_cast<const cbindgen_private::WindowAdapterRc *>(win_ptr)));
return wid; return wid;
} }
#endif #endif
@ -1010,10 +1010,10 @@ inline void send_keyboard_string_sequence(const slint::interpreter::ComponentIns
const slint::SharedString &str, const slint::SharedString &str,
KeyboardModifiers modifiers = {}) KeyboardModifiers modifiers = {})
{ {
const cbindgen_private::PlatformWindowRcOpaque *win_ptr = nullptr; const cbindgen_private::WindowAdapterRcOpaque *win_ptr = nullptr;
cbindgen_private::slint_interpreter_component_instance_window( cbindgen_private::slint_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr); reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
cbindgen_private::send_keyboard_string_sequence( cbindgen_private::send_keyboard_string_sequence(
&str, modifiers, reinterpret_cast<const cbindgen_private::PlatformWindowRc *>(win_ptr)); &str, modifiers, reinterpret_cast<const cbindgen_private::WindowAdapterRc *>(win_ptr));
} }
} }

View file

@ -4,7 +4,7 @@
/*! This crate just expose the function used by the C++ integration */ /*! This crate just expose the function used by the C++ integration */
use core::ffi::c_void; use core::ffi::c_void;
use i_slint_core::window::{ffi::PlatformWindowRcOpaque, PlatformWindow}; use i_slint_core::window::{ffi::WindowAdapterRcOpaque, WindowAdapter};
use std::rc::Rc; use std::rc::Rc;
#[doc(hidden)] #[doc(hidden)]
@ -17,13 +17,13 @@ pub fn use_modules() -> usize {
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_init(out: *mut PlatformWindowRcOpaque) { pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowAdapterRcOpaque) {
assert_eq!( assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(), core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<PlatformWindowRcOpaque>() core::mem::size_of::<WindowAdapterRcOpaque>()
); );
let win = i_slint_backend_selector::with_platform_abstraction(|b| b.create_window()); let win = i_slint_backend_selector::with_platform_abstraction(|b| b.create_window());
core::ptr::write(out as *mut Rc<dyn PlatformWindow>, win); core::ptr::write(out as *mut Rc<dyn WindowAdapter>, win);
} }
#[no_mangle] #[no_mangle]
@ -67,16 +67,14 @@ pub unsafe extern "C" fn slint_quit_event_loop() {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_register_font_from_path( pub unsafe extern "C" fn slint_register_font_from_path(
win: *const PlatformWindowRcOpaque, win: *const WindowAdapterRcOpaque,
path: &i_slint_core::SharedString, path: &i_slint_core::SharedString,
error_str: *mut i_slint_core::SharedString, error_str: *mut i_slint_core::SharedString,
) { ) {
let platform_window = &*(win as *const Rc<dyn PlatformWindow>); let window_adapter = &*(win as *const Rc<dyn WindowAdapter>);
core::ptr::write( core::ptr::write(
error_str, error_str,
match platform_window match window_adapter.renderer().register_font_from_path(std::path::Path::new(path.as_str()))
.renderer()
.register_font_from_path(std::path::Path::new(path.as_str()))
{ {
Ok(()) => Default::default(), Ok(()) => Default::default(),
Err(err) => err.to_string().into(), Err(err) => err.to_string().into(),
@ -86,14 +84,14 @@ pub unsafe extern "C" fn slint_register_font_from_path(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_register_font_from_data( pub unsafe extern "C" fn slint_register_font_from_data(
win: *const PlatformWindowRcOpaque, win: *const WindowAdapterRcOpaque,
data: i_slint_core::slice::Slice<'static, u8>, data: i_slint_core::slice::Slice<'static, u8>,
error_str: *mut i_slint_core::SharedString, error_str: *mut i_slint_core::SharedString,
) { ) {
let platform_window = &*(win as *const Rc<dyn PlatformWindow>); let window_adapter = &*(win as *const Rc<dyn WindowAdapter>);
core::ptr::write( core::ptr::write(
error_str, error_str,
match platform_window.renderer().register_font_from_memory(data.as_slice()) { match window_adapter.renderer().register_font_from_memory(data.as_slice()) {
Ok(()) => Default::default(), Ok(()) => Default::default(),
Err(err) => err.to_string().into(), Err(err) => err.to_string().into(),
}, },

View file

@ -15,7 +15,7 @@ mod persistent_context;
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>); struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>); struct WrappedComponentRc(Option<slint_interpreter::ComponentInstance>);
struct WrappedWindow(Option<std::rc::Rc<dyn i_slint_core::window::PlatformWindow>>); struct WrappedWindow(Option<std::rc::Rc<dyn i_slint_core::window::WindowAdapter>>);
/// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime /// We need to do some gymnastic with closures to pass the ExecuteContext with the right lifetime
type GlobalContextCallback<'c> = type GlobalContextCallback<'c> =
@ -352,9 +352,9 @@ declare_types! {
let this = cx.this(); let this = cx.this();
let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong())); let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong()));
let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?; let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
let platform_window = component.window().window_handle().platform_window(); let window_adapter = component.window().window_handle().window_adapter();
let mut obj = SlintWindow::new::<_, JsValue, _>(&mut cx, std::iter::empty())?; let mut obj = SlintWindow::new::<_, JsValue, _>(&mut cx, std::iter::empty())?;
cx.borrow_mut(&mut obj, |mut obj| obj.0 = Some(platform_window)); cx.borrow_mut(&mut obj, |mut obj| obj.0 = Some(window_adapter));
Ok(obj.as_value(&mut cx)) Ok(obj.as_value(&mut cx))
} }
method get_property(mut cx) { method get_property(mut cx) {
@ -534,9 +534,9 @@ declare_types! {
method get_size(mut cx) { method get_size(mut cx) {
let this = cx.this(); let this = cx.this();
let platform_window = cx.borrow(&this, |x| x.0.as_ref().cloned()); let window_adapter = cx.borrow(&this, |x| x.0.as_ref().cloned());
let platform_window = platform_window.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?; let window_adapter = window_adapter.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
let size = platform_window.window().size(); let size = window_adapter.window().size();
let size_object = JsObject::new(&mut cx); let size_object = JsObject::new(&mut cx);
let width_value = JsNumber::new(&mut cx, size.width).as_value(&mut cx); let width_value = JsNumber::new(&mut cx, size.width).as_value(&mut cx);
@ -548,9 +548,9 @@ declare_types! {
method set_size(mut cx) { method set_size(mut cx) {
let this = cx.this(); let this = cx.this();
let platform_window = cx.borrow(&this, |x| x.0.as_ref().cloned()); let window_adapter = cx.borrow(&this, |x| x.0.as_ref().cloned());
let platform_window = platform_window.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?; let window_adapter = window_adapter.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
let window = platform_window.window(); let window = window_adapter.window();
let size_object = cx.argument::<JsObject>(0)?; let size_object = cx.argument::<JsObject>(0)?;
let width = size_object.get(&mut cx, "width")?.downcast_or_throw::<JsNumber, _>(&mut cx)?.value(); let width = size_object.get(&mut cx, "width")?.downcast_or_throw::<JsNumber, _>(&mut cx)?.value();

View file

@ -284,7 +284,7 @@ pub mod re_exports {
pub use i_slint_core::model::*; pub use i_slint_core::model::*;
pub use i_slint_core::properties::{set_state_binding, Property, PropertyTracker, StateInfo}; pub use i_slint_core::properties::{set_state_binding, Property, PropertyTracker, StateInfo};
pub use i_slint_core::slice::Slice; pub use i_slint_core::slice::Slice;
pub use i_slint_core::window::{PlatformWindow, WindowHandleAccess, WindowInner}; pub use i_slint_core::window::{WindowAdapter, WindowHandleAccess, WindowInner};
pub use i_slint_core::Color; pub use i_slint_core::Color;
pub use i_slint_core::ComponentVTable_static; pub use i_slint_core::ComponentVTable_static;
pub use i_slint_core::Coord; pub use i_slint_core::Coord;
@ -435,7 +435,7 @@ pub mod internal {
/// Creates a new window to render components in. /// Creates a new window to render components in.
#[doc(hidden)] #[doc(hidden)]
pub fn create_window() -> alloc::rc::Rc<dyn re_exports::PlatformWindow> { pub fn create_window() -> alloc::rc::Rc<dyn re_exports::WindowAdapter> {
i_slint_backend_selector::with_platform_abstraction(|b| b.create_window()) i_slint_backend_selector::with_platform_abstraction(|b| b.create_window())
} }
@ -474,7 +474,7 @@ pub mod testing {
&dyn_rc, &dyn_rc,
x, x,
y, y,
&rc.window_handle().platform_window(), &rc.window_handle().window_adapter(),
); );
} }
@ -503,7 +503,7 @@ pub mod testing {
i_slint_core::tests::send_keyboard_string_sequence( i_slint_core::tests::send_keyboard_string_sequence(
&super::SharedString::from(sequence), &super::SharedString::from(sequence),
KEYBOARD_MODIFIERS.with(|x| x.get()), KEYBOARD_MODIFIERS.with(|x| x.get()),
&component.window_handle().platform_window(), &component.window_handle().window_adapter(),
) )
} }

View file

@ -67,7 +67,7 @@ struct PicoBackend {
window: RefCell<Option<Rc<PicoWindow>>>, window: RefCell<Option<Rc<PicoWindow>>>,
} }
impl slint::platform::Platform for PicoBackend { impl slint::platform::Platform for PicoBackend {
fn create_window(&self) -> Rc<dyn slint::platform::PlatformWindow> { fn create_window(&self) -> Rc<dyn slint::platform::WindowAdapter> {
let window = Rc::new_cyclic(|self_weak: &Weak<PicoWindow>| PicoWindow { let window = Rc::new_cyclic(|self_weak: &Weak<PicoWindow>| PicoWindow {
window: slint::Window::new(self_weak.clone()), window: slint::Window::new(self_weak.clone()),
renderer: renderer::SoftwareRenderer::new(self_weak.clone()), renderer: renderer::SoftwareRenderer::new(self_weak.clone()),
@ -285,7 +285,7 @@ struct PicoWindow {
needs_redraw: Cell<bool>, needs_redraw: Cell<bool>,
} }
impl slint::platform::PlatformWindow for PicoWindow { impl slint::platform::WindowAdapter for PicoWindow {
fn show(&self) { fn show(&self) {
self.window.set_size(DISPLAY_SIZE.cast()); self.window.set_size(DISPLAY_SIZE.cast());
} }

View file

@ -51,7 +51,7 @@ struct StmBackend {
timer: once_cell::unsync::OnceCell<hal::timer::Timer<pac::TIM2>>, timer: once_cell::unsync::OnceCell<hal::timer::Timer<pac::TIM2>>,
} }
impl slint::platform::Platform for StmBackend { impl slint::platform::Platform for StmBackend {
fn create_window(&self) -> Rc<dyn slint::platform::PlatformWindow> { fn create_window(&self) -> Rc<dyn slint::platform::WindowAdapter> {
let window = Rc::new_cyclic(|self_weak: &Weak<StmWindow>| StmWindow { let window = Rc::new_cyclic(|self_weak: &Weak<StmWindow>| StmWindow {
window: slint::Window::new(self_weak.clone()), window: slint::Window::new(self_weak.clone()),
renderer: swrenderer::SoftwareRenderer::new(self_weak.clone()), renderer: swrenderer::SoftwareRenderer::new(self_weak.clone()),
@ -372,7 +372,7 @@ struct StmWindow {
needs_redraw: core::cell::Cell<bool>, needs_redraw: core::cell::Cell<bool>,
} }
impl slint::platform::PlatformWindow for StmWindow { impl slint::platform::WindowAdapter for StmWindow {
fn show(&self) { fn show(&self) {
self.window.set_size((DISPLAY_WIDTH as u32, DISPLAY_HEIGHT as u32).into()); self.window.set_size((DISPLAY_WIDTH as u32, DISPLAY_HEIGHT as u32).into());
} }

View file

@ -40,7 +40,7 @@ pub fn use_modules() -> usize {
mod ffi { mod ffi {
#[no_mangle] #[no_mangle]
pub extern "C" fn slint_qt_get_widget( pub extern "C" fn slint_qt_get_widget(
_: &i_slint_core::window::PlatformWindowRc, _: &i_slint_core::window::WindowAdapterRc,
) -> *mut std::ffi::c_void { ) -> *mut std::ffi::c_void {
std::ptr::null_mut() std::ptr::null_mut()
} }
@ -137,7 +137,7 @@ pub fn native_style_metrics_deinit(_: core::pin::Pin<&mut native_widgets::Native
pub struct Backend; pub struct Backend;
impl i_slint_core::platform::Platform for Backend { impl i_slint_core::platform::Platform for Backend {
fn create_window(&self) -> Rc<dyn i_slint_core::window::PlatformWindow> { fn create_window(&self) -> Rc<dyn i_slint_core::window::WindowAdapter> {
#[cfg(no_qt)] #[cfg(no_qt)]
panic!("The Qt backend needs Qt"); panic!("The Qt backend needs Qt");
#[cfg(not(no_qt))] #[cfg(not(no_qt))]

View file

@ -31,7 +31,7 @@ use i_slint_core::items::{Item, ItemConsts, ItemRc, ItemVTable, RenderingResult,
use i_slint_core::layout::{LayoutInfo, Orientation}; use i_slint_core::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use i_slint_core::rtti::*; use i_slint_core::rtti::*;
use i_slint_core::window::{PlatformWindow, PlatformWindowRc, WindowHandleAccess}; use i_slint_core::window::{WindowAdapter, WindowAdapterRc, WindowHandleAccess};
use i_slint_core::{ use i_slint_core::{
declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector, declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector,
}; };

View file

@ -188,7 +188,7 @@ impl NativeButton {
} }
impl Item for NativeButton { impl Item for NativeButton {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -197,7 +197,7 @@ impl Item for NativeButton {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let standard_button_kind = self.actual_standard_button_kind(); let standard_button_kind = self.actual_standard_button_kind();
let mut text: qttypes::QString = self.actual_text(standard_button_kind); let mut text: qttypes::QString = self.actual_text(standard_button_kind);
@ -233,7 +233,7 @@ impl Item for NativeButton {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -242,7 +242,7 @@ impl Item for NativeButton {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let enabled = self.enabled(); let enabled = self.enabled();
@ -275,7 +275,7 @@ impl Item for NativeButton {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &KeyEvent, event: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
match event.event_type { match event.event_type {
KeyEventType::KeyPressed if event.text == " " || event.text == "\n" => { KeyEventType::KeyPressed if event.text == " " || event.text == "\n" => {
@ -294,7 +294,7 @@ impl Item for NativeButton {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &FocusEvent, event: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
if self.enabled() { if self.enabled() {
Self::FIELD_OFFSETS Self::FIELD_OFFSETS

View file

@ -22,7 +22,7 @@ pub struct NativeCheckBox {
} }
impl Item for NativeCheckBox { impl Item for NativeCheckBox {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -31,7 +31,7 @@ impl Item for NativeCheckBox {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let text: qttypes::QString = self.text().as_str().into(); let text: qttypes::QString = self.text().as_str().into();
let size = cpp!(unsafe [ let size = cpp!(unsafe [
@ -58,7 +58,7 @@ impl Item for NativeCheckBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -67,7 +67,7 @@ impl Item for NativeCheckBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if !self.enabled() { if !self.enabled() {
@ -85,7 +85,7 @@ impl Item for NativeCheckBox {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &KeyEvent, event: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
match event.event_type { match event.event_type {
KeyEventType::KeyPressed if event.text == " " || event.text == "\n" => { KeyEventType::KeyPressed if event.text == " " || event.text == "\n" => {
@ -101,7 +101,7 @@ impl Item for NativeCheckBox {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &FocusEvent, event: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
if self.enabled() { if self.enabled() {
Self::FIELD_OFFSETS Self::FIELD_OFFSETS

View file

@ -22,7 +22,7 @@ pub struct NativeComboBox {
} }
impl Item for NativeComboBox { impl Item for NativeComboBox {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -31,7 +31,7 @@ impl Item for NativeComboBox {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let size = cpp!(unsafe [] -> qttypes::QSize as "QSize" { let size = cpp!(unsafe [] -> qttypes::QSize as "QSize" {
ensure_initialized(); ensure_initialized();
@ -53,7 +53,7 @@ impl Item for NativeComboBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -62,7 +62,7 @@ impl Item for NativeComboBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let enabled = self.enabled(); let enabled = self.enabled();
@ -95,7 +95,7 @@ impl Item for NativeComboBox {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -103,7 +103,7 @@ impl Item for NativeComboBox {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -171,7 +171,7 @@ pub struct NativeComboBoxPopup {
} }
impl Item for NativeComboBoxPopup { impl Item for NativeComboBoxPopup {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -180,7 +180,7 @@ impl Item for NativeComboBoxPopup {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
Default::default() Default::default()
} }
@ -188,7 +188,7 @@ impl Item for NativeComboBoxPopup {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -197,7 +197,7 @@ impl Item for NativeComboBoxPopup {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -206,7 +206,7 @@ impl Item for NativeComboBoxPopup {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -214,7 +214,7 @@ impl Item for NativeComboBoxPopup {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -62,7 +62,7 @@ fn minimum_group_box_size(title: qttypes::QString) -> qttypes::QSize {
} }
impl Item for NativeGroupBox { impl Item for NativeGroupBox {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) { fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {
let shared_data = Rc::pin(GroupBoxData::default()); let shared_data = Rc::pin(GroupBoxData::default());
Property::link_two_way( Property::link_two_way(
@ -146,7 +146,7 @@ impl Item for NativeGroupBox {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let text: qttypes::QString = self.title().as_str().into(); let text: qttypes::QString = self.title().as_str().into();
@ -165,7 +165,7 @@ impl Item for NativeGroupBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -174,7 +174,7 @@ impl Item for NativeGroupBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -183,7 +183,7 @@ impl Item for NativeGroupBox {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -191,7 +191,7 @@ impl Item for NativeGroupBox {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -25,7 +25,7 @@ pub struct NativeLineEdit {
} }
impl Item for NativeLineEdit { impl Item for NativeLineEdit {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) { fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {
let paddings = Rc::pin(Property::default()); let paddings = Rc::pin(Property::default());
paddings.as_ref().set_binding(move || { paddings.as_ref().set_binding(move || {
@ -76,7 +76,7 @@ impl Item for NativeLineEdit {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { LayoutInfo {
min: match orientation { min: match orientation {
@ -91,7 +91,7 @@ impl Item for NativeLineEdit {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -100,7 +100,7 @@ impl Item for NativeLineEdit {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -109,7 +109,7 @@ impl Item for NativeLineEdit {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -117,7 +117,7 @@ impl Item for NativeLineEdit {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -21,7 +21,7 @@ pub struct NativeStandardListViewItem {
} }
impl Item for NativeStandardListViewItem { impl Item for NativeStandardListViewItem {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -30,7 +30,7 @@ impl Item for NativeStandardListViewItem {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let index: i32 = self.index(); let index: i32 = self.index();
let item = self.item(); let item = self.item();
@ -64,7 +64,7 @@ impl Item for NativeStandardListViewItem {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -73,7 +73,7 @@ impl Item for NativeStandardListViewItem {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_event: MouseEvent, _event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -82,7 +82,7 @@ impl Item for NativeStandardListViewItem {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -90,7 +90,7 @@ impl Item for NativeStandardListViewItem {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -30,7 +30,7 @@ pub struct NativeScrollView {
} }
impl Item for NativeScrollView { impl Item for NativeScrollView {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) { fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {
let paddings = Rc::pin(Property::default()); let paddings = Rc::pin(Property::default());
paddings.as_ref().set_binding(move || { paddings.as_ref().set_binding(move || {
@ -88,7 +88,7 @@ impl Item for NativeScrollView {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { LayoutInfo {
min: match orientation { min: match orientation {
@ -103,7 +103,7 @@ impl Item for NativeScrollView {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -112,7 +112,7 @@ impl Item for NativeScrollView {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let size: qttypes::QSize = get_size!(self); let size: qttypes::QSize = get_size!(self);
@ -259,7 +259,7 @@ impl Item for NativeScrollView {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -267,7 +267,7 @@ impl Item for NativeScrollView {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -57,7 +57,7 @@ void initQSliderOptions(QStyleOptionSlider &option, bool pressed, bool enabled,
}} }}
impl Item for NativeSlider { impl Item for NativeSlider {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -66,7 +66,7 @@ impl Item for NativeSlider {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let enabled = self.enabled(); let enabled = self.enabled();
let value = self.value() as i32; let value = self.value() as i32;
@ -106,7 +106,7 @@ impl Item for NativeSlider {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -115,7 +115,7 @@ impl Item for NativeSlider {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let size: qttypes::QSize = get_size!(self); let size: qttypes::QSize = get_size!(self);
@ -197,7 +197,7 @@ impl Item for NativeSlider {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -205,7 +205,7 @@ impl Item for NativeSlider {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -54,7 +54,7 @@ option.frame = true;
}} }}
impl Item for NativeSpinBox { impl Item for NativeSpinBox {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -63,7 +63,7 @@ impl Item for NativeSpinBox {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
//let value: i32 = self.value(); //let value: i32 = self.value();
let data = self.data(); let data = self.data();
@ -108,7 +108,7 @@ impl Item for NativeSpinBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -117,7 +117,7 @@ impl Item for NativeSpinBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &i_slint_core::items::ItemRc, self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let size: qttypes::QSize = get_size!(self); let size: qttypes::QSize = get_size!(self);
@ -188,7 +188,7 @@ impl Item for NativeSpinBox {
if let MouseEvent::Pressed { .. } = event { if let MouseEvent::Pressed { .. } = event {
if !self.has_focus() { if !self.has_focus() {
platform_window.window().window_handle().set_focus_item(self_rc); window_adapter.window().window_handle().set_focus_item(self_rc);
} }
} }
InputEventResult::EventAccepted InputEventResult::EventAccepted
@ -197,7 +197,7 @@ impl Item for NativeSpinBox {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &KeyEvent, event: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
if !self.enabled() || event.event_type != KeyEventType::KeyPressed { if !self.enabled() || event.event_type != KeyEventType::KeyPressed {
return KeyEventResult::EventIgnored; return KeyEventResult::EventIgnored;
@ -220,7 +220,7 @@ impl Item for NativeSpinBox {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &FocusEvent, event: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
match event { match event {
FocusEvent::FocusIn => { FocusEvent::FocusIn => {

View file

@ -35,7 +35,7 @@ pub struct NativeTabWidget {
} }
impl Item for NativeTabWidget { impl Item for NativeTabWidget {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) { fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {
#[derive(Default, Clone)] #[derive(Default, Clone)]
#[repr(C)] #[repr(C)]
struct TabWidgetMetrics { struct TabWidgetMetrics {
@ -171,7 +171,7 @@ impl Item for NativeTabWidget {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let (content_size, tabbar_size) = match orientation { let (content_size, tabbar_size) = match orientation {
Orientation::Horizontal => ( Orientation::Horizontal => (
@ -227,7 +227,7 @@ impl Item for NativeTabWidget {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -236,7 +236,7 @@ impl Item for NativeTabWidget {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &i_slint_core::items::ItemRc, _self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -245,7 +245,7 @@ impl Item for NativeTabWidget {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -253,7 +253,7 @@ impl Item for NativeTabWidget {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -336,7 +336,7 @@ pub struct NativeTab {
} }
impl Item for NativeTab { impl Item for NativeTab {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -345,7 +345,7 @@ impl Item for NativeTab {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let text: qttypes::QString = self.title().as_str().into(); let text: qttypes::QString = self.title().as_str().into();
let icon: qttypes::QPixmap = let icon: qttypes::QPixmap =
@ -394,7 +394,7 @@ impl Item for NativeTab {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -403,7 +403,7 @@ impl Item for NativeTab {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &i_slint_core::items::ItemRc, self_rc: &i_slint_core::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let enabled = self.enabled(); let enabled = self.enabled();
@ -429,7 +429,7 @@ impl Item for NativeTab {
if matches!(event, MouseEvent::Released { .. } if !click_on_press) if matches!(event, MouseEvent::Released { .. } if !click_on_press)
|| matches!(event, MouseEvent::Pressed { .. } if click_on_press) || matches!(event, MouseEvent::Pressed { .. } if click_on_press)
{ {
platform_window.window().window_handle().set_focus_item(self_rc); window_adapter.window().window_handle().set_focus_item(self_rc);
self.current.set(self.tab_index()); self.current.set(self.tab_index());
InputEventResult::EventAccepted InputEventResult::EventAccepted
} else { } else {
@ -440,7 +440,7 @@ impl Item for NativeTab {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -448,7 +448,7 @@ impl Item for NativeTab {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -20,7 +20,7 @@ use i_slint_core::items::{
PointerEventButton, RenderingResult, TextOverflow, TextWrap, PointerEventButton, RenderingResult, TextOverflow, TextWrap,
}; };
use i_slint_core::layout::Orientation; use i_slint_core::layout::Orientation;
use i_slint_core::window::{PlatformWindow, WindowHandleAccess}; use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
use i_slint_core::{ImageInner, PathData, Property, SharedString}; use i_slint_core::{ImageInner, PathData, Property, SharedString};
use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment}; use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment};
@ -605,7 +605,7 @@ impl ItemRenderer for QtItemRenderer<'_> {
} }
let font: QFont = let font: QFont =
get_font(text_input.font_request(&self.window.window_handle().platform_window())); get_font(text_input.font_request(&self.window.window_handle().window_adapter()));
let flags = match text_input.horizontal_alignment() { let flags = match text_input.horizontal_alignment() {
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft, TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
TextHorizontalAlignment::Center => key_generated::Qt_AlignmentFlag_AlignHCenter, TextHorizontalAlignment::Center => key_generated::Qt_AlignmentFlag_AlignHCenter,
@ -1338,7 +1338,7 @@ impl QtWindow {
} }
#[allow(unused)] #[allow(unused)]
impl PlatformWindow for QtWindow { impl WindowAdapter for QtWindow {
fn show(&self) { fn show(&self) {
let component_rc = self.window.window_handle().component(); let component_rc = self.window.window_handle().component();
let component = ComponentRc::borrow_pin(&component_rc); let component = ComponentRc::borrow_pin(&component_rc);
@ -1479,7 +1479,7 @@ impl PlatformWindow for QtWindow {
self.tree_structure_changed.replace(true); self.tree_structure_changed.replace(true);
} }
fn create_popup(&self, geometry: Rect) -> Option<Rc<dyn PlatformWindow>> { fn create_popup(&self, geometry: Rect) -> Option<Rc<dyn WindowAdapter>> {
let popup_window = QtWindow::new(); let popup_window = QtWindow::new();
let size = qttypes::QSize { width: geometry.width() as _, height: geometry.height() as _ }; let size = qttypes::QSize { width: geometry.width() as _, height: geometry.height() as _ };
@ -1607,7 +1607,7 @@ impl Renderer for QtWindow {
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input); let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
let pos = qttypes::QPointF { x: pos.x as _, y: pos.y as _ }; let pos = qttypes::QPointF { x: pos.x as _, y: pos.y as _ };
let font: QFont = let font: QFont =
get_font(text_input.font_request(&self.window.window_handle().platform_window())); get_font(text_input.font_request(&self.window.window_handle().window_adapter()));
let string = qttypes::QString::from(text_input.text().as_str()); let string = qttypes::QString::from(text_input.text().as_str());
let flags = match text_input.horizontal_alignment() { let flags = match text_input.horizontal_alignment() {
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft, TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
@ -1663,7 +1663,7 @@ impl Renderer for QtWindow {
) -> Rect { ) -> Rect {
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input); let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
let font: QFont = let font: QFont =
get_font(text_input.font_request(&self.window.window_handle().platform_window())); get_font(text_input.font_request(&self.window.window_handle().window_adapter()));
let text = text_input.text(); let text = text_input.text();
let mut string = qttypes::QString::from(text.as_str()); let mut string = qttypes::QString::from(text.as_str());
let offset: u32 = utf8_byte_offset_to_utf16_units(text.as_str(), byte_offset) as _; let offset: u32 = utf8_byte_offset_to_utf16_units(text.as_str(), byte_offset) as _;
@ -1941,9 +1941,9 @@ pub(crate) mod ffi {
#[no_mangle] #[no_mangle]
pub extern "C" fn slint_qt_get_widget( pub extern "C" fn slint_qt_get_widget(
platform_window: &i_slint_core::window::PlatformWindowRc, window_adapter: &i_slint_core::window::WindowAdapterRc,
) -> *mut c_void { ) -> *mut c_void {
<dyn std::any::Any>::downcast_ref(platform_window.as_any()) <dyn std::any::Any>::downcast_ref(window_adapter.as_any())
.map_or(std::ptr::null_mut(), |win: &QtWindow| { .map_or(std::ptr::null_mut(), |win: &QtWindow| {
win.widget_ptr().cast::<c_void>().as_ptr() win.widget_ptr().cast::<c_void>().as_ptr()
}) })

View file

@ -8,7 +8,7 @@ use i_slint_core::api::euclid;
use i_slint_core::api::PhysicalPx; use i_slint_core::api::PhysicalPx;
use i_slint_core::graphics::{Point, Rect, Size}; use i_slint_core::graphics::{Point, Rect, Size};
use i_slint_core::renderer::Renderer; use i_slint_core::renderer::Renderer;
use i_slint_core::window::PlatformWindow; use i_slint_core::window::WindowAdapter;
use std::pin::Pin; use std::pin::Pin;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Mutex; use std::sync::Mutex;
@ -19,7 +19,7 @@ pub struct TestingBackend {
} }
impl i_slint_core::platform::Platform for TestingBackend { impl i_slint_core::platform::Platform for TestingBackend {
fn create_window(&self) -> Rc<dyn PlatformWindow> { fn create_window(&self) -> Rc<dyn WindowAdapter> {
Rc::new_cyclic(|self_weak| TestingWindow { Rc::new_cyclic(|self_weak| TestingWindow {
window: i_slint_core::api::Window::new(self_weak.clone() as _), window: i_slint_core::api::Window::new(self_weak.clone() as _),
}) })
@ -43,7 +43,7 @@ pub struct TestingWindow {
window: i_slint_core::api::Window, window: i_slint_core::api::Window,
} }
impl PlatformWindow for TestingWindow { impl WindowAdapter for TestingWindow {
fn show(&self) { fn show(&self) {
unimplemented!("showing a testing window") unimplemented!("showing a testing window")
} }

View file

@ -4,7 +4,7 @@
#![warn(missing_docs)] #![warn(missing_docs)]
/*! /*!
This module contains the event loop implementation using winit, as well as the This module contains the event loop implementation using winit, as well as the
[PlatformWindow] trait used by the generated code and the run-time to change [WindowAdapter] trait used by the generated code and the run-time to change
aspects of windows on the screen. aspects of windows on the screen.
*/ */
use copypasta::ClipboardProvider; use copypasta::ClipboardProvider;
@ -24,7 +24,7 @@ use winit::event::WindowEvent;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
use winit::platform::run_return::EventLoopExtRunReturn; use winit::platform::run_return::EventLoopExtRunReturn;
pub trait WinitWindow: PlatformWindow { pub trait WinitWindow: WindowAdapter {
fn currently_pressed_key_code(&self) -> &Cell<Option<winit::event::VirtualKeyCode>>; fn currently_pressed_key_code(&self) -> &Cell<Option<winit::event::VirtualKeyCode>>;
fn current_keyboard_modifiers(&self) -> &Cell<KeyboardModifiers>; fn current_keyboard_modifiers(&self) -> &Cell<KeyboardModifiers>;
fn draw(&self); fn draw(&self);

View file

@ -17,13 +17,13 @@ use corelib::component::ComponentRc;
use corelib::input::KeyboardModifiers; use corelib::input::KeyboardModifiers;
use corelib::items::{ItemRef, MouseCursor}; use corelib::items::{ItemRef, MouseCursor};
use corelib::layout::Orientation; use corelib::layout::Orientation;
use corelib::window::{PlatformWindow, WindowHandleAccess}; use corelib::window::{WindowAdapter, WindowHandleAccess};
use corelib::Property; use corelib::Property;
use corelib::{graphics::*, Coord}; use corelib::{graphics::*, Coord};
use i_slint_core as corelib; use i_slint_core as corelib;
use winit::dpi::LogicalSize; use winit::dpi::LogicalSize;
/// GraphicsWindow is an implementation of the [PlatformWindow][`crate::eventloop::PlatformWindow`] trait. This is /// GraphicsWindow is an implementation of the [WindowAdapter][`crate::eventloopMyWindowAdapter`] trait. This is
/// typically instantiated by entry factory functions of the different graphics back ends. /// typically instantiated by entry factory functions of the different graphics back ends.
pub(crate) struct GLWindow<Renderer: WinitCompatibleRenderer + 'static> { pub(crate) struct GLWindow<Renderer: WinitCompatibleRenderer + 'static> {
window: corelib::api::Window, window: corelib::api::Window,
@ -45,7 +45,7 @@ impl<Renderer: WinitCompatibleRenderer + 'static> GLWindow<Renderer> {
/// * `graphics_backend_factory`: The factor function stored in the GraphicsWindow that's called when the state /// * `graphics_backend_factory`: The factor function stored in the GraphicsWindow that's called when the state
/// of the window changes to mapped. The event loop and window builder parameters can be used to create a /// of the window changes to mapped. The event loop and window builder parameters can be used to create a
/// backing window. /// backing window.
pub(crate) fn new(#[cfg(target_arch = "wasm32")] canvas_id: String) -> Rc<dyn PlatformWindow> { pub(crate) fn new(#[cfg(target_arch = "wasm32")] canvas_id: String) -> Rc<dyn WindowAdapter> {
let self_rc = Rc::new_cyclic(|self_weak| Self { let self_rc = Rc::new_cyclic(|self_weak| Self {
window: corelib::api::Window::new(self_weak.clone() as _), window: corelib::api::Window::new(self_weak.clone() as _),
self_weak: self_weak.clone(), self_weak: self_weak.clone(),
@ -210,7 +210,7 @@ impl<Renderer: WinitCompatibleRenderer + 'static> WinitWindow for GLWindow<Rende
} }
} }
impl<Renderer: WinitCompatibleRenderer + 'static> PlatformWindow for GLWindow<Renderer> { impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapter for GLWindow<Renderer> {
fn request_redraw(&self) { fn request_redraw(&self) {
self.with_window_handle(&mut |window| window.request_redraw()) self.with_window_handle(&mut |window| window.request_redraw())
} }

View file

@ -12,7 +12,7 @@ extern crate alloc;
use std::rc::Rc; use std::rc::Rc;
use std::sync::Mutex; use std::sync::Mutex;
use i_slint_core::window::PlatformWindow; use i_slint_core::window::WindowAdapter;
mod glwindow; mod glwindow;
use glwindow::*; use glwindow::*;
@ -22,7 +22,7 @@ pub(crate) mod event_loop;
mod renderer { mod renderer {
use std::rc::Weak; use std::rc::Weak;
use i_slint_core::window::PlatformWindow; use i_slint_core::window::WindowAdapter;
mod boxshadowcache; mod boxshadowcache;
@ -30,14 +30,14 @@ mod renderer {
type Canvas: WinitCompatibleCanvas; type Canvas: WinitCompatibleCanvas;
fn new( fn new(
platform_window_weak: &Weak<dyn PlatformWindow>, window_adapter_weak: &Weak<dyn WindowAdapter>,
#[cfg(target_arch = "wasm32")] canvas_id: String, #[cfg(target_arch = "wasm32")] canvas_id: String,
) -> Self; ) -> Self;
fn create_canvas(&self, window_builder: winit::window::WindowBuilder) -> Self::Canvas; fn create_canvas(&self, window_builder: winit::window::WindowBuilder) -> Self::Canvas;
fn release_canvas(&self, canvas: Self::Canvas); fn release_canvas(&self, canvas: Self::Canvas);
fn render(&self, canvas: &Self::Canvas, window: &dyn PlatformWindow); fn render(&self, canvas: &Self::Canvas, window: &dyn WindowAdapter);
} }
pub(crate) trait WinitCompatibleCanvas { pub(crate) trait WinitCompatibleCanvas {
@ -66,7 +66,7 @@ pub(crate) mod wasm_input_helper;
mod stylemetrics; mod stylemetrics;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
pub fn create_gl_window_with_canvas_id(canvas_id: String) -> Rc<dyn PlatformWindow> { pub fn create_gl_window_with_canvas_id(canvas_id: String) -> Rc<dyn WindowAdapter> {
GLWindow::<crate::renderer::femtovg::FemtoVGRenderer>::new(canvas_id) GLWindow::<crate::renderer::femtovg::FemtoVGRenderer>::new(canvas_id)
} }
@ -87,7 +87,7 @@ pub use stylemetrics::native_style_metrics_deinit;
pub use stylemetrics::native_style_metrics_init; pub use stylemetrics::native_style_metrics_init;
pub struct Backend { pub struct Backend {
window_factory_fn: Mutex<Box<dyn Fn() -> Rc<dyn PlatformWindow> + Send>>, window_factory_fn: Mutex<Box<dyn Fn() -> Rc<dyn WindowAdapter> + Send>>,
} }
impl Backend { impl Backend {
@ -143,7 +143,7 @@ impl Backend {
} }
impl i_slint_core::platform::Platform for Backend { impl i_slint_core::platform::Platform for Backend {
fn create_window(&self) -> Rc<dyn PlatformWindow> { fn create_window(&self) -> Rc<dyn WindowAdapter> {
self.window_factory_fn.lock().unwrap()() self.window_factory_fn.lock().unwrap()()
} }

View file

@ -12,7 +12,7 @@ use i_slint_core::graphics::{
rendering_metrics_collector::RenderingMetricsCollector, Point, Rect, Size, rendering_metrics_collector::RenderingMetricsCollector, Point, Rect, Size,
}; };
use i_slint_core::renderer::Renderer; use i_slint_core::renderer::Renderer;
use i_slint_core::window::{PlatformWindow, WindowHandleAccess}; use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
use i_slint_core::Coord; use i_slint_core::Coord;
use crate::WindowSystemName; use crate::WindowSystemName;
@ -26,7 +26,7 @@ mod itemrenderer;
const PASSWORD_CHARACTER: &str = ""; const PASSWORD_CHARACTER: &str = "";
pub struct FemtoVGRenderer { pub struct FemtoVGRenderer {
platform_window_weak: Weak<dyn PlatformWindow>, window_adapter_weak: Weak<dyn WindowAdapter>,
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
canvas_id: String, canvas_id: String,
rendering_notifier: RefCell<Option<Box<dyn RenderingNotifier>>>, rendering_notifier: RefCell<Option<Box<dyn RenderingNotifier>>>,
@ -36,11 +36,11 @@ impl super::WinitCompatibleRenderer for FemtoVGRenderer {
type Canvas = FemtoVGCanvas; type Canvas = FemtoVGCanvas;
fn new( fn new(
platform_window_weak: &Weak<dyn PlatformWindow>, window_adapter_weak: &Weak<dyn WindowAdapter>,
#[cfg(target_arch = "wasm32")] canvas_id: String, #[cfg(target_arch = "wasm32")] canvas_id: String,
) -> Self { ) -> Self {
Self { Self {
platform_window_weak: platform_window_weak.clone(), window_adapter_weak: window_adapter_weak.clone(),
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
canvas_id, canvas_id,
rendering_notifier: Default::default(), rendering_notifier: Default::default(),
@ -55,7 +55,7 @@ impl super::WinitCompatibleRenderer for FemtoVGRenderer {
); );
let rendering_metrics_collector = RenderingMetricsCollector::new( let rendering_metrics_collector = RenderingMetricsCollector::new(
self.platform_window_weak.clone(), self.window_adapter_weak.clone(),
&format!( &format!(
"FemtoVG renderer (windowing system: {})", "FemtoVG renderer (windowing system: {})",
opengl_context.window().winsys_name() opengl_context.window().winsys_name()
@ -127,14 +127,14 @@ impl super::WinitCompatibleRenderer for FemtoVGRenderer {
}) })
} }
fn render(&self, canvas: &FemtoVGCanvas, platform_window: &dyn PlatformWindow) { fn render(&self, canvas: &FemtoVGCanvas, window_adapter: &dyn WindowAdapter) {
let size = canvas.opengl_context.window().inner_size(); let size = canvas.opengl_context.window().inner_size();
let width = size.width; let width = size.width;
let height = size.height; let height = size.height;
canvas.opengl_context.make_current(); canvas.opengl_context.make_current();
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
window.draw_contents(|components| { window.draw_contents(|components| {
{ {
@ -172,7 +172,7 @@ impl super::WinitCompatibleRenderer for FemtoVGRenderer {
let mut item_renderer = self::itemrenderer::GLItemRenderer::new( let mut item_renderer = self::itemrenderer::GLItemRenderer::new(
canvas, canvas,
platform_window.window(), window_adapter.window(),
width, width,
height, height,
); );
@ -222,12 +222,12 @@ impl Renderer for FemtoVGRenderer {
text_input: Pin<&i_slint_core::items::TextInput>, text_input: Pin<&i_slint_core::items::TextInput>,
pos: Point, pos: Point,
) -> usize { ) -> usize {
let platform_window = match self.platform_window_weak.upgrade() { let window_adapter = match self.window_adapter_weak.upgrade() {
Some(window) => window, Some(window) => window,
None => return 0, None => return 0,
}; };
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
let scale_factor = window.scale_factor(); let scale_factor = window.scale_factor();
let pos = pos * scale_factor; let pos = pos * scale_factor;
@ -243,7 +243,7 @@ impl Renderer for FemtoVGRenderer {
let font = crate::renderer::femtovg::fonts::FONT_CACHE.with(|cache| { let font = crate::renderer::femtovg::fonts::FONT_CACHE.with(|cache| {
cache.borrow_mut().font( cache.borrow_mut().font(
text_input.font_request(&platform_window), text_input.font_request(&window_adapter),
scale_factor, scale_factor,
&text_input.text(), &text_input.text(),
) )
@ -301,20 +301,18 @@ impl Renderer for FemtoVGRenderer {
text_input: Pin<&i_slint_core::items::TextInput>, text_input: Pin<&i_slint_core::items::TextInput>,
byte_offset: usize, byte_offset: usize,
) -> Rect { ) -> Rect {
let platform_window = match self.platform_window_weak.upgrade() { let window_adapter = match self.window_adapter_weak.upgrade() {
Some(window) => window, Some(window) => window,
None => return Default::default(), None => return Default::default(),
}; };
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
let text = text_input.text(); let text = text_input.text();
let scale_factor = window.scale_factor(); let scale_factor = window.scale_factor();
let font_size = text_input let font_size =
.font_request(&platform_window) text_input.font_request(&window_adapter).pixel_size.unwrap_or(fonts::DEFAULT_FONT_SIZE);
.pixel_size
.unwrap_or(fonts::DEFAULT_FONT_SIZE);
let mut result = Point::default(); let mut result = Point::default();
@ -326,7 +324,7 @@ impl Renderer for FemtoVGRenderer {
let font = crate::renderer::femtovg::fonts::FONT_CACHE.with(|cache| { let font = crate::renderer::femtovg::fonts::FONT_CACHE.with(|cache| {
cache.borrow_mut().font( cache.borrow_mut().font(
text_input.font_request(&platform_window), text_input.font_request(&window_adapter),
scale_factor, scale_factor,
&text_input.text(), &text_input.text(),
) )

View file

@ -283,7 +283,7 @@ impl<'a> ItemRenderer for GLItemRenderer<'a> {
let font = fonts::FONT_CACHE.with(|cache| { let font = fonts::FONT_CACHE.with(|cache| {
cache.borrow_mut().font( cache.borrow_mut().font(
text_input.font_request(&self.window.window_handle().platform_window()), text_input.font_request(&self.window.window_handle().window_adapter()),
self.scale_factor, self.scale_factor,
&text_input.text(), &text_input.text(),
) )

View file

@ -9,7 +9,7 @@ use i_slint_core::api::{
}; };
use i_slint_core::graphics::rendering_metrics_collector::RenderingMetricsCollector; use i_slint_core::graphics::rendering_metrics_collector::RenderingMetricsCollector;
use i_slint_core::item_rendering::ItemCache; use i_slint_core::item_rendering::ItemCache;
use i_slint_core::window::{PlatformWindow, WindowHandleAccess}; use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
use crate::WindowSystemName; use crate::WindowSystemName;
@ -37,16 +37,16 @@ cfg_if::cfg_if! {
} }
pub struct SkiaRenderer { pub struct SkiaRenderer {
platform_window_weak: Weak<dyn PlatformWindow>, window_adapter_weak: Weak<dyn WindowAdapter>,
rendering_notifier: RefCell<Option<Box<dyn RenderingNotifier>>>, rendering_notifier: RefCell<Option<Box<dyn RenderingNotifier>>>,
} }
impl super::WinitCompatibleRenderer for SkiaRenderer { impl super::WinitCompatibleRenderer for SkiaRenderer {
type Canvas = SkiaCanvas<DefaultSurface>; type Canvas = SkiaCanvas<DefaultSurface>;
fn new(platform_window_weak: &Weak<dyn PlatformWindow>) -> Self { fn new(window_adapter_weak: &Weak<dyn WindowAdapter>) -> Self {
Self { Self {
platform_window_weak: platform_window_weak.clone(), window_adapter_weak: window_adapter_weak.clone(),
rendering_notifier: Default::default(), rendering_notifier: Default::default(),
} }
} }
@ -55,7 +55,7 @@ impl super::WinitCompatibleRenderer for SkiaRenderer {
let surface = DefaultSurface::new(window_builder); let surface = DefaultSurface::new(window_builder);
let rendering_metrics_collector = RenderingMetricsCollector::new( let rendering_metrics_collector = RenderingMetricsCollector::new(
self.platform_window_weak.clone(), self.window_adapter_weak.clone(),
&format!( &format!(
"Skia renderer (windowing system: {}; skia backend {})", "Skia renderer (windowing system: {}; skia backend {})",
surface.with_window_handle(|winit_window| winit_window.winsys_name()), surface.with_window_handle(|winit_window| winit_window.winsys_name()),
@ -83,8 +83,8 @@ impl super::WinitCompatibleRenderer for SkiaRenderer {
}); });
} }
fn render(&self, canvas: &Self::Canvas, platform_window: &dyn PlatformWindow) { fn render(&self, canvas: &Self::Canvas, window_adapter: &dyn WindowAdapter) {
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
canvas.surface.render(|skia_canvas, gr_context| { canvas.surface.render(|skia_canvas, gr_context| {
window.draw_contents(|components| { window.draw_contents(|components| {
@ -108,7 +108,7 @@ impl super::WinitCompatibleRenderer for SkiaRenderer {
let mut item_renderer = itemrenderer::SkiaRenderer::new( let mut item_renderer = itemrenderer::SkiaRenderer::new(
skia_canvas, skia_canvas,
platform_window.window(), window_adapter.window(),
&canvas.image_cache, &canvas.image_cache,
&mut box_shadow_cache, &mut box_shadow_cache,
); );

View file

@ -7,15 +7,15 @@ use super::WinitCompatibleCanvas;
use i_slint_core::graphics::Rgb8Pixel; use i_slint_core::graphics::Rgb8Pixel;
use i_slint_core::lengths::PhysicalLength; use i_slint_core::lengths::PhysicalLength;
pub use i_slint_core::swrenderer::SoftwareRenderer; pub use i_slint_core::swrenderer::SoftwareRenderer;
use i_slint_core::window::PlatformWindow; use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Weak; use std::rc::Weak;
impl<const BUFFER_COUNT: usize> super::WinitCompatibleRenderer for SoftwareRenderer<BUFFER_COUNT> { impl<const BUFFER_COUNT: usize> super::WinitCompatibleRenderer for SoftwareRenderer<BUFFER_COUNT> {
type Canvas = SwCanvas; type Canvas = SwCanvas;
fn new(platform_window_weak: &Weak<dyn PlatformWindow>) -> Self { fn new(window_adapter_weak: &Weak<dyn WindowAdapter>) -> Self {
SoftwareRenderer::new(platform_window_weak.clone()) SoftwareRenderer::new(window_adapter_weak.clone())
} }
fn create_canvas(&self, window_builder: winit::window::WindowBuilder) -> Self::Canvas { fn create_canvas(&self, window_builder: winit::window::WindowBuilder) -> Self::Canvas {
@ -33,7 +33,7 @@ impl<const BUFFER_COUNT: usize> super::WinitCompatibleRenderer for SoftwareRende
fn release_canvas(&self, _canvas: Self::Canvas) {} fn release_canvas(&self, _canvas: Self::Canvas) {}
fn render(&self, canvas: &SwCanvas, _: &dyn PlatformWindow) { fn render(&self, canvas: &SwCanvas, _: &dyn WindowAdapter) {
let size = canvas.opengl_context.window().inner_size(); let size = canvas.opengl_context.window().inner_size();
let width = size.width as usize; let width = size.width as usize;
let height = size.height as usize; let height = size.height as usize;

View file

@ -21,7 +21,7 @@ use std::cell::RefCell;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use i_slint_core::input::{KeyEvent, KeyEventType, KeyboardModifiers}; use i_slint_core::input::{KeyEvent, KeyEventType, KeyboardModifiers};
use i_slint_core::window::{PlatformWindow, WindowHandleAccess}; use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
use i_slint_core::SharedString; use i_slint_core::SharedString;
use wasm_bindgen::closure::Closure; use wasm_bindgen::closure::Closure;
use wasm_bindgen::convert::FromWasmAbi; use wasm_bindgen::convert::FromWasmAbi;
@ -67,7 +67,7 @@ impl WasmInputState {
impl WasmInputHelper { impl WasmInputHelper {
#[allow(unused)] #[allow(unused)]
pub fn new( pub fn new(
platform_window: Weak<dyn PlatformWindow>, window_adapter: Weak<dyn WindowAdapter>,
canvas: web_sys::HtmlCanvasElement, canvas: web_sys::HtmlCanvasElement,
) -> Self { ) -> Self {
let input = web_sys::window() let input = web_sys::window()
@ -92,24 +92,24 @@ impl WasmInputHelper {
let shared_state = Rc::new(RefCell::new(WasmInputState::default())); let shared_state = Rc::new(RefCell::new(WasmInputState::default()));
let win = platform_window.clone(); let win = window_adapter.clone();
h.add_event_listener("blur", move |_: web_sys::Event| { h.add_event_listener("blur", move |_: web_sys::Event| {
// Make sure that the window gets marked as unfocused when the focus leaves the input // Make sure that the window gets marked as unfocused when the focus leaves the input
if let Some(platform_window) = win.upgrade() { if let Some(window_adapter) = win.upgrade() {
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
if !canvas.matches(":focus").unwrap_or(false) { if !canvas.matches(":focus").unwrap_or(false) {
window.set_active(false); window.set_active(false);
window.set_focus(false); window.set_focus(false);
} }
} }
}); });
let win = platform_window.clone(); let win = window_adapter.clone();
let shared_state2 = shared_state.clone(); let shared_state2 = shared_state.clone();
h.add_event_listener("keydown", move |e: web_sys::KeyboardEvent| { h.add_event_listener("keydown", move |e: web_sys::KeyboardEvent| {
if let (Some(platform_window), Some(text)) = (win.upgrade(), event_text(&e)) { if let (Some(window_adapter), Some(text)) = (win.upgrade(), event_text(&e)) {
e.prevent_default(); e.prevent_default();
shared_state2.borrow_mut().has_key_down = true; shared_state2.borrow_mut().has_key_down = true;
platform_window.window().window_handle().process_key_input(&KeyEvent { window_adapter.window().window_handle().process_key_input(&KeyEvent {
modifiers: modifiers(&e), modifiers: modifiers(&e),
text, text,
event_type: KeyEventType::KeyPressed, event_type: KeyEventType::KeyPressed,
@ -117,13 +117,13 @@ impl WasmInputHelper {
} }
}); });
let win = platform_window.clone(); let win = window_adapter.clone();
let shared_state2 = shared_state.clone(); let shared_state2 = shared_state.clone();
h.add_event_listener("keyup", move |e: web_sys::KeyboardEvent| { h.add_event_listener("keyup", move |e: web_sys::KeyboardEvent| {
if let (Some(platform_window), Some(text)) = (win.upgrade(), event_text(&e)) { if let (Some(window_adapter), Some(text)) = (win.upgrade(), event_text(&e)) {
e.prevent_default(); e.prevent_default();
shared_state2.borrow_mut().has_key_down = false; shared_state2.borrow_mut().has_key_down = false;
platform_window.window().window_handle().process_key_input(&KeyEvent { window_adapter.window().window_handle().process_key_input(&KeyEvent {
modifiers: modifiers(&e), modifiers: modifiers(&e),
text, text,
event_type: KeyEventType::KeyReleased, event_type: KeyEventType::KeyReleased,
@ -131,14 +131,14 @@ impl WasmInputHelper {
} }
}); });
let win = platform_window.clone(); let win = window_adapter.clone();
let shared_state2 = shared_state.clone(); let shared_state2 = shared_state.clone();
let input = h.input.clone(); let input = h.input.clone();
h.add_event_listener("input", move |e: web_sys::InputEvent| { h.add_event_listener("input", move |e: web_sys::InputEvent| {
if let (Some(platform_window), Some(data)) = (win.upgrade(), e.data()) { if let (Some(window_adapter), Some(data)) = (win.upgrade(), e.data()) {
if !e.is_composing() && e.input_type() != "insertCompositionText" { if !e.is_composing() && e.input_type() != "insertCompositionText" {
if !shared_state2.borrow_mut().has_key_down { if !shared_state2.borrow_mut().has_key_down {
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
let text = SharedString::from(data.as_str()); let text = SharedString::from(data.as_str());
window.process_key_input(&KeyEvent { window.process_key_input(&KeyEvent {
modifiers: Default::default(), modifiers: Default::default(),
@ -158,12 +158,12 @@ impl WasmInputHelper {
}); });
for event in ["compositionend", "compositionupdate"] { for event in ["compositionend", "compositionupdate"] {
let win = platform_window.clone(); let win = window_adapter.clone();
let shared_state2 = shared_state.clone(); let shared_state2 = shared_state.clone();
let input = h.input.clone(); let input = h.input.clone();
h.add_event_listener(event, move |e: web_sys::CompositionEvent| { h.add_event_listener(event, move |e: web_sys::CompositionEvent| {
if let (Some(platform_window), Some(data)) = (win.upgrade(), e.data()) { if let (Some(window_adapter), Some(data)) = (win.upgrade(), e.data()) {
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
let is_end = event == "compositionend"; let is_end = event == "compositionend";
let (text, to_delete) = let (text, to_delete) =
shared_state2.borrow_mut().text_from_compose(data, is_end); shared_state2.borrow_mut().text_from_compose(data, is_end);

View file

@ -616,7 +616,7 @@ fn generate_public_component(file: &mut File, component: &llr::PublicComponent)
Declaration::Var(Var { Declaration::Var(Var {
ty: "slint::Window".into(), ty: "slint::Window".into(),
name: "m_window".into(), name: "m_window".into(),
init: Some("slint::Window{slint::private_api::PlatformWindowRc()}".into()), init: Some("slint::Window{slint::private_api::WindowAdapterRc()}".into()),
..Default::default() ..Default::default()
}), }),
)); ));
@ -700,7 +700,7 @@ fn generate_public_component(file: &mut File, component: &llr::PublicComponent)
}), }),
)); ));
component_struct.friends.push("slint::private_api::PlatformWindowRc".into()); component_struct.friends.push("slint::private_api::WindowAdapterRc".into());
component_struct component_struct
.friends .friends

View file

@ -347,7 +347,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
} }
fn window(&self) -> &slint::Window { fn window(&self) -> &slint::Window {
vtable::VRc::as_pin_ref(&self.0).get_ref().platform_window.get().unwrap().window() vtable::VRc::as_pin_ref(&self.0).get_ref().window_adapter.get().unwrap().window()
} }
fn global<'a, T: slint::Global<'a, Self>>(&'a self) -> T { fn global<'a, T: slint::Global<'a, Self>>(&'a self) -> T {
@ -859,7 +859,7 @@ fn generate_sub_component(
self_weak : slint::re_exports::OnceCell<slint::re_exports::VWeakMapped<slint::re_exports::ComponentVTable, #inner_component_id>>, self_weak : slint::re_exports::OnceCell<slint::re_exports::VWeakMapped<slint::re_exports::ComponentVTable, #inner_component_id>>,
#(parent : #parent_component_type,)* #(parent : #parent_component_type,)*
// FIXME: Do we really need a window all the time? // FIXME: Do we really need a window all the time?
platform_window: slint::re_exports::OnceCell<slint::re_exports::Rc<dyn slint::re_exports::PlatformWindow>>, window_adapter: slint::re_exports::OnceCell<slint::re_exports::Rc<dyn slint::re_exports::WindowAdapter>>,
root : slint::re_exports::OnceCell<slint::re_exports::VWeak<slint::re_exports::ComponentVTable, #root_component_id>>, root : slint::re_exports::OnceCell<slint::re_exports::VWeak<slint::re_exports::ComponentVTable, #root_component_id>>,
tree_index: ::core::cell::Cell<u32>, tree_index: ::core::cell::Cell<u32>,
tree_index_of_first_child: ::core::cell::Cell<u32>, tree_index_of_first_child: ::core::cell::Cell<u32>,
@ -874,7 +874,7 @@ fn generate_sub_component(
let _self = self_rc.as_pin_ref(); let _self = self_rc.as_pin_ref();
_self.self_weak.set(VRcMapped::downgrade(&self_rc)); _self.self_weak.set(VRcMapped::downgrade(&self_rc));
_self.root.set(VRc::downgrade(root)); _self.root.set(VRc::downgrade(root));
_self.platform_window.set(root.platform_window.get().unwrap().clone()); _self.window_adapter.set(root.window_adapter.get().unwrap().clone());
_self.tree_index.set(tree_index); _self.tree_index.set(tree_index);
_self.tree_index_of_first_child.set(tree_index_of_first_child); _self.tree_index_of_first_child.set(tree_index_of_first_child);
#(#init)* #(#init)*
@ -1105,10 +1105,10 @@ fn generate_item_tree(
}; };
let (create_window, init_window) = if parent_ctx.is_none() { let (create_window, init_window) = if parent_ctx.is_none() {
( (
Some(quote!(let platform_window = slint::create_window();)), Some(quote!(let window_adapter = slint::create_window();)),
Some(quote! { Some(quote! {
_self.platform_window.set(platform_window); _self.window_adapter.set(window_adapter);
_self.platform_window.get().unwrap().window().window_handle().set_component(&VRc::into_dyn(self_rc.clone())); _self.window_adapter.get().unwrap().window().window_handle().set_component(&VRc::into_dyn(self_rc.clone()));
}), }),
) )
} else { } else {
@ -1195,7 +1195,7 @@ fn generate_item_tree(
let self_rc = VRc::new(_self); let self_rc = VRc::new(_self);
let _self = self_rc.as_pin_ref(); let _self = self_rc.as_pin_ref();
#init_window #init_window
slint::re_exports::register_component(_self, Self::item_array(), #root_token.platform_window.get().unwrap()); slint::re_exports::register_component(_self, Self::item_array(), #root_token.window_adapter.get().unwrap());
Self::init(slint::re_exports::VRc::map(self_rc.clone(), |x| x), #root_token, 0, 1); Self::init(slint::re_exports::VRc::map(self_rc.clone(), |x| x), #root_token, 0, 1);
self_rc self_rc
} }
@ -1220,13 +1220,13 @@ fn generate_item_tree(
fn drop(self: core::pin::Pin<&mut #inner_component_id>) { fn drop(self: core::pin::Pin<&mut #inner_component_id>) {
use slint::re_exports::*; use slint::re_exports::*;
new_vref!(let vref : VRef<ComponentVTable> for Component = self.as_ref().get_ref()); new_vref!(let vref : VRef<ComponentVTable> for Component = self.as_ref().get_ref());
slint::re_exports::unregister_component(self.as_ref(), vref, Self::item_array(), self.platform_window.get().unwrap()); slint::re_exports::unregister_component(self.as_ref(), vref, Self::item_array(), self.window_adapter.get().unwrap());
} }
} }
impl slint::re_exports::WindowHandleAccess for #inner_component_id { impl slint::re_exports::WindowHandleAccess for #inner_component_id {
fn window_handle(&self) -> &slint::re_exports::WindowInner { fn window_handle(&self) -> &slint::re_exports::WindowInner {
self.platform_window.get().unwrap().window().window_handle() self.window_adapter.get().unwrap().window().window_handle()
} }
} }
@ -1533,9 +1533,9 @@ fn follow_sub_component_path<'a>(
(compo_path, sub_component) (compo_path, sub_component)
} }
fn access_platform_window_field(ctx: &EvaluationContext) -> TokenStream { fn access_window_adapter_field(ctx: &EvaluationContext) -> TokenStream {
let root = &ctx.generator_state; let root = &ctx.generator_state;
quote!(#root.platform_window.get().unwrap()) quote!(#root.window_adapter.get().unwrap())
} }
/// Given a property reference to a native item (eg, the property name is empty) /// Given a property reference to a native item (eg, the property name is empty)
@ -1985,7 +1985,7 @@ fn compile_builtin_function_call(
match function { match function {
BuiltinFunction::SetFocusItem => { BuiltinFunction::SetFocusItem => {
if let [Expression::PropertyReference(pr)] = arguments { if let [Expression::PropertyReference(pr)] = arguments {
let window_tokens = access_platform_window_field(ctx); let window_tokens = access_window_adapter_field(ctx);
let focus_item = access_item_rc(pr, ctx); let focus_item = access_item_rc(pr, ctx);
quote!( quote!(
#window_tokens.window().window_handle().set_focus_item(#focus_item); #window_tokens.window().window_handle().set_focus_item(#focus_item);
@ -2014,9 +2014,9 @@ fn compile_builtin_function_call(
let parent_component = access_item_rc(parent_ref, ctx); let parent_component = access_item_rc(parent_ref, ctx);
let x = compile_expression(x, ctx); let x = compile_expression(x, ctx);
let y = compile_expression(y, ctx); let y = compile_expression(y, ctx);
let platform_window_tokens = access_platform_window_field(ctx); let window_adapter_tokens = access_window_adapter_field(ctx);
quote!( quote!(
#platform_window_tokens.window().window_handle().show_popup( #window_adapter_tokens.window().window_handle().show_popup(
&VRc::into_dyn(#popup_window_id::new(#component_access_tokens.self_weak.get().unwrap().clone()).into()), &VRc::into_dyn(#popup_window_id::new(#component_access_tokens.self_weak.get().unwrap().clone()).into()),
Point::new(#x as slint::re_exports::Coord, #y as slint::re_exports::Coord), Point::new(#x as slint::re_exports::Coord, #y as slint::re_exports::Coord),
#parent_component #parent_component
@ -2029,9 +2029,9 @@ fn compile_builtin_function_call(
BuiltinFunction::ImplicitLayoutInfo(orient) => { BuiltinFunction::ImplicitLayoutInfo(orient) => {
if let [Expression::PropertyReference(pr)] = arguments { if let [Expression::PropertyReference(pr)] = arguments {
let item = access_member(pr, ctx); let item = access_member(pr, ctx);
let platform_window_tokens = access_platform_window_field(ctx); let window_adapter_tokens = access_window_adapter_field(ctx);
quote!( quote!(
#item.layout_info(#orient, #platform_window_tokens) #item.layout_info(#orient, #window_adapter_tokens)
) )
} else { } else {
panic!("internal error: invalid args to ImplicitLayoutInfo {:?}", arguments) panic!("internal error: invalid args to ImplicitLayoutInfo {:?}", arguments)
@ -2039,8 +2039,8 @@ fn compile_builtin_function_call(
} }
BuiltinFunction::RegisterCustomFontByPath => { BuiltinFunction::RegisterCustomFontByPath => {
if let [Expression::StringLiteral(path)] = arguments { if let [Expression::StringLiteral(path)] = arguments {
let platform_window_tokens = access_platform_window_field(ctx); let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#platform_window_tokens.renderer().register_font_from_path(&std::path::PathBuf::from(#path));) quote!(#window_adapter_tokens.renderer().register_font_from_path(&std::path::PathBuf::from(#path));)
} else { } else {
panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments) panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments)
} }
@ -2049,8 +2049,8 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments { if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _; let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id); let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
let platform_window_tokens = access_platform_window_field(ctx); let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#platform_window_tokens.renderer().register_font_from_memory(#symbol.into());) quote!(#window_adapter_tokens.renderer().register_font_from_memory(#symbol.into());)
} else { } else {
panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments) panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments)
} }
@ -2059,15 +2059,15 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments { if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _; let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id); let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
let platform_window_tokens = access_platform_window_field(ctx); let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#platform_window_tokens.renderer().register_bitmap_font(&#symbol);) quote!(#window_adapter_tokens.renderer().register_bitmap_font(&#symbol);)
} else { } else {
panic!("internal error: invalid args to RegisterBitmapFont must be a number") panic!("internal error: invalid args to RegisterBitmapFont must be a number")
} }
} }
BuiltinFunction::GetWindowScaleFactor => { BuiltinFunction::GetWindowScaleFactor => {
let platform_window_tokens = access_platform_window_field(ctx); let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#platform_window_tokens.window().window_handle().scale_factor()) quote!(#window_adapter_tokens.window().window_handle().scale_factor())
} }
BuiltinFunction::AnimationTick => quote!(slint::re_exports::animation_tick()), BuiltinFunction::AnimationTick => quote!(slint::re_exports::animation_tick()),
BuiltinFunction::Debug => quote!(slint::internal::debug(#(#a)*)), BuiltinFunction::Debug => quote!(slint::internal::debug(#(#a)*)),

View file

@ -10,7 +10,7 @@ This module contains types that are public and re-exported in the slint-rs as we
use alloc::boxed::Box; use alloc::boxed::Box;
use crate::component::ComponentVTable; use crate::component::ComponentVTable;
use crate::window::{PlatformWindow, WindowInner}; use crate::window::{WindowAdapter, WindowInner};
pub use crate::lengths::LogicalPx; pub use crate::lengths::LogicalPx;
pub use crate::lengths::PhysicalPx; pub use crate::lengths::PhysicalPx;
@ -118,41 +118,41 @@ impl Default for CloseRequestResponse {
} }
impl Window { impl Window {
/// Create a new window from a platform window. /// Create a new window from a window adapter
/// ///
/// You only need to create the window yourself when you create a /// You only need to create the window yourself when you create a
/// [`PlatformWindow`](crate::platform::PlatformWindow) from /// [`WindowAdapter`](crate::platform::WindowAdapter) from
/// [`Platform::create_window`](crate::platform::Platform::create_window) /// [`Platform::create_window`](crate::platform::Platform::create_window)
/// ///
/// Since the platform window must own the Window, this function is meant to be used with /// Since the window adapter must own the Window, this function is meant to be used with
/// [`Rc::new_cyclic`](alloc::rc::Rc::new_cyclic) /// [`Rc::new_cyclic`](alloc::rc::Rc::new_cyclic)
/// ///
/// # Example /// # Example
/// ```rust /// ```rust
/// use std::rc::Rc; /// use std::rc::Rc;
/// use slint::platform::PlatformWindow; /// use slint::platform::WindowAdapter;
/// use slint::Window; /// use slint::Window;
/// struct MyPlatformWindow { /// struct MyWindowAdapter {
/// window: Window, /// window: Window,
/// //... /// //...
/// } /// }
/// impl PlatformWindow for MyPlatformWindow { /// impl WindowAdapter for MyWindowAdapter {
/// fn window(&self) -> &Window { &self.window } /// fn window(&self) -> &Window { &self.window }
/// # fn renderer(&self) -> &dyn i_slint_core::renderer::Renderer { unimplemented!() } /// # fn renderer(&self) -> &dyn i_slint_core::renderer::Renderer { unimplemented!() }
/// # fn as_any(&self) -> &(dyn core::any::Any + 'static) { self } /// # fn as_any(&self) -> &(dyn core::any::Any + 'static) { self }
/// //... /// //...
/// } /// }
/// fn create_window() -> Rc<dyn PlatformWindow> { /// fn create_window() -> Rc<dyn WindowAdapter> {
/// Rc::<MyPlatformWindow>::new_cyclic(|weak| { /// Rc::<MyWindowAdapter>::new_cyclic(|weak| {
/// MyPlatformWindow { /// MyWindowAdapter {
/// window: Window::new(weak.clone()), /// window: Window::new(weak.clone()),
/// //... /// //...
/// } /// }
/// }) /// })
/// } /// }
/// ``` /// ```
pub fn new(platform_window_weak: alloc::rc::Weak<dyn PlatformWindow>) -> Self { pub fn new(window_adapter_weak: alloc::rc::Weak<dyn WindowAdapter>) -> Self {
Self(WindowInner::new(platform_window_weak)) Self(WindowInner::new(window_adapter_weak))
} }
/// Registers the window with the windowing system in order to make it visible on the screen. /// Registers the window with the windowing system in order to make it visible on the screen.
@ -171,7 +171,7 @@ impl Window {
&self, &self,
callback: impl FnMut(RenderingState, &GraphicsAPI) + 'static, callback: impl FnMut(RenderingState, &GraphicsAPI) + 'static,
) -> Result<(), SetRenderingNotifierError> { ) -> Result<(), SetRenderingNotifierError> {
self.0.platform_window().renderer().set_rendering_notifier(Box::new(callback)) self.0.window_adapter().renderer().set_rendering_notifier(Box::new(callback))
} }
/// This function allows registering a callback that's invoked when the user tries to close a window. /// This function allows registering a callback that's invoked when the user tries to close a window.
@ -182,7 +182,7 @@ impl Window {
/// This function issues a request to the windowing system to redraw the contents of the window. /// This function issues a request to the windowing system to redraw the contents of the window.
pub fn request_redraw(&self) { pub fn request_redraw(&self) {
self.0.platform_window().request_redraw(); self.0.window_adapter().request_redraw();
// When this function is called by the user, we want it to translate to a requestAnimationFrame() // When this function is called by the user, we want it to translate to a requestAnimationFrame()
// on the web. If called through the rendering notifier (so from within the event loop processing), // on the web. If called through the rendering notifier (so from within the event loop processing),
@ -202,14 +202,14 @@ impl Window {
/// Returns the position of the window on the screen, in physical screen coordinates and including /// Returns the position of the window on the screen, in physical screen coordinates and including
/// a window frame (if present). /// a window frame (if present).
pub fn position(&self) -> euclid::Point2D<i32, PhysicalPx> { pub fn position(&self) -> euclid::Point2D<i32, PhysicalPx> {
self.0.platform_window().position() self.0.window_adapter().position()
} }
/// Sets the position of the window on the screen, in physical screen coordinates and including /// Sets the position of the window on the screen, in physical screen coordinates and including
/// a window frame (if present). /// a window frame (if present).
/// Note that on some windowing systems, such as Wayland, this functionality is not available. /// Note that on some windowing systems, such as Wayland, this functionality is not available.
pub fn set_position(&self, position: euclid::Point2D<i32, PhysicalPx>) { pub fn set_position(&self, position: euclid::Point2D<i32, PhysicalPx>) {
self.0.platform_window().set_position(position) self.0.window_adapter().set_position(position)
} }
/// Returns the size of the window on the screen, in physical screen coordinates and excluding /// Returns the size of the window on the screen, in physical screen coordinates and excluding
@ -227,7 +227,7 @@ impl Window {
let l = size.cast() / self.scale_factor(); let l = size.cast() / self.scale_factor();
self.0.set_window_item_geometry(l.width as _, l.height as _); self.0.set_window_item_geometry(l.width as _, l.height as _);
self.0.platform_window().set_inner_size(size) self.0.window_adapter().set_inner_size(size)
} }
/// Dispatch a pointer event (touch or mouse) to the window /// Dispatch a pointer event (touch or mouse) to the window

View file

@ -12,7 +12,7 @@ use crate::item_tree::{
use crate::items::{AccessibleRole, ItemVTable}; use crate::items::{AccessibleRole, ItemVTable};
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
use crate::slice::Slice; use crate::slice::Slice;
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use crate::SharedString; use crate::SharedString;
use alloc::rc::Rc; use alloc::rc::Rc;
use vtable::*; use vtable::*;
@ -115,10 +115,10 @@ pub type ComponentWeak = vtable::VWeak<ComponentVTable, Dyn>;
pub fn register_component<Base>( pub fn register_component<Base>(
base: core::pin::Pin<&Base>, base: core::pin::Pin<&Base>,
item_array: &[vtable::VOffset<Base, ItemVTable, vtable::AllowPin>], item_array: &[vtable::VOffset<Base, ItemVTable, vtable::AllowPin>],
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) { ) {
item_array.iter().for_each(|item| item.apply_pin(base).as_ref().init(platform_window)); item_array.iter().for_each(|item| item.apply_pin(base).as_ref().init(window_adapter));
platform_window.register_component(); window_adapter.register_component();
} }
/// Free the backend graphics resources allocated by the component's items. /// Free the backend graphics resources allocated by the component's items.
@ -126,9 +126,9 @@ pub fn unregister_component<Base>(
base: core::pin::Pin<&Base>, base: core::pin::Pin<&Base>,
component: ComponentRef, component: ComponentRef,
item_array: &[vtable::VOffset<Base, ItemVTable, vtable::AllowPin>], item_array: &[vtable::VOffset<Base, ItemVTable, vtable::AllowPin>],
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) { ) {
platform_window window_adapter
.unregister_component(component, &mut item_array.iter().map(|item| item.apply_pin(base))); .unregister_component(component, &mut item_array.iter().map(|item| item.apply_pin(base)));
} }
@ -136,7 +136,7 @@ pub fn unregister_component<Base>(
pub(crate) mod ffi { pub(crate) mod ffi {
#![allow(unsafe_code)] #![allow(unsafe_code)]
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use super::*; use super::*;
@ -145,13 +145,13 @@ pub(crate) mod ffi {
pub unsafe extern "C" fn slint_register_component( pub unsafe extern "C" fn slint_register_component(
component: ComponentRefPin, component: ComponentRefPin,
item_array: Slice<vtable::VOffset<u8, ItemVTable, vtable::AllowPin>>, item_array: Slice<vtable::VOffset<u8, ItemVTable, vtable::AllowPin>>,
window_handle: *const crate::window::ffi::PlatformWindowRcOpaque, window_handle: *const crate::window::ffi::WindowAdapterRcOpaque,
) { ) {
let platform_window = &*(window_handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(window_handle as *const Rc<dyn WindowAdapter>);
super::register_component( super::register_component(
core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)), core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)),
item_array.as_slice(), item_array.as_slice(),
platform_window, window_adapter,
) )
} }
@ -160,14 +160,14 @@ pub(crate) mod ffi {
pub unsafe extern "C" fn slint_unregister_component( pub unsafe extern "C" fn slint_unregister_component(
component: ComponentRefPin, component: ComponentRefPin,
item_array: Slice<vtable::VOffset<u8, ItemVTable, vtable::AllowPin>>, item_array: Slice<vtable::VOffset<u8, ItemVTable, vtable::AllowPin>>,
window_handle: *const crate::window::ffi::PlatformWindowRcOpaque, window_handle: *const crate::window::ffi::WindowAdapterRcOpaque,
) { ) {
let platform_window = &*(window_handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(window_handle as *const Rc<dyn WindowAdapter>);
super::unregister_component( super::unregister_component(
core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)), core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)),
core::pin::Pin::into_inner(component), core::pin::Pin::into_inner(component),
item_array.as_slice(), item_array.as_slice(),
platform_window, window_adapter,
) )
} }
} }

View file

@ -6,7 +6,7 @@ This module contains a simple helper type to measure the average number of frame
*/ */
use crate::timers::*; use crate::timers::*;
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use std::cell::RefCell; use std::cell::RefCell;
use std::convert::TryFrom; use std::convert::TryFrom;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
@ -60,7 +60,7 @@ pub struct RenderingMetricsCollector {
refresh_mode: RefreshMode, refresh_mode: RefreshMode,
output_console: bool, output_console: bool,
output_overlay: bool, output_overlay: bool,
platform_window: Weak<dyn PlatformWindow>, window_adapter: Weak<dyn WindowAdapter>,
} }
impl RenderingMetricsCollector { impl RenderingMetricsCollector {
@ -73,7 +73,7 @@ impl RenderingMetricsCollector {
/// ///
/// If enabled, this will also print out some system information such as whether /// If enabled, this will also print out some system information such as whether
/// this is a debug or release build, as well as the provided winsys_info string. /// this is a debug or release build, as well as the provided winsys_info string.
pub fn new(platform_window: Weak<dyn PlatformWindow>, winsys_info: &str) -> Option<Rc<Self>> { pub fn new(window_adapter: Weak<dyn WindowAdapter>, winsys_info: &str) -> Option<Rc<Self>> {
let options = match std::env::var("SLINT_DEBUG_PERFORMANCE") { let options = match std::env::var("SLINT_DEBUG_PERFORMANCE") {
Ok(var) => var, Ok(var) => var,
_ => return None, _ => return None,
@ -102,7 +102,7 @@ impl RenderingMetricsCollector {
refresh_mode, refresh_mode,
output_console, output_console,
output_overlay, output_overlay,
platform_window, window_adapter,
}); });
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
@ -171,7 +171,7 @@ impl RenderingMetricsCollector {
.borrow_mut() .borrow_mut()
.push(FrameData { timestamp: instant::Instant::now(), metrics: renderer.metrics() }); .push(FrameData { timestamp: instant::Instant::now(), metrics: renderer.metrics() });
if matches!(self.refresh_mode, RefreshMode::FullSpeed) { if matches!(self.refresh_mode, RefreshMode::FullSpeed) {
if let Some(window) = self.platform_window.upgrade() { if let Some(window) = self.window_adapter.upgrade() {
window.request_redraw(); window.request_redraw();
} }
crate::animations::CURRENT_ANIMATION_DRIVER crate::animations::CURRENT_ANIMATION_DRIVER

View file

@ -9,7 +9,7 @@ use crate::graphics::Point;
use crate::item_tree::{ItemRc, ItemVisitorResult, ItemWeak, VisitChildrenResult}; use crate::item_tree::{ItemRc, ItemVisitorResult, ItemWeak, VisitChildrenResult};
pub use crate::items::PointerEventButton; pub use crate::items::PointerEventButton;
use crate::items::{ItemRef, TextCursorDirection}; use crate::items::{ItemRef, TextCursorDirection};
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use crate::{component::ComponentRc, SharedString}; use crate::{component::ComponentRc, SharedString};
use crate::{Coord, Property}; use crate::{Coord, Property};
use alloc::rc::Rc; use alloc::rc::Rc;
@ -401,7 +401,7 @@ pub struct MouseInputState {
/// Try to handle the mouse grabber. Return true if the event has handled, or false otherwise /// Try to handle the mouse grabber. Return true if the event has handled, or false otherwise
fn handle_mouse_grab( fn handle_mouse_grab(
mouse_event: &MouseEvent, mouse_event: &MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
mouse_input_state: &mut MouseInputState, mouse_input_state: &mut MouseInputState,
) -> bool { ) -> bool {
if !mouse_input_state.grabbed || mouse_input_state.item_stack.is_empty() { if !mouse_input_state.grabbed || mouse_input_state.item_stack.is_empty() {
@ -423,7 +423,7 @@ fn handle_mouse_grab(
return false; return false;
}; };
if intercept { if intercept {
item.borrow().as_ref().input_event(MouseEvent::Exit, platform_window, &item); item.borrow().as_ref().input_event(MouseEvent::Exit, window_adapter, &item);
return false; return false;
} }
let g = item.borrow().as_ref().geometry(); let g = item.borrow().as_ref().geometry();
@ -432,7 +432,7 @@ fn handle_mouse_grab(
if it.1 == InputEventFilterResult::ForwardAndInterceptGrab if it.1 == InputEventFilterResult::ForwardAndInterceptGrab
&& item.borrow().as_ref().input_event_filter_before_children( && item.borrow().as_ref().input_event_filter_before_children(
event, event,
platform_window, window_adapter,
&item, &item,
) == InputEventFilterResult::Intercept ) == InputEventFilterResult::Intercept
{ {
@ -445,10 +445,10 @@ fn handle_mouse_grab(
} }
let grabber = mouse_input_state.item_stack.last().unwrap().0.upgrade().unwrap(); let grabber = mouse_input_state.item_stack.last().unwrap().0.upgrade().unwrap();
let input_result = grabber.borrow().as_ref().input_event(event, platform_window, &grabber); let input_result = grabber.borrow().as_ref().input_event(event, window_adapter, &grabber);
if input_result != InputEventResult::GrabMouse { if input_result != InputEventResult::GrabMouse {
mouse_input_state.grabbed = false; mouse_input_state.grabbed = false;
send_exit_events(mouse_input_state, mouse_event.position(), platform_window); send_exit_events(mouse_input_state, mouse_event.position(), window_adapter);
} }
true true
@ -457,7 +457,7 @@ fn handle_mouse_grab(
fn send_exit_events( fn send_exit_events(
mouse_input_state: &MouseInputState, mouse_input_state: &MouseInputState,
mut pos: Option<Point>, mut pos: Option<Point>,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) { ) {
for it in mouse_input_state.item_stack.iter() { for it in mouse_input_state.item_stack.iter() {
let item = if let Some(item) = it.0.upgrade() { item } else { break }; let item = if let Some(item) = it.0.upgrade() { item } else { break };
@ -467,7 +467,7 @@ fn send_exit_events(
*p -= g.origin.to_vector(); *p -= g.origin.to_vector();
} }
if !contains { if !contains {
item.borrow().as_ref().input_event(MouseEvent::Exit, platform_window, &item); item.borrow().as_ref().input_event(MouseEvent::Exit, window_adapter, &item);
} }
} }
} }
@ -478,10 +478,10 @@ fn send_exit_events(
pub fn process_mouse_input( pub fn process_mouse_input(
component: ComponentRc, component: ComponentRc,
mouse_event: MouseEvent, mouse_event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
mut mouse_input_state: MouseInputState, mut mouse_input_state: MouseInputState,
) -> MouseInputState { ) -> MouseInputState {
if handle_mouse_grab(&mouse_event, platform_window, &mut mouse_input_state) { if handle_mouse_grab(&mouse_event, window_adapter, &mut mouse_input_state) {
return mouse_input_state; return mouse_input_state;
} }
@ -510,7 +510,7 @@ pub fn process_mouse_input(
event2.translate(-geom.origin.to_vector()); event2.translate(-geom.origin.to_vector());
let filter_result = item.as_ref().input_event_filter_before_children( let filter_result = item.as_ref().input_event_filter_before_children(
event2, event2,
platform_window, window_adapter,
&item_rc, &item_rc,
); );
mouse_grabber_stack.push((item_rc.downgrade(), filter_result)); mouse_grabber_stack.push((item_rc.downgrade(), filter_result));
@ -554,7 +554,7 @@ pub fn process_mouse_input(
if r.has_aborted() && !intercept { if r.has_aborted() && !intercept {
return r; return r;
} }
match item.as_ref().input_event(event2, platform_window, &item_rc) { match item.as_ref().input_event(event2, window_adapter, &item_rc) {
InputEventResult::EventAccepted => { InputEventResult::EventAccepted => {
if result.item_stack.is_empty() { if result.item_stack.is_empty() {
// In case the item stack is set already, it shouldn't // In case the item stack is set already, it shouldn't
@ -582,7 +582,7 @@ pub fn process_mouse_input(
(Vector2D::new(0 as Coord, 0 as Coord), Vec::new(), mouse_event), (Vector2D::new(0 as Coord, 0 as Coord), Vec::new(), mouse_event),
); );
send_exit_events(&mouse_input_state, mouse_event.position(), platform_window); send_exit_events(&mouse_input_state, mouse_event.position(), window_adapter);
result result
} }

View file

@ -136,7 +136,7 @@ impl<T: Clone> ItemCache<T> {
/// Function that must be called when a component is destroyed. /// Function that must be called when a component is destroyed.
/// ///
/// Usually can be called from [`crate::window::PlatformWindow::unregister_component`] /// Usually can be called from [`crate::window::WindowAdapter::unregister_component`]
pub fn component_destroyed(&self, component: crate::component::ComponentRef) { pub fn component_destroyed(&self, component: crate::component::ComponentRef) {
let component_ptr: *const _ = let component_ptr: *const _ =
crate::component::ComponentRef::as_ptr(component).cast().as_ptr(); crate::component::ComponentRef::as_ptr(component).cast().as_ptr();

View file

@ -30,7 +30,7 @@ pub use crate::item_tree::ItemRc;
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::{PlatformWindow, PlatformWindowRc, WindowHandleAccess}; use crate::window::{WindowAdapter, WindowAdapterRc, WindowHandleAccess};
use crate::{Callback, Coord, Property, SharedString}; use crate::{Callback, Coord, Property, SharedString};
use alloc::rc::Rc; use alloc::rc::Rc;
use const_field_offset::FieldOffsets; use const_field_offset::FieldOffsets;
@ -108,7 +108,7 @@ pub struct ItemVTable {
/// This function is called by the run-time after the memory for the item /// This function is called by the run-time after the memory for the item
/// has been allocated and initialized. It will be called before any user specified /// has been allocated and initialized. It will be called before any user specified
/// bindings are set. /// bindings are set.
pub init: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, platform_window: &PlatformWindowRc), pub init: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, window_adapter: &WindowAdapterRc),
/// Returns the geometry of this item (relative to its parent item) /// Returns the geometry of this item (relative to its parent item)
pub geometry: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>) -> Rect, pub geometry: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>) -> Rect,
@ -123,7 +123,7 @@ pub struct ItemVTable {
pub layout_info: extern "C" fn( pub layout_info: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
orientation: Orientation, orientation: Orientation,
platform_window: &PlatformWindowRc, window_adapter: &WindowAdapterRc,
) -> LayoutInfo, ) -> LayoutInfo,
/// Event handler for mouse and touch event. This function is called before being called on children. /// Event handler for mouse and touch event. This function is called before being called on children.
@ -133,7 +133,7 @@ pub struct ItemVTable {
pub input_event_filter_before_children: extern "C" fn( pub input_event_filter_before_children: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
MouseEvent, MouseEvent,
platform_window: &PlatformWindowRc, window_adapter: &WindowAdapterRc,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventFilterResult, ) -> InputEventFilterResult,
@ -141,20 +141,20 @@ pub struct ItemVTable {
pub input_event: extern "C" fn( pub input_event: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
MouseEvent, MouseEvent,
platform_window: &PlatformWindowRc, window_adapter: &WindowAdapterRc,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventResult, ) -> InputEventResult,
pub focus_event: extern "C" fn( pub focus_event: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
&FocusEvent, &FocusEvent,
platform_window: &PlatformWindowRc, window_adapter: &WindowAdapterRc,
) -> FocusEventResult, ) -> FocusEventResult,
pub key_event: extern "C" fn( pub key_event: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
&KeyEvent, &KeyEvent,
platform_window: &PlatformWindowRc, window_adapter: &WindowAdapterRc,
) -> KeyEventResult, ) -> KeyEventResult,
pub render: extern "C" fn( pub render: extern "C" fn(
@ -182,7 +182,7 @@ pub struct Rectangle {
} }
impl Item for Rectangle { impl Item for Rectangle {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -191,7 +191,7 @@ impl Item for Rectangle {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -199,7 +199,7 @@ impl Item for Rectangle {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -208,7 +208,7 @@ impl Item for Rectangle {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -217,7 +217,7 @@ impl Item for Rectangle {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -225,7 +225,7 @@ impl Item for Rectangle {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -268,7 +268,7 @@ pub struct BorderRectangle {
} }
impl Item for BorderRectangle { impl Item for BorderRectangle {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -277,7 +277,7 @@ impl Item for BorderRectangle {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -285,7 +285,7 @@ impl Item for BorderRectangle {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -294,7 +294,7 @@ impl Item for BorderRectangle {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -303,7 +303,7 @@ impl Item for BorderRectangle {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -311,7 +311,7 @@ impl Item for BorderRectangle {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -369,7 +369,7 @@ pub struct TouchArea {
} }
impl Item for TouchArea { impl Item for TouchArea {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -378,7 +378,7 @@ impl Item for TouchArea {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -386,7 +386,7 @@ impl Item for TouchArea {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if !self.enabled() { if !self.enabled() {
@ -399,7 +399,7 @@ impl Item for TouchArea {
let hovering = !matches!(event, MouseEvent::Exit); let hovering = !matches!(event, MouseEvent::Exit);
Self::FIELD_OFFSETS.has_hover.apply_pin(self).set(hovering); Self::FIELD_OFFSETS.has_hover.apply_pin(self).set(hovering);
if hovering { if hovering {
platform_window.set_mouse_cursor(self.mouse_cursor()); window_adapter.set_mouse_cursor(self.mouse_cursor());
} }
InputEventFilterResult::ForwardAndInterceptGrab InputEventFilterResult::ForwardAndInterceptGrab
} }
@ -407,12 +407,12 @@ impl Item for TouchArea {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if matches!(event, MouseEvent::Exit) { if matches!(event, MouseEvent::Exit) {
Self::FIELD_OFFSETS.has_hover.apply_pin(self).set(false); Self::FIELD_OFFSETS.has_hover.apply_pin(self).set(false);
platform_window.set_mouse_cursor(MouseCursor::Default); window_adapter.set_mouse_cursor(MouseCursor::Default);
} }
if !self.enabled() { if !self.enabled() {
return InputEventResult::EventIgnored; return InputEventResult::EventIgnored;
@ -483,7 +483,7 @@ impl Item for TouchArea {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -491,7 +491,7 @@ impl Item for TouchArea {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -534,7 +534,7 @@ pub struct FocusScope {
} }
impl Item for FocusScope { impl Item for FocusScope {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -543,7 +543,7 @@ impl Item for FocusScope {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -551,7 +551,7 @@ impl Item for FocusScope {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -560,11 +560,11 @@ impl Item for FocusScope {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if self.enabled() && matches!(event, MouseEvent::Pressed { .. }) && !self.has_focus() { if self.enabled() && matches!(event, MouseEvent::Pressed { .. }) && !self.has_focus() {
platform_window.window().window_handle().set_focus_item(self_rc); window_adapter.window().window_handle().set_focus_item(self_rc);
} }
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
@ -572,7 +572,7 @@ impl Item for FocusScope {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &KeyEvent, event: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
let r = match event.event_type { let r = match event.event_type {
KeyEventType::KeyPressed => { KeyEventType::KeyPressed => {
@ -591,7 +591,7 @@ impl Item for FocusScope {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &FocusEvent, event: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
if !self.enabled() { if !self.enabled() {
return FocusEventResult::FocusIgnored; return FocusEventResult::FocusIgnored;
@ -644,7 +644,7 @@ pub struct Clip {
} }
impl Item for Clip { impl Item for Clip {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -653,7 +653,7 @@ impl Item for Clip {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -661,7 +661,7 @@ impl Item for Clip {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if let Some(pos) = event.position() { if let Some(pos) = event.position() {
@ -680,7 +680,7 @@ impl Item for Clip {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -689,7 +689,7 @@ impl Item for Clip {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -697,7 +697,7 @@ impl Item for Clip {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -735,7 +735,7 @@ pub struct Opacity {
} }
impl Item for Opacity { impl Item for Opacity {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -744,7 +744,7 @@ impl Item for Opacity {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -752,7 +752,7 @@ impl Item for Opacity {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -761,7 +761,7 @@ impl Item for Opacity {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -770,7 +770,7 @@ impl Item for Opacity {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -778,7 +778,7 @@ impl Item for Opacity {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -845,7 +845,7 @@ pub struct Layer {
} }
impl Item for Layer { impl Item for Layer {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -854,7 +854,7 @@ impl Item for Layer {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -862,7 +862,7 @@ impl Item for Layer {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -871,7 +871,7 @@ impl Item for Layer {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -880,7 +880,7 @@ impl Item for Layer {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -888,7 +888,7 @@ impl Item for Layer {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -927,7 +927,7 @@ pub struct Rotate {
} }
impl Item for Rotate { impl Item for Rotate {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(0 as _, 0 as _, self.width(), self.height()) euclid::rect(0 as _, 0 as _, self.width(), self.height())
@ -936,7 +936,7 @@ impl Item for Rotate {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -944,7 +944,7 @@ impl Item for Rotate {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -953,7 +953,7 @@ impl Item for Rotate {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -962,7 +962,7 @@ impl Item for Rotate {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -970,7 +970,7 @@ impl Item for Rotate {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -1043,7 +1043,7 @@ pub struct WindowItem {
} }
impl Item for WindowItem { impl Item for WindowItem {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(0 as _, 0 as _, self.width(), self.height()) euclid::rect(0 as _, 0 as _, self.width(), self.height())
@ -1052,7 +1052,7 @@ impl Item for WindowItem {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -1060,7 +1060,7 @@ impl Item for WindowItem {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -1069,7 +1069,7 @@ impl Item for WindowItem {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_event: MouseEvent, _event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -1078,7 +1078,7 @@ impl Item for WindowItem {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -1086,7 +1086,7 @@ impl Item for WindowItem {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -1158,7 +1158,7 @@ pub struct BoxShadow {
} }
impl Item for BoxShadow { impl Item for BoxShadow {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -1167,7 +1167,7 @@ impl Item for BoxShadow {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -1175,7 +1175,7 @@ impl Item for BoxShadow {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -1184,7 +1184,7 @@ impl Item for BoxShadow {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_event: MouseEvent, _event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -1193,7 +1193,7 @@ impl Item for BoxShadow {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -1201,7 +1201,7 @@ impl Item for BoxShadow {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -21,7 +21,7 @@ use crate::items::{PropertyAnimation, Rectangle};
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use crate::Coord; use crate::Coord;
use crate::Property; use crate::Property;
use alloc::boxed::Box; use alloc::boxed::Box;
@ -55,7 +55,7 @@ pub struct Flickable {
} }
impl Item for Flickable { impl Item for Flickable {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -64,7 +64,7 @@ impl Item for Flickable {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -72,7 +72,7 @@ impl Item for Flickable {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if let Some(pos) = event.position() { if let Some(pos) = event.position() {
@ -89,7 +89,7 @@ impl Item for Flickable {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if !self.interactive() && !matches!(event, MouseEvent::Wheel { .. }) { if !self.interactive() && !matches!(event, MouseEvent::Wheel { .. }) {
@ -112,7 +112,7 @@ impl Item for Flickable {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -120,7 +120,7 @@ impl Item for Flickable {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -18,7 +18,7 @@ use crate::item_rendering::ItemRenderer;
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use crate::{Brush, Coord, Property}; use crate::{Brush, Coord, Property};
use alloc::rc::Rc; use alloc::rc::Rc;
use const_field_offset::FieldOffsets; use const_field_offset::FieldOffsets;
@ -41,7 +41,7 @@ pub struct ImageItem {
} }
impl Item for ImageItem { impl Item for ImageItem {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -50,7 +50,7 @@ impl Item for ImageItem {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let natural_size = self.source().size(); let natural_size = self.source().size();
LayoutInfo { LayoutInfo {
@ -68,7 +68,7 @@ impl Item for ImageItem {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -77,7 +77,7 @@ impl Item for ImageItem {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -86,7 +86,7 @@ impl Item for ImageItem {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -94,7 +94,7 @@ impl Item for ImageItem {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -137,7 +137,7 @@ pub struct ClippedImage {
} }
impl Item for ClippedImage { impl Item for ClippedImage {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -146,7 +146,7 @@ impl Item for ClippedImage {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let natural_size = self.source().size(); let natural_size = self.source().size();
LayoutInfo { LayoutInfo {
@ -164,7 +164,7 @@ impl Item for ClippedImage {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -173,7 +173,7 @@ impl Item for ClippedImage {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -182,7 +182,7 @@ impl Item for ClippedImage {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -190,7 +190,7 @@ impl Item for ClippedImage {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -19,7 +19,7 @@ use crate::item_rendering::CachedRenderingData;
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::PlatformWindow; use crate::window::WindowAdapter;
use crate::{Coord, Property}; use crate::{Coord, Property};
use alloc::rc::Rc; use alloc::rc::Rc;
use const_field_offset::FieldOffsets; use const_field_offset::FieldOffsets;
@ -49,7 +49,7 @@ pub struct Path {
} }
impl Item for Path { impl Item for Path {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -58,7 +58,7 @@ impl Item for Path {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -66,7 +66,7 @@ impl Item for Path {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if let Some(pos) = event.position() { if let Some(pos) = event.position() {
@ -85,7 +85,7 @@ impl Item for Path {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -94,7 +94,7 @@ impl Item for Path {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -102,7 +102,7 @@ impl Item for Path {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }

View file

@ -22,7 +22,7 @@ use crate::item_rendering::{CachedRenderingData, ItemRenderer};
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::{PlatformWindow, WindowHandleAccess, WindowInner}; use crate::window::{WindowAdapter, WindowHandleAccess, WindowInner};
use crate::{Callback, Coord, Property, SharedString}; use crate::{Callback, Coord, Property, SharedString};
use alloc::rc::Rc; use alloc::rc::Rc;
use alloc::string::String; use alloc::string::String;
@ -56,7 +56,7 @@ pub struct Text {
} }
impl Item for Text { impl Item for Text {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -65,15 +65,15 @@ impl Item for Text {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let window = platform_window.window().window_handle(); let window = window_adapter.window().window_handle();
let implicit_size = |max_width| { let implicit_size = |max_width| {
platform_window.renderer().text_size( window_adapter.renderer().text_size(
self.font_request(window), self.font_request(window),
self.text().as_str(), self.text().as_str(),
max_width, max_width,
platform_window.window().scale_factor().get(), window_adapter.window().scale_factor().get(),
) )
}; };
@ -85,7 +85,7 @@ impl Item for Text {
let implicit_size = implicit_size(None); let implicit_size = implicit_size(None);
let min = match self.overflow() { let min = match self.overflow() {
TextOverflow::Elide => implicit_size.width.min( TextOverflow::Elide => implicit_size.width.min(
platform_window window_adapter
.renderer() .renderer()
.text_size(self.font_request(window), "", None, window.scale_factor()) .text_size(self.font_request(window), "", None, window.scale_factor())
.width, .width,
@ -115,7 +115,7 @@ impl Item for Text {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -124,7 +124,7 @@ impl Item for Text {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
@ -133,7 +133,7 @@ impl Item for Text {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &KeyEvent, _: &KeyEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
@ -141,7 +141,7 @@ impl Item for Text {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
_: &FocusEvent, _: &FocusEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
FocusEventResult::FocusIgnored FocusEventResult::FocusIgnored
} }
@ -235,7 +235,7 @@ pub struct TextInput {
} }
impl Item for TextInput { impl Item for TextInput {
fn init(self: Pin<&Self>, _platform_window: &Rc<dyn PlatformWindow>) {} fn init(self: Pin<&Self>, _window_adapter: &Rc<dyn WindowAdapter>) {}
// FIXME: width / height. or maybe it doesn't matter? ( // FIXME: width / height. or maybe it doesn't matter? (
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
@ -245,12 +245,12 @@ impl Item for TextInput {
fn layout_info( fn layout_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) -> LayoutInfo { ) -> LayoutInfo {
let text = self.text(); let text = self.text();
let implicit_size = |max_width| { let implicit_size = |max_width| {
platform_window.renderer().text_size( window_adapter.renderer().text_size(
self.font_request(platform_window), self.font_request(window_adapter),
{ {
if text.is_empty() { if text.is_empty() {
"*" "*"
@ -259,7 +259,7 @@ impl Item for TextInput {
} }
}, },
max_width, max_width,
platform_window.window().scale_factor().get(), window_adapter.window().scale_factor().get(),
) )
}; };
@ -293,7 +293,7 @@ impl Item for TextInput {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_platform_window: &Rc<dyn PlatformWindow>, _window_adapter: &Rc<dyn WindowAdapter>,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -302,7 +302,7 @@ impl Item for TextInput {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if !self.enabled() { if !self.enabled() {
@ -311,13 +311,13 @@ impl Item for TextInput {
match event { match event {
MouseEvent::Pressed { position, button: PointerEventButton::Left } => { MouseEvent::Pressed { position, button: PointerEventButton::Left } => {
let clicked_offset = let clicked_offset =
platform_window.renderer().text_input_byte_offset_for_position(self, position) window_adapter.renderer().text_input_byte_offset_for_position(self, position)
as i32; as i32;
self.as_ref().pressed.set(true); self.as_ref().pressed.set(true);
self.as_ref().anchor_position.set(clicked_offset); self.as_ref().anchor_position.set(clicked_offset);
self.set_cursor_position(clicked_offset, true, platform_window); self.set_cursor_position(clicked_offset, true, window_adapter);
if !self.has_focus() { if !self.has_focus() {
platform_window.window().window_handle().set_focus_item(self_rc); window_adapter.window().window_handle().set_focus_item(self_rc);
} }
} }
MouseEvent::Released { button: PointerEventButton::Left, .. } | MouseEvent::Exit => { MouseEvent::Released { button: PointerEventButton::Left, .. } | MouseEvent::Exit => {
@ -325,11 +325,11 @@ impl Item for TextInput {
} }
MouseEvent::Moved { position } => { MouseEvent::Moved { position } => {
if self.as_ref().pressed.get() { if self.as_ref().pressed.get() {
let clicked_offset = platform_window let clicked_offset = window_adapter
.renderer() .renderer()
.text_input_byte_offset_for_position(self, position) .text_input_byte_offset_for_position(self, position)
as i32; as i32;
self.set_cursor_position(clicked_offset, true, platform_window); self.set_cursor_position(clicked_offset, true, window_adapter);
} }
} }
_ => return InputEventResult::EventIgnored, _ => return InputEventResult::EventIgnored,
@ -340,7 +340,7 @@ impl Item for TextInput {
fn key_event( fn key_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &KeyEvent, event: &KeyEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) -> KeyEventResult { ) -> KeyEventResult {
if !self.enabled() { if !self.enabled() {
return KeyEventResult::EventIgnored; return KeyEventResult::EventIgnored;
@ -355,7 +355,7 @@ impl Item for TextInput {
self, self,
direction, direction,
event.modifiers.into(), event.modifiers.into(),
platform_window, window_adapter,
); );
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
@ -363,7 +363,7 @@ impl Item for TextInput {
TextInput::select_and_delete( TextInput::select_and_delete(
self, self,
TextCursorDirection::Forward, TextCursorDirection::Forward,
platform_window, window_adapter,
); );
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
@ -372,7 +372,7 @@ impl Item for TextInput {
TextInput::select_and_delete( TextInput::select_and_delete(
self, self,
TextCursorDirection::PreviousCharacter, TextCursorDirection::PreviousCharacter,
platform_window, window_adapter,
); );
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
@ -380,7 +380,7 @@ impl Item for TextInput {
TextInput::select_and_delete( TextInput::select_and_delete(
self, self,
TextCursorDirection::ForwardByWord, TextCursorDirection::ForwardByWord,
platform_window, window_adapter,
); );
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
@ -388,7 +388,7 @@ impl Item for TextInput {
TextInput::select_and_delete( TextInput::select_and_delete(
self, self,
TextCursorDirection::BackwardByWord, TextCursorDirection::BackwardByWord,
platform_window, window_adapter,
); );
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
@ -418,7 +418,7 @@ impl Item for TextInput {
match event.shortcut() { match event.shortcut() {
Some(shortcut) => match shortcut { Some(shortcut) => match shortcut {
StandardShortcut::SelectAll => { StandardShortcut::SelectAll => {
self.select_all(platform_window); self.select_all(window_adapter);
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
StandardShortcut::Copy => { StandardShortcut::Copy => {
@ -426,12 +426,12 @@ impl Item for TextInput {
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
StandardShortcut::Paste if !self.read_only() => { StandardShortcut::Paste if !self.read_only() => {
self.paste(platform_window); self.paste(window_adapter);
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
StandardShortcut::Cut if !self.read_only() => { StandardShortcut::Cut if !self.read_only() => {
self.copy(); self.copy();
self.delete_selection(platform_window); self.delete_selection(window_adapter);
return KeyEventResult::EventAccepted; return KeyEventResult::EventAccepted;
} }
StandardShortcut::Paste | StandardShortcut::Cut => { StandardShortcut::Paste | StandardShortcut::Cut => {
@ -444,7 +444,7 @@ impl Item for TextInput {
if self.read_only() || event.modifiers.control { if self.read_only() || event.modifiers.control {
return KeyEventResult::EventIgnored; return KeyEventResult::EventIgnored;
} }
self.delete_selection(platform_window); self.delete_selection(window_adapter);
let mut text: String = self.text().into(); let mut text: String = self.text().into();
@ -455,11 +455,11 @@ impl Item for TextInput {
self.as_ref().text.set(text.into()); self.as_ref().text.set(text.into());
let new_cursor_pos = (insert_pos + event.text.len()) as i32; let new_cursor_pos = (insert_pos + event.text.len()) as i32;
self.as_ref().anchor_position.set(new_cursor_pos); self.as_ref().anchor_position.set(new_cursor_pos);
self.set_cursor_position(new_cursor_pos, true, platform_window); self.set_cursor_position(new_cursor_pos, true, window_adapter);
// Keep the cursor visible when inserting text. Blinking should only occur when // Keep the cursor visible when inserting text. Blinking should only occur when
// nothing is entered or the cursor isn't moved. // nothing is entered or the cursor isn't moved.
self.as_ref().show_cursor(platform_window); self.as_ref().show_cursor(window_adapter);
Self::FIELD_OFFSETS.edited.apply_pin(self).call(&()); Self::FIELD_OFFSETS.edited.apply_pin(self).call(&());
@ -472,18 +472,18 @@ impl Item for TextInput {
fn focus_event( fn focus_event(
self: Pin<&Self>, self: Pin<&Self>,
event: &FocusEvent, event: &FocusEvent,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) -> FocusEventResult { ) -> FocusEventResult {
match event { match event {
FocusEvent::FocusIn | FocusEvent::WindowReceivedFocus => { FocusEvent::FocusIn | FocusEvent::WindowReceivedFocus => {
self.has_focus.set(true); self.has_focus.set(true);
self.show_cursor(platform_window); self.show_cursor(window_adapter);
platform_window.show_virtual_keyboard(self.input_type()); window_adapter.show_virtual_keyboard(self.input_type());
} }
FocusEvent::FocusOut | FocusEvent::WindowLostFocus => { FocusEvent::FocusOut | FocusEvent::WindowLostFocus => {
self.has_focus.set(false); self.has_focus.set(false);
self.hide_cursor(); self.hide_cursor();
platform_window.hide_virtual_keyboard(); window_adapter.hide_virtual_keyboard();
} }
} }
FocusEventResult::FocusAccepted FocusEventResult::FocusAccepted
@ -557,8 +557,8 @@ impl From<KeyboardModifiers> for AnchorMode {
} }
impl TextInput { impl TextInput {
fn show_cursor(&self, platform_window: &Rc<dyn PlatformWindow>) { fn show_cursor(&self, window_adapter: &Rc<dyn WindowAdapter>) {
platform_window.window().window_handle().set_cursor_blink_binding(&self.cursor_visible); window_adapter.window().window_handle().set_cursor_blink_binding(&self.cursor_visible);
} }
fn hide_cursor(&self) { fn hide_cursor(&self) {
@ -570,14 +570,14 @@ impl TextInput {
self: Pin<&Self>, self: Pin<&Self>,
direction: TextCursorDirection, direction: TextCursorDirection,
anchor_mode: AnchorMode, anchor_mode: AnchorMode,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) -> bool { ) -> bool {
let text = self.text(); let text = self.text();
if text.is_empty() { if text.is_empty() {
return false; return false;
} }
let renderer = platform_window.renderer(); let renderer = window_adapter.renderer();
let last_cursor_pos = (self.cursor_position() as usize).max(0).min(text.len()); let last_cursor_pos = (self.cursor_position() as usize).max(0).min(text.len());
@ -586,10 +586,10 @@ impl TextInput {
let font_height = renderer let font_height = renderer
.text_size( .text_size(
self.font_request(platform_window), self.font_request(window_adapter),
" ", " ",
None, None,
platform_window.window().scale_factor().get(), window_adapter.window().scale_factor().get(),
) )
.height; .height;
@ -695,11 +695,11 @@ impl TextInput {
self.as_ref().anchor_position.set(new_cursor_pos as i32); self.as_ref().anchor_position.set(new_cursor_pos as i32);
} }
} }
self.set_cursor_position(new_cursor_pos as i32, reset_preferred_x_pos, platform_window); self.set_cursor_position(new_cursor_pos as i32, reset_preferred_x_pos, window_adapter);
// Keep the cursor visible when moving. Blinking should only occur when // Keep the cursor visible when moving. Blinking should only occur when
// nothing is entered or the cursor isn't moved. // nothing is entered or the cursor isn't moved.
self.as_ref().show_cursor(platform_window); self.as_ref().show_cursor(window_adapter);
new_cursor_pos != last_cursor_pos new_cursor_pos != last_cursor_pos
} }
@ -708,11 +708,11 @@ impl TextInput {
self: Pin<&Self>, self: Pin<&Self>,
new_position: i32, new_position: i32,
reset_preferred_x_pos: bool, reset_preferred_x_pos: bool,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) { ) {
self.cursor_position.set(new_position); self.cursor_position.set(new_position);
if new_position >= 0 { if new_position >= 0 {
let pos = platform_window let pos = window_adapter
.renderer() .renderer()
.text_input_cursor_rect_for_byte_offset(self, new_position as usize) .text_input_cursor_rect_for_byte_offset(self, new_position as usize)
.origin; .origin;
@ -726,15 +726,15 @@ impl TextInput {
fn select_and_delete( fn select_and_delete(
self: Pin<&Self>, self: Pin<&Self>,
step: TextCursorDirection, step: TextCursorDirection,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) { ) {
if !self.has_selection() { if !self.has_selection() {
self.move_cursor(step, AnchorMode::KeepAnchor, platform_window); self.move_cursor(step, AnchorMode::KeepAnchor, window_adapter);
} }
self.delete_selection(platform_window); self.delete_selection(window_adapter);
} }
fn delete_selection(self: Pin<&Self>, platform_window: &Rc<dyn PlatformWindow>) { fn delete_selection(self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>) {
let text: String = self.text().into(); let text: String = self.text().into();
if text.is_empty() { if text.is_empty() {
return; return;
@ -748,7 +748,7 @@ impl TextInput {
let text = [text.split_at(anchor).0, text.split_at(cursor).1].concat(); let text = [text.split_at(anchor).0, text.split_at(cursor).1].concat();
self.text.set(text.into()); self.text.set(text.into());
self.anchor_position.set(anchor as i32); self.anchor_position.set(anchor as i32);
self.set_cursor_position(anchor as i32, true, platform_window); self.set_cursor_position(anchor as i32, true, window_adapter);
Self::FIELD_OFFSETS.edited.apply_pin(self).call(&()); Self::FIELD_OFFSETS.edited.apply_pin(self).call(&());
} }
@ -771,8 +771,8 @@ impl TextInput {
anchor_pos != cursor_pos anchor_pos != cursor_pos
} }
fn insert(self: Pin<&Self>, text_to_insert: &str, platform_window: &Rc<dyn PlatformWindow>) { fn insert(self: Pin<&Self>, text_to_insert: &str, window_adapter: &Rc<dyn WindowAdapter>) {
self.delete_selection(platform_window); self.delete_selection(window_adapter);
let mut text: String = self.text().into(); let mut text: String = self.text().into();
let cursor_pos = self.selection_anchor_and_cursor().1; let cursor_pos = self.selection_anchor_and_cursor().1;
if text_to_insert.contains('\n') && self.single_line() { if text_to_insert.contains('\n') && self.single_line() {
@ -783,13 +783,13 @@ impl TextInput {
let cursor_pos = cursor_pos + text_to_insert.len(); let cursor_pos = cursor_pos + text_to_insert.len();
self.text.set(text.into()); self.text.set(text.into());
self.anchor_position.set(cursor_pos as i32); self.anchor_position.set(cursor_pos as i32);
self.set_cursor_position(cursor_pos as i32, true, platform_window); self.set_cursor_position(cursor_pos as i32, true, window_adapter);
Self::FIELD_OFFSETS.edited.apply_pin(self).call(&()); Self::FIELD_OFFSETS.edited.apply_pin(self).call(&());
} }
fn select_all(self: Pin<&Self>, platform_window: &Rc<dyn PlatformWindow>) { fn select_all(self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>) {
self.move_cursor(TextCursorDirection::StartOfText, AnchorMode::MoveAnchor, platform_window); self.move_cursor(TextCursorDirection::StartOfText, AnchorMode::MoveAnchor, window_adapter);
self.move_cursor(TextCursorDirection::EndOfText, AnchorMode::KeepAnchor, platform_window); self.move_cursor(TextCursorDirection::EndOfText, AnchorMode::KeepAnchor, window_adapter);
} }
fn copy(self: Pin<&Self>) { fn copy(self: Pin<&Self>) {
@ -805,16 +805,16 @@ impl TextInput {
}); });
} }
fn paste(self: Pin<&Self>, platform_window: &Rc<dyn PlatformWindow>) { fn paste(self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>) {
if let Some(text) = crate::platform::PLATFORM_ABSTRACTION_INSTANCE if let Some(text) = crate::platform::PLATFORM_ABSTRACTION_INSTANCE
.with(|p| p.get().and_then(|p| p.clipboard_text())) .with(|p| p.get().and_then(|p| p.clipboard_text()))
{ {
self.insert(&text, platform_window); self.insert(&text, window_adapter);
} }
} }
pub fn font_request(self: Pin<&Self>, platform_window: &Rc<dyn PlatformWindow>) -> FontRequest { pub fn font_request(self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>) -> FontRequest {
let window_item = platform_window.window().window_handle().window_item(); let window_item = window_adapter.window().window_handle().window_item();
FontRequest { FontRequest {
family: { family: {

View file

@ -21,7 +21,7 @@ pub use crate::lengths::{PhysicalLength, PhysicalPoint};
pub use crate::renderer::Renderer; pub use crate::renderer::Renderer;
#[cfg(feature = "swrenderer")] #[cfg(feature = "swrenderer")]
pub use crate::swrenderer; pub use crate::swrenderer;
pub use crate::window::PlatformWindow; pub use crate::window::WindowAdapter;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
/// Behavior describing how the event loop should terminate. /// Behavior describing how the event loop should terminate.
@ -35,7 +35,7 @@ pub enum EventLoopQuitBehavior {
/// Interface implemented by back-ends /// Interface implemented by back-ends
pub trait Platform { pub trait Platform {
/// Instantiate a window for a component. /// Instantiate a window for a component.
fn create_window(&self) -> Rc<dyn PlatformWindow>; fn create_window(&self) -> Rc<dyn WindowAdapter>;
/// Spins an event loop and renders the visible windows. /// Spins an event loop and renders the visible windows.
fn run_event_loop(&self, _behavior: EventLoopQuitBehavior) { fn run_event_loop(&self, _behavior: EventLoopQuitBehavior) {

View file

@ -29,7 +29,7 @@ pub extern "C" fn slint_send_mouse_click(
component: &crate::component::ComponentRc, component: &crate::component::ComponentRc,
x: Coord, x: Coord,
y: Coord, y: Coord,
platform_window: &crate::window::PlatformWindowRc, window_adapter: &crate::window::WindowAdapterRc,
) { ) {
let mut state = crate::input::MouseInputState::default(); let mut state = crate::input::MouseInputState::default();
let position = euclid::point2(x, y); let position = euclid::point2(x, y);
@ -37,20 +37,20 @@ pub extern "C" fn slint_send_mouse_click(
state = crate::input::process_mouse_input( state = crate::input::process_mouse_input(
component.clone(), component.clone(),
MouseEvent::Moved { position }, MouseEvent::Moved { position },
platform_window, window_adapter,
state, state,
); );
state = crate::input::process_mouse_input( state = crate::input::process_mouse_input(
component.clone(), component.clone(),
MouseEvent::Pressed { position, button: crate::items::PointerEventButton::Left }, MouseEvent::Pressed { position, button: crate::items::PointerEventButton::Left },
platform_window, window_adapter,
state, state,
); );
slint_mock_elapsed_time(50); slint_mock_elapsed_time(50);
crate::input::process_mouse_input( crate::input::process_mouse_input(
component.clone(), component.clone(),
MouseEvent::Released { position, button: crate::items::PointerEventButton::Left }, MouseEvent::Released { position, button: crate::items::PointerEventButton::Left },
platform_window, window_adapter,
state, state,
); );
} }
@ -60,7 +60,7 @@ pub extern "C" fn slint_send_mouse_click(
pub extern "C" fn send_keyboard_string_sequence( pub extern "C" fn send_keyboard_string_sequence(
sequence: &crate::SharedString, sequence: &crate::SharedString,
modifiers: KeyboardModifiers, modifiers: KeyboardModifiers,
platform_window: &crate::window::PlatformWindowRc, window_adapter: &crate::window::WindowAdapterRc,
) { ) {
for ch in sequence.chars() { for ch in sequence.chars() {
let mut modifiers = modifiers; let mut modifiers = modifiers;
@ -70,12 +70,12 @@ pub extern "C" fn send_keyboard_string_sequence(
let mut buffer = [0; 6]; let mut buffer = [0; 6];
let text = SharedString::from(ch.encode_utf8(&mut buffer) as &str); let text = SharedString::from(ch.encode_utf8(&mut buffer) as &str);
platform_window.window().window_handle().process_key_input(&KeyEvent { window_adapter.window().window_handle().process_key_input(&KeyEvent {
event_type: KeyEventType::KeyPressed, event_type: KeyEventType::KeyPressed,
text: text.clone(), text: text.clone(),
modifiers, modifiers,
}); });
platform_window.window().window_handle().process_key_input(&KeyEvent { window_adapter.window().window_handle().process_key_input(&KeyEvent {
event_type: KeyEventType::KeyReleased, event_type: KeyEventType::KeyReleased,
text, text,
modifiers, modifiers,

View file

@ -34,7 +34,7 @@ fn previous_focus_item(item: ItemRc) -> ItemRc {
/// This trait represents the interface that the generated code and the run-time /// This trait represents the interface that the generated code and the run-time
/// require in order to implement functionality such as device-independent pixels, /// require in order to implement functionality such as device-independent pixels,
/// window resizing and other typically windowing system related tasks. /// window resizing and other typically windowing system related tasks.
pub trait PlatformWindow { pub trait WindowAdapter {
/// Registers the window with the windowing system. /// Registers the window with the windowing system.
fn show(&self) {} fn show(&self) {}
/// De-registers the window from the windowing system. /// De-registers the window from the windowing system.
@ -62,7 +62,7 @@ pub trait PlatformWindow {
/// ///
/// If this function return None (the default implementation), then the /// If this function return None (the default implementation), then the
/// popup will be rendered within the window itself. /// popup will be rendered within the window itself.
fn create_popup(&self, _geometry: Rect) -> Option<Rc<dyn PlatformWindow>> { fn create_popup(&self, _geometry: Rect) -> Option<Rc<dyn WindowAdapter>> {
None None
} }
@ -122,25 +122,25 @@ pub trait PlatformWindow {
} }
struct WindowPropertiesTracker { struct WindowPropertiesTracker {
platform_window_weak: Weak<dyn PlatformWindow>, window_adapter_weak: Weak<dyn WindowAdapter>,
} }
impl crate::properties::PropertyDirtyHandler for WindowPropertiesTracker { impl crate::properties::PropertyDirtyHandler for WindowPropertiesTracker {
fn notify(&self) { fn notify(&self) {
if let Some(platform_window) = self.platform_window_weak.upgrade() { if let Some(window_adapter) = self.window_adapter_weak.upgrade() {
platform_window.request_window_properties_update(); window_adapter.request_window_properties_update();
}; };
} }
} }
struct WindowRedrawTracker { struct WindowRedrawTracker {
platform_window_weak: Weak<dyn PlatformWindow>, window_adapter_weak: Weak<dyn WindowAdapter>,
} }
impl crate::properties::PropertyDirtyHandler for WindowRedrawTracker { impl crate::properties::PropertyDirtyHandler for WindowRedrawTracker {
fn notify(&self) { fn notify(&self) {
if let Some(platform_window) = self.platform_window_weak.upgrade() { if let Some(window_adapter) = self.window_adapter_weak.upgrade() {
platform_window.request_redraw(); window_adapter.request_redraw();
}; };
} }
} }
@ -148,7 +148,7 @@ impl crate::properties::PropertyDirtyHandler for WindowRedrawTracker {
/// This enum describes the different ways a popup can be rendered by the back-end. /// This enum describes the different ways a popup can be rendered by the back-end.
pub enum PopupWindowLocation { pub enum PopupWindowLocation {
/// The popup is rendered in its own top-level window that is know to the windowing system. /// The popup is rendered in its own top-level window that is know to the windowing system.
TopLevel(Rc<dyn PlatformWindow>), TopLevel(Rc<dyn WindowAdapter>),
/// The popup is rendered as an embedded child window at the given position. /// The popup is rendered as an embedded child window at the given position.
ChildWindow(Point), ChildWindow(Point),
} }
@ -164,7 +164,7 @@ pub struct PopupWindow {
/// Inner datastructure for the [`crate::api::Window`] /// Inner datastructure for the [`crate::api::Window`]
pub struct WindowInner { pub struct WindowInner {
platform_window_weak: Weak<dyn PlatformWindow>, window_adapter_weak: Weak<dyn WindowAdapter>,
component: RefCell<ComponentWeak>, component: RefCell<ComponentWeak>,
mouse_input_state: Cell<MouseInputState>, mouse_input_state: Cell<MouseInputState>,
redraw_tracker: Pin<Box<PropertyTracker<WindowRedrawTracker>>>, redraw_tracker: Pin<Box<PropertyTracker<WindowRedrawTracker>>>,
@ -193,17 +193,17 @@ impl Drop for WindowInner {
} }
impl WindowInner { impl WindowInner {
/// Create a new instance of the window, given the platform_window factory fn /// Create a new instance of the window, given the window_adapter factory fn
pub fn new(platform_window_weak: Weak<dyn PlatformWindow>) -> Self { pub fn new(window_adapter_weak: Weak<dyn WindowAdapter>) -> Self {
#![allow(unused_mut)] #![allow(unused_mut)]
let mut window_properties_tracker = let mut window_properties_tracker =
PropertyTracker::new_with_dirty_handler(WindowPropertiesTracker { PropertyTracker::new_with_dirty_handler(WindowPropertiesTracker {
platform_window_weak: platform_window_weak.clone(), window_adapter_weak: window_adapter_weak.clone(),
}); });
let mut redraw_tracker = PropertyTracker::new_with_dirty_handler(WindowRedrawTracker { let mut redraw_tracker = PropertyTracker::new_with_dirty_handler(WindowRedrawTracker {
platform_window_weak: platform_window_weak.clone(), window_adapter_weak: window_adapter_weak.clone(),
}); });
#[cfg(slint_debug_property)] #[cfg(slint_debug_property)]
@ -214,7 +214,7 @@ impl WindowInner {
} }
let window = Self { let window = Self {
platform_window_weak, window_adapter_weak,
component: Default::default(), component: Default::default(),
mouse_input_state: Default::default(), mouse_input_state: Default::default(),
redraw_tracker: Box::pin(redraw_tracker), redraw_tracker: Box::pin(redraw_tracker),
@ -240,9 +240,9 @@ impl WindowInner {
self.mouse_input_state.replace(Default::default()); self.mouse_input_state.replace(Default::default());
self.component.replace(ComponentRc::downgrade(component)); self.component.replace(ComponentRc::downgrade(component));
self.meta_properties_tracker.set_dirty(); // component changed, layout constraints for sure must be re-calculated self.meta_properties_tracker.set_dirty(); // component changed, layout constraints for sure must be re-calculated
let platform_window = self.platform_window(); let window_adapter = self.window_adapter();
platform_window.request_window_properties_update(); window_adapter.request_window_properties_update();
platform_window.request_redraw(); window_adapter.request_redraw();
} }
/// return the component. /// return the component.
@ -304,7 +304,7 @@ impl WindowInner {
self.mouse_input_state.set(crate::input::process_mouse_input( self.mouse_input_state.set(crate::input::process_mouse_input(
component, component,
event, event,
&self.platform_window(), &self.window_adapter(),
self.mouse_input_state.take(), self.mouse_input_state.take(),
)); ));
@ -329,7 +329,7 @@ impl WindowInner {
// Reset the focus... not great, but better than keeping it. // Reset the focus... not great, but better than keeping it.
self.take_focus_item(); self.take_focus_item();
} else { } else {
if focus_item.borrow().as_ref().key_event(event, &self.platform_window()) if focus_item.borrow().as_ref().key_event(event, &self.window_adapter())
== crate::input::KeyEventResult::EventAccepted == crate::input::KeyEventResult::EventAccepted
{ {
return; return;
@ -367,7 +367,7 @@ impl WindowInner {
pub fn set_focus_item(&self, focus_item: &ItemRc) { pub fn set_focus_item(&self, focus_item: &ItemRc) {
let old = self.take_focus_item(); let old = self.take_focus_item();
let new = self.clone().move_focus(focus_item.clone(), next_focus_item); let new = self.clone().move_focus(focus_item.clone(), next_focus_item);
self.platform_window().handle_focus_change(old, new); self.window_adapter().handle_focus_change(old, new);
} }
/// Sets the focus on the window to true or false, depending on the have_focus argument. /// Sets the focus on the window to true or false, depending on the have_focus argument.
@ -380,7 +380,7 @@ impl WindowInner {
}; };
if let Some(focus_item) = self.focus_item.borrow().upgrade() { if let Some(focus_item) = self.focus_item.borrow().upgrade() {
focus_item.borrow().as_ref().focus_event(&event, &self.platform_window()); focus_item.borrow().as_ref().focus_event(&event, &self.window_adapter());
} }
} }
@ -394,7 +394,7 @@ impl WindowInner {
focus_item_rc focus_item_rc
.borrow() .borrow()
.as_ref() .as_ref()
.focus_event(&crate::input::FocusEvent::FocusOut, &self.platform_window()); .focus_event(&crate::input::FocusEvent::FocusOut, &self.window_adapter());
Some(focus_item_rc) Some(focus_item_rc)
} else { } else {
None None
@ -410,7 +410,7 @@ impl WindowInner {
*self.focus_item.borrow_mut() = item.downgrade(); *self.focus_item.borrow_mut() = item.downgrade();
item.borrow() item.borrow()
.as_ref() .as_ref()
.focus_event(&crate::input::FocusEvent::FocusIn, &self.platform_window()) .focus_event(&crate::input::FocusEvent::FocusIn, &self.window_adapter())
} }
None => { None => {
*self.focus_item.borrow_mut() = Default::default(); *self.focus_item.borrow_mut() = Default::default();
@ -447,7 +447,7 @@ impl WindowInner {
.map(next_focus_item) .map(next_focus_item)
.unwrap_or_else(|| ItemRc::new(component, 0)); .unwrap_or_else(|| ItemRc::new(component, 0));
let end_item = self.move_focus(start_item.clone(), next_focus_item); let end_item = self.move_focus(start_item.clone(), next_focus_item);
self.platform_window().handle_focus_change(Some(start_item), end_item); self.window_adapter().handle_focus_change(Some(start_item), end_item);
} }
/// Move keyboard focus to the previous item. /// Move keyboard focus to the previous item.
@ -457,7 +457,7 @@ impl WindowInner {
self.take_focus_item().unwrap_or_else(|| ItemRc::new(component, 0)), self.take_focus_item().unwrap_or_else(|| ItemRc::new(component, 0)),
); );
let end_item = self.move_focus(start_item.clone(), previous_focus_item); let end_item = self.move_focus(start_item.clone(), previous_focus_item);
self.platform_window().handle_focus_change(Some(start_item), end_item); self.window_adapter().handle_focus_change(Some(start_item), end_item);
} }
/// Marks the window to be the active window. This typically coincides with the keyboard /// Marks the window to be the active window. This typically coincides with the keyboard
@ -480,7 +480,7 @@ impl WindowInner {
// an evaluation. // an evaluation.
self.window_properties_tracker.as_ref().evaluate_as_dependency_root(|| { self.window_properties_tracker.as_ref().evaluate_as_dependency_root(|| {
if let Some(window_item) = self.window_item() { if let Some(window_item) = self.window_item() {
self.platform_window().apply_window_properties(window_item.as_pin_ref()); self.window_adapter().apply_window_properties(window_item.as_pin_ref());
} }
}); });
} }
@ -493,7 +493,7 @@ impl WindowInner {
let component = ComponentRc::borrow_pin(&component_rc); let component = ComponentRc::borrow_pin(&component_rc);
self.meta_properties_tracker.as_ref().evaluate_if_dirty(|| { self.meta_properties_tracker.as_ref().evaluate_if_dirty(|| {
self.platform_window().apply_geometry_constraint( self.window_adapter().apply_geometry_constraint(
component.as_ref().layout_info(crate::layout::Orientation::Horizontal), component.as_ref().layout_info(crate::layout::Orientation::Horizontal),
component.as_ref().layout_info(crate::layout::Orientation::Vertical), component.as_ref().layout_info(crate::layout::Orientation::Vertical),
); );
@ -523,13 +523,13 @@ impl WindowInner {
/// Registers the window with the windowing system, in order to render the component's items and react /// Registers the window with the windowing system, in order to render the component's items and react
/// to input events once the event loop spins. /// to input events once the event loop spins.
pub fn show(&self) { pub fn show(&self) {
self.platform_window().show(); self.window_adapter().show();
self.update_window_properties(); self.update_window_properties();
} }
/// De-registers the window with the windowing system. /// De-registers the window with the windowing system.
pub fn hide(&self) { pub fn hide(&self) {
self.platform_window().hide(); self.window_adapter().hide();
} }
/// Show a popup at the given position relative to the item /// Show a popup at the given position relative to the item
@ -584,15 +584,15 @@ impl WindowInner {
height_property.set(size.height); height_property.set(size.height);
}; };
let location = match self.platform_window().create_popup(Rect::new(position, size)) { let location = match self.window_adapter().create_popup(Rect::new(position, size)) {
None => { None => {
self.meta_properties_tracker.set_dirty(); self.meta_properties_tracker.set_dirty();
PopupWindowLocation::ChildWindow(position) PopupWindowLocation::ChildWindow(position)
} }
Some(platform_window) => { Some(window_adapter) => {
platform_window.window().window_handle().set_component(popup_componentrc); window_adapter.window().window_handle().set_component(popup_componentrc);
PopupWindowLocation::TopLevel(platform_window) PopupWindowLocation::TopLevel(window_adapter)
} }
}; };
@ -612,9 +612,9 @@ impl WindowInner {
.translate(offset.to_vector()); .translate(offset.to_vector());
if !popup_region.is_empty() { if !popup_region.is_empty() {
let platform_window = self.platform_window(); let window_adapter = self.window_adapter();
platform_window.renderer().mark_dirty_region(popup_region.to_box2d()); window_adapter.renderer().mark_dirty_region(popup_region.to_box2d());
platform_window.request_redraw(); window_adapter.request_redraw();
} }
} }
} }
@ -677,9 +677,9 @@ impl WindowInner {
} }
} }
/// Returns the upgraded platform window. /// Returns the upgraded window adapter
pub fn platform_window(&self) -> Rc<dyn PlatformWindow> { pub fn window_adapter(&self) -> Rc<dyn WindowAdapter> {
self.platform_window_weak.upgrade().unwrap() self.window_adapter_weak.upgrade().unwrap()
} }
} }
@ -689,8 +689,8 @@ pub trait WindowHandleAccess {
fn window_handle(&self) -> &WindowInner; fn window_handle(&self) -> &WindowInner;
} }
/// Internal alias for Rc<dyn PlatformWindow>. /// Internal alias for Rc<dyn WindowAdapter>.
pub type PlatformWindowRc = Rc<dyn PlatformWindow>; pub type WindowAdapterRc = Rc<dyn WindowAdapter>;
/// This module contains the functions needed to interface with the event loop and window traits /// This module contains the functions needed to interface with the event loop and window traits
/// from outside the Rust language. /// from outside the Rust language.
@ -714,112 +714,112 @@ pub mod ffi {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
type c_void = (); type c_void = ();
/// Same layout as PlatformWindowRc /// Same layout as WindowAdapterRc
#[repr(C)] #[repr(C)]
pub struct PlatformWindowRcOpaque(*const c_void, *const c_void); pub struct WindowAdapterRcOpaque(*const c_void, *const c_void);
/// Releases the reference to the windowrc held by handle. /// Releases the reference to the windowrc held by handle.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_drop(handle: *mut PlatformWindowRcOpaque) { pub unsafe extern "C" fn slint_windowrc_drop(handle: *mut WindowAdapterRcOpaque) {
assert_eq!( assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(), core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<PlatformWindowRcOpaque>() core::mem::size_of::<WindowAdapterRcOpaque>()
); );
core::ptr::read(handle as *mut Rc<dyn PlatformWindow>); core::ptr::read(handle as *mut Rc<dyn WindowAdapter>);
} }
/// Releases the reference to the component window held by handle. /// Releases the reference to the component window held by handle.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_clone( pub unsafe extern "C" fn slint_windowrc_clone(
source: *const PlatformWindowRcOpaque, source: *const WindowAdapterRcOpaque,
target: *mut PlatformWindowRcOpaque, target: *mut WindowAdapterRcOpaque,
) { ) {
assert_eq!( assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(), core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<PlatformWindowRcOpaque>() core::mem::size_of::<WindowAdapterRcOpaque>()
); );
let window = &*(source as *const Rc<dyn PlatformWindow>); let window = &*(source as *const Rc<dyn WindowAdapter>);
core::ptr::write(target as *mut Rc<dyn PlatformWindow>, window.clone()); core::ptr::write(target as *mut Rc<dyn WindowAdapter>, window.clone());
} }
/// Spins an event loop and renders the items of the provided component in this window. /// Spins an event loop and renders the items of the provided component in this window.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_show(handle: *const PlatformWindowRcOpaque) { pub unsafe extern "C" fn slint_windowrc_show(handle: *const WindowAdapterRcOpaque) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.show(); window_adapter.show();
} }
/// Spins an event loop and renders the items of the provided component in this window. /// Spins an event loop and renders the items of the provided component in this window.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_hide(handle: *const PlatformWindowRcOpaque) { pub unsafe extern "C" fn slint_windowrc_hide(handle: *const WindowAdapterRcOpaque) {
let window = &*(handle as *const Rc<dyn PlatformWindow>); let window = &*(handle as *const Rc<dyn WindowAdapter>);
window.hide(); window.hide();
} }
/// Returns the window scale factor. /// Returns the window scale factor.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_get_scale_factor( pub unsafe extern "C" fn slint_windowrc_get_scale_factor(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
) -> f32 { ) -> f32 {
assert_eq!( assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(), core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<PlatformWindowRcOpaque>() core::mem::size_of::<WindowAdapterRcOpaque>()
); );
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().scale_factor() window_adapter.window().window_handle().scale_factor()
} }
/// Sets the window scale factor, merely for testing purposes. /// Sets the window scale factor, merely for testing purposes.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_scale_factor( pub unsafe extern "C" fn slint_windowrc_set_scale_factor(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
value: f32, value: f32,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().set_scale_factor(value) window_adapter.window().window_handle().set_scale_factor(value)
} }
/// Sets the focus item. /// Sets the focus item.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_focus_item( pub unsafe extern "C" fn slint_windowrc_set_focus_item(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
focus_item: &ItemRc, focus_item: &ItemRc,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().set_focus_item(focus_item) window_adapter.window().window_handle().set_focus_item(focus_item)
} }
/// Associates the window with the given component. /// Associates the window with the given component.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_component( pub unsafe extern "C" fn slint_windowrc_set_component(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
component: &ComponentRc, component: &ComponentRc,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().set_component(component) window_adapter.window().window_handle().set_component(component)
} }
/// Show a popup. /// Show a popup.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_show_popup( pub unsafe extern "C" fn slint_windowrc_show_popup(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
popup: &ComponentRc, popup: &ComponentRc,
position: crate::graphics::Point, position: crate::graphics::Point,
parent_item: &ItemRc, parent_item: &ItemRc,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().show_popup(popup, position, parent_item); window_adapter.window().window_handle().show_popup(popup, position, parent_item);
} }
/// Close the current popup /// Close the current popup
pub unsafe extern "C" fn slint_windowrc_close_popup(handle: *const PlatformWindowRcOpaque) { pub unsafe extern "C" fn slint_windowrc_close_popup(handle: *const WindowAdapterRcOpaque) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().close_popup(); window_adapter.window().window_handle().close_popup();
} }
/// C binding to the set_rendering_notifier() API of Window /// C binding to the set_rendering_notifier() API of Window
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_rendering_notifier( pub unsafe extern "C" fn slint_windowrc_set_rendering_notifier(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
callback: extern "C" fn( callback: extern "C" fn(
rendering_state: RenderingState, rendering_state: RenderingState,
graphics_api: GraphicsAPI, graphics_api: GraphicsAPI,
@ -855,7 +855,7 @@ pub mod ffi {
} }
} }
let window = &*(handle as *const Rc<dyn PlatformWindow>); let window = &*(handle as *const Rc<dyn WindowAdapter>);
match window.renderer().set_rendering_notifier(Box::new(CNotifier { match window.renderer().set_rendering_notifier(Box::new(CNotifier {
callback, callback,
drop_user_data, drop_user_data,
@ -872,7 +872,7 @@ pub mod ffi {
/// C binding to the on_close_requested() API of Window /// C binding to the on_close_requested() API of Window
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_on_close_requested( pub unsafe extern "C" fn slint_windowrc_on_close_requested(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
callback: extern "C" fn(user_data: *mut c_void) -> CloseRequestResponse, callback: extern "C" fn(user_data: *mut c_void) -> CloseRequestResponse,
drop_user_data: extern "C" fn(user_data: *mut c_void), drop_user_data: extern "C" fn(user_data: *mut c_void),
user_data: *mut c_void, user_data: *mut c_void,
@ -897,26 +897,26 @@ pub mod ffi {
let with_user_data = WithUserData { callback, drop_user_data, user_data }; let with_user_data = WithUserData { callback, drop_user_data, user_data };
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().on_close_requested(move || with_user_data.call()); window_adapter.window().on_close_requested(move || with_user_data.call());
} }
/// This function issues a request to the windowing system to redraw the contents of the window. /// This function issues a request to the windowing system to redraw the contents of the window.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_request_redraw(handle: *const PlatformWindowRcOpaque) { pub unsafe extern "C" fn slint_windowrc_request_redraw(handle: *const WindowAdapterRcOpaque) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.request_redraw(); window_adapter.request_redraw();
} }
/// Returns the position of the window on the screen, in physical screen coordinates and including /// Returns the position of the window on the screen, in physical screen coordinates and including
/// a window frame (if present). /// a window frame (if present).
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_position( pub unsafe extern "C" fn slint_windowrc_position(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
pos: &mut euclid::default::Point2D<i32>, pos: &mut euclid::default::Point2D<i32>,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
*pos = platform_window.position().to_untyped() *pos = window_adapter.position().to_untyped()
} }
/// Sets the position of the window on the screen, in physical screen coordinates and including /// Sets the position of the window on the screen, in physical screen coordinates and including
@ -924,29 +924,29 @@ pub mod ffi {
/// Note that on some windowing systems, such as Wayland, this functionality is not available. /// Note that on some windowing systems, such as Wayland, this functionality is not available.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_position( pub unsafe extern "C" fn slint_windowrc_set_position(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
pos: &euclid::default::Point2D<i32>, pos: &euclid::default::Point2D<i32>,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.set_position(euclid::Point2D::from_untyped(*pos)); window_adapter.set_position(euclid::Point2D::from_untyped(*pos));
} }
/// Returns the size of the window on the screen, in physical screen coordinates and excluding /// Returns the size of the window on the screen, in physical screen coordinates and excluding
/// a window frame (if present). /// a window frame (if present).
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_size(handle: *const PlatformWindowRcOpaque) -> IntSize { pub unsafe extern "C" fn slint_windowrc_size(handle: *const WindowAdapterRcOpaque) -> IntSize {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.window().window_handle().inner_size.get().to_untyped().cast() window_adapter.window().window_handle().inner_size.get().to_untyped().cast()
} }
/// Resizes the window to the specified size on the screen, in physical pixels and excluding /// Resizes the window to the specified size on the screen, in physical pixels and excluding
/// a window frame (if present). /// a window frame (if present).
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_size( pub unsafe extern "C" fn slint_windowrc_set_size(
handle: *const PlatformWindowRcOpaque, handle: *const WindowAdapterRcOpaque,
size: &IntSize, size: &IntSize,
) { ) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>); let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
platform_window.set_inner_size([size.width, size.height].into()); window_adapter.set_inner_size([size.width, size.height].into());
} }
} }

View file

@ -586,7 +586,7 @@ impl ComponentDefinition {
.inner .inner
.unerase(guard) .unerase(guard)
.clone() .clone()
.create_with_existing_window(&window.window_handle().platform_window()), .create_with_existing_window(&window.window_handle().window_adapter()),
} }
} }
@ -964,13 +964,13 @@ impl ComponentHandle for ComponentInstance {
fn show(&self) { fn show(&self) {
generativity::make_guard!(guard); generativity::make_guard!(guard);
let comp = self.inner.unerase(guard); let comp = self.inner.unerase(guard);
comp.borrow_instance().platform_window().show(); comp.borrow_instance().window_adapter().show();
} }
fn hide(&self) { fn hide(&self) {
generativity::make_guard!(guard); generativity::make_guard!(guard);
let comp = self.inner.unerase(guard); let comp = self.inner.unerase(guard);
comp.borrow_instance().platform_window().hide(); comp.borrow_instance().window_adapter().hide();
} }
fn run(&self) { fn run(&self) {
@ -980,7 +980,7 @@ impl ComponentHandle for ComponentInstance {
} }
fn window(&self) -> &Window { fn window(&self) -> &Window {
self.inner.platform_window().window() self.inner.window_adapter().window()
} }
fn global<'a, T: Global<'a, Self>>(&'a self) -> T fn global<'a, T: Global<'a, Self>>(&'a self) -> T
@ -1058,7 +1058,7 @@ pub mod testing {
&vtable::VRc::into_dyn(comp.inner.clone()), &vtable::VRc::into_dyn(comp.inner.clone()),
x, x,
y, y,
&comp.window().window_handle().platform_window(), &comp.window().window_handle().window_adapter(),
); );
} }
/// Wrapper around [`i_slint_core::tests::send_keyboard_string_sequence`] /// Wrapper around [`i_slint_core::tests::send_keyboard_string_sequence`]
@ -1069,7 +1069,7 @@ pub mod testing {
i_slint_core::tests::send_keyboard_string_sequence( i_slint_core::tests::send_keyboard_string_sequence(
&string, &string,
Default::default(), Default::default(),
&comp.window().window_handle().platform_window(), &comp.window().window_handle().window_adapter(),
); );
} }
} }

View file

@ -28,7 +28,7 @@ use i_slint_core::model::Repeater;
use i_slint_core::properties::InterpolatedPropertyValue; use i_slint_core::properties::InterpolatedPropertyValue;
use i_slint_core::rtti::{self, AnimatedBindingKind, FieldOffset, PropertyInfo}; use i_slint_core::rtti::{self, AnimatedBindingKind, FieldOffset, PropertyInfo};
use i_slint_core::slice::Slice; use i_slint_core::slice::Slice;
use i_slint_core::window::{PlatformWindow, WindowHandleAccess}; use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
use i_slint_core::{Brush, Color, Property, SharedString, SharedVector}; use i_slint_core::{Brush, Color, Property, SharedString, SharedVector};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::collections::HashMap; use std::collections::HashMap;
@ -54,9 +54,9 @@ impl<'id> ComponentBox<'id> {
InstanceRef { instance: self.instance.as_pin_ref(), component_type: &self.component_type } InstanceRef { instance: self.instance.as_pin_ref(), component_type: &self.component_type }
} }
pub fn platform_window(&self) -> &Rc<dyn PlatformWindow> { pub fn window_adapter(&self) -> &Rc<dyn WindowAdapter> {
self.component_type self.component_type
.platform_window_offset .window_adapter_offset
.apply(self.instance.as_pin_ref().get_ref()) .apply(self.instance.as_pin_ref().get_ref())
.as_ref() .as_ref()
.as_ref() .as_ref()
@ -67,12 +67,12 @@ impl<'id> ComponentBox<'id> {
impl<'id> Drop for ComponentBox<'id> { impl<'id> Drop for ComponentBox<'id> {
fn drop(&mut self) { fn drop(&mut self) {
let instance_ref = self.borrow_instance(); let instance_ref = self.borrow_instance();
if let Some(platform_window) = eval::platform_window_ref(instance_ref) { if let Some(window_adapter) = eval::window_adapter_ref(instance_ref) {
i_slint_core::component::unregister_component( i_slint_core::component::unregister_component(
instance_ref.instance, instance_ref.instance,
Pin::into_inner(instance_ref.borrow()), Pin::into_inner(instance_ref.borrow()),
instance_ref.component_type.item_array.as_slice(), instance_ref.component_type.item_array.as_slice(),
platform_window, window_adapter,
); );
} }
} }
@ -316,7 +316,7 @@ pub struct ComponentDescription<'id> {
pub(crate) parent_component_offset: pub(crate) parent_component_offset:
Option<FieldOffset<Instance<'id>, Option<ComponentRefPin<'id>>>>, Option<FieldOffset<Instance<'id>, Option<ComponentRefPin<'id>>>>,
/// Offset to the window reference /// Offset to the window reference
pub(crate) platform_window_offset: FieldOffset<Instance<'id>, Option<Rc<dyn PlatformWindow>>>, pub(crate) window_adapter_offset: FieldOffset<Instance<'id>, Option<Rc<dyn WindowAdapter>>>,
/// Offset of a ComponentExtraData /// Offset of a ComponentExtraData
pub(crate) extra_data_offset: FieldOffset<Instance<'id>, ComponentExtraData>, pub(crate) extra_data_offset: FieldOffset<Instance<'id>, ComponentExtraData>,
/// Keep the Rc alive /// Keep the Rc alive
@ -389,25 +389,25 @@ impl<'id> ComponentDescription<'id> {
self: Rc<Self>, self: Rc<Self>,
#[cfg(target_arch = "wasm32")] canvas_id: String, #[cfg(target_arch = "wasm32")] canvas_id: String,
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> { ) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
let platform_window = i_slint_backend_selector::with_platform_abstraction(|_b| { let window_adapter = i_slint_backend_selector::with_platform_abstraction(|_b| {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
return _b.create_window(); return _b.create_window();
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
i_slint_backend_winit::create_gl_window_with_canvas_id(canvas_id) i_slint_backend_winit::create_gl_window_with_canvas_id(canvas_id)
}); });
self.create_with_existing_window(&platform_window) self.create_with_existing_window(&window_adapter)
} }
#[doc(hidden)] #[doc(hidden)]
pub fn create_with_existing_window( pub fn create_with_existing_window(
self: Rc<Self>, self: Rc<Self>,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> { ) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
let component_ref = instantiate(self, None, Some(platform_window), Default::default()); let component_ref = instantiate(self, None, Some(window_adapter), Default::default());
component_ref component_ref
.as_pin_ref() .as_pin_ref()
.platform_window() .window_adapter()
.window() .window()
.window_handle() .window_handle()
.set_component(&vtable::VRc::into_dyn(component_ref.clone())); .set_component(&vtable::VRc::into_dyn(component_ref.clone()));
@ -649,16 +649,16 @@ fn ensure_repeater_updated<'id>(
) { ) {
let repeater = rep_in_comp.offset.apply_pin(instance_ref.instance); let repeater = rep_in_comp.offset.apply_pin(instance_ref.instance);
let init = || { let init = || {
let platform_window = instance_ref let window_adapter = instance_ref
.component_type .component_type
.platform_window_offset .window_adapter_offset
.apply(instance_ref.as_ref()) .apply(instance_ref.as_ref())
.as_ref() .as_ref()
.unwrap(); .unwrap();
let instance = instantiate( let instance = instantiate(
rep_in_comp.component_to_repeat.clone(), rep_in_comp.component_to_repeat.clone(),
Some(instance_ref.borrow()), Some(instance_ref.borrow()),
Some(platform_window), Some(window_adapter),
Default::default(), Default::default(),
); );
instance.run_setup_code(); instance.run_setup_code();
@ -1027,8 +1027,8 @@ pub(crate) fn generate_component<'id>(
None None
}; };
let platform_window_offset = let window_adapter_offset =
builder.type_builder.add_field_type::<Option<Rc<dyn PlatformWindow>>>(); builder.type_builder.add_field_type::<Option<Rc<dyn WindowAdapter>>>();
let extra_data_offset = builder.type_builder.add_field_type::<ComponentExtraData>(); let extra_data_offset = builder.type_builder.add_field_type::<ComponentExtraData>();
@ -1090,7 +1090,7 @@ pub(crate) fn generate_component<'id>(
repeater: builder.repeater, repeater: builder.repeater,
repeater_names: builder.repeater_names, repeater_names: builder.repeater_names,
parent_component_offset, parent_component_offset,
platform_window_offset, window_adapter_offset,
extra_data_offset, extra_data_offset,
public_properties, public_properties,
compiled_globals, compiled_globals,
@ -1192,7 +1192,7 @@ fn make_binding_eval_closure(
pub fn instantiate( pub fn instantiate(
component_type: Rc<ComponentDescription>, component_type: Rc<ComponentDescription>,
parent_ctx: Option<ComponentRefPin>, parent_ctx: Option<ComponentRefPin>,
platform_window: Option<&Rc<dyn PlatformWindow>>, window_adapter: Option<&Rc<dyn WindowAdapter>>,
mut globals: crate::global_component::GlobalStorage, mut globals: crate::global_component::GlobalStorage,
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> { ) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
let mut instance = component_type.dynamic_type.clone().create_instance(); let mut instance = component_type.dynamic_type.clone().create_instance();
@ -1215,7 +1215,7 @@ pub fn instantiate(
.map(|(path, er)| (er.id, path.clone())) .map(|(path, er)| (er.id, path.clone()))
.collect(); .collect();
} }
*component_type.platform_window_offset.apply_mut(instance.as_mut()) = platform_window.cloned(); *component_type.window_adapter_offset.apply_mut(instance.as_mut()) = window_adapter.cloned();
let component_box = ComponentBox { instance, component_type: component_type.clone() }; let component_box = ComponentBox { instance, component_type: component_type.clone() };
let instance_ref = component_box.borrow_instance(); let instance_ref = component_box.borrow_instance();
@ -1224,7 +1224,7 @@ pub fn instantiate(
i_slint_core::component::register_component( i_slint_core::component::register_component(
instance_ref.instance, instance_ref.instance,
instance_ref.component_type.item_array.as_slice(), instance_ref.component_type.item_array.as_slice(),
eval::platform_window_ref(instance_ref).unwrap(), eval::window_adapter_ref(instance_ref).unwrap(),
); );
} }
@ -1437,8 +1437,8 @@ impl ErasedComponentBox {
self.0.borrow() self.0.borrow()
} }
pub fn platform_window(&self) -> &Rc<dyn PlatformWindow> { pub fn window_adapter(&self) -> &Rc<dyn WindowAdapter> {
self.0.platform_window() self.0.window_adapter()
} }
pub fn run_setup_code(&self) { pub fn run_setup_code(&self) {
@ -1467,7 +1467,7 @@ impl<'id> From<ComponentBox<'id>> for ErasedComponentBox {
impl i_slint_core::window::WindowHandleAccess for ErasedComponentBox { impl i_slint_core::window::WindowHandleAccess for ErasedComponentBox {
fn window_handle(&self) -> &i_slint_core::window::WindowInner { fn window_handle(&self) -> &i_slint_core::window::WindowInner {
self.platform_window().window().window_handle() self.window_adapter().window().window_handle()
} }
} }
@ -1490,7 +1490,7 @@ extern "C" fn layout_info(component: ComponentRefPin, orientation: Orientation)
let mut result = crate::eval_layout::get_layout_info( let mut result = crate::eval_layout::get_layout_info(
&instance_ref.component_type.original.root_element, &instance_ref.component_type.original.root_element,
instance_ref, instance_ref,
eval::platform_window_ref(instance_ref).unwrap(), eval::window_adapter_ref(instance_ref).unwrap(),
orientation, orientation,
); );
@ -1691,8 +1691,8 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
&extra_data.self_weak &extra_data.self_weak
} }
pub fn platform_window(&self) -> &Rc<dyn PlatformWindow> { pub fn window_adapter(&self) -> &Rc<dyn WindowAdapter> {
self.component_type.platform_window_offset.apply(self.as_ref()).as_ref().as_ref().unwrap() self.component_type.window_adapter_offset.apply(self.as_ref()).as_ref().as_ref().unwrap()
} }
pub fn parent_instance(&self) -> Option<InstanceRef<'a, 'id>> { pub fn parent_instance(&self) -> Option<InstanceRef<'a, 'id>> {
@ -1728,16 +1728,16 @@ pub fn show_popup(
popup: &object_tree::PopupWindow, popup: &object_tree::PopupWindow,
pos: i_slint_core::graphics::Point, pos: i_slint_core::graphics::Point,
parent_comp: ComponentRefPin, parent_comp: ComponentRefPin,
parent_platform_window: &Rc<dyn PlatformWindow>, parent_window_adapter: &Rc<dyn WindowAdapter>,
parent_item: &ItemRc, parent_item: &ItemRc,
) { ) {
generativity::make_guard!(guard); generativity::make_guard!(guard);
// FIXME: we should compile once and keep the cached compiled component // FIXME: we should compile once and keep the cached compiled component
let compiled = generate_component(&popup.component, guard); let compiled = generate_component(&popup.component, guard);
let inst = let inst =
instantiate(compiled, Some(parent_comp), Some(parent_platform_window), Default::default()); instantiate(compiled, Some(parent_comp), Some(parent_window_adapter), Default::default());
inst.run_setup_code(); inst.run_setup_code();
parent_platform_window.window().window_handle().show_popup( parent_window_adapter.window().window_handle().show_popup(
&vtable::VRc::into_dyn(inst), &vtable::VRc::into_dyn(inst),
pos, pos,
parent_item, parent_item,

View file

@ -341,7 +341,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
popup, popup,
i_slint_core::graphics::Point::new(x.try_into().unwrap(), y.try_into().unwrap()), i_slint_core::graphics::Point::new(x.try_into().unwrap(), y.try_into().unwrap()),
component.borrow(), component.borrow(),
platform_window_ref(component).unwrap(), window_adapter_ref(component).unwrap(),
&parent_item); &parent_item);
Value::Void Value::Void
} else { } else {
@ -451,8 +451,8 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
let item_info = &component_type.items[item.borrow().id.as_str()]; let item_info = &component_type.items[item.borrow().id.as_str()];
let item_ref = unsafe { item_info.item_from_component(enclosing_component.as_ptr()) }; let item_ref = unsafe { item_info.item_from_component(enclosing_component.as_ptr()) };
let platform_window = platform_window_ref(component).unwrap(); let window_adapter = window_adapter_ref(component).unwrap();
item_ref.as_ref().layout_info(crate::eval_layout::to_runtime(*orient), platform_window).into() item_ref.as_ref().layout_info(crate::eval_layout::to_runtime(*orient), window_adapter).into()
} else { } else {
panic!("internal error: incorrect arguments to ImplicitLayoutInfo {:?}", arguments); panic!("internal error: incorrect arguments to ImplicitLayoutInfo {:?}", arguments);
} }
@ -466,7 +466,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
ComponentInstance::GlobalComponent(_) => panic!("Cannot access the implicit item size from a global component") ComponentInstance::GlobalComponent(_) => panic!("Cannot access the implicit item size from a global component")
}; };
if let Value::String(s) = eval_expression(&arguments[0], local_context) { if let Value::String(s) = eval_expression(&arguments[0], local_context) {
if let Some(err) = platform_window_ref(component).unwrap().renderer().register_font_from_path(&std::path::PathBuf::from(s.as_str())).err() { if let Some(err) = window_adapter_ref(component).unwrap().renderer().register_font_from_path(&std::path::PathBuf::from(s.as_str())).err() {
corelib::debug_log!("Error loading custom font {}: {}", s.as_str(), err); corelib::debug_log!("Error loading custom font {}: {}", s.as_str(), err);
} }
Value::Void Value::Void
@ -993,16 +993,16 @@ fn root_component_instance<'a, 'old_id, 'new_id>(
} }
} }
pub fn platform_window_ref<'a>( pub fn window_adapter_ref<'a>(
component: InstanceRef<'a, '_>, component: InstanceRef<'a, '_>,
) -> Option<&'a Rc<dyn i_slint_core::window::PlatformWindow>> { ) -> Option<&'a Rc<dyn i_slint_core::window::WindowAdapter>> {
component.component_type.platform_window_offset.apply(component.instance.get_ref()).as_ref() component.component_type.window_adapter_offset.apply(component.instance.get_ref()).as_ref()
} }
pub fn window_ref<'a>( pub fn window_ref<'a>(
component: InstanceRef<'a, '_>, component: InstanceRef<'a, '_>,
) -> Option<&'a i_slint_core::window::WindowInner> { ) -> Option<&'a i_slint_core::window::WindowInner> {
platform_window_ref(component).map(|platform_window| platform_window.window().window_handle()) window_adapter_ref(component).map(|window_adapter| window_adapter.window().window_handle())
} }
/// Return the component instance which hold the given element. /// Return the component instance which hold the given element.

View file

@ -13,7 +13,7 @@ use i_slint_core::items::DialogButtonRole;
use i_slint_core::layout::{self as core_layout}; use i_slint_core::layout::{self as core_layout};
use i_slint_core::model::RepeatedComponent; use i_slint_core::model::RepeatedComponent;
use i_slint_core::slice::Slice; use i_slint_core::slice::Slice;
use i_slint_core::window::PlatformWindow; use i_slint_core::window::WindowAdapter;
use std::convert::TryInto; use std::convert::TryInto;
use std::rc::Rc; use std::rc::Rc;
use std::str::FromStr; use std::str::FromStr;
@ -187,7 +187,7 @@ fn grid_layout_data(
let mut layout_info = get_layout_info( let mut layout_info = get_layout_info(
&cell.item.element, &cell.item.element,
component, component,
eval::platform_window_ref(component).unwrap(), eval::window_adapter_ref(component).unwrap(),
orientation, orientation,
); );
fill_layout_info_constraints( fill_layout_info_constraints(
@ -210,7 +210,7 @@ fn box_layout_data(
expr_eval: &impl Fn(&NamedReference) -> f32, expr_eval: &impl Fn(&NamedReference) -> f32,
mut repeater_indices: Option<&mut Vec<u32>>, mut repeater_indices: Option<&mut Vec<u32>>,
) -> (Vec<core_layout::BoxLayoutCellData>, i_slint_core::items::LayoutAlignment) { ) -> (Vec<core_layout::BoxLayoutCellData>, i_slint_core::items::LayoutAlignment) {
let platform_window = eval::platform_window_ref(component).unwrap(); let window_adapter = eval::window_adapter_ref(component).unwrap();
let mut cells = Vec::with_capacity(box_layout.elems.len()); let mut cells = Vec::with_capacity(box_layout.elems.len());
for cell in &box_layout.elems { for cell in &box_layout.elems {
if cell.element.borrow().repeated.is_some() { if cell.element.borrow().repeated.is_some() {
@ -224,7 +224,7 @@ fn box_layout_data(
let instance = crate::dynamic_component::instantiate( let instance = crate::dynamic_component::instantiate(
rep.1.clone(), rep.1.clone(),
Some(component.borrow()), Some(component.borrow()),
Some(platform_window), Some(window_adapter),
Default::default(), Default::default(),
); );
instance.run_setup_code(); instance.run_setup_code();
@ -242,7 +242,7 @@ fn box_layout_data(
); );
} else { } else {
let mut layout_info = let mut layout_info =
get_layout_info(&cell.element, component, platform_window, orientation); get_layout_info(&cell.element, component, window_adapter, orientation);
fill_layout_info_constraints( fill_layout_info_constraints(
&mut layout_info, &mut layout_info,
&cell.constraints, &cell.constraints,
@ -267,7 +267,7 @@ fn box_layout_data(
} }
fn repeater_indices(children: &[ElementRc], component: InstanceRef) -> Vec<u32> { fn repeater_indices(children: &[ElementRc], component: InstanceRef) -> Vec<u32> {
let platform_window = eval::platform_window_ref(component).unwrap(); let window_adapter = eval::window_adapter_ref(component).unwrap();
let mut idx = 0; let mut idx = 0;
let mut ri = Vec::new(); let mut ri = Vec::new();
@ -283,7 +283,7 @@ fn repeater_indices(children: &[ElementRc], component: InstanceRef) -> Vec<u32>
let instance = crate::dynamic_component::instantiate( let instance = crate::dynamic_component::instantiate(
rep.1.clone(), rep.1.clone(),
Some(component.borrow()), Some(component.borrow()),
Some(platform_window), Some(window_adapter),
Default::default(), Default::default(),
); );
instance.run_setup_code(); instance.run_setup_code();
@ -361,7 +361,7 @@ pub(crate) fn fill_layout_info_constraints(
pub(crate) fn get_layout_info( pub(crate) fn get_layout_info(
elem: &ElementRc, elem: &ElementRc,
component: InstanceRef, component: InstanceRef,
platform_window: &Rc<dyn PlatformWindow>, window_adapter: &Rc<dyn WindowAdapter>,
orientation: Orientation, orientation: Orientation,
) -> core_layout::LayoutInfo { ) -> core_layout::LayoutInfo {
let elem = elem.borrow(); let elem = elem.borrow();
@ -376,7 +376,7 @@ pub(crate) fn get_layout_info(
unsafe { unsafe {
item.item_from_component(component.as_ptr()) item.item_from_component(component.as_ptr())
.as_ref() .as_ref()
.layout_info(to_runtime(orientation), platform_window) .layout_info(to_runtime(orientation), window_adapter)
} }
} }
} }

View file

@ -7,7 +7,7 @@ use super::*;
use core::ptr::NonNull; use core::ptr::NonNull;
use i_slint_core::model::{Model, ModelNotify, SharedVectorModel}; use i_slint_core::model::{Model, ModelNotify, SharedVectorModel};
use i_slint_core::slice::Slice; use i_slint_core::slice::Slice;
use i_slint_core::window::PlatformWindow; use i_slint_core::window::WindowAdapter;
use std::ffi::c_void; use std::ffi::c_void;
use vtable::VRef; use vtable::VRef;
@ -547,9 +547,9 @@ pub extern "C" fn slint_interpreter_component_instance_show(
generativity::make_guard!(guard); generativity::make_guard!(guard);
let comp = inst.unerase(guard); let comp = inst.unerase(guard);
if is_visible { if is_visible {
comp.borrow_instance().platform_window().show(); comp.borrow_instance().window_adapter().show();
} else { } else {
comp.borrow_instance().platform_window().hide(); comp.borrow_instance().window_adapter().hide();
} }
} }
@ -560,13 +560,13 @@ pub extern "C" fn slint_interpreter_component_instance_show(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn slint_interpreter_component_instance_window( pub unsafe extern "C" fn slint_interpreter_component_instance_window(
inst: &ErasedComponentBox, inst: &ErasedComponentBox,
out: *mut *const i_slint_core::window::ffi::PlatformWindowRcOpaque, out: *mut *const i_slint_core::window::ffi::WindowAdapterRcOpaque,
) { ) {
assert_eq!( assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(), core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<i_slint_core::window::ffi::PlatformWindowRcOpaque>() core::mem::size_of::<i_slint_core::window::ffi::WindowAdapterRcOpaque>()
); );
core::ptr::write(out as *mut *const Rc<dyn PlatformWindow>, inst.platform_window() as *const _) core::ptr::write(out as *mut *const Rc<dyn WindowAdapter>, inst.window_adapter() as *const _)
} }
/// Instantiate an instance from a definition. /// Instantiate an instance from a definition.