-
Notifications
You must be signed in to change notification settings - Fork 55
Description
The PistonWindow struct stores a GlutinWindow and that stores a GlWindow. Only GlWindow has a bunch of the properties we need to access in order to get/set all the information we need to in Drawing. This means that in order to access most of what we need, we often need to do something like window.window.window.blah().
Lines 28 to 40 in b51e3e0
| if next.width != current.width || next.height != current.height { | |
| window.window.window.set_inner_size(next.width, next.height); | |
| } | |
| if next.maximized != current.maximized { | |
| window.window.window.set_maximized(next.maximized); | |
| } | |
| if next.fullscreen != current.fullscreen { | |
| if next.fullscreen { | |
| window.window.window.set_fullscreen(Some(window.window.window.get_current_monitor())); | |
| } | |
| else { | |
| window.window.window.set_fullscreen(None); | |
| } |
The API is overall very clunky and difficult to use. There are a lot setters, but barely any getters. That means that we often cannot see the "actual" value of some part of the window.
For example, we cannot tell whether the window is maximized or not. We store our own maximized boolean and update it whenever Drawing::maximize() is called. This works okay, but stops being reliable if the user clicks the maximize button on the window itself. There is no event that provides information about that happening so we can't even track it manually.
This lack of information and poor API has made it so that our maximize(), unmaximize() and is_maximized() methods are all unstable. We don't even have methods to do things like disable resizing or minimize the window. This is despite WindowSettings supporting a set_resizeable method. That means that windows can be made resizeable or not during construction, but not set that way after they have been created.
1. Problems to Address in Window Library
Addressing all of these problems may involve moving to a new library or maybe contributing to/forking winit/PistonWindow/glutin.
- Solution must be cross platform (Windows, Mac, Ubuntu/Linux)
- Solution must not require any additional installation (i.e. anyone should just be able to compile a turtle application with
cargo buildwithout installing additional dependencies) - If additional installation is required, it is done automatically on the major platforms we support
- Solution must not require any additional installation (i.e. anyone should just be able to compile a turtle application with
- No more
window.window.window - getters for all window properties so that we no longer need to track a "current" drawing state
- methods for enabling/disabling resizing of the window after the window has been created
- methods for minimizing/unminimizing
- (optional if getters are good enough) events for entering/exiting fullscreen and maximized
- No more pixel format issues (Couldn't find any pixel format that matches the criterias #63)
2. After Problems Have Been Addressed
- Make sure
is_maximized()is accurate even if window maximize button is used - Remove unstable message from
maximize(),unmaximize()andis_maximized() - Add methods to
Drawingforis_resizeable()andset_resizeable() - Add methods for
is_minimized(),minimize(),unminimize() - No more pixel format issues (Couldn't find any pixel format that matches the criterias #63)