Skip to main content

WindowInner

Struct WindowInner 

Source
pub struct WindowInner {
    pub focus_item: RefCell<ItemWeak>,
    pub active_popups: RefCell<Vec<PopupWindow>>,
    /* private fields */
}
Expand description

Inner datastructure for the crate::api::Window

Fields§

§focus_item: RefCell<ItemWeak>

ItemRC that currently have the focus (possibly an instance of TextInput)

§active_popups: RefCell<Vec<PopupWindow>>

Stack of currently active popups

Implementations§

Source§

impl WindowInner

Source

pub fn new(window_adapter_weak: Weak<dyn WindowAdapter>) -> Self

Create a new instance of the window, given the window_adapter factory fn

Source

pub fn set_component(&self, component: &ItemTreeRc)

Associates this window with the specified component. Further event handling and rendering, etc. will be done with that component.

Source

pub fn component(&self) -> ItemTreeRc

return the component. Panics if it wasn’t set.

Source

pub fn try_component(&self) -> Option<ItemTreeRc>

returns the component or None if it isn’t set.

Source

pub fn ensure_tree_instantiated(&self)

Walk the component tree and every active popup to materialize every Repeater, Conditional and ComponentContainer. Runs change handlers and the instantiation pass in a loop because init callbacks may set properties that trigger change handlers, and change handlers may make new conditionals/repeaters dirty.

Source

pub fn active_popups(&self) -> Ref<'_, [PopupWindow]>

Returns a slice of the active popups.

Source

pub fn process_drag_event(&self, event: BackendDragEvent) -> Option<DragAction>

Dispatch a drag and drop event. Returns the action negotiated with the accepting DropArea, or None when none accepted.

Drag and drop is the one kind of input that backends don’t deliver through crate::api::Window::dispatch_event_with_result(): they need the negotiated action back, which crate::platform::WindowEventDispatchResult can’t express, and a drag leaving the window isn’t the pointer leaving the window. BackendDragEvent keeps this entry point to drag and drop, so that nothing else bypasses the window event hook.

Source

pub fn report_drag_finished(&self, action: DragAction)

Report that the in-flight native drag finished with action.

Backends call this when the OS drag completes (DragAction::None if cancelled); the source DragArea clears dragging and fires drag-finished.

Source

pub fn start_in_window_drag(&self)

Fall back to the in-window drag for the in-flight native drag.

Backends call this when a native start fails after taking the drag over; subsequent mouse moves then drive DragMove/Drop and the drag-image overlay, in-process.

Installs a binding on the specified property that’s toggled whenever the text cursor is supposed to be visible or not.

Source

pub fn set_focus_item( &self, new_focus_item: &ItemRc, set_focus: bool, reason: FocusReason, )

Sets the focus to the item pointed to by item_ptr. This will remove the focus from any currently focused item. If set_focus is false, the focus is cleared.

Source

pub fn focus_next_item(&self)

Move keyboard focus to the next item

Source

pub fn focus_previous_item(&self)

Move keyboard focus to the previous item.

Source

pub fn set_active(&self, have_focus: bool)

Marks the window to be the active window. This typically coincides with the keyboard focus. One exception though is when a popup is shown, in which case the window may remain active but temporarily loose focus to the popup.

This results in WindowFocusReceived and WindowFocusLost events.

Source

pub fn active(&self) -> bool

Returns true of the window is the active window. That typically implies having the keyboard focus, except when a popup is shown and temporarily takes the focus.

Source

pub fn update_window_properties(&self)

If the component’s root item is a Window element, then this function synchronizes its properties, such as the title for example, with the properties known to the windowing system.

Source

pub fn draw_contents<T>( &self, render_components: impl FnOnce(&[(ItemTreeWeak, LogicalPoint)], &dyn Fn(&mut dyn ItemRenderer)) -> T, ) -> Option<T>

Calls the render_components to render the main component and any sub-window components, tracked by a property dependency tracker.

The closure also receives a post_render callback. The renderer must invoke it once with its ItemRenderer after walking the components but before flushing, so the runtime can draw overlays that sit on top of the scene without being part of any item tree.

Returns None if no component is set yet.

Source

pub fn show(&self) -> Result<(), PlatformError>

Registers the window with the windowing system, in order to render the component’s items and react to input events once the event loop spins.

Source

pub fn hide(&self) -> Result<(), PlatformError>

De-registers the window with the windowing system.

Source

pub fn supports_native_menu_bar(&self) -> bool

Return whether the platform supports native menu bars

Source

pub fn setup_menubar(&self, menubar: VRc<MenuVTable>)

