mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Replace the internal WindowHandleAccess
trait with a helper function on WindowInner
The reversal of ownership removes the need for the glue trait in the publicly visible API.
This commit is contained in:
parent
ea94089b05
commit
7967bf1ab0
25 changed files with 124 additions and 143 deletions
|
@ -4,7 +4,7 @@
|
|||
use core::cell::RefCell;
|
||||
use i_slint_compiler::langtype::Type;
|
||||
use i_slint_core::model::{Model, ModelRc};
|
||||
use i_slint_core::window::WindowHandleAccess;
|
||||
use i_slint_core::window::WindowInner;
|
||||
use i_slint_core::{ImageInner, SharedVector};
|
||||
use neon::prelude::*;
|
||||
use rand::RngCore;
|
||||
|
@ -352,7 +352,7 @@ declare_types! {
|
|||
let this = cx.this();
|
||||
let component = cx.borrow(&this, |x| x.0.as_ref().map(|c| c.clone_strong()));
|
||||
let component = component.ok_or(()).or_else(|()| cx.throw_error("Invalid type"))?;
|
||||
let window_adapter = component.window().window_handle().window_adapter();
|
||||
let window_adapter = WindowInner::from_pub(component.window()).window_adapter();
|
||||
let mut obj = SlintWindow::new::<_, JsValue, _>(&mut cx, std::iter::empty())?;
|
||||
cx.borrow_mut(&mut obj, |mut obj| obj.0 = Some(window_adapter));
|
||||
Ok(obj.as_value(&mut cx))
|
||||
|
|
|
@ -269,14 +269,13 @@ pub mod testing {
|
|||
thread_local!(static KEYBOARD_MODIFIERS : Cell<i_slint_core::input::KeyboardModifiers> = Default::default());
|
||||
|
||||
use super::ComponentHandle;
|
||||
use i_slint_core::window::WindowInner;
|
||||
|
||||
pub use i_slint_core::tests::slint_mock_elapsed_time as mock_elapsed_time;
|
||||
|
||||
/// Simulate a mouse click
|
||||
pub fn send_mouse_click<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||
+ i_slint_core::window::WindowHandleAccess
|
||||
+ 'static,
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable> + 'static,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
|
@ -289,14 +288,13 @@ pub mod testing {
|
|||
&dyn_rc,
|
||||
x,
|
||||
y,
|
||||
&rc.window_handle().window_adapter(),
|
||||
&WindowInner::from_pub(component.window()).window_adapter(),
|
||||
);
|
||||
}
|
||||
|
||||
/// Simulate a change in keyboard modifiers being pressed
|
||||
pub fn set_current_keyboard_modifiers<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||
+ i_slint_core::window::WindowHandleAccess,
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
_component: &Component,
|
||||
|
@ -307,33 +305,29 @@ pub mod testing {
|
|||
|
||||
/// Simulate entering a sequence of ascii characters key by key.
|
||||
pub fn send_keyboard_string_sequence<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||
+ i_slint_core::window::WindowHandleAccess,
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
sequence: &str,
|
||||
) {
|
||||
let component = component.clone_strong().into();
|
||||
i_slint_core::tests::send_keyboard_string_sequence(
|
||||
&super::SharedString::from(sequence),
|
||||
KEYBOARD_MODIFIERS.with(|x| x.get()),
|
||||
&component.window_handle().window_adapter(),
|
||||
&WindowInner::from_pub(component.window()).window_adapter(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Applies the specified scale factor to the window that's associated with the given component.
|
||||
/// This overrides the value provided by the windowing system.
|
||||
pub fn set_window_scale_factor<
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>
|
||||
+ i_slint_core::window::WindowHandleAccess,
|
||||
X: vtable::HasStaticVTable<i_slint_core::component::ComponentVTable>,
|
||||
Component: Into<vtable::VRc<i_slint_core::component::ComponentVTable, X>> + ComponentHandle,
|
||||
>(
|
||||
component: &Component,
|
||||
factor: f32,
|
||||
) {
|
||||
let component = component.clone_strong().into();
|
||||
component.window_handle().set_scale_factor(factor)
|
||||
WindowInner::from_pub(component.window()).set_scale_factor(factor)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ pub mod re_exports {
|
|||
pub use i_slint_core::model::*;
|
||||
pub use i_slint_core::properties::{set_state_binding, Property, PropertyTracker, StateInfo};
|
||||
pub use i_slint_core::slice::Slice;
|
||||
pub use i_slint_core::window::{WindowAdapter, WindowHandleAccess, WindowInner};
|
||||
pub use i_slint_core::window::{WindowAdapter, WindowInner};
|
||||
pub use i_slint_core::Color;
|
||||
pub use i_slint_core::ComponentVTable_static;
|
||||
pub use i_slint_core::Coord;
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::accessible_generated::*;
|
|||
use i_slint_core::accessibility::AccessibleStringProperty;
|
||||
use i_slint_core::item_tree::{ItemRc, ItemWeak};
|
||||
use i_slint_core::properties::{PropertyDirtyHandler, PropertyTracker};
|
||||
use i_slint_core::window::WindowHandleAccess;
|
||||
use i_slint_core::window::WindowInner;
|
||||
use i_slint_core::SharedVector;
|
||||
|
||||
use cpp::*;
|
||||
|
@ -330,7 +330,7 @@ cpp! {{
|
|||
void *root_item_for_window(void *rustWindow) {
|
||||
return rust!(root_item_for_window_ [rustWindow: &crate::qt_window::QtWindow as "void*"]
|
||||
-> *mut c_void as "void*" {
|
||||
let root_item = Box::new(ItemRc::new(rustWindow.window.window_handle().component(), 0).downgrade());
|
||||
let root_item = Box::new(ItemRc::new(WindowInner::from_pub(&rustWindow.window).component(), 0).downgrade());
|
||||
Box::into_raw(root_item) as _
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ use i_slint_core::items::{Item, ItemConsts, ItemRc, ItemVTable, RenderingResult,
|
|||
use i_slint_core::layout::{LayoutInfo, Orientation};
|
||||
#[cfg(feature = "rtti")]
|
||||
use i_slint_core::rtti::*;
|
||||
use i_slint_core::window::{WindowAdapter, WindowAdapterRc, WindowHandleAccess};
|
||||
use i_slint_core::window::{WindowAdapter, WindowAdapterRc, WindowInner};
|
||||
use i_slint_core::{
|
||||
declare_item_vtable, Callback, ItemVTable_static, Property, SharedString, SharedVector,
|
||||
};
|
||||
|
@ -59,7 +59,7 @@ macro_rules! fn_render {
|
|||
let $dpr: f32 = backend.scale_factor();
|
||||
|
||||
let window = backend.window();
|
||||
let active: bool = window.window_handle().active();
|
||||
let active: bool = WindowInner::from_pub(window).active();
|
||||
// This should include self.enabled() as well, but not every native widget
|
||||
// has that property right now.
|
||||
let $initial_state = cpp!(unsafe [ active as "bool" ] -> i32 as "int" {
|
||||
|
|
|
@ -188,7 +188,7 @@ impl Item for NativeSpinBox {
|
|||
|
||||
if let MouseEvent::Pressed { .. } = event {
|
||||
if !self.has_focus() {
|
||||
window_adapter.window().window_handle().set_focus_item(self_rc);
|
||||
WindowInner::from_pub(window_adapter.window()).set_focus_item(self_rc);
|
||||
}
|
||||
}
|
||||
InputEventResult::EventAccepted
|
||||
|
|
|
@ -429,7 +429,7 @@ impl Item for NativeTab {
|
|||
if matches!(event, MouseEvent::Released { .. } if !click_on_press)
|
||||
|| matches!(event, MouseEvent::Pressed { .. } if click_on_press)
|
||||
{
|
||||
window_adapter.window().window_handle().set_focus_item(self_rc);
|
||||
WindowInner::from_pub(window_adapter.window()).set_focus_item(self_rc);
|
||||
self.current.set(self.tab_index());
|
||||
InputEventResult::EventAccepted
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@ use i_slint_core::items::{
|
|||
PointerEventButton, RenderingResult, TextOverflow, TextWrap,
|
||||
};
|
||||
use i_slint_core::layout::Orientation;
|
||||
use i_slint_core::window::{WindowAdapter, WindowAdapterSealed, WindowHandleAccess};
|
||||
use i_slint_core::window::{WindowAdapter, WindowAdapterSealed, WindowInner};
|
||||
use i_slint_core::{ImageInner, PathData, Property, SharedString};
|
||||
use items::{ImageFit, TextHorizontalAlignment, TextVerticalAlignment};
|
||||
|
||||
|
@ -187,7 +187,7 @@ cpp! {{
|
|||
void customEvent(QEvent *event) override {
|
||||
if (event->type() == QEvent::User) {
|
||||
rust!(Slint_updateWindowProps [rust_window: &QtWindow as "void*"] {
|
||||
rust_window.window.window_handle().update_window_properties()
|
||||
WindowInner::from_pub(&rust_window.window).update_window_properties()
|
||||
});
|
||||
} else {
|
||||
QWidget::customEvent(event);
|
||||
|
@ -198,7 +198,7 @@ cpp! {{
|
|||
if (event->type() == QEvent::ActivationChange) {
|
||||
bool active = isActiveWindow();
|
||||
rust!(Slint_updateWindowActivation [rust_window: &QtWindow as "void*", active: bool as "bool"] {
|
||||
rust_window.window.window_handle().set_active(active)
|
||||
WindowInner::from_pub(&rust_window.window).set_active(active)
|
||||
});
|
||||
}
|
||||
QWidget::changeEvent(event);
|
||||
|
@ -206,7 +206,7 @@ cpp! {{
|
|||
|
||||
void closeEvent(QCloseEvent *event) override {
|
||||
bool accepted = rust!(Slint_requestClose [rust_window: &QtWindow as "void*"] -> bool as "bool" {
|
||||
return rust_window.window.window_handle().request_close();
|
||||
return WindowInner::from_pub(&rust_window.window).request_close();
|
||||
});
|
||||
if (accepted) {
|
||||
event->accept();
|
||||
|
@ -217,7 +217,7 @@ cpp! {{
|
|||
|
||||
QSize sizeHint() const override {
|
||||
auto preferred_size = rust!(Slint_sizeHint [rust_window: &QtWindow as "void*"] -> qttypes::QSize as "QSize" {
|
||||
let component_rc = rust_window.window.window_handle().component();
|
||||
let component_rc = WindowInner::from_pub(&rust_window.window).component();
|
||||
let component = ComponentRc::borrow_pin(&component_rc);
|
||||
let layout_info_h = component.as_ref().layout_info(Orientation::Horizontal);
|
||||
let layout_info_v = component.as_ref().layout_info(Orientation::Vertical);
|
||||
|
@ -511,7 +511,7 @@ impl ItemRenderer for QtItemRenderer<'_> {
|
|||
let rect: qttypes::QRectF = get_geometry!(items::Text, text);
|
||||
let fill_brush: qttypes::QBrush = into_qbrush(text.color(), rect.width, rect.height);
|
||||
let mut string: qttypes::QString = text.text().as_str().into();
|
||||
let font: QFont = get_font(text.font_request(self.window.window_handle()));
|
||||
let font: QFont = get_font(text.font_request(WindowInner::from_pub(&self.window)));
|
||||
let flags = match text.horizontal_alignment() {
|
||||
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
|
||||
TextHorizontalAlignment::Center => key_generated::Qt_AlignmentFlag_AlignHCenter,
|
||||
|
@ -602,8 +602,9 @@ impl ItemRenderer for QtItemRenderer<'_> {
|
|||
}}
|
||||
}
|
||||
|
||||
let font: QFont =
|
||||
get_font(text_input.font_request(&self.window.window_handle().window_adapter()));
|
||||
let font: QFont = get_font(
|
||||
text_input.font_request(&WindowInner::from_pub(&self.window).window_adapter()),
|
||||
);
|
||||
let flags = match text_input.horizontal_alignment() {
|
||||
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
|
||||
TextHorizontalAlignment::Center => key_generated::Qt_AlignmentFlag_AlignHCenter,
|
||||
|
@ -1246,7 +1247,7 @@ impl QtWindow {
|
|||
}
|
||||
|
||||
fn paint_event(&self, painter: QPainterPtr) {
|
||||
let runtime_window = self.window.window_handle();
|
||||
let runtime_window = WindowInner::from_pub(&self.window);
|
||||
runtime_window.draw_contents(|components| {
|
||||
i_slint_core::animations::update_animations();
|
||||
let mut renderer = QtItemRenderer {
|
||||
|
@ -1299,7 +1300,7 @@ impl QtWindow {
|
|||
}
|
||||
|
||||
fn mouse_event(&self, event: MouseEvent) {
|
||||
self.window.window_handle().process_mouse_input(event);
|
||||
WindowInner::from_pub(&self.window).process_mouse_input(event);
|
||||
timer_event();
|
||||
}
|
||||
|
||||
|
@ -1320,13 +1321,13 @@ impl QtWindow {
|
|||
text,
|
||||
modifiers,
|
||||
};
|
||||
self.window.window_handle().process_key_input(&event);
|
||||
WindowInner::from_pub(&self.window).process_key_input(&event);
|
||||
|
||||
timer_event();
|
||||
}
|
||||
|
||||
fn close_popup(&self) {
|
||||
self.window.window_handle().close_popup();
|
||||
WindowInner::from_pub(&self.window).close_popup();
|
||||
}
|
||||
|
||||
fn free_graphics_resources(&self, component: ComponentRef) {
|
||||
|
@ -1343,7 +1344,7 @@ impl WindowAdapter for QtWindow {
|
|||
|
||||
impl WindowAdapterSealed for QtWindow {
|
||||
fn show(&self) {
|
||||
let component_rc = self.window.window_handle().component();
|
||||
let component_rc = WindowInner::from_pub(&self.window).component();
|
||||
let component = ComponentRc::borrow_pin(&component_rc);
|
||||
let root_item = component.as_ref().get_item_ref(0);
|
||||
if let Some(window_item) = ItemRef::downcast_pin(root_item) {
|
||||
|
@ -1605,8 +1606,9 @@ impl Renderer for QtWindow {
|
|||
}
|
||||
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
|
||||
let pos = qttypes::QPointF { x: pos.x as _, y: pos.y as _ };
|
||||
let font: QFont =
|
||||
get_font(text_input.font_request(&self.window.window_handle().window_adapter()));
|
||||
let font: QFont = get_font(
|
||||
text_input.font_request(&WindowInner::from_pub(&self.window).window_adapter()),
|
||||
);
|
||||
let string = qttypes::QString::from(text_input.text().as_str());
|
||||
let flags = match text_input.horizontal_alignment() {
|
||||
TextHorizontalAlignment::Left => key_generated::Qt_AlignmentFlag_AlignLeft,
|
||||
|
@ -1661,8 +1663,9 @@ impl Renderer for QtWindow {
|
|||
byte_offset: usize,
|
||||
) -> Rect {
|
||||
let rect: qttypes::QRectF = get_geometry!(items::TextInput, text_input);
|
||||
let font: QFont =
|
||||
get_font(text_input.font_request(&self.window.window_handle().window_adapter()));
|
||||
let font: QFont = get_font(
|
||||
text_input.font_request(&WindowInner::from_pub(&self.window).window_adapter()),
|
||||
);
|
||||
let text = text_input.text();
|
||||
let mut string = qttypes::QString::from(text.as_str());
|
||||
let offset: u32 = utf8_byte_offset_to_utf16_units(text.as_str(), byte_offset) as _;
|
||||
|
|
|
@ -385,7 +385,7 @@ fn process_window_event(
|
|||
event
|
||||
}
|
||||
|
||||
let runtime_window = window.window().window_handle();
|
||||
let runtime_window = WindowInner::from_pub(window.window());
|
||||
match event {
|
||||
WindowEvent::Resized(size) => {
|
||||
window.resize_event(size);
|
||||
|
@ -637,7 +637,7 @@ pub fn run() {
|
|||
.drain(..)
|
||||
.flat_map(|window_id| window_by_id(window_id))
|
||||
{
|
||||
window.window().window_handle().update_window_properties();
|
||||
WindowInner::from_pub(window.window()).update_window_properties();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ use corelib::component::ComponentRc;
|
|||
use corelib::input::KeyboardModifiers;
|
||||
use corelib::items::{ItemRef, MouseCursor};
|
||||
use corelib::layout::Orientation;
|
||||
use corelib::window::{WindowAdapter, WindowAdapterSealed, WindowHandleAccess};
|
||||
use corelib::window::{WindowAdapter, WindowAdapterSealed, WindowInner};
|
||||
use corelib::Property;
|
||||
use corelib::{graphics::*, Coord};
|
||||
use i_slint_core as corelib;
|
||||
|
@ -106,7 +106,7 @@ impl<Renderer: WinitCompatibleRenderer + 'static> GLWindow<Renderer> {
|
|||
GraphicsWindowBackendState::Mapped(_) => return,
|
||||
};
|
||||
|
||||
let runtime_window = self.window().window_handle();
|
||||
let runtime_window = WindowInner::from_pub(self.window());
|
||||
let component_rc = runtime_window.component();
|
||||
let component = ComponentRc::borrow_pin(&component_rc);
|
||||
|
||||
|
@ -196,7 +196,7 @@ impl<Renderer: WinitCompatibleRenderer + 'static> GLWindow<Renderer> {
|
|||
let canvas = self.renderer.create_canvas(window_builder);
|
||||
|
||||
let id = canvas.with_window_handle(|winit_window| {
|
||||
self.window.window_handle().set_scale_factor(
|
||||
WindowInner::from_pub(&self.window).set_scale_factor(
|
||||
scale_factor_override.unwrap_or_else(|| winit_window.scale_factor()) as _,
|
||||
);
|
||||
// On wasm, with_inner_size on the WindowBuilder don't have effect, so apply manually
|
||||
|
|
|
@ -12,7 +12,7 @@ use i_slint_core::graphics::{
|
|||
euclid, rendering_metrics_collector::RenderingMetricsCollector, Point, Rect, Size,
|
||||
};
|
||||
use i_slint_core::renderer::Renderer;
|
||||
use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
|
||||
use i_slint_core::window::{WindowAdapter, WindowInner};
|
||||
use i_slint_core::Coord;
|
||||
|
||||
use crate::WindowSystemName;
|
||||
|
@ -135,7 +135,7 @@ impl super::WinitCompatibleRenderer for FemtoVGRenderer {
|
|||
|
||||
canvas.opengl_context.make_current();
|
||||
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window = WindowInner::from_pub(window_adapter.window());
|
||||
|
||||
window.draw_contents(|components| {
|
||||
{
|
||||
|
@ -228,7 +228,7 @@ impl Renderer for FemtoVGRenderer {
|
|||
None => return 0,
|
||||
};
|
||||
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window = WindowInner::from_pub(window_adapter.window());
|
||||
|
||||
let scale_factor = window.scale_factor();
|
||||
let pos = pos * scale_factor;
|
||||
|
@ -307,7 +307,7 @@ impl Renderer for FemtoVGRenderer {
|
|||
None => return Default::default(),
|
||||
};
|
||||
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window = WindowInner::from_pub(window_adapter.window());
|
||||
|
||||
let text = text_input.text();
|
||||
let scale_factor = window.scale_factor();
|
||||
|
|
|
@ -14,7 +14,7 @@ use i_slint_core::items::{
|
|||
self, Clip, FillRule, ImageFit, ImageRendering, InputType, Item, ItemRc, Layer, Opacity,
|
||||
RenderingResult,
|
||||
};
|
||||
use i_slint_core::window::WindowHandleAccess;
|
||||
use i_slint_core::window::WindowInner;
|
||||
use i_slint_core::{Brush, Color, ImageInner, Property, SharedString};
|
||||
|
||||
use super::fonts;
|
||||
|
@ -245,7 +245,7 @@ impl<'a> ItemRenderer for GLItemRenderer<'a> {
|
|||
let string = string.as_str();
|
||||
let font = fonts::FONT_CACHE.with(|cache| {
|
||||
cache.borrow_mut().font(
|
||||
text.font_request(self.window.window_handle()),
|
||||
text.font_request(WindowInner::from_pub(&self.window)),
|
||||
self.scale_factor,
|
||||
&text.text(),
|
||||
)
|
||||
|
@ -283,7 +283,7 @@ impl<'a> ItemRenderer for GLItemRenderer<'a> {
|
|||
|
||||
let font = fonts::FONT_CACHE.with(|cache| {
|
||||
cache.borrow_mut().font(
|
||||
text_input.font_request(&self.window.window_handle().window_adapter()),
|
||||
text_input.font_request(&WindowInner::from_pub(&self.window).window_adapter()),
|
||||
self.scale_factor,
|
||||
&text_input.text(),
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ use i_slint_core::api::{
|
|||
};
|
||||
use i_slint_core::graphics::rendering_metrics_collector::RenderingMetricsCollector;
|
||||
use i_slint_core::item_rendering::ItemCache;
|
||||
use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
|
||||
use i_slint_core::window::{WindowAdapter, WindowInner};
|
||||
|
||||
use crate::WindowSystemName;
|
||||
|
||||
|
@ -80,11 +80,11 @@ impl super::WinitCompatibleRenderer for SkiaRenderer {
|
|||
}
|
||||
|
||||
fn render(&self, canvas: &Self::Canvas, window_adapter: &dyn WindowAdapter) {
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window_inner = WindowInner::from_pub(window_adapter.window());
|
||||
|
||||
canvas.surface.render(|skia_canvas, gr_context| {
|
||||
window.draw_contents(|components| {
|
||||
if let Some(window_item) = window.window_item() {
|
||||
window_inner.draw_contents(|components| {
|
||||
if let Some(window_item) = window_inner.window_item() {
|
||||
skia_canvas
|
||||
.clear(itemrenderer::to_skia_color(&window_item.as_pin_ref().background()));
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::pin::Pin;
|
|||
use i_slint_core::graphics::euclid;
|
||||
use i_slint_core::item_rendering::{ItemCache, ItemRenderer};
|
||||
use i_slint_core::items::{ImageFit, ImageRendering, ItemRc, Layer, Opacity, RenderingResult};
|
||||
use i_slint_core::window::WindowHandleAccess;
|
||||
use i_slint_core::window::WindowInner;
|
||||
use i_slint_core::{items, Brush, Color, Property};
|
||||
|
||||
use super::super::boxshadowcache::BoxShadowCache;
|
||||
|
@ -359,7 +359,7 @@ impl<'a> ItemRenderer for SkiaRenderer<'a> {
|
|||
|
||||
let string = text.text();
|
||||
let string = string.as_str();
|
||||
let font_request = text.font_request(self.window.window_handle());
|
||||
let font_request = text.font_request(WindowInner::from_pub(&self.window));
|
||||
|
||||
let paint = match self.brush_to_paint(text.color(), max_width, max_height) {
|
||||
Some(paint) => paint,
|
||||
|
|
|
@ -21,7 +21,7 @@ use std::cell::RefCell;
|
|||
use std::rc::{Rc, Weak};
|
||||
|
||||
use i_slint_core::input::{KeyEvent, KeyEventType, KeyboardModifiers};
|
||||
use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
|
||||
use i_slint_core::window::{WindowAdapter, WindowInner};
|
||||
use i_slint_core::SharedString;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
use wasm_bindgen::convert::FromWasmAbi;
|
||||
|
@ -96,10 +96,10 @@ impl WasmInputHelper {
|
|||
h.add_event_listener("blur", move |_: web_sys::Event| {
|
||||
// Make sure that the window gets marked as unfocused when the focus leaves the input
|
||||
if let Some(window_adapter) = win.upgrade() {
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window_inner = WindowInner::from_pub(window_adapter.window());
|
||||
if !canvas.matches(":focus").unwrap_or(false) {
|
||||
window.set_active(false);
|
||||
window.set_focus(false);
|
||||
window_inner.set_active(false);
|
||||
window_inner.set_focus(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -109,7 +109,7 @@ impl WasmInputHelper {
|
|||
if let (Some(window_adapter), Some(text)) = (win.upgrade(), event_text(&e)) {
|
||||
e.prevent_default();
|
||||
shared_state2.borrow_mut().has_key_down = true;
|
||||
window_adapter.window().window_handle().process_key_input(&KeyEvent {
|
||||
WindowInner::from_pub(window_adapter.window()).process_key_input(&KeyEvent {
|
||||
modifiers: modifiers(&e),
|
||||
text,
|
||||
event_type: KeyEventType::KeyPressed,
|
||||
|
@ -123,7 +123,7 @@ impl WasmInputHelper {
|
|||
if let (Some(window_adapter), Some(text)) = (win.upgrade(), event_text(&e)) {
|
||||
e.prevent_default();
|
||||
shared_state2.borrow_mut().has_key_down = false;
|
||||
window_adapter.window().window_handle().process_key_input(&KeyEvent {
|
||||
WindowInner::from_pub(window_adapter.window()).process_key_input(&KeyEvent {
|
||||
modifiers: modifiers(&e),
|
||||
text,
|
||||
event_type: KeyEventType::KeyReleased,
|
||||
|
@ -138,14 +138,14 @@ impl WasmInputHelper {
|
|||
if let (Some(window_adapter), Some(data)) = (win.upgrade(), e.data()) {
|
||||
if !e.is_composing() && e.input_type() != "insertCompositionText" {
|
||||
if !shared_state2.borrow_mut().has_key_down {
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window_inner = WindowInner::from_pub(window_adapter.window());
|
||||
let text = SharedString::from(data.as_str());
|
||||
window.process_key_input(&KeyEvent {
|
||||
window_inner.process_key_input(&KeyEvent {
|
||||
modifiers: Default::default(),
|
||||
text: text.clone(),
|
||||
event_type: KeyEventType::KeyPressed,
|
||||
});
|
||||
window.process_key_input(&KeyEvent {
|
||||
window_inner.process_key_input(&KeyEvent {
|
||||
modifiers: Default::default(),
|
||||
text,
|
||||
event_type: KeyEventType::KeyReleased,
|
||||
|
@ -163,7 +163,7 @@ impl WasmInputHelper {
|
|||
let input = h.input.clone();
|
||||
h.add_event_listener(event, move |e: web_sys::CompositionEvent| {
|
||||
if let (Some(window_adapter), Some(data)) = (win.upgrade(), e.data()) {
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window_inner = WindowInner::from_pub(window_adapter.window());
|
||||
let is_end = event == "compositionend";
|
||||
let (text, to_delete) =
|
||||
shared_state2.borrow_mut().text_from_compose(data, is_end);
|
||||
|
@ -174,19 +174,19 @@ impl WasmInputHelper {
|
|||
as &str,
|
||||
);
|
||||
for _ in 0..to_delete {
|
||||
window.process_key_input(&KeyEvent {
|
||||
window_inner.process_key_input(&KeyEvent {
|
||||
modifiers: Default::default(),
|
||||
text: backspace.clone(),
|
||||
event_type: KeyEventType::KeyPressed,
|
||||
});
|
||||
}
|
||||
}
|
||||
window.process_key_input(&KeyEvent {
|
||||
window_inner.process_key_input(&KeyEvent {
|
||||
modifiers: Default::default(),
|
||||
text: text.clone(),
|
||||
event_type: KeyEventType::KeyPressed,
|
||||
});
|
||||
window.process_key_input(&KeyEvent {
|
||||
window_inner.process_key_input(&KeyEvent {
|
||||
modifiers: Default::default(),
|
||||
text,
|
||||
event_type: KeyEventType::KeyReleased,
|
||||
|
|
|
@ -1118,7 +1118,7 @@ fn generate_item_tree(
|
|||
),
|
||||
Some(quote! {
|
||||
_self.window_adapter.set(window_adapter);
|
||||
_self.window_adapter.get().unwrap().window().window_handle().set_component(&VRc::into_dyn(self_rc.clone()));
|
||||
slint::private_unstable_api::re_exports::WindowInner::from_pub(_self.window_adapter.get().unwrap().window()).set_component(&VRc::into_dyn(self_rc.clone()));
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
|
@ -1234,12 +1234,6 @@ fn generate_item_tree(
|
|||
}
|
||||
}
|
||||
|
||||
impl slint::private_unstable_api::re_exports::WindowHandleAccess for #inner_component_id {
|
||||
fn window_handle(&self) -> &slint::private_unstable_api::re_exports::WindowInner {
|
||||
self.window_adapter.get().unwrap().window().window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
impl slint::private_unstable_api::re_exports::Component for #inner_component_id {
|
||||
fn visit_children_item(self: ::core::pin::Pin<&Self>, index: isize, order: slint::private_unstable_api::re_exports::TraversalOrder, visitor: slint::private_unstable_api::re_exports::ItemVisitorRefMut)
|
||||
-> slint::private_unstable_api::re_exports::VisitChildrenResult
|
||||
|
@ -2000,7 +1994,7 @@ fn compile_builtin_function_call(
|
|||
let window_tokens = access_window_adapter_field(ctx);
|
||||
let focus_item = access_item_rc(pr, ctx);
|
||||
quote!(
|
||||
#window_tokens.window().window_handle().set_focus_item(#focus_item);
|
||||
slint::private_unstable_api::re_exports::WindowInner::from_pub(#window_tokens.window()).set_focus_item(#focus_item);
|
||||
)
|
||||
} else {
|
||||
panic!("internal error: invalid args to SetFocusItem {:?}", arguments)
|
||||
|
@ -2028,7 +2022,7 @@ fn compile_builtin_function_call(
|
|||
let y = compile_expression(y, ctx);
|
||||
let window_adapter_tokens = access_window_adapter_field(ctx);
|
||||
quote!(
|
||||
#window_adapter_tokens.window().window_handle().show_popup(
|
||||
slint::private_unstable_api::re_exports::WindowInner::from_pub(#window_adapter_tokens.window()).show_popup(
|
||||
&VRc::into_dyn(#popup_window_id::new(#component_access_tokens.self_weak.get().unwrap().clone()).into()),
|
||||
Point::new(#x as slint::private_unstable_api::re_exports::Coord, #y as slint::private_unstable_api::re_exports::Coord),
|
||||
#parent_component
|
||||
|
@ -2079,7 +2073,7 @@ fn compile_builtin_function_call(
|
|||
}
|
||||
BuiltinFunction::GetWindowScaleFactor => {
|
||||
let window_adapter_tokens = access_window_adapter_field(ctx);
|
||||
quote!(#window_adapter_tokens.window().window_handle().scale_factor())
|
||||
quote!(slint::private_unstable_api::re_exports::WindowInner::from_pub(#window_adapter_tokens.window()).scale_factor())
|
||||
}
|
||||
BuiltinFunction::AnimationTick => {
|
||||
quote!(slint::private_unstable_api::re_exports::animation_tick())
|
||||
|
|
|
@ -239,7 +239,7 @@ pub enum SetRenderingNotifierError {
|
|||
/// scene of a component. It provides API to control windowing system specific aspects such
|
||||
/// as the position on the screen.
|
||||
#[repr(transparent)]
|
||||
pub struct Window(WindowInner);
|
||||
pub struct Window(pub(crate) WindowInner);
|
||||
|
||||
/// This enum describes whether a Window is allowed to be hidden when the user tries to close the window.
|
||||
/// It is the return type of the callback provided to [Window::on_close_requested].
|
||||
|
@ -389,12 +389,6 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
impl crate::window::WindowHandleAccess for Window {
|
||||
fn window_handle(&self) -> &crate::window::WindowInner {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
pub use crate::input::PointerEventButton;
|
||||
|
||||
/// An event sent to a window
|
||||
|
|
|
@ -30,7 +30,7 @@ pub use crate::item_tree::ItemRc;
|
|||
use crate::layout::{LayoutInfo, Orientation};
|
||||
#[cfg(feature = "rtti")]
|
||||
use crate::rtti::*;
|
||||
use crate::window::{WindowAdapter, WindowAdapterRc, WindowHandleAccess};
|
||||
use crate::window::{WindowAdapter, WindowAdapterRc, WindowInner};
|
||||
use crate::{Callback, Coord, Property, SharedString};
|
||||
use alloc::rc::Rc;
|
||||
use const_field_offset::FieldOffsets;
|
||||
|
@ -564,7 +564,7 @@ impl Item for FocusScope {
|
|||
self_rc: &ItemRc,
|
||||
) -> InputEventResult {
|
||||
if self.enabled() && matches!(event, MouseEvent::Pressed { .. }) && !self.has_focus() {
|
||||
window_adapter.window().window_handle().set_focus_item(self_rc);
|
||||
WindowInner::from_pub(window_adapter.window()).set_focus_item(self_rc);
|
||||
}
|
||||
InputEventResult::EventIgnored
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use crate::item_rendering::{CachedRenderingData, ItemRenderer};
|
|||
use crate::layout::{LayoutInfo, Orientation};
|
||||
#[cfg(feature = "rtti")]
|
||||
use crate::rtti::*;
|
||||
use crate::window::{WindowAdapter, WindowHandleAccess, WindowInner};
|
||||
use crate::window::{WindowAdapter, WindowInner};
|
||||
use crate::{Callback, Coord, Property, SharedString};
|
||||
use alloc::rc::Rc;
|
||||
use alloc::string::String;
|
||||
|
@ -67,10 +67,10 @@ impl Item for Text {
|
|||
orientation: Orientation,
|
||||
window_adapter: &Rc<dyn WindowAdapter>,
|
||||
) -> LayoutInfo {
|
||||
let window = window_adapter.window().window_handle();
|
||||
let window_inner = WindowInner::from_pub(window_adapter.window());
|
||||
let implicit_size = |max_width| {
|
||||
window_adapter.renderer().text_size(
|
||||
self.font_request(window),
|
||||
self.font_request(window_inner),
|
||||
self.text().as_str(),
|
||||
max_width,
|
||||
window_adapter.window().scale_factor(),
|
||||
|
@ -87,7 +87,12 @@ impl Item for Text {
|
|||
TextOverflow::Elide => implicit_size.width.min(
|
||||
window_adapter
|
||||
.renderer()
|
||||
.text_size(self.font_request(window), "…", None, window.scale_factor())
|
||||
.text_size(
|
||||
self.font_request(window_inner),
|
||||
"…",
|
||||
None,
|
||||
window_inner.scale_factor(),
|
||||
)
|
||||
.width,
|
||||
),
|
||||
TextOverflow::Clip => match self.wrap() {
|
||||
|
@ -317,7 +322,7 @@ impl Item for TextInput {
|
|||
self.as_ref().anchor_position.set(clicked_offset);
|
||||
self.set_cursor_position(clicked_offset, true, window_adapter);
|
||||
if !self.has_focus() {
|
||||
window_adapter.window().window_handle().set_focus_item(self_rc);
|
||||
WindowInner::from_pub(window_adapter.window()).set_focus_item(self_rc);
|
||||
}
|
||||
}
|
||||
MouseEvent::Released { button: PointerEventButton::Left, .. } | MouseEvent::Exit => {
|
||||
|
@ -558,7 +563,8 @@ impl From<KeyboardModifiers> for AnchorMode {
|
|||
|
||||
impl TextInput {
|
||||
fn show_cursor(&self, window_adapter: &Rc<dyn WindowAdapter>) {
|
||||
window_adapter.window().window_handle().set_cursor_blink_binding(&self.cursor_visible);
|
||||
WindowInner::from_pub(window_adapter.window())
|
||||
.set_cursor_blink_binding(&self.cursor_visible);
|
||||
}
|
||||
|
||||
fn hide_cursor(&self) {
|
||||
|
@ -814,7 +820,7 @@ impl TextInput {
|
|||
}
|
||||
|
||||
pub fn font_request(self: Pin<&Self>, window_adapter: &Rc<dyn WindowAdapter>) -> FontRequest {
|
||||
let window_item = window_adapter.window().window_handle().window_item();
|
||||
let window_item = WindowInner::from_pub(window_adapter.window()).window_item();
|
||||
|
||||
FontRequest {
|
||||
family: {
|
||||
|
|
|
@ -21,7 +21,7 @@ use crate::lengths::{
|
|||
};
|
||||
use crate::renderer::Renderer;
|
||||
use crate::textlayout::{FontMetrics as _, TextParagraphLayout};
|
||||
use crate::window::{WindowAdapter, WindowHandleAccess, WindowInner};
|
||||
use crate::window::{WindowAdapter, WindowInner};
|
||||
use crate::{Color, Coord, ImageInner, StaticTextures};
|
||||
use alloc::rc::{Rc, Weak};
|
||||
use alloc::{vec, vec::Vec};
|
||||
|
@ -133,10 +133,10 @@ impl<const BUFFER_COUNT: usize> SoftwareRenderer<BUFFER_COUNT> {
|
|||
/// returns the dirty region for this frame (not including the extra_draw_region)
|
||||
pub fn render(&self, buffer: &mut [impl TargetPixel], buffer_stride: usize) {
|
||||
let window = self.window.upgrade().expect("render() called on a destroyed Window");
|
||||
let window = window.window().window_handle();
|
||||
let factor = ScaleFactor::new(window.scale_factor());
|
||||
let window_inner = WindowInner::from_pub(window.window());
|
||||
let factor = ScaleFactor::new(window_inner.scale_factor());
|
||||
let (size, background) = if let Some(window_item) =
|
||||
window.window_item().as_ref().map(|item| item.as_pin_ref())
|
||||
window_inner.window_item().as_ref().map(|item| item.as_pin_ref())
|
||||
{
|
||||
(
|
||||
(euclid::size2(window_item.width() as f32, window_item.height() as f32) * factor)
|
||||
|
@ -152,7 +152,7 @@ impl<const BUFFER_COUNT: usize> SoftwareRenderer<BUFFER_COUNT> {
|
|||
let buffer_renderer = SceneBuilder::new(
|
||||
size,
|
||||
factor,
|
||||
window,
|
||||
window_inner,
|
||||
RenderToBuffer { buffer, stride: buffer_stride },
|
||||
);
|
||||
let mut renderer = crate::item_rendering::PartialRenderer::new(
|
||||
|
@ -161,7 +161,7 @@ impl<const BUFFER_COUNT: usize> SoftwareRenderer<BUFFER_COUNT> {
|
|||
buffer_renderer,
|
||||
);
|
||||
|
||||
window.draw_contents(|components| {
|
||||
window_inner.draw_contents(|components| {
|
||||
for (component, origin) in components {
|
||||
renderer.compute_dirty_regions(component, *origin);
|
||||
}
|
||||
|
@ -218,17 +218,17 @@ impl<const BUFFER_COUNT: usize> SoftwareRenderer<BUFFER_COUNT> {
|
|||
/// ```
|
||||
pub fn render_by_line(&self, line_buffer: impl LineBufferProvider) {
|
||||
let window = self.window.upgrade().expect("render() called on a destroyed Window");
|
||||
let window = window.window().window_handle();
|
||||
let component_rc = window.component();
|
||||
let window_inner = WindowInner::from_pub(window.window());
|
||||
let component_rc = window_inner.component();
|
||||
let component = crate::component::ComponentRc::borrow_pin(&component_rc);
|
||||
if let Some(window_item) = crate::items::ItemRef::downcast_pin::<crate::items::WindowItem>(
|
||||
component.as_ref().get_item_ref(0),
|
||||
) {
|
||||
let factor = ScaleFactor::new(window.scale_factor());
|
||||
let factor = ScaleFactor::new(window_inner.scale_factor());
|
||||
let size =
|
||||
euclid::size2(window_item.width() as f32, window_item.height() as f32) * factor;
|
||||
render_window_frame_by_line(
|
||||
window,
|
||||
window_inner,
|
||||
window_item.background(),
|
||||
size.cast(),
|
||||
&self,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#![allow(unsafe_code)]
|
||||
|
||||
use crate::input::{KeyEvent, KeyEventType, KeyboardModifiers, MouseEvent};
|
||||
use crate::window::WindowHandleAccess;
|
||||
use crate::window::WindowInner;
|
||||
use crate::Coord;
|
||||
use crate::SharedString;
|
||||
|
||||
|
@ -70,12 +70,12 @@ pub extern "C" fn send_keyboard_string_sequence(
|
|||
let mut buffer = [0; 6];
|
||||
let text = SharedString::from(ch.encode_utf8(&mut buffer) as &str);
|
||||
|
||||
window_adapter.window().window_handle().process_key_input(&KeyEvent {
|
||||
WindowInner::from_pub(window_adapter.window()).process_key_input(&KeyEvent {
|
||||
event_type: KeyEventType::KeyPressed,
|
||||
text: text.clone(),
|
||||
modifiers,
|
||||
});
|
||||
window_adapter.window().window_handle().process_key_input(&KeyEvent {
|
||||
WindowInner::from_pub(window_adapter.window()).process_key_input(&KeyEvent {
|
||||
event_type: KeyEventType::KeyReleased,
|
||||
text,
|
||||
modifiers,
|
||||
|
|
|
@ -598,7 +598,7 @@ impl WindowInner {
|
|||
None => PopupWindowLocation::ChildWindow(position),
|
||||
|
||||
Some(window_adapter) => {
|
||||
window_adapter.window().window_handle().set_component(popup_componentrc);
|
||||
WindowInner::from_pub(window_adapter.window()).set_component(popup_componentrc);
|
||||
PopupWindowLocation::TopLevel(window_adapter)
|
||||
}
|
||||
};
|
||||
|
@ -683,12 +683,11 @@ impl WindowInner {
|
|||
pub fn window_adapter(&self) -> Rc<dyn WindowAdapter> {
|
||||
self.window_adapter_weak.upgrade().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal trait used by generated code to access window internals.
|
||||
pub trait WindowHandleAccess {
|
||||
/// Returns a reference to the window implementation.
|
||||
fn window_handle(&self) -> &WindowInner;
|
||||
/// Private access to the WindowInner for a given window.
|
||||
pub fn from_pub(window: &crate::api::Window) -> &Self {
|
||||
&window.0
|
||||
}
|
||||
}
|
||||
|
||||
/// Internal alias for Rc<dyn WindowAdapter>.
|
||||
|
@ -768,7 +767,7 @@ pub mod ffi {
|
|||
core::mem::size_of::<WindowAdapterRcOpaque>()
|
||||
);
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().scale_factor()
|
||||
WindowInner::from_pub(window_adapter.window()).scale_factor()
|
||||
}
|
||||
|
||||
/// Sets the window scale factor, merely for testing purposes.
|
||||
|
@ -778,7 +777,7 @@ pub mod ffi {
|
|||
value: f32,
|
||||
) {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().set_scale_factor(value)
|
||||
WindowInner::from_pub(window_adapter.window()).set_scale_factor(value)
|
||||
}
|
||||
|
||||
/// Sets the focus item.
|
||||
|
@ -788,7 +787,7 @@ pub mod ffi {
|
|||
focus_item: &ItemRc,
|
||||
) {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().set_focus_item(focus_item)
|
||||
WindowInner::from_pub(window_adapter.window()).set_focus_item(focus_item)
|
||||
}
|
||||
|
||||
/// Associates the window with the given component.
|
||||
|
@ -798,7 +797,7 @@ pub mod ffi {
|
|||
component: &ComponentRc,
|
||||
) {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().set_component(component)
|
||||
WindowInner::from_pub(window_adapter.window()).set_component(component)
|
||||
}
|
||||
|
||||
/// Show a popup.
|
||||
|
@ -810,12 +809,12 @@ pub mod ffi {
|
|||
parent_item: &ItemRc,
|
||||
) {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().show_popup(popup, position, parent_item);
|
||||
WindowInner::from_pub(window_adapter.window()).show_popup(popup, position, parent_item);
|
||||
}
|
||||
/// Close the current popup
|
||||
pub unsafe extern "C" fn slint_windowrc_close_popup(handle: *const WindowAdapterRcOpaque) {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().close_popup();
|
||||
WindowInner::from_pub(window_adapter.window()).close_popup();
|
||||
}
|
||||
|
||||
/// C binding to the set_rendering_notifier() API of Window
|
||||
|
@ -938,7 +937,7 @@ pub mod ffi {
|
|||
#[no_mangle]
|
||||
pub unsafe extern "C" fn slint_windowrc_size(handle: *const WindowAdapterRcOpaque) -> IntSize {
|
||||
let window_adapter = &*(handle as *const Rc<dyn WindowAdapter>);
|
||||
window_adapter.window().window_handle().inner_size.get().to_euclid().cast()
|
||||
WindowInner::from_pub(window_adapter.window()).inner_size.get().to_euclid().cast()
|
||||
}
|
||||
|
||||
/// Resizes the window to the specified size on the screen, in physical pixels and excluding
|
||||
|
|
|
@ -5,7 +5,7 @@ use core::convert::TryFrom;
|
|||
use i_slint_compiler::langtype::Type as LangType;
|
||||
use i_slint_core::graphics::Image;
|
||||
use i_slint_core::model::{Model, ModelRc};
|
||||
use i_slint_core::window::WindowHandleAccess;
|
||||
use i_slint_core::window::WindowInner;
|
||||
use i_slint_core::{Brush, PathData, SharedString, SharedVector};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
|
@ -586,7 +586,7 @@ impl ComponentDefinition {
|
|||
.inner
|
||||
.unerase(guard)
|
||||
.clone()
|
||||
.create_with_existing_window(&window.window_handle().window_adapter()),
|
||||
.create_with_existing_window(&WindowInner::from_pub(window).window_adapter()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1048,7 +1048,7 @@ pub fn run_event_loop() {
|
|||
/// This module contains a few function use by tests
|
||||
pub mod testing {
|
||||
use super::ComponentHandle;
|
||||
use i_slint_core::window::WindowHandleAccess;
|
||||
use i_slint_core::window::WindowInner;
|
||||
|
||||
/// Wrapper around [`i_slint_core::tests::slint_send_mouse_click`]
|
||||
pub fn send_mouse_click(comp: &super::ComponentInstance, x: f32, y: f32) {
|
||||
|
@ -1056,7 +1056,7 @@ pub mod testing {
|
|||
&vtable::VRc::into_dyn(comp.inner.clone()),
|
||||
x,
|
||||
y,
|
||||
&comp.window().window_handle().window_adapter(),
|
||||
&WindowInner::from_pub(comp.window()).window_adapter(),
|
||||
);
|
||||
}
|
||||
/// Wrapper around [`i_slint_core::tests::send_keyboard_string_sequence`]
|
||||
|
@ -1067,7 +1067,7 @@ pub mod testing {
|
|||
i_slint_core::tests::send_keyboard_string_sequence(
|
||||
&string,
|
||||
Default::default(),
|
||||
&comp.window().window_handle().window_adapter(),
|
||||
&WindowInner::from_pub(comp.window()).window_adapter(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ use i_slint_core::model::Repeater;
|
|||
use i_slint_core::properties::InterpolatedPropertyValue;
|
||||
use i_slint_core::rtti::{self, AnimatedBindingKind, FieldOffset, PropertyInfo};
|
||||
use i_slint_core::slice::Slice;
|
||||
use i_slint_core::window::{WindowAdapter, WindowHandleAccess};
|
||||
use i_slint_core::window::{WindowAdapter, WindowInner};
|
||||
use i_slint_core::{Brush, Color, Property, SharedString, SharedVector};
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
|
@ -405,11 +405,7 @@ impl<'id> ComponentDescription<'id> {
|
|||
window_adapter: &Rc<dyn WindowAdapter>,
|
||||
) -> vtable::VRc<ComponentVTable, ErasedComponentBox> {
|
||||
let component_ref = instantiate(self, None, Some(window_adapter), Default::default());
|
||||
component_ref
|
||||
.as_pin_ref()
|
||||
.window_adapter()
|
||||
.window()
|
||||
.window_handle()
|
||||
WindowInner::from_pub(component_ref.as_pin_ref().window_adapter().window())
|
||||
.set_component(&vtable::VRc::into_dyn(component_ref.clone()));
|
||||
component_ref.run_setup_code();
|
||||
component_ref
|
||||
|
@ -1465,12 +1461,6 @@ impl<'id> From<ComponentBox<'id>> for ErasedComponentBox {
|
|||
}
|
||||
}
|
||||
|
||||
impl i_slint_core::window::WindowHandleAccess for ErasedComponentBox {
|
||||
fn window_handle(&self) -> &i_slint_core::window::WindowInner {
|
||||
self.window_adapter().window().window_handle()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_repeater_by_name<'a, 'id>(
|
||||
instance_ref: InstanceRef<'a, '_>,
|
||||
name: &str,
|
||||
|
@ -1737,7 +1727,7 @@ pub fn show_popup(
|
|||
let inst =
|
||||
instantiate(compiled, Some(parent_comp), Some(parent_window_adapter), Default::default());
|
||||
inst.run_setup_code();
|
||||
parent_window_adapter.window().window_handle().show_popup(
|
||||
WindowInner::from_pub(parent_window_adapter.window()).show_popup(
|
||||
&vtable::VRc::into_dyn(inst),
|
||||
pos,
|
||||
parent_item,
|
||||
|
|
|
@ -9,7 +9,7 @@ use corelib::graphics::{GradientStop, LinearGradientBrush, PathElement, RadialGr
|
|||
use corelib::items::{ItemRef, PropertyAnimation};
|
||||
use corelib::model::{Model, ModelRc};
|
||||
use corelib::rtti::AnimatedBindingKind;
|
||||
use corelib::window::WindowHandleAccess;
|
||||
use corelib::window::WindowInner;
|
||||
use corelib::{Brush, Color, PathData, SharedString, SharedVector};
|
||||
use i_slint_compiler::expression_tree::{
|
||||
BuiltinFunction, EasingCurve, Expression, Path as ExprPath, PathElement as ExprPathElement,
|
||||
|
@ -1002,7 +1002,8 @@ pub fn window_adapter_ref<'a>(
|
|||
pub fn window_ref<'a>(
|
||||
component: InstanceRef<'a, '_>,
|
||||
) -> Option<&'a i_slint_core::window::WindowInner> {
|
||||
window_adapter_ref(component).map(|window_adapter| window_adapter.window().window_handle())
|
||||
window_adapter_ref(component)
|
||||
.map(|window_adapter| WindowInner::from_pub(window_adapter.window()))
|
||||
}
|
||||
|
||||
/// Return the component instance which hold the given element.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue