internal cleanup: Rename ComponentWindow to WindowRc

That's all it is nowadays, it's a wrapper around Rc<Window>. It's not an
alias because we need to also "wrap" it to C++ via cbindgen, but that's
about it.
This commit is contained in:
Simon Hausmann 2021-07-21 17:53:24 +02:00 committed by Simon Hausmann
parent 57389c1731
commit eaddbe664e
22 changed files with 274 additions and 300 deletions

View file

@ -79,36 +79,33 @@ using ItemTreeNode = cbindgen_private::ItemTreeNode<uint8_t>;
using cbindgen_private::KeyboardModifiers; using cbindgen_private::KeyboardModifiers;
using cbindgen_private::KeyEvent; using cbindgen_private::KeyEvent;
class ComponentWindow class WindowRc
{ {
public: public:
ComponentWindow() { cbindgen_private::sixtyfps_component_window_init(&inner); } WindowRc() { cbindgen_private::sixtyfps_windowrc_init(&inner); }
~ComponentWindow() { cbindgen_private::sixtyfps_component_window_drop(&inner); } ~WindowRc() { cbindgen_private::sixtyfps_windowrc_drop(&inner); }
ComponentWindow(const ComponentWindow &other) WindowRc(const WindowRc &other)
{ {
cbindgen_private::sixtyfps_component_window_clone(&other.inner, &inner); cbindgen_private::sixtyfps_windowrc_clone(&other.inner, &inner);
} }
ComponentWindow(ComponentWindow &&) = delete; WindowRc(WindowRc &&) = delete;
ComponentWindow &operator=(const ComponentWindow &) = delete; WindowRc &operator=(const WindowRc &) = delete;
void show() const { sixtyfps_component_window_show(&inner); } void show() const { sixtyfps_windowrc_show(&inner); }
void hide() const { sixtyfps_component_window_hide(&inner); } void hide() const { sixtyfps_windowrc_hide(&inner); }
float scale_factor() const { return sixtyfps_component_window_get_scale_factor(&inner); } float scale_factor() const { return sixtyfps_windowrc_get_scale_factor(&inner); }
void set_scale_factor(float value) const void set_scale_factor(float value) const { sixtyfps_windowrc_set_scale_factor(&inner, value); }
{
sixtyfps_component_window_set_scale_factor(&inner, value);
}
void free_graphics_resources(const sixtyfps::Slice<ItemRef> &items) const void free_graphics_resources(const sixtyfps::Slice<ItemRef> &items) const
{ {
cbindgen_private::sixtyfps_component_window_free_graphics_resources(&inner, &items); cbindgen_private::sixtyfps_windowrc_free_graphics_resources(&inner, &items);
} }
void set_focus_item(const ComponentRc &component_rc, uintptr_t item_index) void set_focus_item(const ComponentRc &component_rc, uintptr_t item_index)
{ {
cbindgen_private::ItemRc item_rc { component_rc, item_index }; cbindgen_private::ItemRc item_rc { component_rc, item_index };
cbindgen_private::sixtyfps_component_window_set_focus_item(&inner, &item_rc); cbindgen_private::sixtyfps_windowrc_set_focus_item(&inner, &item_rc);
} }
template<typename Component, typename ItemTree> template<typename Component, typename ItemTree>
@ -122,18 +119,18 @@ public:
void set_component(const Component &c) const void set_component(const Component &c) const
{ {
auto self_rc = c.self_weak.lock().value().into_dyn(); auto self_rc = c.self_weak.lock().value().into_dyn();
sixtyfps_component_window_set_component(&inner, &self_rc); sixtyfps_windowrc_set_component(&inner, &self_rc);
} }
template<typename Component, typename Parent> template<typename Component, typename Parent>
void show_popup(const Parent *parent_component, cbindgen_private::Point p) const void show_popup(const Parent *parent_component, cbindgen_private::Point p) const
{ {
auto popup = Component::create(parent_component).into_dyn(); auto popup = Component::create(parent_component).into_dyn();
cbindgen_private::sixtyfps_component_window_show_popup(&inner, &popup, p); cbindgen_private::sixtyfps_windowrc_show_popup(&inner, &popup, p);
} }
private: private:
cbindgen_private::ComponentWindowOpaque inner; cbindgen_private::WindowRcOpaque inner;
}; };
constexpr inline ItemTreeNode make_item_node(std::uintptr_t offset, constexpr inline ItemTreeNode make_item_node(std::uintptr_t offset,

View file

@ -244,8 +244,8 @@ private:
/// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value> /// Note that models are only represented in one direction: You can create a sixtyfps::Model<Value>
/// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a /// in C++, store it in a std::shared_ptr and construct Value from it. Then you can set it on a
/// property in your .60 code that was declared to be either an array (`property <[sometype]> foo;`) /// property in your .60 code that was declared to be either an array (`property <[sometype]> foo;`)
/// or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are dynamic /// or an object literal (`property <{foo: string, bar: int}> my_prop;`). Such properties are
/// and accept models implemented in C++. /// dynamic and accept models implemented in C++.
/// ///
/// ``` /// ```
/// Value v(42.0); // Creates a value that holds a double with the value 42. /// Value v(42.0); // Creates a value that holds a double with the value 42.
@ -582,11 +582,11 @@ public:
/// it may return nullptr if the Qt backend is not used at runtime. /// it may return nullptr if the Qt backend is not used at runtime.
QWidget *qwidget() const QWidget *qwidget() const
{ {
cbindgen_private::ComponentWindowOpaque win; cbindgen_private::WindowRcOpaque win;
cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win); cbindgen_private::sixtyfps_interpreter_component_instance_window(inner(), &win);
auto wid = reinterpret_cast<QWidget *>(cbindgen_private::sixtyfps_qt_get_widget( auto wid = reinterpret_cast<QWidget *>(cbindgen_private::sixtyfps_qt_get_widget(
reinterpret_cast<cbindgen_private::ComponentWindow *>(&win))); reinterpret_cast<cbindgen_private::WindowRc *>(&win)));
cbindgen_private::sixtyfps_component_window_drop(&win); cbindgen_private::sixtyfps_windowrc_drop(&win);
return wid; return wid;
} }
#endif #endif
@ -925,11 +925,11 @@ inline void send_keyboard_string_sequence(const sixtyfps::interpreter::Component
const sixtyfps::SharedString &str, const sixtyfps::SharedString &str,
KeyboardModifiers modifiers = {}) KeyboardModifiers modifiers = {})
{ {
cbindgen_private::ComponentWindowOpaque win; cbindgen_private::WindowRcOpaque win;
cbindgen_private::sixtyfps_interpreter_component_instance_window( cbindgen_private::sixtyfps_interpreter_component_instance_window(
reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win); reinterpret_cast<const cbindgen_private::ErasedComponentBox *>(component), &win);
cbindgen_private::send_keyboard_string_sequence( cbindgen_private::send_keyboard_string_sequence(
&str, modifiers, reinterpret_cast<cbindgen_private::ComponentWindow *>(&win)); &str, modifiers, reinterpret_cast<cbindgen_private::WindowRc *>(&win));
cbindgen_private::sixtyfps_component_window_drop(&win); cbindgen_private::sixtyfps_windowrc_drop(&win);
} }
} }

View file

