Skip to content

Commit

Permalink
Register reflect on cursor icon and move to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
eero-lehtinen committed Sep 7, 2024
1 parent 5cfcbf4 commit edc38ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
11 changes: 11 additions & 0 deletions crates/bevy_render/src/view/window/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use bevy_app::{App, Last, Plugin};
use bevy_asset::{AssetId, Assets, Handle};
use bevy_ecs::{
change_detection::DetectChanges,
Expand All @@ -19,6 +20,16 @@ use wgpu::TextureFormat;

use crate::prelude::Image;

pub struct CursorPlugin;

impl Plugin for CursorPlugin {
fn build(&self, app: &mut App) {
app.register_type::<CursorIcon>()
.init_resource::<CustomCursorCache>()
.add_systems(Last, update_cursors);
}
}

/// Insert into a window entity to set the cursor for that window.
#[derive(Component, Debug, Clone, Reflect, PartialEq, Eq)]
#[reflect(Component, Debug, Default)]
Expand Down
9 changes: 3 additions & 6 deletions crates/bevy_render/src/view/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use crate::{
renderer::{RenderAdapter, RenderDevice, RenderInstance},
Extract, ExtractSchedule, Render, RenderApp, RenderSet, WgpuWrapper,
};
use bevy_app::{App, Last, Plugin};
use bevy_app::{App, Plugin};
use bevy_ecs::{entity::EntityHashMap, prelude::*};
#[cfg(target_os = "linux")]
use bevy_utils::warn_once;
use bevy_utils::{default, tracing::debug, HashSet};
use bevy_window::{
CompositeAlphaMode, PresentMode, PrimaryWindow, RawHandleWrapper, Window, WindowClosing,
};
use bevy_winit::CustomCursorCache;
use cursor::CursorPlugin;
use std::{
num::NonZero,
ops::{Deref, DerefMut},
Expand All @@ -23,16 +23,13 @@ use wgpu::{
pub mod cursor;
pub mod screenshot;

use self::cursor::update_cursors;
use screenshot::{ScreenshotPlugin, ScreenshotToScreenPipeline};

pub struct WindowRenderPlugin;

impl Plugin for WindowRenderPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(ScreenshotPlugin)
.init_resource::<CustomCursorCache>()
.add_systems(Last, update_cursors);
app.add_plugins((ScreenshotPlugin, CursorPlugin));

if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
render_app
Expand Down

0 comments on commit edc38ba

Please sign in to comment.