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

View file

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

View file

@ -564,7 +564,7 @@ public:
/// such as the position on the screen.
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);
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.
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);
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;
}
#endif
@ -1010,10 +1010,10 @@ inline void send_keyboard_string_sequence(const slint::interpreter::ComponentIns
const slint::SharedString &str,
KeyboardModifiers modifiers = {})
{
const cbindgen_private::PlatformWindowRcOpaque *win_ptr = nullptr;
const cbindgen_private::WindowAdapterRcOpaque *win_ptr = nullptr;
cbindgen_private::slint_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win_ptr);
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 */
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;
#[doc(hidden)]
@ -17,13 +17,13 @@ pub fn use_modules() -> usize {
}
#[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!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(),
core::mem::size_of::<PlatformWindowRcOpaque>()
core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<WindowAdapterRcOpaque>()
);
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]
@ -67,16 +67,14 @@ pub unsafe extern "C" fn slint_quit_event_loop() {
#[no_mangle]
pub unsafe extern "C" fn slint_register_font_from_path(
win: *const PlatformWindowRcOpaque,
win: *const WindowAdapterRcOpaque,
path: &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(
error_str,
match platform_window
.renderer()
.register_font_from_path(std::path::Path::new(path.as_str()))
match window_adapter.renderer().register_font_from_path(std::path::Path::new(path.as_str()))
{
Ok(()) => Default::default(),
Err(err) => err.to_string().into(),
@ -86,14 +84,14 @@ pub unsafe extern "C" fn slint_register_font_from_path(
#[no_mangle]
pub unsafe extern "C" fn slint_register_font_from_data(
win: *const PlatformWindowRcOpaque,
win: *const WindowAdapterRcOpaque,
data: i_slint_core::slice::Slice<'static, u8>,
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(
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(),
Err(err) => err.to_string().into(),
},

View file

@ -15,7 +15,7 @@ mod persistent_context;
struct WrappedComponentType(Option<slint_interpreter::ComponentDefinition>);
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
type GlobalContextCallback<'c> =
@ -352,9 +352,9 @@ declare_types! {
let this = cx.this();
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 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())?;
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))
}
method get_property(mut cx) {
@ -534,9 +534,9 @@ declare_types! {
method get_size(mut cx) {
let this = cx.this();
let platform_window = cx.borrow(&this, |x| x.0.as_ref().cloned());
let platform_window = platform_window.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
let size = platform_window.window().size();
let window_adapter = cx.borrow(&this, |x| x.0.as_ref().cloned());
let window_adapter = window_adapter.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
let size = window_adapter.window().size();
let size_object = JsObject::new(&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) {
let this = cx.this();
let platform_window = 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 = platform_window.window();
let window_adapter = cx.borrow(&this, |x| x.0.as_ref().cloned());
let window_adapter = window_adapter.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
let window = window_adapter.window();
let size_object = cx.argument::<JsObject>(0)?;
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::properties::{set_state_binding, Property, PropertyTracker, StateInfo};
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::ComponentVTable_static;
pub use i_slint_core::Coord;
@ -435,7 +435,7 @@ pub mod internal {
/// Creates a new window to render components in.
#[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())
}
@ -474,7 +474,7 @@ pub mod testing {
&dyn_rc,
x,
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(
&super::SharedString::from(sequence),
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>>>,
}
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 {
window: slint::Window::new(self_weak.clone()),
renderer: renderer::SoftwareRenderer::new(self_weak.clone()),
@ -285,7 +285,7 @@ struct PicoWindow {
needs_redraw: Cell<bool>,
}
impl slint::platform::PlatformWindow for PicoWindow {
impl slint::platform::WindowAdapter for PicoWindow {
fn show(&self) {
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>>,
}
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 {
window: slint::Window::new(self_weak.clone()),
renderer: swrenderer::SoftwareRenderer::new(self_weak.clone()),
@ -372,7 +372,7 @@ struct StmWindow {
needs_redraw: core::cell::Cell<bool>,
}
impl slint::platform::PlatformWindow for StmWindow {
impl slint::platform::WindowAdapter for StmWindow {
fn show(&self) {
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 {
#[no_mangle]
pub extern "C" fn slint_qt_get_widget(
_: &i_slint_core::window::PlatformWindowRc,
_: &i_slint_core::window::WindowAdapterRc,
) -> *mut std::ffi::c_void {
std::ptr::null_mut()
}
@ -137,7 +137,7 @@ pub fn native_style_metrics_deinit(_: core::pin::Pin<&mut native_widgets::Native
pub struct 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)]
panic!("The Qt backend needs 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};
#[cfg(feature = "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::{
declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector,
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -20,7 +20,7 @@ use i_slint_core::items::{
PointerEventButton, RenderingResult, TextOverflow, TextWrap,
};
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 items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment};
@ -605,7 +605,7 @@ impl ItemRenderer for QtItemRenderer<'_> {
}
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() {
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
TextHorizontalAlignment::Center => key_generated::Qt_AlignmentFlag_AlignHCenter,
@ -1338,7 +1338,7 @@ impl QtWindow {
}
#[allow(unused)]
impl PlatformWindow for QtWindow {
impl WindowAdapter for QtWindow {
fn show(&self) {
let component_rc = self.window.window_handle().component();
let component = ComponentRc::borrow_pin(&component_rc);
@ -1479,7 +1479,7 @@ impl PlatformWindow for QtWindow {
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 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 pos = qttypes::QPointF { x: pos.x as _, y: pos.y as _ };
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 flags = match text_input.horizontal_alignment() {
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
@ -1663,7 +1663,7 @@ impl Renderer for QtWindow {
) -> Rect {
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
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 mut string = qttypes::QString::from(text.as_str());
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]
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 {
<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| {
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::graphics::{Point, Rect, Size};
use i_slint_core::renderer::Renderer;
use i_slint_core::window::PlatformWindow;
use i_slint_core::window::WindowAdapter;
use std::pin::Pin;
use std::rc::Rc;
use std::sync::Mutex;
@ -19,7 +19,7 @@ pub struct 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 {
window: i_slint_core::api::Window::new(self_weak.clone() as _),
})
@ -43,7 +43,7 @@ pub struct TestingWindow {
window: i_slint_core::api::Window,
}
impl PlatformWindow for TestingWindow {
impl WindowAdapter for TestingWindow {
fn show(&self) {
unimplemented!("showing a testing window")
}

View file

@ -4,7 +4,7 @@
#![warn(missing_docs)]
/*!
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.
*/
use copypasta::ClipboardProvider;
@ -24,7 +24,7 @@ use winit::event::WindowEvent;
#[cfg(not(target_arch = "wasm32"))]
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 current_keyboard_modifiers(&self) -> &Cell<KeyboardModifiers>;
fn draw(&self);

View file

@ -17,13 +17,13 @@ use corelib::component::ComponentRc;
use corelib::input::KeyboardModifiers;
use corelib::items::{ItemRef, MouseCursor};
use corelib::layout::Orientation;
use corelib::window::{PlatformWindow, WindowHandleAccess};
use corelib::window::{WindowAdapter, WindowHandleAccess};
use corelib::Property;
use corelib::{graphics::*, Coord};
use i_slint_core as corelib;
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.
pub(crate) struct GLWindow<Renderer: WinitCompatibleRenderer + 'static> {
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
/// of the window changes to mapped. The event loop and window builder parameters can be used to create a
/// 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 {
window: corelib::api::Window::new(self_weak.clone() as _),
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) {
self.with_window_handle(&mut |window| window.request_redraw())
}

View file

@ -12,7 +12,7 @@ extern crate alloc;
use std::rc::Rc;
use std::sync::Mutex;
use i_slint_core::window::PlatformWindow;
use i_slint_core::window::WindowAdapter;
mod glwindow;
use glwindow::*;
@ -22,7 +22,7 @@ pub(crate) mod event_loop;
mod renderer {
use std::rc::Weak;
use i_slint_core::window::PlatformWindow;
use i_slint_core::window::WindowAdapter;
mod boxshadowcache;
@ -30,14 +30,14 @@ mod renderer {
type Canvas: WinitCompatibleCanvas;
fn new(
platform_window_weak: &Weak<dyn PlatformWindow>,
window_adapter_weak: &Weak<dyn WindowAdapter>,
#[cfg(target_arch = "wasm32")] canvas_id: String,
) -> Self;
fn create_canvas(&self, window_builder: winit::window::WindowBuilder) -> 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 {
@ -66,7 +66,7 @@ pub(crate) mod wasm_input_helper;
mod stylemetrics;
#[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)
}
@ -87,7 +87,7 @@ pub use stylemetrics::native_style_metrics_deinit;
pub use stylemetrics::native_style_metrics_init;
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 {
@ -143,7 +143,7 @@ impl 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()()
}

View file

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

View file

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

View file

@ -7,15 +7,15 @@ use super::WinitCompatibleCanvas;
use i_slint_core::graphics::Rgb8Pixel;
use i_slint_core::lengths::PhysicalLength;
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::rc::Weak;
impl<const BUFFER_COUNT: usize> super::WinitCompatibleRenderer for SoftwareRenderer<BUFFER_COUNT> {
type Canvas = SwCanvas;
fn new(platform_window_weak: &Weak<dyn PlatformWindow>) -> Self {
SoftwareRenderer::new(platform_window_weak.clone())
fn new(window_adapter_weak: &Weak<dyn WindowAdapter>) -> Self {
SoftwareRenderer::new(window_adapter_weak.clone())
}
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 render(&self, canvas: &SwCanvas, _: &dyn PlatformWindow) {
fn render(&self, canvas: &SwCanvas, _: &dyn WindowAdapter) {
let size = canvas.opengl_context.window().inner_size();
let width = size.width as usize;
let height = size.height as usize;

View file

@ -21,7 +21,7 @@ use std::cell::RefCell;
use std::rc::{Rc, Weak};
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 wasm_bindgen::closure::Closure;
use wasm_bindgen::convert::FromWasmAbi;
@ -67,7 +67,7 @@ impl WasmInputState {
impl WasmInputHelper {
#[allow(unused)]
pub fn new(
platform_window: Weak<dyn PlatformWindow>,
window_adapter: Weak<dyn WindowAdapter>,
canvas: web_sys::HtmlCanvasElement,
) -> Self {
let input = web_sys::window()
@ -92,24 +92,24 @@ impl WasmInputHelper {
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| {
// Make sure that the window gets marked as unfocused when the focus leaves the input
if let Some(platform_window) = win.upgrade() {
let window = platform_window.window().window_handle();
if let Some(window_adapter) = win.upgrade() {
let window = window_adapter.window().window_handle();
if !canvas.matches(":focus").unwrap_or(false) {
window.set_active(false);
window.set_focus(false);
}
}
});
let win = platform_window.clone();
let win = window_adapter.clone();
let shared_state2 = shared_state.clone();
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();
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),
text,
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();
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();
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),
text,
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 input = h.input.clone();
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 !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());
window.process_key_input(&KeyEvent {
modifiers: Default::default(),
@ -158,12 +158,12 @@ impl WasmInputHelper {
});
for event in ["compositionend", "compositionupdate"] {
let win = platform_window.clone();
let win = window_adapter.clone();
let shared_state2 = shared_state.clone();
let input = h.input.clone();
h.add_event_listener(event, move |e: web_sys::CompositionEvent| {
if let (Some(platform_window), Some(data)) = (win.upgrade(), e.data()) {
let window = platform_window.window().window_handle();
if let (Some(window_adapter), Some(data)) = (win.upgrade(), e.data()) {
let window = window_adapter.window().window_handle();
let is_end = event == "compositionend";
let (text, to_delete) =
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 {
ty: "slint::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()
}),
));
@ -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
.friends

View file

@ -347,7 +347,7 @@ fn generate_public_component(llr: &llr::PublicComponent) -> TokenStream {
}
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 {
@ -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>>,
#(parent : #parent_component_type,)*
// 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>>,
tree_index: ::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();
_self.self_weak.set(VRcMapped::downgrade(&self_rc));
_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_of_first_child.set(tree_index_of_first_child);
#(#init)*
@ -1105,10 +1105,10 @@ fn generate_item_tree(
};
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! {
_self.platform_window.set(platform_window);
_self.platform_window.get().unwrap().window().window_handle().set_component(&VRc::into_dyn(self_rc.clone()));
_self.window_adapter.set(window_adapter);
_self.window_adapter.get().unwrap().window().window_handle().set_component(&VRc::into_dyn(self_rc.clone()));
}),
)
} else {
@ -1195,7 +1195,7 @@ fn generate_item_tree(
let self_rc = VRc::new(_self);
let _self = self_rc.as_pin_ref();
#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_rc
}
@ -1220,13 +1220,13 @@ fn generate_item_tree(
fn drop(self: core::pin::Pin<&mut #inner_component_id>) {
use slint::re_exports::*;
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 {
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)
}
fn access_platform_window_field(ctx: &EvaluationContext) -> TokenStream {
fn access_window_adapter_field(ctx: &EvaluationContext) -> TokenStream {
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)
@ -1985,7 +1985,7 @@ fn compile_builtin_function_call(
match function {
BuiltinFunction::SetFocusItem => {
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);
quote!(
#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 x = compile_expression(x, 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!(
#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()),
Point::new(#x as slint::re_exports::Coord, #y as slint::re_exports::Coord),
#parent_component
@ -2029,9 +2029,9 @@ fn compile_builtin_function_call(
BuiltinFunction::ImplicitLayoutInfo(orient) => {
if let [Expression::PropertyReference(pr)] = arguments {
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!(
#item.layout_info(#orient, #platform_window_tokens)
#item.layout_info(#orient, #window_adapter_tokens)
)
} else {
panic!("internal error: invalid args to ImplicitLayoutInfo {:?}", arguments)
@ -2039,8 +2039,8 @@ fn compile_builtin_function_call(
}
BuiltinFunction::RegisterCustomFontByPath => {
if let [Expression::StringLiteral(path)] = arguments {
let platform_window_tokens = access_platform_window_field(ctx);
quote!(#platform_window_tokens.renderer().register_font_from_path(&std::path::PathBuf::from(#path));)
let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#window_adapter_tokens.renderer().register_font_from_path(&std::path::PathBuf::from(#path));)
} else {
panic!("internal error: invalid args to RegisterCustomFontByPath {:?}", arguments)
}
@ -2049,8 +2049,8 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
let platform_window_tokens = access_platform_window_field(ctx);
quote!(#platform_window_tokens.renderer().register_font_from_memory(#symbol.into());)
let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#window_adapter_tokens.renderer().register_font_from_memory(#symbol.into());)
} else {
panic!("internal error: invalid args to RegisterCustomFontByMemory {:?}", arguments)
}
@ -2059,15 +2059,15 @@ fn compile_builtin_function_call(
if let [Expression::NumberLiteral(resource_id)] = &arguments {
let resource_id: usize = *resource_id as _;
let symbol = format_ident!("SLINT_EMBEDDED_RESOURCE_{}", resource_id);
let platform_window_tokens = access_platform_window_field(ctx);
quote!(#platform_window_tokens.renderer().register_bitmap_font(&#symbol);)
let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#window_adapter_tokens.renderer().register_bitmap_font(&#symbol);)
} else {
panic!("internal error: invalid args to RegisterBitmapFont must be a number")
}
}
BuiltinFunction::GetWindowScaleFactor => {
let platform_window_tokens = access_platform_window_field(ctx);
quote!(#platform_window_tokens.window().window_handle().scale_factor())
let window_adapter_tokens = access_window_adapter_field(ctx);
quote!(#window_adapter_tokens.window().window_handle().scale_factor())
}
BuiltinFunction::AnimationTick => quote!(slint::re_exports::animation_tick()),
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 crate::component::ComponentVTable;
use crate::window::{PlatformWindow, WindowInner};
use crate::window::{WindowAdapter, WindowInner};
pub use crate::lengths::LogicalPx;
pub use crate::lengths::PhysicalPx;
@ -118,41 +118,41 @@ impl Default for CloseRequestResponse {
}
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
/// [`PlatformWindow`](crate::platform::PlatformWindow) from
/// [`WindowAdapter`](crate::platform::WindowAdapter) from
/// [`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)
///
/// # Example
/// ```rust
/// use std::rc::Rc;
/// use slint::platform::PlatformWindow;
/// use slint::platform::WindowAdapter;
/// use slint::Window;
/// struct MyPlatformWindow {
/// struct MyWindowAdapter {
/// window: Window,
/// //...
/// }
/// impl PlatformWindow for MyPlatformWindow {
/// impl WindowAdapter for MyWindowAdapter {
/// fn window(&self) -> &Window { &self.window }
/// # fn renderer(&self) -> &dyn i_slint_core::renderer::Renderer { unimplemented!() }
/// # fn as_any(&self) -> &(dyn core::any::Any + 'static) { self }
/// //...
/// }
/// fn create_window() -> Rc<dyn PlatformWindow> {
/// Rc::<MyPlatformWindow>::new_cyclic(|weak| {
/// MyPlatformWindow {
/// fn create_window() -> Rc<dyn WindowAdapter> {
/// Rc::<MyWindowAdapter>::new_cyclic(|weak| {
/// MyWindowAdapter {
/// window: Window::new(weak.clone()),
/// //...
/// }
/// })
/// }
/// ```
pub fn new(platform_window_weak: alloc::rc::Weak<dyn PlatformWindow>) -> Self {
Self(WindowInner::new(platform_window_weak))
pub fn new(window_adapter_weak: alloc::rc::Weak<dyn WindowAdapter>) -> Self {
Self(WindowInner::new(window_adapter_weak))
}
/// Registers the window with the windowing system in order to make it visible on the screen.
@ -171,7 +171,7 @@ impl Window {
&self,
callback: impl FnMut(RenderingState, &GraphicsAPI) + 'static,
) -> 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.
@ -182,7 +182,7 @@ impl Window {
/// This function issues a request to the windowing system to redraw the contents of the window.
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()
// 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
/// a window frame (if present).
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
/// a window frame (if present).
/// Note that on some windowing systems, such as Wayland, this functionality is not available.
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
@ -227,7 +227,7 @@ impl Window {
let l = size.cast() / self.scale_factor();
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

View file

@ -12,7 +12,7 @@ use crate::item_tree::{
use crate::items::{AccessibleRole, ItemVTable};
use crate::layout::{LayoutInfo, Orientation};
use crate::slice::Slice;
use crate::window::PlatformWindow;
use crate::window::WindowAdapter;
use crate::SharedString;
use alloc::rc::Rc;
use vtable::*;
@ -115,10 +115,10 @@ pub type ComponentWeak = vtable::VWeak<ComponentVTable, Dyn>;
pub fn register_component<Base>(
base: core::pin::Pin<&Base>,
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));
platform_window.register_component();
item_array.iter().for_each(|item| item.apply_pin(base).as_ref().init(window_adapter));
window_adapter.register_component();
}
/// 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>,
component: ComponentRef,
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)));
}
@ -136,7 +136,7 @@ pub fn unregister_component<Base>(
pub(crate) mod ffi {
#![allow(unsafe_code)]
use crate::window::PlatformWindow;
use crate::window::WindowAdapter;
use super::*;
@ -145,13 +145,13 @@ pub(crate) mod ffi {
pub unsafe extern "C" fn slint_register_component(
component: ComponentRefPin,
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(
core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)),
item_array.as_slice(),
platform_window,
window_adapter,
)
}
@ -160,14 +160,14 @@ pub(crate) mod ffi {
pub unsafe extern "C" fn slint_unregister_component(
component: ComponentRefPin,
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(
core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)),
core::pin::Pin::into_inner(component),
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::window::PlatformWindow;
use crate::window::WindowAdapter;
use std::cell::RefCell;
use std::convert::TryFrom;
use std::rc::{Rc, Weak};
@ -60,7 +60,7 @@ pub struct RenderingMetricsCollector {
refresh_mode: RefreshMode,
output_console: bool,
output_overlay: bool,
platform_window: Weak<dyn PlatformWindow>,
window_adapter: Weak<dyn WindowAdapter>,
}
impl RenderingMetricsCollector {
@ -73,7 +73,7 @@ impl RenderingMetricsCollector {
///
/// 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.
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") {
Ok(var) => var,
_ => return None,
@ -102,7 +102,7 @@ impl RenderingMetricsCollector {
refresh_mode,
output_console,
output_overlay,
platform_window,
window_adapter,
});
#[cfg(debug_assertions)]
@ -171,7 +171,7 @@ impl RenderingMetricsCollector {
.borrow_mut()
.push(FrameData { timestamp: instant::Instant::now(), metrics: renderer.metrics() });
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();
}
crate::animations::CURRENT_ANIMATION_DRIVER

View file

@ -9,7 +9,7 @@ use crate::graphics::Point;
use crate::item_tree::{ItemRc, ItemVisitorResult, ItemWeak, VisitChildrenResult};
pub use crate::items::PointerEventButton;
use crate::items::{ItemRef, TextCursorDirection};
use crate::window::PlatformWindow;
use crate::window::WindowAdapter;
use crate::{component::ComponentRc, SharedString};
use crate::{Coord, Property};
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
fn handle_mouse_grab(
mouse_event: &MouseEvent,
platform_window: &Rc<dyn PlatformWindow>,
window_adapter: &Rc<dyn WindowAdapter>,
mouse_input_state: &mut MouseInputState,
) -> bool {
if !mouse_input_state.grabbed || mouse_input_state.item_stack.is_empty() {
@ -423,7 +423,7 @@ fn handle_mouse_grab(
return false;
};
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;
}
let g = item.borrow().as_ref().geometry();
@ -432,7 +432,7 @@ fn handle_mouse_grab(
if it.1 == InputEventFilterResult::ForwardAndInterceptGrab
&& item.borrow().as_ref().input_event_filter_before_children(
event,
platform_window,
window_adapter,
&item,
) == InputEventFilterResult::Intercept
{
@ -445,10 +445,10 @@ fn handle_mouse_grab(
}
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 {
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
@ -457,7 +457,7 @@ fn handle_mouse_grab(
fn send_exit_events(
mouse_input_state: &MouseInputState,
mut pos: Option<Point>,
platform_window: &Rc<dyn PlatformWindow>,
window_adapter: &Rc<dyn WindowAdapter>,
) {
for it in mouse_input_state.item_stack.iter() {
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();
}
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(
component: ComponentRc,
mouse_event: MouseEvent,
platform_window: &Rc<dyn PlatformWindow>,
window_adapter: &Rc<dyn WindowAdapter>,
mut mouse_input_state: 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;
}
@ -510,7 +510,7 @@ pub fn process_mouse_input(
event2.translate(-geom.origin.to_vector());
let filter_result = item.as_ref().input_event_filter_before_children(
event2,
platform_window,
window_adapter,
&item_rc,
);
mouse_grabber_stack.push((item_rc.downgrade(), filter_result));
@ -554,7 +554,7 @@ pub fn process_mouse_input(
if r.has_aborted() && !intercept {
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 => {
if result.item_stack.is_empty() {
// 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),
);
send_exit_events(&mouse_input_state, mouse_event.position(), platform_window);
send_exit_events(&mouse_input_state, mouse_event.position(), window_adapter);
result
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,7 +21,7 @@ pub use crate::lengths::{PhysicalLength, PhysicalPoint};
pub use crate::renderer::Renderer;
#[cfg(feature = "swrenderer")]
pub use crate::swrenderer;
pub use crate::window::PlatformWindow;
pub use crate::window::WindowAdapter;
#[derive(Copy, Clone)]
/// Behavior describing how the event loop should terminate.
@ -35,7 +35,7 @@ pub enum EventLoopQuitBehavior {
/// Interface implemented by back-ends
pub trait Platform {
/// 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.
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,
x: Coord,
y: Coord,
platform_window: &crate::window::PlatformWindowRc,
window_adapter: &crate::window::WindowAdapterRc,
) {
let mut state = crate::input::MouseInputState::default();
let position = euclid::point2(x, y);
@ -37,20 +37,20 @@ pub extern "C" fn slint_send_mouse_click(
state = crate::input::process_mouse_input(
component.clone(),
MouseEvent::Moved { position },
platform_window,
window_adapter,
state,
);
state = crate::input::process_mouse_input(
component.clone(),
MouseEvent::Pressed { position, button: crate::items::PointerEventButton::Left },
platform_window,
window_adapter,
state,
);
slint_mock_elapsed_time(50);
crate::input::process_mouse_input(
component.clone(),
MouseEvent::Released { position, button: crate::items::PointerEventButton::Left },
platform_window,
window_adapter,
state,
);
}
@ -60,7 +60,7 @@ pub extern "C" fn slint_send_mouse_click(
pub extern "C" fn send_keyboard_string_sequence(
sequence: &crate::SharedString,
modifiers: KeyboardModifiers,
platform_window: &crate::window::PlatformWindowRc,
window_adapter: &crate::window::WindowAdapterRc,
) {
for ch in sequence.chars() {
let mut modifiers = modifiers;
@ -70,12 +70,12 @@ pub extern "C" fn send_keyboard_string_sequence(
let mut buffer = [0; 6];
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,
text: text.clone(),
modifiers,
});
platform_window.window().window_handle().process_key_input(&KeyEvent {
window_adapter.window().window_handle().process_key_input(&KeyEvent {
event_type: KeyEventType::KeyReleased,
text,
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
/// require in order to implement functionality such as device-independent pixels,
/// window resizing and other typically windowing system related tasks.
pub trait PlatformWindow {
pub trait WindowAdapter {
/// Registers the window with the windowing system.
fn show(&self) {}
/// 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
/// 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
}
@ -122,25 +122,25 @@ pub trait PlatformWindow {
}
struct WindowPropertiesTracker {
platform_window_weak: Weak<dyn PlatformWindow>,
window_adapter_weak: Weak<dyn WindowAdapter>,
}
impl crate::properties::PropertyDirtyHandler for WindowPropertiesTracker {
fn notify(&self) {
if let Some(platform_window) = self.platform_window_weak.upgrade() {
platform_window.request_window_properties_update();
if let Some(window_adapter) = self.window_adapter_weak.upgrade() {
window_adapter.request_window_properties_update();
};
}
}
struct WindowRedrawTracker {
platform_window_weak: Weak<dyn PlatformWindow>,
window_adapter_weak: Weak<dyn WindowAdapter>,
}
impl crate::properties::PropertyDirtyHandler for WindowRedrawTracker {
fn notify(&self) {
if let Some(platform_window) = self.platform_window_weak.upgrade() {
platform_window.request_redraw();
if let Some(window_adapter) = self.window_adapter_weak.upgrade() {
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.
pub enum PopupWindowLocation {
/// 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.
ChildWindow(Point),
}
@ -164,7 +164,7 @@ pub struct PopupWindow {
/// Inner datastructure for the [`crate::api::Window`]
pub struct WindowInner {
platform_window_weak: Weak<dyn PlatformWindow>,
window_adapter_weak: Weak<dyn WindowAdapter>,
component: RefCell<ComponentWeak>,
mouse_input_state: Cell<MouseInputState>,
redraw_tracker: Pin<Box<PropertyTracker<WindowRedrawTracker>>>,
@ -193,17 +193,17 @@ impl Drop for WindowInner {
}
impl WindowInner {
/// Create a new instance of the window, given the platform_window factory fn
pub fn new(platform_window_weak: Weak<dyn PlatformWindow>) -> Self {
/// Create a new instance of the window, given the window_adapter factory fn
pub fn new(window_adapter_weak: Weak<dyn WindowAdapter>) -> Self {
#![allow(unused_mut)]
let mut window_properties_tracker =
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 {
platform_window_weak: platform_window_weak.clone(),
window_adapter_weak: window_adapter_weak.clone(),
});
#[cfg(slint_debug_property)]
@ -214,7 +214,7 @@ impl WindowInner {
}
let window = Self {
platform_window_weak,
window_adapter_weak,
component: Default::default(),
mouse_input_state: Default::default(),
redraw_tracker: Box::pin(redraw_tracker),
@ -240,9 +240,9 @@ impl WindowInner {
self.mouse_input_state.replace(Default::default());
self.component.replace(ComponentRc::downgrade(component));
self.meta_properties_tracker.set_dirty(); // component changed, layout constraints for sure must be re-calculated
let platform_window = self.platform_window();
platform_window.request_window_properties_update();
platform_window.request_redraw();
let window_adapter = self.window_adapter();
window_adapter.request_window_properties_update();
window_adapter.request_redraw();
}
/// return the component.
@ -304,7 +304,7 @@ impl WindowInner {
self.mouse_input_state.set(crate::input::process_mouse_input(
component,
event,
&self.platform_window(),
&self.window_adapter(),
self.mouse_input_state.take(),
));
@ -329,7 +329,7 @@ impl WindowInner {
// Reset the focus... not great, but better than keeping it.
self.take_focus_item();
} 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
{
return;
@ -367,7 +367,7 @@ impl WindowInner {
pub fn set_focus_item(&self, focus_item: &ItemRc) {
let old = self.take_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.
@ -380,7 +380,7 @@ impl WindowInner {
};
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
.borrow()
.as_ref()
.focus_event(&crate::input::FocusEvent::FocusOut, &self.platform_window());
.focus_event(&crate::input::FocusEvent::FocusOut, &self.window_adapter());
Some(focus_item_rc)
} else {
None
@ -410,7 +410,7 @@ impl WindowInner {
*self.focus_item.borrow_mut() = item.downgrade();
item.borrow()
.as_ref()
.focus_event(&crate::input::FocusEvent::FocusIn, &self.platform_window())
.focus_event(&crate::input::FocusEvent::FocusIn, &self.window_adapter())
}
None => {
*self.focus_item.borrow_mut() = Default::default();
@ -447,7 +447,7 @@ impl WindowInner {
.map(next_focus_item)
.unwrap_or_else(|| ItemRc::new(component, 0));
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.
@ -457,7 +457,7 @@ impl WindowInner {
self.take_focus_item().unwrap_or_else(|| ItemRc::new(component, 0)),
);
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
@ -480,7 +480,7 @@ impl WindowInner {
// an evaluation.
self.window_properties_tracker.as_ref().evaluate_as_dependency_root(|| {
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);
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::Vertical),
);
@ -523,13 +523,13 @@ impl WindowInner {
/// 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.
pub fn show(&self) {
self.platform_window().show();
self.window_adapter().show();
self.update_window_properties();
}
/// De-registers the window with the windowing system.
pub fn hide(&self) {
self.platform_window().hide();
self.window_adapter().hide();
}
/// Show a popup at the given position relative to the item
@ -584,15 +584,15 @@ impl WindowInner {
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 => {
self.meta_properties_tracker.set_dirty();
PopupWindowLocation::ChildWindow(position)
}
Some(platform_window) => {
platform_window.window().window_handle().set_component(popup_componentrc);
PopupWindowLocation::TopLevel(platform_window)
Some(window_adapter) => {
window_adapter.window().window_handle().set_component(popup_componentrc);
PopupWindowLocation::TopLevel(window_adapter)
}
};
@ -612,9 +612,9 @@ impl WindowInner {
.translate(offset.to_vector());
if !popup_region.is_empty() {
let platform_window = self.platform_window();
platform_window.renderer().mark_dirty_region(popup_region.to_box2d());
platform_window.request_redraw();
let window_adapter = self.window_adapter();
window_adapter.renderer().mark_dirty_region(popup_region.to_box2d());
window_adapter.request_redraw();
}
}
}
@ -677,9 +677,9 @@ impl WindowInner {
}
}
/// Returns the upgraded platform window.
pub fn platform_window(&self) -> Rc<dyn PlatformWindow> {
self.platform_window_weak.upgrade().unwrap()
/// Returns the upgraded window adapter
pub fn window_adapter(&self) -> Rc<dyn WindowAdapter> {
self.window_adapter_weak.upgrade().unwrap()
}
}
@ -689,8 +689,8 @@ pub trait WindowHandleAccess {
fn window_handle(&self) -> &WindowInner;
}
/// Internal alias for Rc<dyn PlatformWindow>.
pub type PlatformWindowRc = Rc<dyn PlatformWindow>;
/// Internal alias for Rc<dyn WindowAdapter>.
pub type WindowAdapterRc = Rc<dyn WindowAdapter>;
/// This module contains the functions needed to interface with the event loop and window traits
/// from outside the Rust language.
@ -714,112 +714,112 @@ pub mod ffi {
#[allow(non_camel_case_types)]
type c_void = ();
/// Same layout as PlatformWindowRc
/// Same layout as WindowAdapterRc
#[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.
#[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!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(),
core::mem::size_of::<PlatformWindowRcOpaque>()
core::mem::size_of::<Rc<dyn WindowAdapter>>(),
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.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_clone(
source: *const PlatformWindowRcOpaque,
target: *mut PlatformWindowRcOpaque,
source: *const WindowAdapterRcOpaque,
target: *mut WindowAdapterRcOpaque,
) {
assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(),
core::mem::size_of::<PlatformWindowRcOpaque>()
core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<WindowAdapterRcOpaque>()
);
let window = &*(source as *const Rc<dyn PlatformWindow>);
core::ptr::write(target as *mut Rc<dyn PlatformWindow>, window.clone());
let window = &*(source as *const Rc<dyn WindowAdapter>);
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.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_show(handle: *const PlatformWindowRcOpaque) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.show();
pub unsafe extern "C" fn slint_windowrc_show(handle: *const WindowAdapterRcOpaque) {
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.show();
}
/// Spins an event loop and renders the items of the provided component in this window.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_hide(handle: *const PlatformWindowRcOpaque) {
let window = &*(handle as *const Rc<dyn PlatformWindow>);
pub unsafe extern "C" fn slint_windowrc_hide(handle: *const WindowAdapterRcOpaque) {
let window = &*(handle as *const Rc<dyn WindowAdapter>);
window.hide();
}
/// Returns the window scale factor.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_get_scale_factor(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
) -> f32 {
assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(),
core::mem::size_of::<PlatformWindowRcOpaque>()
core::mem::size_of::<Rc<dyn WindowAdapter>>(),
core::mem::size_of::<WindowAdapterRcOpaque>()
);
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().scale_factor()
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.window().window_handle().scale_factor()
}
/// Sets the window scale factor, merely for testing purposes.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_scale_factor(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
value: f32,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().set_scale_factor(value)
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.window().window_handle().set_scale_factor(value)
}
/// Sets the focus item.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_focus_item(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
focus_item: &ItemRc,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().set_focus_item(focus_item)
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.window().window_handle().set_focus_item(focus_item)
}
/// Associates the window with the given component.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_component(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
component: &ComponentRc,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().set_component(component)
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.window().window_handle().set_component(component)
}
/// Show a popup.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_show_popup(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
popup: &ComponentRc,
position: crate::graphics::Point,
parent_item: &ItemRc,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().show_popup(popup, position, parent_item);
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.window().window_handle().show_popup(popup, position, parent_item);
}
/// Close the current popup
pub unsafe extern "C" fn slint_windowrc_close_popup(handle: *const PlatformWindowRcOpaque) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().close_popup();
pub unsafe extern "C" fn slint_windowrc_close_popup(handle: *const WindowAdapterRcOpaque) {
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.window().window_handle().close_popup();
}
/// C binding to the set_rendering_notifier() API of Window
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_rendering_notifier(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
callback: extern "C" fn(
rendering_state: RenderingState,
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 {
callback,
drop_user_data,
@ -872,7 +872,7 @@ pub mod ffi {
/// C binding to the on_close_requested() API of Window
#[no_mangle]
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,
drop_user_data: extern "C" fn(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 platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().on_close_requested(move || with_user_data.call());
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
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.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_request_redraw(handle: *const PlatformWindowRcOpaque) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.request_redraw();
pub unsafe extern "C" fn slint_windowrc_request_redraw(handle: *const WindowAdapterRcOpaque) {
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.request_redraw();
}
/// Returns the position of the window on the screen, in physical screen coordinates and including
/// a window frame (if present).
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_position(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
pos: &mut euclid::default::Point2D<i32>,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
*pos = platform_window.position().to_untyped()
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
*pos = window_adapter.position().to_untyped()
}
/// 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.
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_position(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
pos: &euclid::default::Point2D<i32>,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.set_position(euclid::Point2D::from_untyped(*pos));
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.set_position(euclid::Point2D::from_untyped(*pos));
}
/// Returns the size of the window on the screen, in physical screen coordinates and excluding
/// a window frame (if present).
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_size(handle: *const PlatformWindowRcOpaque) -> IntSize {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.window().window_handle().inner_size.get().to_untyped().cast()
pub unsafe extern "C" fn slint_windowrc_size(handle: *const WindowAdapterRcOpaque) -> IntSize {
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
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
/// a window frame (if present).
#[no_mangle]
pub unsafe extern "C" fn slint_windowrc_set_size(
handle: *const PlatformWindowRcOpaque,
handle: *const WindowAdapterRcOpaque,
size: &IntSize,
) {
let platform_window = &*(handle as *const Rc<dyn PlatformWindow>);
platform_window.set_inner_size([size.width, size.height].into());
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
window_adapter.set_inner_size([size.width, size.height].into());
}
}

View file

@ -586,7 +586,7 @@ impl ComponentDefinition {
.inner
.unerase(guard)
.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) {
generativity::make_guard!(guard);
let comp = self.inner.unerase(guard);
comp.borrow_instance().platform_window().show();
comp.borrow_instance().window_adapter().show();
}
fn hide(&self) {
generativity::make_guard!(guard);
let comp = self.inner.unerase(guard);
comp.borrow_instance().platform_window().hide();
comp.borrow_instance().window_adapter().hide();
}
fn run(&self) {
@ -980,7 +980,7 @@ impl ComponentHandle for ComponentInstance {
}
fn window(&self) -> &Window {
self.inner.platform_window().window()
self.inner.window_adapter().window()
}
fn global<'a, T: Global<'a, Self>>(&'a self) -> T
@ -1058,7 +1058,7 @@ pub mod testing {
&vtable::VRc::into_dyn(comp.inner.clone()),
x,
y,
&comp.window().window_handle().platform_window(),
&comp.window().window_handle().window_adapter(),
);
}
/// 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(
&string,
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::rtti::{self, AnimatedBindingKind, FieldOffset, PropertyInfo};
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 std::collections::BTreeMap;
use std::collections::HashMap;
@ -54,9 +54,9 @@ impl<'id> ComponentBox<'id> {
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
.platform_window_offset
.window_adapter_offset
.apply(self.instance.as_pin_ref().get_ref())
.as_ref()
.as_ref()
@ -67,12 +67,12 @@ impl<'id> ComponentBox<'id> {
impl<'id> Drop for ComponentBox<'id> {
fn drop(&mut self) {
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(
instance_ref.instance,
Pin::into_inner(instance_ref.borrow()),
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:
Option<FieldOffset<Instance<'id>, Option<ComponentRefPin<'id>>>>,
/// 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
pub(crate) extra_data_offset: FieldOffset<Instance<'id>, ComponentExtraData>,
/// Keep the Rc alive
@ -389,25 +389,25 @@ impl<'id> ComponentDescription<'id> {
self: Rc<Self>,
#[cfg(target_arch = "wasm32")] canvas_id: String,
) -> 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"))]
return _b.create_window();
#[cfg(target_arch = "wasm32")]
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)]
pub fn create_with_existing_window(
self: Rc<Self>,
platform_window: &Rc<dyn PlatformWindow>,
window_adapter: &Rc<dyn WindowAdapter>,
) -> 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
.as_pin_ref()
.platform_window()
.window_adapter()
.window()
.window_handle()
.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 init = || {
let platform_window = instance_ref
let window_adapter = instance_ref
.component_type
.platform_window_offset
.window_adapter_offset
.apply(instance_ref.as_ref())
.as_ref()
.unwrap();
let instance = instantiate(
rep_in_comp.component_to_repeat.clone(),
Some(instance_ref.borrow()),
Some(platform_window),
Some(window_adapter),
Default::default(),
);
instance.run_setup_code();
@ -1027,8 +1027,8 @@ pub(crate) fn generate_component<'id>(
None
};
let platform_window_offset =
builder.type_builder.add_field_type::<Option<Rc<dyn PlatformWindow>>>();
let window_adapter_offset =
builder.type_builder.add_field_type::<Option<Rc<dyn WindowAdapter>>>();
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_names: builder.repeater_names,
parent_component_offset,
platform_window_offset,
window_adapter_offset,
extra_data_offset,
public_properties,
compiled_globals,
@ -1192,7 +1192,7 @@ fn make_binding_eval_closure(
pub fn instantiate(
component_type: Rc<ComponentDescription>,
parent_ctx: Option<ComponentRefPin>,
platform_window: Option<&Rc<dyn PlatformWindow>>,
window_adapter: Option<&Rc<dyn WindowAdapter>>,
mut globals: crate::global_component::GlobalStorage,
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
let mut instance = component_type.dynamic_type.clone().create_instance();
@ -1215,7 +1215,7 @@ pub fn instantiate(
.map(|(path, er)| (er.id, path.clone()))
.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 instance_ref = component_box.borrow_instance();
@ -1224,7 +1224,7 @@ pub fn instantiate(
i_slint_core::component::register_component(
instance_ref.instance,
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()
}
pub fn platform_window(&self) -> &Rc<dyn PlatformWindow> {
self.0.platform_window()
pub fn window_adapter(&self) -> &Rc<dyn WindowAdapter> {
self.0.window_adapter()
}
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 {
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(
&instance_ref.component_type.original.root_element,
instance_ref,
eval::platform_window_ref(instance_ref).unwrap(),
eval::window_adapter_ref(instance_ref).unwrap(),
orientation,
);
@ -1691,8 +1691,8 @@ impl<'a, 'id> InstanceRef<'a, 'id> {
&extra_data.self_weak
}
pub fn platform_window(&self) -> &Rc<dyn PlatformWindow> {
self.component_type.platform_window_offset.apply(self.as_ref()).as_ref().as_ref().unwrap()
pub fn window_adapter(&self) -> &Rc<dyn WindowAdapter> {
self.component_type.window_adapter_offset.apply(self.as_ref()).as_ref().as_ref().unwrap()
}
pub fn parent_instance(&self) -> Option<InstanceRef<'a, 'id>> {
@ -1728,16 +1728,16 @@ pub fn show_popup(
popup: &object_tree::PopupWindow,
pos: i_slint_core::graphics::Point,
parent_comp: ComponentRefPin,
parent_platform_window: &Rc<dyn PlatformWindow>,
parent_window_adapter: &Rc<dyn WindowAdapter>,
parent_item: &ItemRc,
) {
generativity::make_guard!(guard);
// FIXME: we should compile once and keep the cached compiled component
let compiled = generate_component(&popup.component, guard);
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();
parent_platform_window.window().window_handle().show_popup(
parent_window_adapter.window().window_handle().show_popup(
&vtable::VRc::into_dyn(inst),
pos,
parent_item,

View file

@ -341,7 +341,7 @@ pub fn eval_expression(expression: &Expression, local_context: &mut EvalLocalCon
popup,
i_slint_core::graphics::Point::new(x.try_into().unwrap(), y.try_into().unwrap()),
component.borrow(),
platform_window_ref(component).unwrap(),
window_adapter_ref(component).unwrap(),
&parent_item);
Value::Void
} 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_ref = unsafe { item_info.item_from_component(enclosing_component.as_ptr()) };
let platform_window = platform_window_ref(component).unwrap();
item_ref.as_ref().layout_info(crate::eval_layout::to_runtime(*orient), platform_window).into()
let window_adapter = window_adapter_ref(component).unwrap();
item_ref.as_ref().layout_info(crate::eval_layout::to_runtime(*orient), window_adapter).into()
} else {
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")
};
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);
}
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, '_>,
) -> Option<&'a Rc<dyn i_slint_core::window::PlatformWindow>> {
component.component_type.platform_window_offset.apply(component.instance.get_ref()).as_ref()
) -> Option<&'a Rc<dyn i_slint_core::window::WindowAdapter>> {
component.component_type.window_adapter_offset.apply(component.instance.get_ref()).as_ref()
}
pub fn window_ref<'a>(
component: InstanceRef<'a, '_>,
) -> 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.

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::model::RepeatedComponent;
use i_slint_core::slice::Slice;
use i_slint_core::window::PlatformWindow;
use i_slint_core::window::WindowAdapter;
use std::convert::TryInto;
use std::rc::Rc;
use std::str::FromStr;
@ -187,7 +187,7 @@ fn grid_layout_data(
let mut layout_info = get_layout_info(
&cell.item.element,
component,
eval::platform_window_ref(component).unwrap(),
eval::window_adapter_ref(component).unwrap(),
orientation,
);
fill_layout_info_constraints(
@ -210,7 +210,7 @@ fn box_layout_data(
expr_eval: &impl Fn(&NamedReference) -> f32,
mut repeater_indices: Option<&mut Vec<u32>>,
) -> (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());
for cell in &box_layout.elems {
if cell.element.borrow().repeated.is_some() {
@ -224,7 +224,7 @@ fn box_layout_data(
let instance = crate::dynamic_component::instantiate(
rep.1.clone(),
Some(component.borrow()),
Some(platform_window),
Some(window_adapter),
Default::default(),
);
instance.run_setup_code();
@ -242,7 +242,7 @@ fn box_layout_data(
);
} else {
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(
&mut layout_info,
&cell.constraints,
@ -267,7 +267,7 @@ fn box_layout_data(
}
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 ri = Vec::new();
@ -283,7 +283,7 @@ fn repeater_indices(children: &[ElementRc], component: InstanceRef) -> Vec<u32>
let instance = crate::dynamic_component::instantiate(
rep.1.clone(),
Some(component.borrow()),
Some(platform_window),
Some(window_adapter),
Default::default(),
);
instance.run_setup_code();
@ -361,7 +361,7 @@ pub(crate) fn fill_layout_info_constraints(
pub(crate) fn get_layout_info(
elem: &ElementRc,
component: InstanceRef,
platform_window: &Rc<dyn PlatformWindow>,
window_adapter: &Rc<dyn WindowAdapter>,
orientation: Orientation,
) -> core_layout::LayoutInfo {
let elem = elem.borrow();
@ -376,7 +376,7 @@ pub(crate) fn get_layout_info(
unsafe {
item.item_from_component(component.as_ptr())
.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 i_slint_core::model::{Model, ModelNotify, SharedVectorModel};
use i_slint_core::slice::Slice;
use i_slint_core::window::PlatformWindow;
use i_slint_core::window::WindowAdapter;
use std::ffi::c_void;
use vtable::VRef;
@ -547,9 +547,9 @@ pub extern "C" fn slint_interpreter_component_instance_show(
generativity::make_guard!(guard);
let comp = inst.unerase(guard);
if is_visible {
comp.borrow_instance().platform_window().show();
comp.borrow_instance().window_adapter().show();
} 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]
pub unsafe extern "C" fn slint_interpreter_component_instance_window(
inst: &ErasedComponentBox,
out: *mut *const i_slint_core::window::ffi::PlatformWindowRcOpaque,
out: *mut *const i_slint_core::window::ffi::WindowAdapterRcOpaque,
) {
assert_eq!(
core::mem::size_of::<Rc<dyn PlatformWindow>>(),
core::mem::size_of::<i_slint_core::window::ffi::PlatformWindowRcOpaque>()
core::mem::size_of::<Rc<dyn WindowAdapter>>(),
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.