[][src]Struct candelabre_windowing::CandlManager

pub struct CandlManager<W: CandlWindow, S> { /* fields omitted */ }

The window manager

Second core element of this lib, the CandlManager is the tool to bring all your app's windows under its command. It's main purpose is to remove the burden of OpenGL contexts swapping, and a way to easily manage multiple windows in a application. Its usage is pretty simple:

  1. create it
  2. insert new window in it
  3. call get_current() to swap contexts and get the window you can work with
  4. done

Check the candelabre examples to see it in action.

Methods

impl<W: CandlWindow> CandlManager<W, ()>[src]

pub fn new() -> Self[src]

most default constructor for the manager

impl<R, D, M, S> CandlManager<CandlSurface<R, D, M>, S> where
    R: CandlRenderer<R, D, M>,
    D: CandlUpdate<M>, 
[src]

pub fn create_window_from_builder<T>(
    &mut self,
    builder: CandlSurfaceBuilder<R, D, M>,
    el: &EventLoopWindowTarget<T>
) -> Result<WindowId, CandlError>
[src]

create a new window from a CandlSurfaceBuilder

pub fn create_window_with_state<T>(
    &mut self,
    el: &EventLoopWindowTarget<T>,
    video_mode: VideoMode,
    dim: CandlDimension,
    title: &str,
    options: CandlOptions,
    render: R,
    init_state: D
) -> Result<WindowId, CandlError>
[src]

create a new window with surface associated state type

impl<W: CandlWindow, S> CandlManager<W, S>[src]

pub fn create_window<T, E: CandlElement<W>>(
    &mut self,
    el: &EventLoopWindowTarget<T>,
    video_mode: VideoMode,
    dim: CandlDimension,
    title: &str,
    options: CandlOptions
) -> Result<WindowId, CandlError>
[src]

create a new window, tracked by the manager

For internal reason, it isn't possible to add a CandlSurface manually created to the manager, it's mandatory to use the create_window() method instead.

This method is the most basic one, creating a surface with no state associated.

WARNING : the first surface created with the manager decide of all the surfaces state type of the manager, it isn't in the scope of this lib to handle the complexity of multiple state type across an hashmap of surfaces.

pub fn new_with_state(init_state: S) -> Self[src]

constructor for the manager with state type link to it

pub fn list_window_ids(&self) -> Vec<WindowId>[src]

vector with all the WindowId managed by the CandlManager

pub fn remove_window(&mut self, id: WindowId)[src]

remove a window from the manager

If you don't call this method after closing a window, the OpenGL context continue to exist, and can lead to memory leaks.

pub fn is_empty(&self) -> bool[src]

check if there is still living windows, or if the manager is empty

The purpose of this method is to check if the application can be close, from an OpenGL perspective.

pub fn get_current(&mut self, id: WindowId) -> Result<&mut W, CandlError>[src]

get a mutable reference to the current surface

This method is the most important of the manager. At first, there is a check for the asked window to see if it's the current one, and if not the method try to swap the OpenGL contexts to make the asked window current, and make the old current context not current.

pub fn state(&self) -> &S[src]

get the state from the manager as an immutable reference

pub fn state_mut(&mut self) -> &mut S[src]

get the state from the manager as a mutable reference

Auto Trait Implementations

impl<W, S> RefUnwindSafe for CandlManager<W, S> where
    S: RefUnwindSafe,
    W: RefUnwindSafe

impl<W, S> Send for CandlManager<W, S> where
    S: Send,
    W: Send

impl<W, S> Sync for CandlManager<W, S> where
    S: Sync,
    W: Sync

impl<W, S> Unpin for CandlManager<W, S> where
    S: Unpin,
    W: Unpin

impl<W, S> UnwindSafe for CandlManager<W, S> where
    S: UnwindSafe,
    W: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.