pel 0.1.0

OpenGL backed framebuffer
Documentation
use crate::{
    input::{KeyboardInput, ModifierKeys, MouseInput},
    Context,
};

/// Pel event loop callbacks.
///
/// User should implement this trait for their type and provide it to [`Config::run`][1].
///
/// [1]: struct.Config.html#method.run
pub trait Events {
    /// Called once, immediately after [`Config::run`][1] is called.
    ///
    /// This indicates that the pel event loop was just initialized.
    ///
    /// [1]: struct.Config.html#method.run
    #[allow(unused_variables)]
    fn init(&mut self, ctx: &mut Context) {}

    /// Called when pel window focus changes.
    ///
    /// `focus` is current window focus state.
    #[allow(unused_variables)]
    fn window_focus(&mut self, ctx: &mut Context, focus: bool) {}

    /// Called when window is resized.
    ///
    /// `size` is in physical pixels.
    #[allow(unused_variables)]
    fn window_resized(&mut self, ctx: &mut Context, size: (usize, usize)) {}

    /// Called when cursor enters (focused) or leaves (unfocused) window client area.
    ///
    /// `focus` is current cursor focus state.
    #[allow(unused_variables)]
    fn cursor_focus(&mut self, ctx: &mut Context, focus: bool) {}

    /// Called when key that has textual meaning is pressed.
    #[allow(unused_variables)]
    fn text_input(&mut self, ctx: &mut Context, codepoint: char) {}

    /// Called when key is pressed.
    ///
    /// `scancode` is physical location on the keyboard.
    #[allow(unused_variables)]
    fn key_input(&mut self, ctx: &mut Context, input: KeyboardInput) {}

    /// Called when mouse cursor changes position.
    ///
    /// `pos` is in physical pixels.
    #[allow(unused_variables)]
    fn mouse_moved(&mut self, ctx: &mut Context, pos: (usize, usize)) {}

    /// Called when mouse button state changes.
    #[allow(unused_variables)]
    fn mouse_click(&mut self, ctx: &mut Context, click: MouseInput) {}

    /// Called when mouse scrollwheel is moved.
    ///
    /// `delta` is virtual lines. Positive values go `up`, or away from user, negative values -
    /// `down` or to user.
    #[allow(unused_variables)]
    fn mouse_scroll(&mut self, ctx: &mut Context, delta: f32) {}

    /// Called when keyboard modifier keys state changes.
    #[allow(unused_variables)]
    fn keyboard_modifiers(&mut self, ctx: &mut Context, modifiers: ModifierKeys) {}

    /// Called every frame before [`draw`][1].
    ///
    /// [1]: trait.Events.html#method.draw
    #[allow(unused_variables)]
    fn update(&mut self, ctx: &mut Context) {}

    /// Called every frame after [`update`][1].
    ///
    /// [1]: trait.Events.html#method.update
    #[allow(unused_variables)]
    fn draw(&mut self, ctx: &mut Context) {}

    /// Called when pel window receives close request.
    ///
    /// Return value indicates if window should be closed.
    #[allow(unused_variables)]
    fn exit_requested(&mut self, ctx: &mut Context) -> bool {
        true
    }

    /// Called when pel event loop is being shut down.
    ///
    /// This is guaranteed to be the last callback ever called.
    fn exit(&mut self) {}
}