Skip to content

Commit

Permalink
Style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexb910 authored and cart committed Oct 16, 2020
1 parent 73f6817 commit 15d8799
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_window/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl Window {
pub fn set_cursor_lock_mode(&mut self, lock_mode: bool) {
self.cursor_locked = lock_mode;
self.command_queue
.push(WindowCommand::SetCursorLockMode {locked: lock_mode});
.push(WindowCommand::SetCursorLockMode { locked: lock_mode });
}

pub fn cursor_visible(&self) -> bool {
Expand All @@ -191,8 +191,9 @@ impl Window {

pub fn set_cursor_visibility(&mut self, visibile_mode: bool) {
self.cursor_visible = visibile_mode;
self.command_queue
.push(WindowCommand::SetCursorVisibility {visible: visibile_mode});
self.command_queue.push(WindowCommand::SetCursorVisibility {
visible: visibile_mode,
});
}

pub fn mode(&self) -> WindowMode {
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_winit/src/winit_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ impl WinitWindows {

let winit_window = winit_window_builder.build(&event_loop).unwrap();

winit_window.set_cursor_grab(window.cursor_locked()).unwrap();
winit_window
.set_cursor_grab(window.cursor_locked())
.unwrap();
winit_window.set_cursor_visible(window.cursor_visible());

self.window_id_to_winit
.insert(window.id(), winit_window.id());
self.winit_to_window_id
.insert(winit_window.id(), window.id());



#[cfg(target_arch = "wasm32")]
{
use winit::platform::web::WindowExtWebSys;
Expand Down
7 changes: 2 additions & 5 deletions examples/window/window_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@ fn change_title(time: Res<Time>, mut windows: ResMut<Windows>) {
}

/// This system toggles the cursor's visibility when the space bar is pressed
fn toggle_cursor(
input: Res<Input<KeyCode>>,
mut windows: ResMut<Windows>
) {
fn toggle_cursor(input: Res<Input<KeyCode>>, mut windows: ResMut<Windows>) {
let window = windows.get_primary_mut().unwrap();
if input.just_pressed(KeyCode::Space) {
window.set_cursor_lock_mode(!window.cursor_locked());
window.set_cursor_visibility(!window.cursor_visible());
}
}
}

0 comments on commit 15d8799

Please sign in to comment.