Window

Struct Window 

Source
pub struct Window { /* private fields */ }
Expand description

A window with a layer container for adding sublayers.

Implementations§

Source§

impl Window

Source

pub fn container(&self) -> &CALayer

Get the container layer.

Add your layers as sublayers of this container.

Source

pub fn size(&self) -> (f64, f64)

Get the window size in points.

Source

pub fn ns_window(&self) -> &NSWindow

Get the underlying NSWindow.

Source

pub fn window_id(&self) -> u64

Returns the CGWindowID for this window.

This is useful for screen recording with t-rec’s HeadlessRecorder.

§Example
use core_animation::prelude::*;
use t_rec::HeadlessRecorder;

let window = WindowBuilder::new()
    .title("Demo")
    .size(400.0, 300.0)
    .build();

let mut recorder = HeadlessRecorder::builder()
    .window_id(window.window_id())
    .fps(30)
    .output_gif("demo.gif")
    .build()?;
Source

pub fn show(&self)

Show the window and bring it to the front.

If the window was created with .non_activating(), it will appear without stealing focus from the currently active application.

Source

pub fn show_for(&self, duration: Duration)

Show the window for a specified duration, then hide it.

This shows the window, processes events for the given duration, and then hides the window before returning.

§Example
use core_animation::prelude::*;

window.show_for(5.seconds());
window.show_for(500.millis());
window.show_for(1.5.seconds());
Source

pub fn hide(&self)

Hide the window.

The window is removed from the screen but not destroyed. It can be shown again with show().

This method runs a brief event loop tick after ordering out to ensure the hide takes effect immediately, which is important when called from within another run loop (like t-rec’s presenter).

Source

pub fn close(&self)

Close and release the window.

After calling this, the window should not be used again. Runs an event loop tick to ensure the close takes effect immediately.

Source

pub fn is_visible(&self) -> bool

Returns whether the window is currently visible.

Source

pub fn run_loop_tick(&self)

Run a single iteration of the event loop.

This processes pending events and returns immediately. Useful for custom animation loops.

Source

pub fn run(&self)

Run the event loop indefinitely until the window is closed.

Auto Trait Implementations§

§

impl Freeze for Window

§

impl !RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl !UnwindSafe for Window

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.
Source§

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