@ -10,8 +10,8 @@ LICENSE END */
/*! This crate just expose the function used by the C++ integration */ /*! This crate just expose the function used by the C++ integration */
use core::ffi::c_void; use core::ffi::c_void;
use sixtyfps_corelib::window::ffi::ComponentWindowOpaque; use sixtyfps_corelib::window::ffi::WindowRcOpaque;
use sixtyfps_corelib::window::ComponentWindow; use sixtyfps_corelib::window::WindowRc;
use sixtyfps_rendering_backend_default::backend; use sixtyfps_rendering_backend_default::backend;
#[doc(hidden)] #[doc(hidden)]
@ -24,12 +24,9 @@ pub fn use_modules() -> usize {
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_init(out: *mut ComponentWindowOpaque) { pub unsafe extern "C" fn sixtyfps_windowrc_init(out: *mut WindowRcOpaque) {
assert_eq!( assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
core::mem::size_of::<ComponentWindow>(), core::ptr::write(out as *mut WindowRc, crate::backend().create_window().into());
core::mem::size_of::<ComponentWindowOpaque>()
);
core::ptr::write(out as *mut ComponentWindow, crate::backend().create_window().into());
} }
#[no_mangle] #[no_mangle]

View file

@ -78,7 +78,7 @@ TEST_CASE("Image")
using namespace sixtyfps; using namespace sixtyfps;
// ensure a backend exists, using private api // ensure a backend exists, using private api
private_api::ComponentWindow wnd; private_api::WindowRc wnd;
Image img; Image img;
{ {

View file

@ -242,7 +242,7 @@ pub mod re_exports {
set_state_binding, Property, PropertyTracker, StateInfo, set_state_binding, Property, PropertyTracker, StateInfo,
}; };
pub use sixtyfps_corelib::slice::Slice; pub use sixtyfps_corelib::slice::Slice;
pub use sixtyfps_corelib::window::{ComponentWindow, WindowHandleAccess}; pub use sixtyfps_corelib::window::{WindowHandleAccess, WindowRc};
pub use sixtyfps_corelib::Color; pub use sixtyfps_corelib::Color;
pub use sixtyfps_corelib::ComponentVTable_static; pub use sixtyfps_corelib::ComponentVTable_static;
pub use sixtyfps_corelib::SharedString; pub use sixtyfps_corelib::SharedString;
@ -253,7 +253,7 @@ pub mod re_exports {
/// Creates a new window to render components in. /// Creates a new window to render components in.
#[doc(hidden)] #[doc(hidden)]
pub fn create_window() -> re_exports::ComponentWindow { pub fn create_window() -> re_exports::WindowRc {
sixtyfps_rendering_backend_default::backend().create_window().into() sixtyfps_rendering_backend_default::backend().create_window().into()
} }
@ -450,7 +450,7 @@ pub mod testing {
/// purposes of testing. /// purposes of testing.
pub trait HasWindow { pub trait HasWindow {
/// Returns a reference to the component's window. /// Returns a reference to the component's window.
fn component_window(&self) -> &super::re_exports::ComponentWindow; fn component_window(&self) -> &super::re_exports::WindowRc;
} }
pub use sixtyfps_corelib::tests::sixtyfps_mock_elapsed_time as mock_elapsed_time; pub use sixtyfps_corelib::tests::sixtyfps_mock_elapsed_time as mock_elapsed_time;

View file

@ -895,7 +895,7 @@ fn generate_component(
component_struct.members.push(( component_struct.members.push((
Access::Private, Access::Private,
Declaration::Var(Var { Declaration::Var(Var {
ty: "sixtyfps::private_api::ComponentWindow".into(), ty: "sixtyfps::private_api::WindowRc".into(),
name: "window".into(), name: "window".into(),
..Var::default() ..Var::default()
}), }),
@ -904,7 +904,7 @@ fn generate_component(
component_struct.members.push(( component_struct.members.push((
Access::Public, // FIXME: many of the different component bindings need to access this Access::Public, // FIXME: many of the different component bindings need to access this
Declaration::Var(Var { Declaration::Var(Var {
ty: "sixtyfps::private_api::ComponentWindow".into(), ty: "sixtyfps::private_api::WindowRc".into(),
name: "window".into(), name: "window".into(),
..Var::default() ..Var::default()
}), }),
@ -958,7 +958,7 @@ fn generate_component(
init.push("self->window.init_items(this, item_tree());".into()); init.push("self->window.init_items(this, item_tree());".into());
component_struct.friends.push("sixtyfps::private_api::ComponentWindow".into()); component_struct.friends.push("sixtyfps::private_api::WindowRc".into());
} }
if !component.is_global() { if !component.is_global() {

View file

@ -622,7 +622,7 @@ fn generate_component(
let mut visibility = None; let mut visibility = None;
let mut parent_component_type = None; let mut parent_component_type = None;
let mut has_window_impl = None; let mut has_window_impl = None;
let mut window_field = Some(quote!(window: sixtyfps::re_exports::ComponentWindow)); let mut window_field = Some(quote!(window: sixtyfps::re_exports::WindowRc));
if let Some(parent_element) = component.parent_element.upgrade() { if let Some(parent_element) = component.parent_element.upgrade() {
if parent_element.borrow().repeated.as_ref().map_or(false, |r| !r.is_conditional_element) { if parent_element.borrow().repeated.as_ref().map_or(false, |r| !r.is_conditional_element) {
declared_property_vars.push(format_ident!("index")); declared_property_vars.push(format_ident!("index"));
@ -640,10 +640,10 @@ fn generate_component(
&parent_element.borrow().enclosing_component.upgrade().unwrap(), &parent_element.borrow().enclosing_component.upgrade().unwrap(),
)); ));
window_field_init = Some(quote!(window: parent_window.clone())); window_field_init = Some(quote!(window: parent_window.clone()));
window_parent_param = Some(quote!(, parent_window: &sixtyfps::re_exports::ComponentWindow)) window_parent_param = Some(quote!(, parent_window: &sixtyfps::re_exports::WindowRc))
} else if !component.is_global() { } else if !component.is_global() {
// FIXME: This field is public for testing. // FIXME: This field is public for testing.
window_field = Some(quote!(pub window: sixtyfps::re_exports::ComponentWindow)); window_field = Some(quote!(pub window: sixtyfps::re_exports::WindowRc));
window_field_init = Some(quote!(window: sixtyfps::create_window())); window_field_init = Some(quote!(window: sixtyfps::create_window()));
visibility = Some(quote!(pub)); visibility = Some(quote!(pub));
@ -652,7 +652,7 @@ fn generate_component(
has_window_impl = Some(quote!( has_window_impl = Some(quote!(
impl sixtyfps::testing::HasWindow for #inner_component_id { impl sixtyfps::testing::HasWindow for #inner_component_id {
fn component_window(&self) -> &sixtyfps::re_exports::ComponentWindow { fn component_window(&self) -> &sixtyfps::re_exports::WindowRc {
&self.window &self.window
} }
} }

View file

@ -14,7 +14,7 @@ LICENSE END */
use crate::item_tree::{ItemVisitorVTable, TraversalOrder, VisitChildrenResult}; use crate::item_tree::{ItemVisitorVTable, TraversalOrder, VisitChildrenResult};
use crate::items::{ItemVTable, ItemWeak}; use crate::items::{ItemVTable, ItemWeak};
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
use crate::window::ComponentWindow; use crate::window::WindowRc;
use vtable::*; use vtable::*;
/// A Component is representing an unit that is allocated together /// A Component is representing an unit that is allocated together
@ -69,7 +69,7 @@ pub type ComponentWeak = vtable::VWeak<ComponentVTable, Dyn>;
pub fn init_component_items<Base>( pub fn init_component_items<Base>(
base: core::pin::Pin<&Base>, base: core::pin::Pin<&Base>,
item_tree: &[crate::item_tree::ItemTreeNode<Base>], item_tree: &[crate::item_tree::ItemTreeNode<Base>],
window: &ComponentWindow, window: &WindowRc,
) { ) {
item_tree.iter().for_each(|entry| match entry { item_tree.iter().for_each(|entry| match entry {
crate::item_tree::ItemTreeNode::Item { item, .. } => { crate::item_tree::ItemTreeNode::Item { item, .. } => {
@ -92,9 +92,9 @@ pub(crate) mod ffi {
pub unsafe extern "C" fn sixtyfps_component_init_items( pub unsafe extern "C" fn sixtyfps_component_init_items(
component: ComponentRefPin, component: ComponentRefPin,
item_tree: Slice<ItemTreeNode<u8>>, item_tree: Slice<ItemTreeNode<u8>>,
window_handle: *const crate::window::ffi::ComponentWindowOpaque, window_handle: *const crate::window::ffi::WindowRcOpaque,
) { ) {
let window = &*(window_handle as *const ComponentWindow); let window = &*(window_handle as *const WindowRc);
super::init_component_items( super::init_component_items(
core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)), core::pin::Pin::new_unchecked(&*(component.as_ptr() as *const u8)),
item_tree.as_slice(), item_tree.as_slice(),

View file

@ -275,7 +275,7 @@ enum MouseGrab {
fn handle_mouse_grab( fn handle_mouse_grab(
mouse_event: &MouseEvent, mouse_event: &MouseEvent,
window: &crate::window::ComponentWindow, window: &crate::window::WindowRc,
mut mouse_input_state: MouseInputState, mut mouse_input_state: MouseInputState,
) -> MouseGrab { ) -> MouseGrab {
if !mouse_input_state.grabbed || mouse_input_state.item_stack.is_empty() { if !mouse_input_state.grabbed || mouse_input_state.item_stack.is_empty() {
@ -330,7 +330,7 @@ fn handle_mouse_grab(
pub fn process_mouse_input( pub fn process_mouse_input(
component: ComponentRc, component: ComponentRc,
mouse_event: MouseEvent, mouse_event: MouseEvent,
window: &crate::window::ComponentWindow, window: &crate::window::WindowRc,
mut mouse_input_state: MouseInputState, mut mouse_input_state: MouseInputState,
) -> MouseInputState { ) -> MouseInputState {
match handle_mouse_grab(&mouse_event, window, mouse_input_state) { match handle_mouse_grab(&mouse_event, window, mouse_input_state) {

View file

@ -35,7 +35,7 @@ use crate::item_rendering::CachedRenderingData;
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::ComponentWindow; use crate::window::WindowRc;
use crate::{Callback, Property, SharedString}; use crate::{Callback, Property, SharedString};
use const_field_offset::FieldOffsets; use const_field_offset::FieldOffsets;
use core::pin::Pin; use core::pin::Pin;
@ -78,7 +78,7 @@ pub struct ItemVTable {
/// This function is called by the run-time after the memory for the item /// This function is called by the run-time after the memory for the item
/// has been allocated and initialized. It will be called before any user specified /// has been allocated and initialized. It will be called before any user specified
/// bindings are set. /// bindings are set.
pub init: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, window: &ComponentWindow), pub init: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, window: &WindowRc),
/// Returns the geometry of this item (relative to its parent item) /// Returns the geometry of this item (relative to its parent item)
pub geometry: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>) -> Rect, pub geometry: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>) -> Rect,
@ -93,7 +93,7 @@ pub struct ItemVTable {
pub layouting_info: extern "C" fn( pub layouting_info: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
orientation: Orientation, orientation: Orientation,
window: &ComponentWindow, window: &WindowRc,
) -> LayoutInfo, ) -> LayoutInfo,
/// Event handler for mouse and touch event. This function is called before being called on children. /// Event handler for mouse and touch event. This function is called before being called on children.
@ -103,7 +103,7 @@ pub struct ItemVTable {
pub input_event_filter_before_children: extern "C" fn( pub input_event_filter_before_children: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
MouseEvent, MouseEvent,
window: &ComponentWindow, window: &WindowRc,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventFilterResult, ) -> InputEventFilterResult,
@ -111,17 +111,17 @@ pub struct ItemVTable {
pub input_event: extern "C" fn( pub input_event: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
MouseEvent, MouseEvent,
window: &ComponentWindow, window: &WindowRc,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventResult, ) -> InputEventResult,
pub focus_event: pub focus_event:
extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, &FocusEvent, window: &ComponentWindow), extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, &FocusEvent, window: &WindowRc),
pub key_event: extern "C" fn( pub key_event: extern "C" fn(
core::pin::Pin<VRef<ItemVTable>>, core::pin::Pin<VRef<ItemVTable>>,
&KeyEvent, &KeyEvent,
window: &ComponentWindow, window: &WindowRc,
) -> KeyEventResult, ) -> KeyEventResult,
pub render: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, backend: &mut ItemRendererRef), pub render: extern "C" fn(core::pin::Pin<VRef<ItemVTable>>, backend: &mut ItemRendererRef),
@ -202,7 +202,7 @@ pub struct Rectangle {
} }
impl Item for Rectangle { impl Item for Rectangle {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -211,7 +211,7 @@ impl Item for Rectangle {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -219,7 +219,7 @@ impl Item for Rectangle {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -228,17 +228,17 @@ impl Item for Rectangle {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
(*backend).draw_rectangle(self) (*backend).draw_rectangle(self)
@ -273,7 +273,7 @@ pub struct BorderRectangle {
} }
impl Item for BorderRectangle { impl Item for BorderRectangle {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -282,7 +282,7 @@ impl Item for BorderRectangle {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -290,7 +290,7 @@ impl Item for BorderRectangle {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -299,17 +299,17 @@ impl Item for BorderRectangle {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
(*backend).draw_border_rectangle(self) (*backend).draw_border_rectangle(self)
@ -354,7 +354,7 @@ pub struct TouchArea {
} }
impl Item for TouchArea { impl Item for TouchArea {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -363,7 +363,7 @@ impl Item for TouchArea {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -371,7 +371,7 @@ impl Item for TouchArea {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if !self.enabled() { if !self.enabled() {
@ -388,7 +388,7 @@ impl Item for TouchArea {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if matches!(event, MouseEvent::MouseExit) { if matches!(event, MouseEvent::MouseExit) {
@ -422,11 +422,11 @@ impl Item for TouchArea {
result result
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, _backend: &mut ItemRendererRef) {} fn render(self: Pin<&Self>, _backend: &mut ItemRendererRef) {}
} }
@ -474,7 +474,7 @@ pub struct FocusScope {
} }
impl Item for FocusScope { impl Item for FocusScope {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -483,7 +483,7 @@ impl Item for FocusScope {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -491,7 +491,7 @@ impl Item for FocusScope {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -500,7 +500,7 @@ impl Item for FocusScope {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
window: &ComponentWindow, window: &WindowRc,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
/*if !self.enabled() { /*if !self.enabled() {
@ -512,7 +512,7 @@ impl Item for FocusScope {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, event: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, event: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
let r = match event.event_type { let r = match event.event_type {
KeyEventType::KeyPressed => { KeyEventType::KeyPressed => {
Self::FIELD_OFFSETS.key_pressed.apply_pin(self).call(&(event.clone(),)) Self::FIELD_OFFSETS.key_pressed.apply_pin(self).call(&(event.clone(),))
@ -527,7 +527,7 @@ impl Item for FocusScope {
} }
} }
fn focus_event(self: Pin<&Self>, event: &FocusEvent, _window: &ComponentWindow) { fn focus_event(self: Pin<&Self>, event: &FocusEvent, _window: &WindowRc) {
match event { match event {
FocusEvent::FocusIn | FocusEvent::WindowReceivedFocus => { FocusEvent::FocusIn | FocusEvent::WindowReceivedFocus => {
self.has_focus.set(true); self.has_focus.set(true);
@ -567,7 +567,7 @@ pub struct Clip {
} }
impl Item for Clip { impl Item for Clip {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -576,7 +576,7 @@ impl Item for Clip {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -584,7 +584,7 @@ impl Item for Clip {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if let Some(pos) = event.pos() { if let Some(pos) = event.pos() {
@ -598,17 +598,17 @@ impl Item for Clip {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
let geometry = self.geometry(); let geometry = self.geometry();
@ -644,7 +644,7 @@ pub struct Opacity {
} }
impl Item for Opacity { impl Item for Opacity {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -653,7 +653,7 @@ impl Item for Opacity {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -661,7 +661,7 @@ impl Item for Opacity {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -670,17 +670,17 @@ impl Item for Opacity {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
backend.apply_opacity(self.opacity()); backend.apply_opacity(self.opacity());
@ -712,7 +712,7 @@ pub struct Rotate {
} }
impl Item for Rotate { impl Item for Rotate {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(0., 0., 0., 0.) euclid::rect(0., 0., 0., 0.)
@ -721,7 +721,7 @@ impl Item for Rotate {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -729,7 +729,7 @@ impl Item for Rotate {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -738,17 +738,17 @@ impl Item for Rotate {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
(*backend).translate(self.origin_x(), self.origin_y()); (*backend).translate(self.origin_x(), self.origin_y());
@ -805,7 +805,7 @@ pub struct Path {
} }
impl Item for Path { impl Item for Path {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -814,7 +814,7 @@ impl Item for Path {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -822,7 +822,7 @@ impl Item for Path {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if let Some(pos) = event.pos() { if let Some(pos) = event.pos() {
@ -838,17 +838,17 @@ impl Item for Path {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
let clip = self.clip(); let clip = self.clip();
@ -918,7 +918,7 @@ pub struct Flickable {
} }
impl Item for Flickable { impl Item for Flickable {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -927,7 +927,7 @@ impl Item for Flickable {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -935,7 +935,7 @@ impl Item for Flickable {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
if let Some(pos) = event.pos() { if let Some(pos) = event.pos() {
@ -952,7 +952,7 @@ impl Item for Flickable {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if !self.interactive() && !matches!(event, MouseEvent::MouseWheel { .. }) { if !self.interactive() && !matches!(event, MouseEvent::MouseWheel { .. }) {
@ -969,11 +969,11 @@ impl Item for Flickable {
self.data.handle_mouse(self, event) self.data.handle_mouse(self, event)
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
let geometry = self.geometry(); let geometry = self.geometry();
@ -1056,7 +1056,7 @@ pub struct WindowItem {
} }
impl Item for WindowItem { impl Item for WindowItem {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(0., 0., self.width(), self.height()) euclid::rect(0., 0., self.width(), self.height())
@ -1065,7 +1065,7 @@ impl Item for WindowItem {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo::default() LayoutInfo::default()
} }
@ -1073,7 +1073,7 @@ impl Item for WindowItem {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -1082,17 +1082,17 @@ impl Item for WindowItem {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_event: MouseEvent, _event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, _backend: &mut ItemRendererRef) {} fn render(self: Pin<&Self>, _backend: &mut ItemRendererRef) {}
} }
@ -1159,7 +1159,7 @@ pub struct BoxShadow {
} }
impl Item for BoxShadow { impl Item for BoxShadow {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -1168,7 +1168,7 @@ impl Item for BoxShadow {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
_orientation: Orientation, _orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { stretch: 1., ..LayoutInfo::default() } LayoutInfo { stretch: 1., ..LayoutInfo::default() }
} }
@ -1176,7 +1176,7 @@ impl Item for BoxShadow {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -1185,17 +1185,17 @@ impl Item for BoxShadow {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_event: MouseEvent, _event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) { fn render(self: Pin<&Self>, backend: &mut ItemRendererRef) {
(*backend).draw_box_shadow(self) (*backend).draw_box_shadow(self)

View file

@ -23,7 +23,7 @@ use crate::item_rendering::ItemRenderer;
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::ComponentWindow; use crate::window::WindowRc;
use crate::{Brush, Property}; use crate::{Brush, Property};
use const_field_offset::FieldOffsets; use const_field_offset::FieldOffsets;
use core::pin::Pin; use core::pin::Pin;
@ -59,7 +59,7 @@ pub struct ImageItem {
} }
impl Item for ImageItem { impl Item for ImageItem {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -68,7 +68,7 @@ impl Item for ImageItem {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let natural_size = self.source().size(); let natural_size = self.source().size();
LayoutInfo { LayoutInfo {
@ -84,7 +84,7 @@ impl Item for ImageItem {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -93,17 +93,17 @@ impl Item for ImageItem {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer) { fn render(self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer) {
(*backend).draw_image(self) (*backend).draw_image(self)
@ -137,7 +137,7 @@ pub struct ClippedImage {
} }
impl Item for ClippedImage { impl Item for ClippedImage {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -146,7 +146,7 @@ impl Item for ClippedImage {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let natural_size = self.source().size(); let natural_size = self.source().size();
LayoutInfo { LayoutInfo {
@ -162,7 +162,7 @@ impl Item for ClippedImage {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -171,17 +171,17 @@ impl Item for ClippedImage {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer) { fn render(self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer) {
(*backend).draw_clipped_image(self) (*backend).draw_clipped_image(self)

View file

@ -25,7 +25,7 @@ use crate::item_rendering::{CachedRenderingData, ItemRenderer};
use crate::layout::{LayoutInfo, Orientation}; use crate::layout::{LayoutInfo, Orientation};
#[cfg(feature = "rtti")] #[cfg(feature = "rtti")]
use crate::rtti::*; use crate::rtti::*;
use crate::window::ComponentWindow; use crate::window::WindowRc;
use crate::{Callback, Property, SharedString}; use crate::{Callback, Property, SharedString};
use const_field_offset::FieldOffsets; use const_field_offset::FieldOffsets;
use core::pin::Pin; use core::pin::Pin;
@ -112,17 +112,13 @@ pub struct Text {
} }
impl Item for Text { impl Item for Text {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
} }
fn layouting_info( fn layouting_info(self: Pin<&Self>, orientation: Orientation, window: &WindowRc) -> LayoutInfo {
self: Pin<&Self>,
orientation: Orientation,
window: &ComponentWindow,
) -> LayoutInfo {
let font_metrics = window.0.font_metrics( let font_metrics = window.0.font_metrics(
&self.cached_rendering_data, &self.cached_rendering_data,
&|| self.unresolved_font_request(), &|| self.unresolved_font_request(),
@ -165,7 +161,7 @@ impl Item for Text {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -174,17 +170,17 @@ impl Item for Text {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn render(self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer) { fn render(self: Pin<&Self>, backend: &mut &mut dyn ItemRenderer) {
(*backend).draw_text(self) (*backend).draw_text(self)
@ -260,18 +256,14 @@ pub struct TextInput {
} }
impl Item for TextInput { impl Item for TextInput {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
// FIXME: width / height. or maybe it doesn't matter? ( // FIXME: width / height. or maybe it doesn't matter? (
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
} }
fn layouting_info( fn layouting_info(self: Pin<&Self>, orientation: Orientation, window: &WindowRc) -> LayoutInfo {
self: Pin<&Self>,
orientation: Orientation,
window: &ComponentWindow,
) -> LayoutInfo {
let font_metrics = window.0.font_metrics( let font_metrics = window.0.font_metrics(
&self.cached_rendering_data, &self.cached_rendering_data,
&|| self.unresolved_font_request(), &|| self.unresolved_font_request(),
@ -295,7 +287,7 @@ impl Item for TextInput {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -304,7 +296,7 @@ impl Item for TextInput {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
window: &ComponentWindow, window: &WindowRc,
self_rc: &ItemRc, self_rc: &ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if !self.enabled() { if !self.enabled() {
@ -342,7 +334,7 @@ impl Item for TextInput {
InputEventResult::EventAccepted InputEventResult::EventAccepted
} }
fn key_event(self: Pin<&Self>, event: &KeyEvent, window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, event: &KeyEvent, window: &WindowRc) -> KeyEventResult {
use std::convert::TryFrom; use std::convert::TryFrom;
if !self.enabled() { if !self.enabled() {
@ -412,7 +404,7 @@ impl Item for TextInput {
} }
} }
fn focus_event(self: Pin<&Self>, event: &FocusEvent, window: &ComponentWindow) { fn focus_event(self: Pin<&Self>, event: &FocusEvent, window: &WindowRc) {
match event { match event {
FocusEvent::FocusIn | FocusEvent::WindowReceivedFocus => { FocusEvent::FocusIn | FocusEvent::WindowReceivedFocus => {
self.has_focus.set(true); self.has_focus.set(true);
@ -474,7 +466,7 @@ impl From<KeyboardModifiers> for AnchorMode {
} }
impl TextInput { impl TextInput {
fn show_cursor(&self, window: &ComponentWindow) { fn show_cursor(&self, window: &WindowRc) {
window.0.set_cursor_blink_binding(&self.cursor_visible); window.0.set_cursor_blink_binding(&self.cursor_visible);
} }
@ -486,7 +478,7 @@ impl TextInput {
self: Pin<&Self>, self: Pin<&Self>,
direction: TextCursorDirection, direction: TextCursorDirection,
anchor_mode: AnchorMode, anchor_mode: AnchorMode,
window: &ComponentWindow, window: &WindowRc,
) -> bool { ) -> bool {
let text = self.text(); let text = self.text();
if text.len() == 0 { if text.len() == 0 {
@ -534,14 +526,14 @@ impl TextInput {
new_cursor_pos != last_cursor_pos new_cursor_pos != last_cursor_pos
} }
fn delete_char(self: Pin<&Self>, window: &ComponentWindow) { fn delete_char(self: Pin<&Self>, window: &WindowRc) {
if !self.has_selection() { if !self.has_selection() {
self.move_cursor(TextCursorDirection::Forward, AnchorMode::KeepAnchor, window); self.move_cursor(TextCursorDirection::Forward, AnchorMode::KeepAnchor, window);
} }
self.delete_selection(); self.delete_selection();
} }
fn delete_previous(self: Pin<&Self>, window: &ComponentWindow) { fn delete_previous(self: Pin<&Self>, window: &WindowRc) {
if self.has_selection() { if self.has_selection() {
self.delete_selection(); self.delete_selection();
return; return;

View file

@ -86,7 +86,7 @@ pub fn use_modules() -> usize {
+ graphics::ffi::sixtyfps_new_path_elements as usize + graphics::ffi::sixtyfps_new_path_elements as usize
+ properties::ffi::sixtyfps_property_init as usize + properties::ffi::sixtyfps_property_init as usize
+ string::ffi::sixtyfps_shared_string_bytes as usize + string::ffi::sixtyfps_shared_string_bytes as usize
+ window::ffi::sixtyfps_component_window_drop as usize + window::ffi::sixtyfps_windowrc_drop as usize
+ component::ffi::sixtyfps_component_init_items as usize + component::ffi::sixtyfps_component_init_items as usize
+ timers::ffi::sixtyfps_timer_start as usize + timers::ffi::sixtyfps_timer_start as usize
+ graphics::color::ffi::sixtyfps_color_brighter as usize + graphics::color::ffi::sixtyfps_color_brighter as usize

View file

@ -12,7 +12,7 @@ LICENSE END */
#![allow(unsafe_code)] #![allow(unsafe_code)]
use crate::input::{KeyEvent, KeyEventType, KeyboardModifiers, MouseEvent}; use crate::input::{KeyEvent, KeyEventType, KeyboardModifiers, MouseEvent};
use crate::window::ComponentWindow; use crate::window::WindowRc;
use crate::SharedString; use crate::SharedString;
/// SixtyFPS animations do not use real time, but use a mocked time. /// SixtyFPS animations do not use real time, but use a mocked time.
@ -34,7 +34,7 @@ pub extern "C" fn sixtyfps_send_mouse_click(
component: &crate::component::ComponentRc, component: &crate::component::ComponentRc,
x: f32, x: f32,
y: f32, y: f32,
window: &ComponentWindow, window: &WindowRc,
) { ) {
let mut state = crate::input::MouseInputState::default(); let mut state = crate::input::MouseInputState::default();
let pos = euclid::point2(x, y); let pos = euclid::point2(x, y);
@ -65,7 +65,7 @@ pub extern "C" fn sixtyfps_send_mouse_click(
pub extern "C" fn send_keyboard_string_sequence( pub extern "C" fn send_keyboard_string_sequence(
sequence: &crate::SharedString, sequence: &crate::SharedString,
modifiers: KeyboardModifiers, modifiers: KeyboardModifiers,
window: &ComponentWindow, window: &WindowRc,
) { ) {
for ch in sequence.chars() { for ch in sequence.chars() {
let mut modifiers = modifiers; let mut modifiers = modifiers;

View file

@ -322,19 +322,18 @@ pub trait WindowHandleAccess {
fn window_handle(&self) -> &std::rc::Rc<Window>; fn window_handle(&self) -> &std::rc::Rc<Window>;
} }
/// The ComponentWindow is the (rust) facing public type that can render the items /// The WindowRc is the (rust) facing wrapper type for Rc<Window>.
/// of components to the screen.
#[repr(C)] #[repr(C)]
#[derive(Clone)] #[derive(Clone)]
pub struct ComponentWindow(pub(crate) std::rc::Rc<Window>); pub struct WindowRc(pub(crate) std::rc::Rc<Window>);
impl From<std::rc::Rc<Window>> for ComponentWindow { impl From<std::rc::Rc<Window>> for WindowRc {
fn from(inner: std::rc::Rc<Window>) -> Self { fn from(inner: std::rc::Rc<Window>) -> Self {
Self(inner) Self(inner)
} }
} }
impl WindowHandleAccess for ComponentWindow { impl WindowHandleAccess for WindowRc {
fn window_handle(&self) -> &std::rc::Rc<Window> { fn window_handle(&self) -> &std::rc::Rc<Window> {
&self.0 &self.0
} }
@ -351,116 +350,105 @@ pub mod ffi {
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
type c_void = (); type c_void = ();
/// Same layout as ComponentWindow /// Same layout as WindowRc
#[repr(C)] #[repr(C)]
pub struct ComponentWindowOpaque(*const c_void); pub struct WindowRcOpaque(*const c_void);
/// Releases the reference to the component window held by handle. /// Releases the reference to the windowrc held by handle.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_drop(handle: *mut ComponentWindowOpaque) { pub unsafe extern "C" fn sixtyfps_windowrc_drop(handle: *mut WindowRcOpaque) {
assert_eq!( assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
core::mem::size_of::<ComponentWindow>(), core::ptr::read(handle as *mut WindowRc);
core::mem::size_of::<ComponentWindowOpaque>()
);
core::ptr::read(handle as *mut ComponentWindow);
} }
/// Releases the reference to the component window held by handle. /// Releases the reference to the component window held by handle.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_clone( pub unsafe extern "C" fn sixtyfps_windowrc_clone(
source: *const ComponentWindowOpaque, source: *const WindowRcOpaque,
target: *mut ComponentWindowOpaque, target: *mut WindowRcOpaque,
) { ) {
assert_eq!( assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
core::mem::size_of::<ComponentWindow>(), let window = &*(source as *const WindowRc);
core::mem::size_of::<ComponentWindowOpaque>() core::ptr::write(target as *mut WindowRc, window.clone());
);
let window = &*(source as *const ComponentWindow);
core::ptr::write(target as *mut ComponentWindow, window.clone());
} }
/// Spins an event loop and renders the items of the provided component in this window. /// Spins an event loop and renders the items of the provided component in this window.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_show(handle: *const ComponentWindowOpaque) { pub unsafe extern "C" fn sixtyfps_windowrc_show(handle: *const WindowRcOpaque) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().show(); window.window_handle().show();
} }
/// Spins an event loop and renders the items of the provided component in this window. /// Spins an event loop and renders the items of the provided component in this window.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_hide(handle: *const ComponentWindowOpaque) { pub unsafe extern "C" fn sixtyfps_windowrc_hide(handle: *const WindowRcOpaque) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().hide(); window.window_handle().hide();
} }
/// Returns the window scale factor. /// Returns the window scale factor.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_get_scale_factor( pub unsafe extern "C" fn sixtyfps_windowrc_get_scale_factor(
handle: *const ComponentWindowOpaque, handle: *const WindowRcOpaque,
) -> f32 { ) -> f32 {
assert_eq!( assert_eq!(core::mem::size_of::<WindowRc>(), core::mem::size_of::<WindowRcOpaque>());
core::mem::size_of::<ComponentWindow>(), let window = &*(handle as *const WindowRc);
core::mem::size_of::<ComponentWindowOpaque>()
);
let window = &*(handle as *const ComponentWindow);
window.window_handle().scale_factor() window.window_handle().scale_factor()
} }
/// Sets the window scale factor, merely for testing purposes. /// Sets the window scale factor, merely for testing purposes.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_set_scale_factor( pub unsafe extern "C" fn sixtyfps_windowrc_set_scale_factor(
handle: *const ComponentWindowOpaque, handle: *const WindowRcOpaque,
value: f32, value: f32,
) { ) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().set_scale_factor(value) window.window_handle().set_scale_factor(value)
} }
/// Sets the window scale factor, merely for testing purposes. /// Sets the window scale factor, merely for testing purposes.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_free_graphics_resources<'a>( pub unsafe extern "C" fn sixtyfps_windowrc_free_graphics_resources<'a>(
handle: *const ComponentWindowOpaque, handle: *const WindowRcOpaque,
items: &Slice<'a, Pin<ItemRef<'a>>>, items: &Slice<'a, Pin<ItemRef<'a>>>,
) { ) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().free_graphics_resources(items) window.window_handle().free_graphics_resources(items)
} }
/// Sets the focus item. /// Sets the focus item.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_set_focus_item( pub unsafe extern "C" fn sixtyfps_windowrc_set_focus_item(
handle: *const ComponentWindowOpaque, handle: *const WindowRcOpaque,
focus_item: &ItemRc, focus_item: &ItemRc,
) { ) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().clone().set_focus_item(focus_item) window.window_handle().clone().set_focus_item(focus_item)
} }
/// Associates the window with the given component. /// Associates the window with the given component.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_set_component( pub unsafe extern "C" fn sixtyfps_windowrc_set_component(
handle: *const ComponentWindowOpaque, handle: *const WindowRcOpaque,
component: &ComponentRc, component: &ComponentRc,
) { ) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().set_component(component) window.window_handle().set_component(component)
} }
/// Show a popup. /// Show a popup.
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_component_window_show_popup( pub unsafe extern "C" fn sixtyfps_windowrc_show_popup(
handle: *const ComponentWindowOpaque, handle: *const WindowRcOpaque,
popup: &ComponentRc, popup: &ComponentRc,
position: crate::graphics::Point, position: crate::graphics::Point,
) { ) {
let window = &*(handle as *const ComponentWindow); let window = &*(handle as *const WindowRc);
window.window_handle().show_popup(popup, position); window.window_handle().show_popup(popup, position);
} }
/// Close the current popup /// Close the current popup
pub unsafe extern "C" fn sixtyfps_component_window_close_popup( pub unsafe extern "C" fn sixtyfps_windowrc_close_popup(handle: *const WindowRcOpaque) {
handle: *const ComponentWindowOpaque, let window = &*(handle as *const WindowRc);
) {
let window = &*(handle as *const ComponentWindow);
window.window_handle().close_popup(); window.window_handle().close_popup();
} }
} }

View file

@ -19,7 +19,7 @@ use sixtyfps_compilerlib::object_tree::ElementRc;
use sixtyfps_corelib::layout::{self as core_layout}; use sixtyfps_corelib::layout::{self as core_layout};
use sixtyfps_corelib::model::RepeatedComponent; use sixtyfps_corelib::model::RepeatedComponent;
use sixtyfps_corelib::slice::Slice; use sixtyfps_corelib::slice::Slice;
use sixtyfps_corelib::window::ComponentWindow; use sixtyfps_corelib::window::WindowRc;
use std::convert::TryInto; use std::convert::TryInto;
pub(crate) fn to_runtime(o: Orientation) -> core_layout::Orientation { pub(crate) fn to_runtime(o: Orientation) -> core_layout::Orientation {
@ -353,7 +353,7 @@ pub(crate) fn fill_layout_info_constraints(
pub(crate) fn get_layout_info( pub(crate) fn get_layout_info(
elem: &ElementRc, elem: &ElementRc,
component: InstanceRef, component: InstanceRef,
window: &ComponentWindow, window: &WindowRc,
orientation: Orientation, orientation: Orientation,
) -> core_layout::LayoutInfo { ) -> core_layout::LayoutInfo {
let elem = elem.borrow(); let elem = elem.borrow();

View file

@ -409,18 +409,18 @@ pub extern "C" fn sixtyfps_interpreter_component_instance_show(
/// Return a window for the component /// Return a window for the component
/// ///
/// The out pointer must be uninitialized and must be destroyed with /// The out pointer must be uninitialized and must be destroyed with
/// sixtyfps_component_window_drop after usage /// sixtyfps_windowrc_drop after usage
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn sixtyfps_interpreter_component_instance_window( pub unsafe extern "C" fn sixtyfps_interpreter_component_instance_window(
inst: &ErasedComponentBox, inst: &ErasedComponentBox,
out: *mut sixtyfps_corelib::window::ffi::ComponentWindowOpaque, out: *mut sixtyfps_corelib::window::ffi::WindowRcOpaque,
) { ) {
use sixtyfps_corelib::window::ComponentWindow; use sixtyfps_corelib::window::WindowRc;
assert_eq!( assert_eq!(
core::mem::size_of::<ComponentWindow>(), core::mem::size_of::<WindowRc>(),
core::mem::size_of::<sixtyfps_corelib::window::ffi::ComponentWindowOpaque>() core::mem::size_of::<sixtyfps_corelib::window::ffi::WindowRcOpaque>()
); );
core::ptr::write(out as *mut ComponentWindow, inst.window().into()) core::ptr::write(out as *mut WindowRc, inst.window().into())
} }
/// Instantiate an instance from a definition. /// Instantiate an instance from a definition.

View file

@ -451,7 +451,7 @@ impl PlatformWindow for GraphicsWindow {
match &*self.map_state.borrow() { match &*self.map_state.borrow() {
GraphicsWindowBackendState::Unmapped => { GraphicsWindowBackendState::Unmapped => {
// Nothing to be done if the window isn't visible. When it becomes visible, // Nothing to be done if the window isn't visible. When it becomes visible,
// ComponentWindow::show() calls update_window_properties() // corelib::window::Window::show() calls update_window_properties()
} }
GraphicsWindowBackendState::Mapped(window) => { GraphicsWindowBackendState::Mapped(window) => {
let backend = window.backend.borrow(); let backend = window.backend.borrow();

View file

@ -49,7 +49,7 @@ pub fn use_modules() -> usize {
mod ffi { mod ffi {
#[no_mangle] #[no_mangle]
pub extern "C" fn sixtyfps_qt_get_widget( pub extern "C" fn sixtyfps_qt_get_widget(
_: &sixtyfps_corelib::window::ComponentWindow, _: &sixtyfps_corelib::window::WindowRc,
) -> *mut std::ffi::c_void { ) -> *mut std::ffi::c_void {
std::ptr::null_mut() std::ptr::null_mut()
} }

View file

@ -1494,7 +1494,7 @@ pub(crate) mod ffi {
#[no_mangle] #[no_mangle]
pub extern "C" fn sixtyfps_qt_get_widget( pub extern "C" fn sixtyfps_qt_get_widget(
window: &sixtyfps_corelib::window::ComponentWindow, window: &sixtyfps_corelib::window::WindowRc,
) -> *mut c_void { ) -> *mut c_void {
use sixtyfps_corelib::window::WindowHandleAccess; use sixtyfps_corelib::window::WindowHandleAccess;
<dyn std::any::Any>::downcast_ref(window.window_handle().as_any()) <dyn std::any::Any>::downcast_ref(window.window_handle().as_any())

View file

@ -35,7 +35,7 @@ use sixtyfps_corelib::item_rendering::{CachedRenderingData, ItemRenderer};
use sixtyfps_corelib::items::{Item, ItemConsts, ItemRc, ItemVTable, VoidArg}; use sixtyfps_corelib::items::{Item, ItemConsts, ItemRc, ItemVTable, VoidArg};
use sixtyfps_corelib::layout::{LayoutInfo, Orientation}; use sixtyfps_corelib::layout::{LayoutInfo, Orientation};
use sixtyfps_corelib::rtti::*; use sixtyfps_corelib::rtti::*;
use sixtyfps_corelib::window::ComponentWindow; use sixtyfps_corelib::window::WindowRc;
use sixtyfps_corelib::{ use sixtyfps_corelib::{
declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector, declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector,
}; };
@ -165,7 +165,7 @@ pub struct NativeButton {
} }
impl Item for NativeButton { impl Item for NativeButton {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -174,7 +174,7 @@ impl Item for NativeButton {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let mut text: qttypes::QString = self.text().as_str().into(); let mut text: qttypes::QString = self.text().as_str().into();
let size = cpp!(unsafe [ let size = cpp!(unsafe [
@ -200,7 +200,7 @@ impl Item for NativeButton {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -209,7 +209,7 @@ impl Item for NativeButton {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let enabled = self.enabled(); let enabled = self.enabled();
@ -237,11 +237,11 @@ impl Item for NativeButton {
} }
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let down: bool = this.pressed(); let down: bool = this.pressed();
@ -298,7 +298,7 @@ pub struct NativeCheckBox {
} }
impl Item for NativeCheckBox { impl Item for NativeCheckBox {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -307,7 +307,7 @@ impl Item for NativeCheckBox {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let text: qttypes::QString = self.text().as_str().into(); let text: qttypes::QString = self.text().as_str().into();
let size = cpp!(unsafe [ let size = cpp!(unsafe [
@ -334,7 +334,7 @@ impl Item for NativeCheckBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -343,7 +343,7 @@ impl Item for NativeCheckBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
if !self.enabled() { if !self.enabled() {
@ -356,11 +356,11 @@ impl Item for NativeCheckBox {
InputEventResult::EventAccepted InputEventResult::EventAccepted
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let checked: bool = this.checked(); let checked: bool = this.checked();
@ -447,7 +447,7 @@ void initQSpinBoxOptions(QStyleOptionSpinBox &option, bool pressed, bool enabled
}} }}
impl Item for NativeSpinBox { impl Item for NativeSpinBox {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -456,7 +456,7 @@ impl Item for NativeSpinBox {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
//let value: i32 = self.value(); //let value: i32 = self.value();
let data = self.data(); let data = self.data();
@ -495,7 +495,7 @@ impl Item for NativeSpinBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -504,7 +504,7 @@ impl Item for NativeSpinBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let size: qttypes::QSize = get_size!(self); let size: qttypes::QSize = get_size!(self);
@ -573,11 +573,11 @@ impl Item for NativeSpinBox {
InputEventResult::EventAccepted InputEventResult::EventAccepted
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let value: i32 = this.value(); let value: i32 = this.value();
@ -665,7 +665,7 @@ void initQSliderOptions(QStyleOptionSlider &option, bool pressed, bool enabled,
}} }}
impl Item for NativeSlider { impl Item for NativeSlider {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -674,7 +674,7 @@ impl Item for NativeSlider {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let enabled = self.enabled(); let enabled = self.enabled();
let value = self.value() as i32; let value = self.value() as i32;
@ -714,7 +714,7 @@ impl Item for NativeSlider {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -723,7 +723,7 @@ impl Item for NativeSlider {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let size: qttypes::QSize = get_size!(self); let size: qttypes::QSize = get_size!(self);
@ -788,11 +788,11 @@ impl Item for NativeSlider {
result result
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let enabled = this.enabled(); let enabled = this.enabled();
@ -858,7 +858,7 @@ struct GroupBoxData {
} }
impl Item for NativeGroupBox { impl Item for NativeGroupBox {
fn init(self: Pin<&Self>, _window: &ComponentWindow) { fn init(self: Pin<&Self>, _window: &WindowRc) {
let shared_data = Rc::pin(GroupBoxData::default()); let shared_data = Rc::pin(GroupBoxData::default());
Property::link_two_way( Property::link_two_way(
@ -951,7 +951,7 @@ impl Item for NativeGroupBox {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { LayoutInfo {
min: match orientation { min: match orientation {
@ -966,7 +966,7 @@ impl Item for NativeGroupBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -975,17 +975,17 @@ impl Item for NativeGroupBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let text: qttypes::QString = let text: qttypes::QString =
@ -1047,7 +1047,7 @@ pub struct NativeLineEdit {
} }
impl Item for NativeLineEdit { impl Item for NativeLineEdit {
fn init(self: Pin<&Self>, _window: &ComponentWindow) { fn init(self: Pin<&Self>, _window: &WindowRc) {
let paddings = Rc::pin(Property::default()); let paddings = Rc::pin(Property::default());
paddings.as_ref().set_binding(move || { paddings.as_ref().set_binding(move || {
@ -1098,7 +1098,7 @@ impl Item for NativeLineEdit {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { LayoutInfo {
min: match orientation { min: match orientation {
@ -1113,7 +1113,7 @@ impl Item for NativeLineEdit {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -1122,17 +1122,17 @@ impl Item for NativeLineEdit {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let focused: bool = this.focused(); let focused: bool = this.focused();
@ -1193,7 +1193,7 @@ pub struct NativeScrollView {
} }
impl Item for NativeScrollView { impl Item for NativeScrollView {
fn init(self: Pin<&Self>, _window: &ComponentWindow) { fn init(self: Pin<&Self>, _window: &WindowRc) {
let paddings = Rc::pin(Property::default()); let paddings = Rc::pin(Property::default());
paddings.as_ref().set_binding(move || { paddings.as_ref().set_binding(move || {
@ -1254,7 +1254,7 @@ impl Item for NativeScrollView {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
LayoutInfo { LayoutInfo {
min: match orientation { min: match orientation {
@ -1269,7 +1269,7 @@ impl Item for NativeScrollView {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -1278,7 +1278,7 @@ impl Item for NativeScrollView {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let size: qttypes::QSize = get_size!(self); let size: qttypes::QSize = get_size!(self);
@ -1422,11 +1422,11 @@ impl Item for NativeScrollView {
} }
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
@ -1558,7 +1558,7 @@ pub struct NativeStandardListViewItem {
} }
impl Item for NativeStandardListViewItem { impl Item for NativeStandardListViewItem {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -1567,7 +1567,7 @@ impl Item for NativeStandardListViewItem {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let index: i32 = self.index(); let index: i32 = self.index();
let item = self.item(); let item = self.item();
@ -1604,7 +1604,7 @@ impl Item for NativeStandardListViewItem {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardAndIgnore InputEventFilterResult::ForwardAndIgnore
@ -1613,17 +1613,17 @@ impl Item for NativeStandardListViewItem {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
_event: MouseEvent, _event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
InputEventResult::EventIgnored InputEventResult::EventIgnored
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let index: i32 = this.index(); let index: i32 = this.index();
@ -1685,7 +1685,7 @@ pub struct NativeComboBox {
} }
impl Item for NativeComboBox { impl Item for NativeComboBox {
fn init(self: Pin<&Self>, _window: &ComponentWindow) {} fn init(self: Pin<&Self>, _window: &WindowRc) {}
fn geometry(self: Pin<&Self>) -> Rect { fn geometry(self: Pin<&Self>) -> Rect {
euclid::rect(self.x(), self.y(), self.width(), self.height()) euclid::rect(self.x(), self.y(), self.width(), self.height())
@ -1694,7 +1694,7 @@ impl Item for NativeComboBox {
fn layouting_info( fn layouting_info(
self: Pin<&Self>, self: Pin<&Self>,
orientation: Orientation, orientation: Orientation,
_window: &ComponentWindow, _window: &WindowRc,
) -> LayoutInfo { ) -> LayoutInfo {
let size = cpp!(unsafe [] -> qttypes::QSize as "QSize" { let size = cpp!(unsafe [] -> qttypes::QSize as "QSize" {
ensure_initialized(); ensure_initialized();
@ -1716,7 +1716,7 @@ impl Item for NativeComboBox {
fn input_event_filter_before_children( fn input_event_filter_before_children(
self: Pin<&Self>, self: Pin<&Self>,
_: MouseEvent, _: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &ItemRc, _self_rc: &ItemRc,
) -> InputEventFilterResult { ) -> InputEventFilterResult {
InputEventFilterResult::ForwardEvent InputEventFilterResult::ForwardEvent
@ -1725,7 +1725,7 @@ impl Item for NativeComboBox {
fn input_event( fn input_event(
self: Pin<&Self>, self: Pin<&Self>,
event: MouseEvent, event: MouseEvent,
_window: &ComponentWindow, _window: &WindowRc,
_self_rc: &sixtyfps_corelib::items::ItemRc, _self_rc: &sixtyfps_corelib::items::ItemRc,
) -> InputEventResult { ) -> InputEventResult {
let enabled = self.enabled(); let enabled = self.enabled();
@ -1755,11 +1755,11 @@ impl Item for NativeComboBox {
} }
} }
fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &ComponentWindow) -> KeyEventResult { fn key_event(self: Pin<&Self>, _: &KeyEvent, _window: &WindowRc) -> KeyEventResult {
KeyEventResult::EventIgnored KeyEventResult::EventIgnored
} }
fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &ComponentWindow) {} fn focus_event(self: Pin<&Self>, _: &FocusEvent, _window: &WindowRc) {}
fn_render! { this dpr size painter => fn_render! { this dpr size painter =>
let down: bool = this.pressed(); let down: bool = this.pressed();

View file

@ -93,7 +93,7 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> {
config.export.include = [ config.export.include = [
"ComponentVTable", "ComponentVTable",
"Slice", "Slice",
"ComponentWindowOpaque", "WindowRcOpaque",
"PropertyAnimation", "PropertyAnimation",
"EasingCurve", "EasingCurve",
"TextHorizontalAlignment", "TextHorizontalAlignment",
@ -127,7 +127,7 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> {
"sixtyfps_property_listener_scope_is_dirty", "sixtyfps_property_listener_scope_is_dirty",
"PropertyTrackerOpaque", "PropertyTrackerOpaque",
"CallbackOpaque", "CallbackOpaque",
"ComponentWindow", "WindowRc",
"VoidArg", "VoidArg",
"KeyEventArg", "KeyEventArg",
"sixtyfps_color_brighter", "sixtyfps_color_brighter",
@ -215,16 +215,16 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> {
special_config.export.include = rust_types.iter().map(|s| s.to_string()).collect(); special_config.export.include = rust_types.iter().map(|s| s.to_string()).collect();
special_config.export.exclude = [ special_config.export.exclude = [
"sixtyfps_visit_item_tree", "sixtyfps_visit_item_tree",
"sixtyfps_component_window_drop", "sixtyfps_windowrc_drop",
"sixtyfps_component_window_clone", "sixtyfps_windowrc_clone",
"sixtyfps_component_window_show", "sixtyfps_windowrc_show",
"sixtyfps_component_window_hide", "sixtyfps_windowrc_hide",
"sixtyfps_component_window_get_scale_factor", "sixtyfps_windowrc_get_scale_factor",
"sixtyfps_component_window_set_scale_factor", "sixtyfps_windowrc_set_scale_factor",
"sixtyfps_component_window_free_graphics_resources", "sixtyfps_windowrc_free_graphics_resources",
"sixtyfps_component_window_set_focus_item", "sixtyfps_windowrc_set_focus_item",
"sixtyfps_component_window_set_component", "sixtyfps_windowrc_set_component",
"sixtyfps_component_window_show_popup", "sixtyfps_windowrc_show_popup",
"sixtyfps_new_path_elements", "sixtyfps_new_path_elements",
"sixtyfps_new_path_events", "sixtyfps_new_path_events",
"sixtyfps_color_brighter", "sixtyfps_color_brighter",
@ -309,8 +309,8 @@ fn gen_corelib(root_dir: &Path, include_dir: &Path) -> anyhow::Result<()> {
.with_after_include(format!( .with_after_include(format!(
r" r"
namespace sixtyfps {{ namespace sixtyfps {{
namespace private_api {{ enum class VersionCheck {{ Major = {}, Minor = {}, Patch = {} }}; class ComponentWindow; }} namespace private_api {{ enum class VersionCheck {{ Major = {}, Minor = {}, Patch = {} }}; class WindowRc; }}
namespace cbindgen_private {{ using sixtyfps::private_api::ComponentWindow; using namespace vtable; struct KeyEvent; using private_api::Property; using private_api::PathData; }} namespace cbindgen_private {{ using sixtyfps::private_api::WindowRc; using namespace vtable; struct KeyEvent; using private_api::Property; using private_api::PathData; }}
}}", }}",
0, 1, 0, 0, 1, 0,
)) ))