-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Split CursorOptions off of Window #19668
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
Changes from all commits
d3a9409
5b337f4
014281e
694e907
b3af32b
e04b09c
6e2e66d
2792020
4c37293
ded6e06
6feda70
0adc791
08bc578
d69ca21
362bd12
ffccf9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ impl Default for WindowPlugin { | |
fn default() -> Self { | ||
WindowPlugin { | ||
primary_window: Some(Window::default()), | ||
primary_cursor_options: Some(CursorOptions::default()), | ||
exit_condition: ExitCondition::OnAllClosed, | ||
close_when_requested: true, | ||
} | ||
|
@@ -76,6 +77,13 @@ pub struct WindowPlugin { | |
/// [`exit_on_all_closed`]. | ||
pub primary_window: Option<Window>, | ||
|
||
/// Settings for the cursor on the primary window. | ||
/// | ||
/// Defaults to `Some(CursorOptions::default())`. | ||
/// | ||
/// Has no effect if [`WindowPlugin::primary_window`] is `None`. | ||
pub primary_cursor_options: Option<CursorOptions>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit tangential but I don't really like how in the window module we use "cursor" to refer to the mouse pointer and in the UI and picking modules we use "pointer". I'd prefer using "pointer" consistently. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a very good point. I'll open an issue for unifying terminology later :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done and already resolved: #19688 (comment) |
||
|
||
/// Whether to exit the app when there are no open windows. | ||
/// | ||
/// If disabling this, ensure that you send the [`bevy_app::AppExit`] | ||
|
@@ -122,10 +130,14 @@ impl Plugin for WindowPlugin { | |
.add_event::<AppLifecycle>(); | ||
|
||
if let Some(primary_window) = &self.primary_window { | ||
app.world_mut().spawn(primary_window.clone()).insert(( | ||
let mut entity_commands = app.world_mut().spawn(primary_window.clone()); | ||
entity_commands.insert(( | ||
PrimaryWindow, | ||
RawHandleWrapperHolder(Arc::new(Mutex::new(None))), | ||
)); | ||
if let Some(primary_cursor_options) = &self.primary_cursor_options { | ||
entity_commands.insert(primary_cursor_options.clone()); | ||
} | ||
} | ||
|
||
match self.exit_condition { | ||
|
@@ -168,7 +180,8 @@ impl Plugin for WindowPlugin { | |
// Register window descriptor and related types | ||
#[cfg(feature = "bevy_reflect")] | ||
app.register_type::<Window>() | ||
.register_type::<PrimaryWindow>(); | ||
.register_type::<PrimaryWindow>() | ||
.register_type::<CursorOptions>(); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left this in for parity with the existing API, but since it's a required component, we could also omit it and let the user override it in an observer for
OnAdd, PrimaryWindow