Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Limitations of PistonWindow, Glutin, and winit #49

Closed
9 of 14 tasks
sunjay opened this issue Dec 21, 2017 · 3 comments · Fixed by #173
Closed
9 of 14 tasks

Address Limitations of PistonWindow, Glutin, and winit #49

sunjay opened this issue Dec 21, 2017 · 3 comments · Fixed by #173

Comments

@sunjay
Copy link
Owner

sunjay commented Dec 21, 2017

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().

turtle/src/renderer.rs

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 build without installing additional dependencies)
    • If additional installation is required, it is done automatically on the major platforms we support
  • 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() and is_maximized()
  • Add methods to Drawing for is_resizeable() and set_resizeable()
  • Add methods for is_minimized(), minimize(), unminimize()
  • No more pixel format issues (Couldn't find any pixel format that matches the criterias #63)
@sunjay
Copy link
Owner Author

sunjay commented Oct 23, 2019

We should consider checking out the very in progress Druid framework. It looks promising because it allows us to define how widgets get painted directly. That might actually be the right level of abstraction for a project like this.

Tutorial: https://pauljmiller.com/posts/druid-widget-tutorial.html

@sunjay
Copy link
Owner Author

sunjay commented Nov 6, 2019

A potential option: https://github.com/aclysma/skulpin

@sunjay
Copy link
Owner Author

sunjay commented Dec 4, 2019

Another potential option that looks quite promising: https://docs.rs/iced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant