mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Cleanup crate root
This commit is contained in:
parent
1cc0447c5e
commit
13b79ffaaf
33
src/events.rs
Normal file
33
src/events.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
#[deriving(Clone,Show)]
|
||||||
|
pub enum Event {
|
||||||
|
/// The position of the window has changed.
|
||||||
|
PositionChanged(uint, uint),
|
||||||
|
|
||||||
|
/// The size of the window has changed.
|
||||||
|
SizeChanged(uint, uint),
|
||||||
|
|
||||||
|
/// The window has been closed.
|
||||||
|
Closed,
|
||||||
|
|
||||||
|
/// The cursor has moved on the window.
|
||||||
|
///
|
||||||
|
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
|
||||||
|
CursorPositionChanged(uint, uint),
|
||||||
|
|
||||||
|
/// The window gained or lost focus.
|
||||||
|
///
|
||||||
|
/// The parameter is true if the window has gained focus, and false if it has lost focus.
|
||||||
|
Focused(bool),
|
||||||
|
|
||||||
|
/// The window has been turned into an icon or restored.
|
||||||
|
///
|
||||||
|
/// The parameter is true if the window has been iconified, and false if it has been restored.
|
||||||
|
Iconified(bool),
|
||||||
|
|
||||||
|
/// The system asked that the content of this window must be redrawn.
|
||||||
|
NeedRefresh,
|
||||||
|
|
||||||
|
/// The size of the framebuffer of the window has changed.
|
||||||
|
FramebufferSizeChanged(uint, uint),
|
||||||
|
}
|
73
src/hints.rs
Normal file
73
src/hints.rs
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
use std::default::Default;
|
||||||
|
|
||||||
|
#[deriving(Clone,Show)]
|
||||||
|
pub struct Hints {
|
||||||
|
pub resizable: bool,
|
||||||
|
pub visible: bool,
|
||||||
|
pub decorated: bool,
|
||||||
|
pub red_bits: u8,
|
||||||
|
pub green_bits: u8,
|
||||||
|
pub blue_bits: u8,
|
||||||
|
pub alpha_bits: u8,
|
||||||
|
pub depth_bits: u8,
|
||||||
|
pub stencil_bits: u8,
|
||||||
|
pub accum_red_bits: u8,
|
||||||
|
pub accum_green_bits: u8,
|
||||||
|
pub accum_blue_bits: u8,
|
||||||
|
pub accum_alpha_bits: u8,
|
||||||
|
pub aux_buffers: u8,
|
||||||
|
pub samples: u8,
|
||||||
|
pub refresh_rate: u8,
|
||||||
|
pub stereo: bool,
|
||||||
|
pub srgb_capable: bool,
|
||||||
|
pub client_api: ClientAPI,
|
||||||
|
pub context_version: (u8, u8),
|
||||||
|
//pub robustness: ,
|
||||||
|
pub opengl_forward_compat: bool,
|
||||||
|
pub opengl_debug_context: bool,
|
||||||
|
pub opengl_profile: Profile,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deriving(Clone, Show)]
|
||||||
|
pub enum ClientAPI {
|
||||||
|
OpenGL,
|
||||||
|
OpenGLES,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deriving(Clone, Show)]
|
||||||
|
pub enum Profile {
|
||||||
|
AnyProfile,
|
||||||
|
CompatProfile,
|
||||||
|
CoreProfile,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Hints {
|
||||||
|
fn default() -> Hints {
|
||||||
|
Hints {
|
||||||
|
resizable: true,
|
||||||
|
visible: true,
|
||||||
|
decorated: true,
|
||||||
|
red_bits: 8,
|
||||||
|
green_bits: 8,
|
||||||
|
blue_bits: 8,
|
||||||
|
alpha_bits: 8,
|
||||||
|
depth_bits: 24,
|
||||||
|
stencil_bits: 8,
|
||||||
|
accum_red_bits: 0,
|
||||||
|
accum_green_bits: 0,
|
||||||
|
accum_blue_bits: 0,
|
||||||
|
accum_alpha_bits: 0,
|
||||||
|
aux_buffers: 0,
|
||||||
|
samples: 0,
|
||||||
|
refresh_rate: 0,
|
||||||
|
stereo: false,
|
||||||
|
srgb_capable: false,
|
||||||
|
client_api: OpenGL,
|
||||||
|
context_version: (1, 0),
|
||||||
|
//robustness: ,
|
||||||
|
opengl_forward_compat: false,
|
||||||
|
opengl_debug_context: false,
|
||||||
|
opengl_profile: AnyProfile,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
169
src/lib.rs
169
src/lib.rs
|
@ -2,113 +2,88 @@
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
|
||||||
|
pub use events::{Event, PositionChanged, SizeChanged, Closed, CursorPositionChanged, Focused};
|
||||||
|
pub use events::{Iconified, NeedRefresh, FramebufferSizeChanged};
|
||||||
|
pub use hints::{Hints, ClientAPI, Profile};
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub use win32::Window;
|
use winimpl = win32;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
mod win32;
|
mod win32;
|
||||||
|
|
||||||
#[deriving(Clone,Show)]
|
mod events;
|
||||||
pub enum Event {
|
mod hints;
|
||||||
/// The position of the window has changed.
|
|
||||||
PositionChanged(uint, uint),
|
|
||||||
|
|
||||||
/// The size of the window has changed.
|
pub struct Window {
|
||||||
SizeChanged(uint, uint),
|
window: winimpl::Window
|
||||||
|
|
||||||
/// The window has been closed.
|
|
||||||
Closed,
|
|
||||||
|
|
||||||
/// The cursor has moved on the window.
|
|
||||||
///
|
|
||||||
/// The parameter are the (x,y) coords in pixels relative to the top-left corner of the window.
|
|
||||||
CursorPositionChanged(uint, uint),
|
|
||||||
|
|
||||||
/// The window gained or lost focus.
|
|
||||||
///
|
|
||||||
/// The parameter is true if the window has gained focus, and false if it has lost focus.
|
|
||||||
Focused(bool),
|
|
||||||
|
|
||||||
/// The window has been turned into an icon or restored.
|
|
||||||
///
|
|
||||||
/// The parameter is true if the window has been iconified, and false if it has been restored.
|
|
||||||
Iconified(bool),
|
|
||||||
|
|
||||||
/// The system asked that the content of this window must be redrawn.
|
|
||||||
NeedRefresh,
|
|
||||||
|
|
||||||
/// The size of the framebuffer of the window has changed.
|
|
||||||
FramebufferSizeChanged(uint, uint),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone,Show)]
|
impl Window {
|
||||||
pub struct Hints {
|
#[inline]
|
||||||
pub resizable: bool,
|
pub fn new(dimensions: Option<(uint, uint)>, title: &str, hints: &Hints)
|
||||||
pub visible: bool,
|
-> Result<Window, String>
|
||||||
pub decorated: bool,
|
{
|
||||||
pub red_bits: u8,
|
let win = try!(winimpl::Window::new(dimensions, title, hints));
|
||||||
pub green_bits: u8,
|
Ok(Window{window: win})
|
||||||
pub blue_bits: u8,
|
}
|
||||||
pub alpha_bits: u8,
|
|
||||||
pub depth_bits: u8,
|
|
||||||
pub stencil_bits: u8,
|
|
||||||
pub accum_red_bits: u8,
|
|
||||||
pub accum_green_bits: u8,
|
|
||||||
pub accum_blue_bits: u8,
|
|
||||||
pub accum_alpha_bits: u8,
|
|
||||||
pub aux_buffers: u8,
|
|
||||||
pub samples: u8,
|
|
||||||
pub refresh_rate: u8,
|
|
||||||
pub stereo: bool,
|
|
||||||
pub srgb_capable: bool,
|
|
||||||
pub client_api: ClientAPI,
|
|
||||||
pub context_version: (u8, u8),
|
|
||||||
//pub robustness: ,
|
|
||||||
pub opengl_forward_compat: bool,
|
|
||||||
pub opengl_debug_context: bool,
|
|
||||||
pub opengl_profile: Profile,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[deriving(Clone, Show)]
|
/// Returns true if the window has been closed by the user.
|
||||||
pub enum ClientAPI {
|
#[inline]
|
||||||
OpenGL,
|
pub fn should_close(&self) -> bool {
|
||||||
OpenGLES,
|
self.window.should_close()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deriving(Clone, Show)]
|
/// Modifies the title of the window.
|
||||||
pub enum Profile {
|
#[inline]
|
||||||
AnyProfile,
|
pub fn set_title(&self, title: &str) {
|
||||||
CompatProfile,
|
self.window.set_title(title)
|
||||||
CoreProfile,
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl std::default::Default for Hints {
|
#[inline]
|
||||||
fn default() -> Hints {
|
pub fn get_position(&self) -> (uint, uint) {
|
||||||
Hints {
|
self.window.get_position()
|
||||||
resizable: true,
|
}
|
||||||
visible: true,
|
|
||||||
decorated: true,
|
#[inline]
|
||||||
red_bits: 8,
|
pub fn set_position(&self, x: uint, y: uint) {
|
||||||
green_bits: 8,
|
self.window.set_position(x, y)
|
||||||
blue_bits: 8,
|
}
|
||||||
alpha_bits: 8,
|
|
||||||
depth_bits: 24,
|
#[inline]
|
||||||
stencil_bits: 8,
|
pub fn get_size(&self) -> (uint, uint) {
|
||||||
accum_red_bits: 0,
|
self.window.get_size()
|
||||||
accum_green_bits: 0,
|
}
|
||||||
accum_blue_bits: 0,
|
|
||||||
accum_alpha_bits: 0,
|
#[inline]
|
||||||
aux_buffers: 0,
|
pub fn set_size(&self, x: uint, y: uint) {
|
||||||
samples: 0,
|
self.window.set_size(x, y)
|
||||||
refresh_rate: 0,
|
}
|
||||||
stereo: false,
|
|
||||||
srgb_capable: false,
|
// TODO: return iterator
|
||||||
client_api: OpenGL,
|
#[inline]
|
||||||
context_version: (1, 0),
|
pub fn poll_events(&self) -> Vec<Event> {
|
||||||
//robustness: ,
|
self.window.poll_events()
|
||||||
opengl_forward_compat: false,
|
}
|
||||||
opengl_debug_context: false,
|
|
||||||
opengl_profile: AnyProfile,
|
// TODO: return iterator
|
||||||
}
|
#[inline]
|
||||||
|
pub fn wait_events(&self) -> Vec<Event> {
|
||||||
|
self.window.wait_events()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn make_current(&self) {
|
||||||
|
self.window.make_current()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn get_proc_address(&self, addr: &str) -> *const () {
|
||||||
|
self.window.get_proc_address(addr)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn swap_buffers(&self) {
|
||||||
|
self.window.swap_buffers()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue