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

[Merged by Bors] - Added documentation to WindowMode to better document what 'use_size' … #3216

Closed
wants to merge 2 commits into from

Conversation

dimitri-br
Copy link
Contributor

This pull request aims to solve the issue of a lack of documentation in the enum WindowMode

Objective

Solution

  • Added a few lines of documentation that should document what the enum does better

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Nov 28, 2021
@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in C-Docs An addition or correction to our documentation S-Needs-Review and removed S-Needs-Triage This issue needs to be labelled labels Nov 28, 2021
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for your first PR :)

Copy link
Contributor

@Weibye Weibye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review labels Nov 28, 2021
Copy link
Member

@mockersf mockersf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, the field is documented on the enum and on the variant.

I think it would be best to keep the documentation on only one place, and that would be on the field itself. This would be better presented on docs.rs, and will also be the doc that will show up in an IDE. Could you move it there?

Also, "best" is not very explicit on how it is chosen. Could you expand the explanation? It seems "best" is from

pub fn get_best_videomode(monitor: &winit::monitor::MonitorHandle) -> winit::monitor::VideoMode {
let mut modes = monitor.video_modes().collect::<Vec<_>>();
modes.sort_by(|a, b| {
use std::cmp::Ordering::*;
match b.size().width.cmp(&a.size().width) {
Equal => match b.size().height.cmp(&a.size().height) {
Equal => b.refresh_rate().cmp(&a.refresh_rate()),
default => default,
},
default => default,
}
});
modes.first().unwrap().clone()
}

so it's picking the one with the bigger height / refresh rate I think?
Or better, add the explanation as doc to this function, then link to it from the field doc.

And from CI, it seems you could run cargo fmt 😃

/// E.g. when use_size is set to false the best video mode possible is chosen.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum WindowMode {
Windowed,
BorderlessFullscreen,
/// When set to true, the window uses the given size.
Copy link
Member

@mockersf mockersf Nov 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true, it will pick the resolution supported by the monitor that is closest to the given resolution, not the given one

…xed the code to ensure it works when creating a window
@dimitri-br
Copy link
Contributor Author

I've updated the documentation and ensured the new changes are compatible with bevy. I've tested it on a few examples and it seems to have run pretty well, but a review would be appreciated!

@cart
Copy link
Member

cart commented Nov 30, 2021

bors r+

@cart
Copy link
Member

cart commented Nov 30, 2021

Nice improvements!

bors bot pushed a commit that referenced this pull request Nov 30, 2021
#3216)

This pull request aims to solve the issue of a lack of documentation in the enum WindowMode

# Objective

- Fixes #3136

## Solution

- Added a few lines of documentation that should document what the enum does better
@bors bors bot changed the title Added documentation to WindowMode to better document what 'use_size' … [Merged by Bors] - Added documentation to WindowMode to better document what 'use_size' … Dec 1, 2021
@bors bors bot closed this Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add documentation for bevy_window::window::WindowMode::Fullscreen
5 participants