Setup the native menu bar

Source

pub fn setup_menubar_shortcuts(&self, menubar: VRc<MenuVTable>)

Setup the shortcuts for the menubar Note: We still register the same shortcuts if the native menubar is active. Generally, the native menubar should capture the shortcuts first, but in case it doesn’t, the window can still match them manually.

Source

pub fn create_child_window_adapter( &self, kind: WindowKind, ) -> Option<Rc<dyn WindowAdapter>>

Create a new popup window adapter This window adapter can be used on a popup component and shown with show_popup()

Source

pub fn show_popup( &self, popup_componentrc: &ItemTreeRc, popup_access_position: Box<dyn Fn() -> LogicalPosition>, close_policy: PopupClosePolicy, parent_item: &ItemRc, window_kind: WindowKind, is_open_setter: Box<dyn Fn(bool)>, ) -> NonZeroU32

Show a popup at the given position relative to the parent_item and returns its ID. The returned ID will always be non-zero.

is_open_setter keeps the parent component’s PopupWindow::is-open property in sync with this popup: it is invoked immediately with true, and again with false when the popup is closed through any path (the Drop impl of PopupWindow handles the false). Pass a no-op closure for popups (such as menus) that do not expose is-open.

Source

pub fn show_native_popup_menu( &self, context_menu_item: VRc<MenuVTable>, position: LogicalPosition, parent_item: &ItemRc, ) -> bool

Attempt to show a native popup menu

context_menu_item is an instance of a ContextMenu

Returns false if the native platform doesn’t support it

Source

pub fn close_popup(&self, popup_id: NonZeroU32)

Removes the popup matching the given ID.

Source

pub fn close_all_popups(&self)

Close all active popups.

Source

pub fn close_top_popup(&self)

Close the top-most popup.

Source

pub fn scale_factor(&self) -> f32

Returns the scale factor set on the window, as provided by the windowing system.

Source

pub fn set_const_scale_factor(&self, factor: f32)

Sets the scale factor for the window. From that point on, the scale factor is constant and cannot be changed anymore.

Source

pub fn text_input_focused(&self) -> bool

Reads the global property TextInputInterface.text-input-focused

Source

pub fn set_text_input_focused(&self, value: bool)

Sets the global property TextInputInterface.text-input-focused

Source

pub fn is_visible(&self) -> bool

Returns true if the window is visible

Source

pub fn window_item_rc(&self) -> Option<ItemRc>

Returns the window item that is the first item in the component. When Some() is returned, it’s guaranteed to be safe to downcast to WindowItem.

Source

pub fn window_item(&self) -> Option<VRcMapped<ItemTreeVTable, WindowItem>>

Returns the window item that is the first item in the component.

Source

pub fn set_window_item_safe_area(&self, inset: LogicalEdges)

The safe area of the window has changed.

Source

pub fn on_close_requested( &self, callback: impl FnMut() -> CloseRequestResponse + 'static, )

Sets the close_requested callback. The callback will be run when the user tries to close a window.

Source

pub fn request_close(&self) -> bool

Runs the close_requested callback. If the callback returns KeepWindowShown, this function returns false. That should prevent the Window from closing. Otherwise it returns true, which allows the Window to hide.

Source

pub fn is_fullscreen(&self) -> bool

Returns if the window is currently in fullscreen mode

Source

pub fn set_fullscreen(&self, enabled: bool)

Set or unset the window to display fullscreen.

Source

pub fn is_maximized(&self) -> bool

Returns if the window is currently maximized

Source

pub fn set_maximized(&self, maximized: bool)

Set the window as maximized or unmaximized

Source

pub fn is_minimized(&self) -> bool

Returns if the window is currently minimized

Source

pub fn set_minimized(&self, minimized: bool)

Set the window as minimized or unminimized

Source

pub fn xdg_app_id(&self) -> Option<SharedString>

Returns the (context global) xdg app id for use with wayland and x11.

Source

pub fn window_adapter(&self) -> Rc<dyn WindowAdapter>

Returns the upgraded window adapter

Source

pub fn from_pub(window: &Window) -> &Self

Private access to the WindowInner for a given window.

Source

pub fn context(&self) -> &SlintContext

Provides access to the Windows’ Slint context.

Source

pub fn try_context(&self) -> Option<&SlintContext>

Like Self::context, but returns None instead of panicking when no context is available yet.

Source

pub fn set_context(&self, ctx: SlintContext)

Set the SlintContext. This needs to be called once before any other functions that would use the context.

Trait Implementations§

Source§

impl Drop for WindowInner

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.