Skip to content

Commit 937419c

Browse files
committed
Some cleanup
1 parent 95dc181 commit 937419c

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/lib.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use std::cell::RefCell;
2121
use std::rc::Rc;
2222
use std::any::Any;
2323

24-
use piston::{ event, window };
2524
use gfx::traits::*;
2625
use gfx_graphics::{ Gfx2d, GfxGraphics };
2726

@@ -33,7 +32,7 @@ type Glyphs = gfx_graphics::GlyphCache<gfx_device_gl::Resources, gfx_device_gl::
3332
type G2d<'a> = GfxGraphics<'a, gfx_device_gl::Resources, gfx_device_gl::CommandBuffer, gfx_device_gl::Output>;
3433

3534
/// Contains everything required for controlling window, graphics, event loop.
36-
pub struct PistonWindow<W: window::Window = GlutinWindow, T = ()> {
35+
pub struct PistonWindow<W: Window = GlutinWindow, T = ()> {
3736
/// The window.
3837
pub window: Rc<RefCell<W>>,
3938
/// GFX stream.
@@ -43,9 +42,9 @@ pub struct PistonWindow<W: window::Window = GlutinWindow, T = ()> {
4342
/// Gfx2d.
4443
pub g2d: Rc<RefCell<Gfx2d<gfx_device_gl::Resources>>>,
4544
/// The event loop.
46-
pub events: Rc<RefCell<event::WindowEvents<W, event::Event<W::Event>>>>,
45+
pub events: Rc<RefCell<WindowEvents<W, Event<W::Event>>>>,
4746
/// The event.
48-
pub event: Option<event::Event<W::Event>>,
47+
pub event: Option<Event<W::Event>>,
4948
/// Application structure.
5049
pub app: Rc<RefCell<T>>,
5150
/// The factory that was created along with the device.
@@ -62,7 +61,7 @@ impl<T> From<WindowSettings> for PistonWindow<T>
6261
}
6362

6463
impl<W, T> Clone for PistonWindow<W, T>
65-
where W: window::Window, W::Event: Clone
64+
where W: Window, W::Event: Clone
6665
{
6766
fn clone(&self) -> Self {
6867
PistonWindow {
@@ -79,11 +78,11 @@ impl<W, T> Clone for PistonWindow<W, T>
7978
}
8079

8180
impl<W, T> PistonWindow<W, T>
82-
where W: window::Window, W::Event: event::GenericEvent
81+
where W: Window, W::Event: GenericEvent
8382
{
8483
/// Creates a new piston object.
8584
pub fn new(window: Rc<RefCell<W>>, app: Rc<RefCell<T>>) -> Self
86-
where W: window::OpenGLWindow
85+
where W: OpenGLWindow
8786
{
8887
use piston::event::Events;
8988
use piston::window::{ OpenGLWindow, Window };
@@ -161,7 +160,7 @@ impl<W, T> PistonWindow<W, T>
161160
}
162161

163162
impl<W, T> Iterator for PistonWindow<W, T>
164-
where W: window::Window, W::Event: event::GenericEvent
163+
where W: Window, W::Event: GenericEvent
165164
{
166165
type Item = PistonWindow<W, T>;
167166

@@ -195,13 +194,13 @@ impl<W, T> Iterator for PistonWindow<W, T>
195194
}
196195
}
197196

198-
impl<W, T> event::GenericEvent for PistonWindow<W, T>
199-
where W: window::Window, W::Event: event::GenericEvent
197+
impl<W, T> GenericEvent for PistonWindow<W, T>
198+
where W: Window, W::Event: GenericEvent
200199
{
201-
fn event_id(&self) -> event::EventId {
200+
fn event_id(&self) -> EventId {
202201
match self.event {
203202
Some(ref e) => e.event_id(),
204-
None => event::EventId("")
203+
None => EventId("")
205204
}
206205
}
207206

@@ -211,9 +210,9 @@ impl<W, T> event::GenericEvent for PistonWindow<W, T>
211210
self.event.as_ref().unwrap().with_args(f)
212211
}
213212

214-
fn from_args(event_id: event::EventId, any: &Any, old_event: &Self) -> Option<Self> {
213+
fn from_args(event_id: EventId, any: &Any, old_event: &Self) -> Option<Self> {
215214
if let Some(ref e) = old_event.event {
216-
match event::GenericEvent::from_args(event_id, any, e) {
215+
match GenericEvent::from_args(event_id, any, e) {
217216
Some(e) => {
218217
Some(PistonWindow {
219218
window: old_event.window.clone(),
@@ -232,22 +231,22 @@ impl<W, T> event::GenericEvent for PistonWindow<W, T>
232231
}
233232
}
234233

235-
impl<W, T> window::Window for PistonWindow<W, T>
236-
where W: window::Window
234+
impl<W, T> Window for PistonWindow<W, T>
235+
where W: Window
237236
{
238-
type Event = <W as window::Window>::Event;
237+
type Event = <W as Window>::Event;
239238

240239
fn should_close(&self) -> bool { self.window.borrow().should_close() }
241-
fn size(&self) -> window::Size { self.window.borrow().size() }
242-
fn draw_size(&self) -> window::Size { self.window.borrow().draw_size() }
240+
fn size(&self) -> Size { self.window.borrow().size() }
241+
fn draw_size(&self) -> Size { self.window.borrow().draw_size() }
243242
fn swap_buffers(&mut self) { self.window.borrow_mut().swap_buffers() }
244243
fn poll_event(&mut self) -> Option<Self::Event> {
245-
window::Window::poll_event(&mut *self.window.borrow_mut())
244+
Window::poll_event(&mut *self.window.borrow_mut())
246245
}
247246
}
248247

249-
impl<W, T> window::AdvancedWindow for PistonWindow<W, T>
250-
where W: window::AdvancedWindow
248+
impl<W, T> AdvancedWindow for PistonWindow<W, T>
249+
where W: AdvancedWindow
251250
{
252251
fn get_title(&self) -> String { self.window.borrow().get_title() }
253252
fn set_title(&mut self, title: String) {

0 commit comments

Comments
 (0)