API cleanup: Rename create_window to create_window_adapter

This commit is contained in:
Tobias Hunger 2022-08-29 15:41:45 +02:00 committed by Tobias Hunger
parent 1e6ffeaa0f
commit 88cf874d03
11 changed files with 15 additions and 15 deletions

View file

@ -22,7 +22,7 @@ pub unsafe extern "C" fn slint_windowrc_init(out: *mut WindowAdapterRcOpaque) {
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());
let win = i_slint_backend_selector::with_platform_abstraction(|b| b.create_window_adapter());
core::ptr::write(out as *mut Rc<dyn WindowAdapter>, win);
}

View file

@ -435,8 +435,8 @@ pub mod internal {
/// Creates a new window to render components in.
#[doc(hidden)]
pub fn create_window() -> alloc::rc::Rc<dyn re_exports::WindowAdapter> {
i_slint_backend_selector::with_platform_abstraction(|b| b.create_window())
pub fn create_window_adapter() -> alloc::rc::Rc<dyn re_exports::WindowAdapter> {
i_slint_backend_selector::with_platform_abstraction(|b| b.create_window_adapter())
}
/// Enters the main event loop. This is necessary in order to receive

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::WindowAdapter> {
fn create_window_adapter(&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()),

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::WindowAdapter> {
fn create_window_adapter(&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()),

View file

@ -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::WindowAdapter> {
fn create_window_adapter(&self) -> Rc<dyn i_slint_core::window::WindowAdapter> {
#[cfg(no_qt)]
panic!("The Qt backend needs Qt");
#[cfg(not(no_qt))]

View file

@ -19,7 +19,7 @@ pub struct TestingBackend {
}
impl i_slint_core::platform::Platform for TestingBackend {
fn create_window(&self) -> Rc<dyn WindowAdapter> {
fn create_window_adapter(&self) -> Rc<dyn WindowAdapter> {
Rc::new_cyclic(|self_weak| TestingWindow {
window: i_slint_core::api::Window::new(self_weak.clone() as _),
})

View file

@ -143,7 +143,7 @@ impl Backend {
}
impl i_slint_core::platform::Platform for Backend {
fn create_window(&self) -> Rc<dyn WindowAdapter> {
fn create_window_adapter(&self) -> Rc<dyn WindowAdapter> {
self.window_factory_fn.lock().unwrap()()
}

View file

@ -1103,9 +1103,9 @@ fn generate_item_tree(
} else {
quote!(&self_rc)
};
let (create_window, init_window) = if parent_ctx.is_none() {
let (create_window_adapter, init_window) = if parent_ctx.is_none() {
(
Some(quote!(let window_adapter = slint::create_window();)),
Some(quote!(let window_adapter = slint::create_window_adapter();)),
Some(quote! {
_self.window_adapter.set(window_adapter);
_self.window_adapter.get().unwrap().window().window_handle().set_component(&VRc::into_dyn(self_rc.clone()));
@ -1189,7 +1189,7 @@ fn generate_item_tree(
{
#![allow(unused)]
use slint::re_exports::*;
#create_window // We must create the window first to initialize the backend before using the style
#create_window_adapter // We must create the window first to initialize the backend before using the style
let mut _self = Self::default();
#(_self.parent = parent.clone() as #parent_component_type;)*
let self_rc = VRc::new(_self);

View file

@ -122,7 +122,7 @@ impl Window {
///
/// You only need to create the window yourself when you create a
/// [`WindowAdapter`](crate::platform::WindowAdapter) from
/// [`Platform::create_window`](crate::platform::Platform::create_window)
/// [`Platform::create_window_adapter`](crate::platform::Platform::create_window_adapter)
///
/// Since the window adapter must own the Window, this function is meant to be used with
/// [`Rc::new_cyclic`](alloc::rc::Rc::new_cyclic)
@ -142,7 +142,7 @@ impl Window {
/// # fn as_any(&self) -> &(dyn core::any::Any + 'static) { self }
/// //...
/// }
/// fn create_window() -> Rc<dyn WindowAdapter> {
/// fn create_window_adapter() -> Rc<dyn WindowAdapter> {
/// Rc::<MyWindowAdapter>::new_cyclic(|weak| {
/// MyWindowAdapter {
/// window: Window::new(weak.clone()),

View file

@ -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 WindowAdapter>;
fn create_window_adapter(&self) -> Rc<dyn WindowAdapter>;
/// Spins an event loop and renders the visible windows.
fn run_event_loop(&self, _behavior: EventLoopQuitBehavior) {

View file

@ -391,7 +391,7 @@ impl<'id> ComponentDescription<'id> {
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
let window_adapter = i_slint_backend_selector::with_platform_abstraction(|_b| {
#[cfg(not(target_arch = "wasm32"))]
return _b.create_window();
return _b.create_window_adapter();
#[cfg(target_arch = "wasm32")]
i_slint_backend_winit::create_gl_window_with_canvas_id(canvas_id)
});