Skip to main content

TestingWindow

Struct TestingWindow 

Source
pub struct TestingWindow {
    pub ime_requests: RefCell<Vec<InputMethodRequest>>,
    pub open_url: Rc<RefCell<Option<SharedString>>>,
    pub debug_logs: Rc<RefCell<Vec<String>>>,
    /* private fields */
}

Fields§

§ime_requests: RefCell<Vec<InputMethodRequest>>§open_url: Rc<RefCell<Option<SharedString>>>§debug_logs: Rc<RefCell<Vec<String>>>

Implementations§

Source§

impl TestingWindow

Source

pub fn use_native_popup(&self, native: bool)

Source

pub fn mouse_cursor(&self) -> MouseCursorInner

Source

pub fn window_move_request_count(&self) -> usize

Number of interactive window moves requested via WindowMoveArea.

Source

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

Source

pub fn take_debug_log(&self) -> Vec<String>

Drain and return all debug_log messages captured since the last call.

Source

pub fn set_simulate_native_drag(&self, enabled: bool)

Enable simulating native (OS-level) drag-and-drop. Once enabled, start_drag takes the drag over as a real backend does (instead of declining it and using the in-window fallback), recording the payload so Self::simulate_native_drag_move and Self::simulate_native_drop can drive the receive side.

Source

pub fn simulate_native_drag_move( &self, target: &Window, position: LogicalPosition, ) -> DragAction

Move the in-flight simulated native drag over target at position, as a backend does when the OS drags across a window. Returns the action the target’s DropArea proposes.

Source

pub fn simulate_native_drop( &self, target: &Window, position: LogicalPosition, ) -> DragAction

Drop the in-flight simulated native drag onto target at position, then report completion back to this source window, as a backend does when the OS drag ends. Returns the final negotiated action.

Trait Implementations§

Source§

impl RendererSealed for TestingWindow

Source§

fn text_size( &self, text_item: Pin<&dyn RenderString>, item_rc: &ItemRc, max_width: Option<LogicalLength>, text_wrap: TextWrap, ) -> LogicalSize

Returns the size of the given text in logical pixels. When set, max_width means that one need to wrap the text, so it does not go further than that, using the wrapping type passed by text_wrap. Read more
Source§

fn text_content_widths( &self, text_item: Pin<&dyn RenderString>, item_rc: &ItemRc, ) -> Option<ContentWidths>

Returns the content widths of the text, or None if the renderer can’t measure them, in which case the caller falls back to text_size without a lower bound. Read more
Source§

fn char_size( &self, text_item: Pin<&dyn HasFont>, item_rc: &ItemRc, ch: char, ) -> LogicalSize

Returns the size of the individual character in logical pixels. Read more
Source§

fn font_metrics(&self, font_request: FontRequest) -> FontMetrics

Returns the metrics of the given font. Read more
Source§

fn text_input_byte_offset_for_position( &self, text_input: Pin<&TextInput>, item_rc: &ItemRc, pos: LogicalPoint, ) -> usize

Returns the (UTF-8) byte offset in the text property that refers to the character that contributed to the glyph cluster that’s visually nearest to the given coordinate. This is used for hit-testing, for example when receiving a mouse click into a text field. Then this function returns the “cursor” position. Read more
Source§

fn text_input_cursor_rect_for_byte_offset( &self, text_input: Pin<&TextInput>, item_rc: &ItemRc, byte_offset: usize, ) -> LogicalRect

That’s the opposite of [Self::text_input_byte_offset_for_position] It takes a (UTF-8) byte offset in the text property, and returns a Rectangle left to the char. It is one logical pixel wide and ends at the baseline. Read more
Source§

fn set_window_adapter(&self, _window_adapter: &Rc<dyn WindowAdapter>)

Source§

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

Source§

fn supports_transformations(&self) -> bool

Whether the renderer supports transformations such as rotations and scaling or not.
§

fn text_layout_cache(&self) -> Option<&TextLayoutCache>

The cache used by the default implementations of the text related trait functions, which lay text out through [crate::textlayout::sharedparley]. Renderers using those default implementations return their cache here; with the default None, text layouts are computed without caching.
§

fn free_graphics_resources( &self, _component: VRef<'_, ItemTreeVTable>, _items: &mut dyn Iterator<Item = Pin<VRef<'_, ItemVTable>>>, ) -> Result<(), PlatformError>

Clear the caches for the items that are being removed
§

fn mark_dirty_region(&self, _region: DirtyRegion)

Mark a given region as dirty regardless whether the items actually are dirty. Read more
§

fn register_font_from_memory( &self, data: &'static [u8], ) -> Result<(), Box<dyn Error>>

This function can be used to register a custom TrueType font with Slint, for use with the font-family property. The provided slice must be a valid TrueType font. Read more
§

fn register_font_from_path(&self, path: &Path) -> Result<(), Box<dyn Error>>

This function can be used to register a custom TrueType font with Slint, for use with the font-family property. The provided path must refer to a valid TrueType font. Read more
§

fn register_bitmap_font(&self, _font_data: &'static BitmapFont)

§

fn set_rendering_notifier( &self, _callback: Box<dyn RenderingNotifier>, ) -> Result<(), SetRenderingNotifierError>

This function is called through the public API to register a callback that the backend needs to invoke during different phases of rendering.
§

fn scale_factor(&self) -> Option<Scale<f32, LogicalPx, PhysicalPx>>

§

fn slint_context(&self) -> Option<SlintContext>

§

fn resize(&self, _size: PhysicalSize) -> Result<(), PlatformError>

§

fn take_snapshot(&self) -> Result<SharedPixelBuffer<Rgba<u8>>, PlatformError>

Re-implement this function to support Window::take_snapshot(), i.e. return the contents of the window in an image buffer.
Source§

impl WindowAdapter for TestingWindow

Source§

fn window(&self) -> &Window

Returns the window API.
Source§

fn size(&self) -> PhysicalSize

Return the size of the Window on the screen
Source§

fn set_size(&self, size: WindowSize)

Request a new size for the window to the specified size on the screen, in physical or logical pixels and excluding a window frame (if present). Read more
Source§

fn renderer(&self) -> &dyn Renderer

Return the renderer. Read more
Source§

fn update_window_properties(&self, properties: WindowProperties<'_>)

Re-implement this function to update the properties such as window title or layout constraints. Read more
§

fn set_visible(&self, _visible: bool) -> Result<(), PlatformError>

Show the window if the argument is true, hide otherwise.
§

fn position(&self) -> Option<PhysicalPosition>

Returns the position of the window on the screen, in physical screen coordinates and including a window frame (if present). Read more
§

fn set_position(&self, _position: WindowPosition)

Sets the position of the window on the screen, in physical screen coordinates and including a window frame (if present). Read more
§

fn request_redraw(&self)

Issues a request to the windowing system to re-render the contents of the window. Read more
§

fn window_handle_06(&self) -> Result<WindowHandle<'_>, HandleError>

Re-implement this to support exposing raw window handles (version 0.6).
§

fn display_handle_06(&self) -> Result<DisplayHandle<'_>, HandleError>

Re-implement this to support exposing raw display handles (version 0.6).

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
§

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.

§

impl<T> Renderer for T
where T: RendererSealed,

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.