[][src]Trait sixtyfps_corelib::eventloop::GenericWindow

pub trait GenericWindow {
    fn draw(self: Rc<Self>, component: Pin<ComponentRef<'_>>);
fn process_mouse_input(
        self: Rc<Self>,
        pos: PhysicalPosition<f64>,
        what: MouseEventType,
        component: Pin<ComponentRef<'_>>
    );
fn process_key_input(
        self: Rc<Self>,
        event: &KeyEvent,
        component: Pin<ComponentRef<'_>>
    );
fn with_platform_window(&self, callback: &dyn Fn(&Window));
fn map_window(
        self: Rc<Self>,
        event_loop: &EventLoop,
        root_item: Pin<ItemRef<'_>>
    );
fn unmap_window(self: Rc<Self>);
fn request_redraw(&self);
fn scale_factor(&self) -> f32;
fn set_scale_factor(&self, factor: f32);
fn set_width(&self, width: f32);
fn set_height(&self, height: f32);
fn free_graphics_resources(self: Rc<Self>, component: Pin<ComponentRef<'_>>);
fn set_cursor_blink_binding(&self, prop: &Property<bool>);
fn current_keyboard_modifiers(&self) -> KeyboardModifiers;
fn set_current_keyboard_modifiers(&self, modifiers: KeyboardModifiers);
fn set_focus_item(
        self: Rc<Self>,
        component: Pin<ComponentRef<'_>>,
        item_ptr: *const u8
    );
fn set_focus(
        self: Rc<Self>,
        component: Pin<ComponentRef<'_>>,
        have_focus: bool
    ); }

This trait represents the interface that the generated code and the run-time require in order to implement functionality such as device-independent pixels, window resizing and other typicaly windowing system related tasks.

crate::graphics provides an implementation of this trait for use with crate::graphics::GraphicsBackend.

Required methods

fn draw(self: Rc<Self>, component: Pin<ComponentRef<'_>>)

Draw the items of the specified component in the given window.

fn process_mouse_input(
    self: Rc<Self>,
    pos: PhysicalPosition<f64>,
    what: MouseEventType,
    component: Pin<ComponentRef<'_>>
)

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 SixtyFPS compiled component that provides the tree of items.

fn process_key_input(
    self: Rc<Self>,
    event: &KeyEvent,
    component: Pin<ComponentRef<'_>>
)

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 SixtyFPS compiled component that provides the tree of items.

fn with_platform_window(&self, callback: &dyn Fn(&Window))

Calls the callback function with the underlying winit::Window that this GenericWindow backs.

fn map_window(
    self: Rc<Self>,
    event_loop: &EventLoop,
    root_item: Pin<ItemRef<'_>>
)

Requests for the window to be mapped to the screen.

Arguments:

  • event_loop: The event loop used to drive further event handling for this window as it will receive events.
  • root_item: The root item of the scene. If the item is a crate::items::Window, then the width and height properties are read and the values are passed to the windowing system as request for the initial size of the window. Then bindings are installed on these properties to keep them up-to-date with the size as it may be changed by the user or the windowing system in general.

fn unmap_window(self: Rc<Self>)

Removes the window from the screen. The window is not destroyed though, it can be show (mapped) again later by calling GenericWindow::map_window.

fn request_redraw(&self)

Issue a request to the windowing system to re-render the contents of the window. This is typically an asynchronous request.

fn scale_factor(&self) -> f32

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

fn set_scale_factor(&self, factor: f32)

Sets an overriding scale factor for the window. This is typically only used for testing.

fn set_width(&self, width: f32)

Sets the size of the window to the specified width. This method is typically called in response to receiving a window resize event from the windowing system.

fn set_height(&self, height: f32)

Sets the size of the window to the specified height. This method is typically called in response to receiving a window resize event from the windowing system.

fn free_graphics_resources(self: Rc<Self>, component: Pin<ComponentRef<'_>>)

This function is called by the generated code when a component and therefore its tree of items are destroyed. The implementation typically uses this to free the underlying graphics resources cached via crate::graphics::RenderingCache.

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

fn current_keyboard_modifiers(&self) -> KeyboardModifiers

Returns the currently active keyboard notifiers.

fn set_current_keyboard_modifiers(&self, modifiers: KeyboardModifiers)

Sets the currently active keyboard notifiers. This is used only for testing or directly from the event loop implementation.

fn set_focus_item(
    self: Rc<Self>,
    component: Pin<ComponentRef<'_>>,
    item_ptr: *const u8
)

Sets the focus to the item pointed to by item_ptr. This will remove the focus from any currently focused item.

fn set_focus(self: Rc<Self>, component: Pin<ComponentRef<'_>>, have_focus: bool)

Sets the focus on the window to true or false, depending on the have_focus argument. This results in WindowFocusReceived and WindowFocusLost events.

Loading content...

Implementors

impl<Backend: GraphicsBackend> GenericWindow for GraphicsWindow<Backend>[src]

fn current_keyboard_modifiers(&self) -> KeyboardModifiers[src]

Returns the currently active keyboard notifiers.

fn set_current_keyboard_modifiers(&self, state: KeyboardModifiers)[src]

Sets the currently active keyboard notifiers. This is used only for testing or directly from the event loop implementation.

Loading content...