PistonDevelopers / window

DEPRECATED - moved into the piston repo
MIT License
0 stars 4 forks source link

What to do with the `Window` trait #16

Closed bvssvni closed 9 years ago

bvssvni commented 9 years ago

I removed it because the where constraints did not propagate properly. I don't know whether this is intentional yet and plan to investigate this closer. A solution would be to add wrapper methods to the Window trait. However, I don't know how this should be done "right", so I did the same as usual, to do as little as possible.

bvssvni commented 9 years ago

The old code was:

pub trait Window<E = Input>:
 SwapBuffers    
 + PollEvent<E>     
 + GetShouldClose + SetShouldClose  
 + GetSize  
 + SetCaptureCursor     
 + GetDrawSize  
 + GetTitle + SetTitle  
 + GetExitOnEsc + SetExitOnEsc {}
bvssvni commented 9 years ago

I think we could auto implement a trait that looks like a "normal" interface for now. Some people prefer to track the window and stay polymorphic over the window back-end. This way they would only need to import one trait to use the window. The trait should not use the property types.

bvssvni commented 9 years ago

Alternative is to make people implement their own Window trait. It is not easy to decide which properties the window should have, and some back-ends might not support all the methods, so if we want to support a Window trait then there must be a defined behavior for all properties.

bvssvni commented 9 years ago

One convention that works in many cases is to do:

use sdl2_window::Sdl2Window as Window;

This could be suggested as way to fix the problem, but it won't work for libraries that tries to use generics.

bvssvni commented 9 years ago

Closing because of outdated.