Add a transition macro system
This commit is contained in:
parent
f1d70d351e
commit
422b332c1b
17 changed files with 162 additions and 87 deletions
|
|
@ -6,7 +6,7 @@ use libc;
|
|||
use std::ffi::{CString};
|
||||
use std::sync::mpsc::{Receiver, channel};
|
||||
use std::os::raw::c_void;
|
||||
use {CreationError, Event, MouseCursor};
|
||||
use {CreationError, WindowEvent as Event, MouseCursor};
|
||||
use CreationError::OsError;
|
||||
use events::ElementState::{Pressed, Released};
|
||||
use events::{Touch, TouchPhase};
|
||||
|
|
@ -17,6 +17,8 @@ use CursorState;
|
|||
use WindowAttributes;
|
||||
use native_monitor::NativeMonitorId;
|
||||
|
||||
gen_api_transition!();
|
||||
|
||||
pub struct Window {
|
||||
native_window: *const c_void,
|
||||
event_rx: Receiver<android_glue::Event>,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ use ContextError;
|
|||
|
||||
pub use api::ios::*;
|
||||
|
||||
gen_api_transition!();
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct PlatformSpecificHeadlessBuilderAttributes;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
|||
|
||||
use CreationError;
|
||||
use CursorState;
|
||||
use Event;
|
||||
use WindowEvent as Event;
|
||||
use MouseCursor;
|
||||
use WindowAttributes;
|
||||
use libc;
|
||||
|
|
@ -17,6 +17,8 @@ use api::x11::XError;
|
|||
use api::x11::XNotSupported;
|
||||
use api::x11::ffi::XVisualInfo;
|
||||
|
||||
gen_api_transition!();
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct PlatformSpecificWindowBuilderAttributes {
|
||||
pub visual_infos: Option<XVisualInfo>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![cfg(target_os = "macos")]
|
||||
|
||||
use {CreationError, Event, MouseCursor, CursorState};
|
||||
use {CreationError, WindowEvent as Event, MouseCursor, CursorState};
|
||||
use CreationError::OsError;
|
||||
use libc;
|
||||
|
||||
|
|
@ -29,6 +29,8 @@ use os::macos::WindowExt;
|
|||
use events::ElementState;
|
||||
use events::{self, MouseButton, TouchPhase};
|
||||
|
||||
gen_api_transition!();
|
||||
|
||||
pub use self::monitor::{MonitorId, get_available_monitors, get_primary_monitor};
|
||||
|
||||
mod monitor;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::ffi::OsString;
|
|||
use std::os::windows::ffi::OsStringExt;
|
||||
|
||||
use CursorState;
|
||||
use Event;
|
||||
use WindowEvent as Event;
|
||||
use super::event;
|
||||
use super::WindowState;
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
{
|
||||
match msg {
|
||||
winapi::WM_DESTROY => {
|
||||
use events::Event::Closed;
|
||||
use events::WindowEvent::Closed;
|
||||
|
||||
CONTEXT_STASH.with(|context_stash| {
|
||||
let context_stash = context_stash.borrow();
|
||||
|
|
@ -93,7 +93,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_SIZE => {
|
||||
use events::Event::Resized;
|
||||
use events::WindowEvent::Resized;
|
||||
let w = winapi::LOWORD(lparam as winapi::DWORD) as u32;
|
||||
let h = winapi::HIWORD(lparam as winapi::DWORD) as u32;
|
||||
send_event(window, Resized(w, h));
|
||||
|
|
@ -101,7 +101,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_MOVE => {
|
||||
use events::Event::Moved;
|
||||
use events::WindowEvent::Moved;
|
||||
let x = winapi::LOWORD(lparam as winapi::DWORD) as i32;
|
||||
let y = winapi::HIWORD(lparam as winapi::DWORD) as i32;
|
||||
send_event(window, Moved(x, y));
|
||||
|
|
@ -110,7 +110,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
|
||||
winapi::WM_CHAR => {
|
||||
use std::mem;
|
||||
use events::Event::ReceivedCharacter;
|
||||
use events::WindowEvent::ReceivedCharacter;
|
||||
let chr: char = mem::transmute(wparam as u32);
|
||||
send_event(window, ReceivedCharacter(chr));
|
||||
0
|
||||
|
|
@ -125,7 +125,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
}
|
||||
|
||||
winapi::WM_MOUSEMOVE => {
|
||||
use events::Event::{MouseEntered, MouseMoved};
|
||||
use events::WindowEvent::{MouseEntered, MouseMoved};
|
||||
let mouse_outside_window = CONTEXT_STASH.with(|context_stash| {
|
||||
let mut context_stash = context_stash.borrow_mut();
|
||||
if let Some(context_stash) = context_stash.as_mut() {
|
||||
|
|
@ -159,7 +159,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_MOUSELEAVE => {
|
||||
use events::Event::MouseLeft;
|
||||
use events::WindowEvent::MouseLeft;
|
||||
let mouse_in_window = CONTEXT_STASH.with(|context_stash| {
|
||||
let mut context_stash = context_stash.borrow_mut();
|
||||
if let Some(context_stash) = context_stash.as_mut() {
|
||||
|
|
@ -180,7 +180,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_MOUSEWHEEL => {
|
||||
use events::Event::MouseWheel;
|
||||
use events::WindowEvent::MouseWheel;
|
||||
use events::MouseScrollDelta::LineDelta;
|
||||
use events::TouchPhase;
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_KEYDOWN | winapi::WM_SYSKEYDOWN => {
|
||||
use events::Event::KeyboardInput;
|
||||
use events::WindowEvent::KeyboardInput;
|
||||
use events::ElementState::Pressed;
|
||||
if msg == winapi::WM_SYSKEYDOWN && wparam as i32 == winapi::VK_F4 {
|
||||
user32::DefWindowProcW(window, msg, wparam, lparam)
|
||||
|
|
@ -206,7 +206,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_KEYUP | winapi::WM_SYSKEYUP => {
|
||||
use events::Event::KeyboardInput;
|
||||
use events::WindowEvent::KeyboardInput;
|
||||
use events::ElementState::Released;
|
||||
let (scancode, vkey) = event::vkeycode_to_element(wparam, lparam);
|
||||
send_event(window, KeyboardInput(Released, scancode, vkey));
|
||||
|
|
@ -214,7 +214,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_LBUTTONDOWN => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Left;
|
||||
use events::ElementState::Pressed;
|
||||
send_event(window, MouseInput(Pressed, Left));
|
||||
|
|
@ -222,7 +222,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_LBUTTONUP => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Left;
|
||||
use events::ElementState::Released;
|
||||
send_event(window, MouseInput(Released, Left));
|
||||
|
|
@ -230,7 +230,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_RBUTTONDOWN => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Right;
|
||||
use events::ElementState::Pressed;
|
||||
send_event(window, MouseInput(Pressed, Right));
|
||||
|
|
@ -238,7 +238,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_RBUTTONUP => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Right;
|
||||
use events::ElementState::Released;
|
||||
send_event(window, MouseInput(Released, Right));
|
||||
|
|
@ -246,7 +246,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_MBUTTONDOWN => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Middle;
|
||||
use events::ElementState::Pressed;
|
||||
send_event(window, MouseInput(Pressed, Middle));
|
||||
|
|
@ -254,7 +254,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_MBUTTONUP => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Middle;
|
||||
use events::ElementState::Released;
|
||||
send_event(window, MouseInput(Released, Middle));
|
||||
|
|
@ -262,7 +262,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_XBUTTONDOWN => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Other;
|
||||
use events::ElementState::Pressed;
|
||||
let xbutton = winapi::HIWORD(wparam as winapi::DWORD) as winapi::c_int; // waiting on PR for winapi to add GET_XBUTTON_WPARAM
|
||||
|
|
@ -271,7 +271,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_XBUTTONUP => {
|
||||
use events::Event::MouseInput;
|
||||
use events::WindowEvent::MouseInput;
|
||||
use events::MouseButton::Other;
|
||||
use events::ElementState::Released;
|
||||
let xbutton = winapi::HIWORD(wparam as winapi::DWORD) as winapi::c_int;
|
||||
|
|
@ -300,13 +300,13 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_SETFOCUS => {
|
||||
use events::Event::Focused;
|
||||
use events::WindowEvent::Focused;
|
||||
send_event(window, Focused(true));
|
||||
0
|
||||
},
|
||||
|
||||
winapi::WM_KILLFOCUS => {
|
||||
use events::Event::Focused;
|
||||
use events::WindowEvent::Focused;
|
||||
send_event(window, Focused(false));
|
||||
0
|
||||
},
|
||||
|
|
@ -345,7 +345,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
winapi::WM_DROPFILES => {
|
||||
use events::Event::DroppedFile;
|
||||
use events::WindowEvent::DroppedFile;
|
||||
|
||||
let hdrop = wparam as winapi::HDROP;
|
||||
let mut pathbuf: [u16; winapi::MAX_PATH] = mem::uninitialized();
|
||||
|
|
@ -394,7 +394,7 @@ pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
|||
},
|
||||
|
||||
x if x == *super::WAKEUP_MSG_ID => {
|
||||
use events::Event::Awakened;
|
||||
use events::WindowEvent::Awakened;
|
||||
send_event(window, Awakened);
|
||||
0
|
||||
},
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ use std::sync::{
|
|||
Mutex
|
||||
};
|
||||
use std::sync::mpsc::Receiver;
|
||||
use {CreationError, Event, MouseCursor};
|
||||
use {CreationError, WindowEvent as Event, MouseCursor};
|
||||
use CursorState;
|
||||
|
||||
use WindowAttributes;
|
||||
|
||||
gen_api_transition!();
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
pub struct PlatformSpecificWindowBuilderAttributes {
|
||||
pub parent: Option<winapi::HWND>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue