use glium;
use glium::glutin;
use {Screen, ScreenType};
use errors::ProcessingErr;
impl<'a> Screen<'a> {
#[inline]
pub fn reset_cursor(&mut self) -> Result<(), ProcessingErr> {
match self.display {
ScreenType::Window(ref d) => (*d).gl_window().set_cursor_state(glutin::CursorState::Normal).map_err(|e| ProcessingErr::CursorStateNotSet(e))?,
_ => (),
};
self.curr_cursor = glium::glutin::MouseCursor::Default;
match self.display {
ScreenType::Window(ref d) => {
(*d).gl_window().set_cursor(
glium::glutin::MouseCursor::Default,
)
}
_ => (),
};
Ok(())
}
#[inline]
pub fn cursor(&mut self, cursor_type: &str) -> Result<(), ProcessingErr> {
match self.display {
ScreenType::Window(ref d) => (*d).gl_window().set_cursor_state(glutin::CursorState::Normal).map_err(|e| ProcessingErr::CursorStateNotSet(e))?,
_ => (),
};
if cursor_type == "HAND" {
self.curr_cursor = glium::glutin::MouseCursor::Hand;
} else if cursor_type == "ARROW" {
self.curr_cursor = glium::glutin::MouseCursor::Arrow;
} else if cursor_type == "CROSS" {
self.curr_cursor = glium::glutin::MouseCursor::Crosshair;
} else if cursor_type == "MOVE" {
self.curr_cursor = glium::glutin::MouseCursor::Move;
} else if cursor_type == "TEXT" {
self.curr_cursor = glium::glutin::MouseCursor::Text;
} else if cursor_type == "WAIT" {
self.curr_cursor = glium::glutin::MouseCursor::Wait;
}
match self.display {
ScreenType::Window(ref d) => (*d).gl_window().set_cursor(self.curr_cursor),
_ => (),
};
Ok(())
}
#[inline]
pub fn focused(&mut self) -> bool {
let mut focused = false;
self.events_loop.poll_events(|event| match event {
glutin::Event::WindowEvent { event, .. } => {
match event {
glutin::WindowEvent::Focused(_) => {
focused = true;
}
_ => (),
}
}
_ => (),
});
focused
}
#[inline]
pub fn frame_count(&self) -> isize {
self.frame_count
}
#[inline]
pub fn get_frame_rate(&self) -> isize {
self.frame_rate
}
#[inline]
pub fn set_frame_rate(&mut self, f_rate: isize) {
self.frame_rate = f_rate;
}
#[inline]
pub fn height(&self) -> u32 {
self.height
}
#[inline]
pub fn no_cursor(&mut self) -> Result<(), ProcessingErr> {
match self.display {
ScreenType::Window(ref d) => (*d).gl_window().set_cursor_state(glutin::CursorState::Hide).map_err(|e| ProcessingErr::CursorStateNotSet(e))?,
_ => (),
};
Ok(())
}
#[inline]
pub fn no_smooth(&mut self) {
self.draw_params = glium::draw_parameters::DrawParameters {
smooth: None,
..self.draw_params.clone()
};
}
#[inline]
pub fn smooth(&mut self) {
self.draw_params = glium::draw_parameters::DrawParameters {
smooth: Some(glium::draw_parameters::Smooth::Nicest),
..self.draw_params.clone()
};
}
#[inline]
pub fn width(&self) -> u32 {
self.width
}
}