i_slint_core::window

Struct WindowInner

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

Inner datastructure for the crate::api::Window

Fields§

§focus_item: RefCell<ItemWeak>

ItemRC that currently have the focus. (possibly a, instance of TextInput)

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 process_mouse_input(&self, event: MouseEvent)

Receive a mouse event and pass it to the items of the component to change their state.

Arguments:

  • pos: The position of the mouse event in window physical coordinates.
  • what: The type of mouse event.
  • component: The Slint compiled component that provides the tree of items.
Source

pub fn process_key_input(&self, event: KeyEvent)

Receive a key event and pass it to the items of the component to change their state.

Arguments:

  • event: The key event received by the windowing system.
  • component: The Slint compiled component that provides the tree of items.

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)

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(&[(&ItemTreeRc, LogicalPoint)]) -> T, ) -> Option<T>

Calls the render_components to render the main component and any sub-window components, tracked by a property dependency tracker. 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 color_scheme(&self) -> ColorScheme

returns the color theme used

Source

pub fn show_popup( &self, popup_componentrc: &ItemTreeRc, position: LogicalPosition, close_policy: PopupClosePolicy, parent_item: &ItemRc, ) -> NonZeroU32

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

Source

pub fn show_native_popup_menu( &self, _context_menu_item: &ItemRc, _position: LogicalPosition, ) -> 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 top_close_policy(&self) -> PopupClosePolicy

Returns the close policy of the top-most popup. PopupClosePolicy::NoAutoClose if there is no active 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 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(&self) -> Option<VRcMapped<ItemTreeVTable, WindowItem>>

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

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 maximized

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.

Trait Implementations§

Source§

impl Drop for WindowInner

Source§

fn drop(&mut self)

Executes the destructor for this type. 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.