Struct WindowSet

Source
pub struct WindowSet<T: Type, C: Color> {
    pub glfw: RefCell<Glfw>,
    pub windows: BTreeMap<WindowId, Window<T, C>>,
}
Expand description

Multiple windows

Fields§

§glfw: RefCell<Glfw>

GLFW handle

§windows: BTreeMap<WindowId, Window<T, C>>

Mapping from WindowId to Window

Implementations§

Source§

impl<T: Type, C: Color> WindowSet<T, C>
where Image<T, C>: ToTexture<T, C>,

Source

pub fn new() -> Result<Self, Error>

Create a new context

Source

pub fn new_with_error_callback<E: 'static>( f: Callback<fn(Error, String, &E), E>, ) -> Result<Self, Error>

Create a new context with error callback

Source

pub fn glfw_context(&self) -> Ref<'_, Glfw>

Access Glfw handle

Source

pub fn glfw_context_mut(&self) -> RefMut<'_, Glfw>

Access mutable Glfw handle

Source

pub fn add(&mut self, window: Window<T, C>) -> Result<WindowId, Error>

Add an existing window

Source

pub fn create( &mut self, title: impl AsRef<str>, image: Image<T, C>, ) -> Result<WindowId, Error>
where Image<T, C>: ToTexture<T, C>,

Create a new window and add it

Source

pub fn get(&self, window_id: &WindowId) -> Option<&Window<T, C>>

Get window by ID

Source

pub fn get_mut(&mut self, window_id: &WindowId) -> Option<&mut Window<T, C>>

Get mutable window by ID

Source

pub fn remove(&mut self, window_id: &WindowId) -> Option<Window<T, C>>

Remove a window and return it

Source

pub fn iter(&self) -> impl Iterator<Item = (&WindowId, &Window<T, C>)>

Iterate over all windows

Source

pub fn iter_mut( &mut self, ) -> impl Iterator<Item = (&WindowId, &mut Window<T, C>)>

Iterate over mutable windows

Source

pub fn iter_windows(&self) -> impl Iterator<Item = &Window<T, C>>

Convert into an interator over windows

Source

pub fn iter_windows_mut(&mut self) -> impl Iterator<Item = &mut Window<T, C>>

Convert into an interator over mutable windows

Source

pub fn into_images(self) -> impl Iterator<Item = Image<T, C>>

Convert into an iterator over images

Source

pub fn step<F: FnMut(&mut Window<T, C>, Option<Event>) -> Result<(), Error>>( &mut self, event_handler: F, ) -> Result<bool, Error>

Returns false when there are no more open windows

Source

pub fn wait_events(&self, timeout: f64)

Poll for new events with the given timeout

Source

pub fn run<F: FnMut(&mut Window<T, C>, Option<Event>) -> Result<(), Error>>( &mut self, event_handler: F, ) -> Result<(), Error>

Run the event loop until all windows are closed

Trait Implementations§

Source§

impl<T: Type, C: Color> Send for WindowSet<T, C>

Source§

impl<T: Type, C: Color> Sync for WindowSet<T, C>

Auto Trait Implementations§

§

impl<T, C> !Freeze for WindowSet<T, C>

§

impl<T, C> !RefUnwindSafe for WindowSet<T, C>

§

impl<T, C> Unpin for WindowSet<T, C>

§

impl<T, C> !UnwindSafe for WindowSet<T, C>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.