Skip to main content

CandlManager

Struct CandlManager 

Source
pub struct CandlManager<W: CandlWindow, S> { /* private fields */ }
Expand description

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.

Implementations§

Source§

impl<W: CandlWindow> CandlManager<W, ()>

Source

pub fn new() -> Self

most default constructor for the manager

Source§

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

Source

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

create a new window from a CandlSurfaceBuilder

Source

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>

create a new window with surface associated state type

Source§

impl<W: CandlWindow, S> CandlManager<W, S>

Source

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>

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.

Source

pub fn new_with_state(init_state: S) -> Self

constructor for the manager with state type link to it

Source

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

vector with all the WindowId managed by the CandlManager

Source

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

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.

Source

pub fn is_empty(&self) -> bool

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.

Source

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

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.

Source

pub fn state(&self) -> &S

get the state from the manager as an immutable reference

Source

pub fn state_mut(&mut self) -> &mut S

get the state from the manager as a mutable reference

Auto Trait Implementations§

§

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

§

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

§

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> UnsafeUnpin for CandlManager<W, S>
where S: UnsafeUnpin,

§

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

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.