Struct image2::window::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> !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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.