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

Make hints more idiomatic #638

Open
phrohdoh opened this issue Apr 18, 2017 · 6 comments
Open

Make hints more idiomatic #638

phrohdoh opened this issue Apr 18, 2017 · 6 comments

Comments

@phrohdoh
Copy link
Contributor

phrohdoh commented Apr 18, 2017

Current

sdl2::hint::set("SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS", "0");

Idea

// if this belongs in sdl2::video, then we'll use that
// or if there is a better place for the enum, great
sdl2::hint::set(sdl2::hint::Hint::MinimizeOnFocusLoss, false);

If this is desired let me know and I'll try to make time for an implementation.

@Cobrand
Copy link
Member

Cobrand commented Apr 18, 2017

Depends if there are other "hints" to be added in later versions of SDL2 or not ... If it's 95% sure we're not getting any more from later versions of SDL2, then sure. I think even knowing that we will probably get some more, having a nice enum which can get a last field being "Other" for non implemented hints that we may miss from later versions of SDL2 still make sense. Like this :

pub enum Hint<'a> {
MinimizeOnFocusLoss,
// other hint variants
Other(&'a str) // unknown hint variants here.
}

Ideally we would want to make a separate function for every hint, since some hints are basically equivalent of booleans but other are more complicated like this one. Meaning that some hints would take a boolean as a parameter while others would take a slice ...

But in the meantime I guess that an enum that lists every hint that we currently have is a nice alternative.

Feel free to open a PR !

@phrohdoh
Copy link
Contributor Author

I'm all for the individual function approach.

Is there a good channel to reach this project's devs at? (irc, gitter, is here the best?, etc)

@Cobrand
Copy link
Member

Cobrand commented Apr 18, 2017 via email

@phrohdoh
Copy link
Contributor Author

#639 was a first step towards this.

I will implement more hints as I need them (there may be long periods of time between PRs).
Hopefully others will do the same.

@HollayHorvath
Copy link

Keep in mind that the names are different than the names in the SDL Wiki Hint page by not containing the HINT_ part, so e.g. SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH becomes SDL_MOUSE_FOCUS_CLICKTHROUGH and so on.

@ThibaultLemaire
Copy link

Without going all the way to independent functions, the enum would IMO already be a step in the right direction. It would help avoid mistakes like this or #1197

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

No branches or pull requests

4 participants