From 2578a07cf13f51a30bf71a63943c7e04d422712c Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Mon, 11 Nov 2024 09:31:45 -0500 Subject: [PATCH] remove rgis-ui dep in rgis-camera --- Cargo.lock | 1 - rgis-camera/Cargo.toml | 1 - rgis-camera/src/systems.rs | 4 ++-- rgis-ui/src/bottom_panel.rs | 2 +- rgis-ui/src/lib.rs | 24 +++--------------------- rgis-ui/src/side_panel.rs | 2 +- rgis-ui/src/systems.rs | 6 +++--- rgis-ui/src/top_panel.rs | 2 +- rgis-units/src/lib.rs | 21 +++++++++++++++++++++ 9 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a27a5a5..18690df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4173,7 +4173,6 @@ dependencies = [ "geo-projected", "rgis-events", "rgis-layers", - "rgis-ui", "rgis-units", "transform", ] diff --git a/rgis-camera/Cargo.toml b/rgis-camera/Cargo.toml index db5e0b1..da929b9 100644 --- a/rgis-camera/Cargo.toml +++ b/rgis-camera/Cargo.toml @@ -22,5 +22,4 @@ geo-projected = { path = "../geo-projected" } rgis-events = { path = "../rgis-events" } rgis-layers = { path = "../rgis-layers" } transform = { path = "../transform" } -rgis-ui = { path = "../rgis-ui" } rgis-units = { path = "../rgis-units" } diff --git a/rgis-camera/src/systems.rs b/rgis-camera/src/systems.rs index 0de64cb..5873533 100644 --- a/rgis-camera/src/systems.rs +++ b/rgis-camera/src/systems.rs @@ -31,7 +31,7 @@ fn handle_change_crs_event( bevy::ecs::query::With, >, windows: Query<&Window, With>, - ui_margins: rgis_ui::UiMargins, + ui_margins: rgis_units::UiMargins, ) -> Result<(), Box> { let Some(event) = change_crs_event_reader.read().last() else { return Ok(()); @@ -142,7 +142,7 @@ fn center_camera( bevy::ecs::query::With, >, windows: Query<&Window, With>, - ui_margins: rgis_ui::UiMargins, + ui_margins: rgis_units::UiMargins, ) { let Ok(window) = windows.get_single() else { return; diff --git a/rgis-ui/src/bottom_panel.rs b/rgis-ui/src/bottom_panel.rs index 2ad8447..659c762 100644 --- a/rgis-ui/src/bottom_panel.rs +++ b/rgis-ui/src/bottom_panel.rs @@ -6,7 +6,7 @@ pub(crate) struct BottomPanel<'a, 'w> { pub rgis_settings: &'a rgis_settings::RgisSettings, pub open_change_crs_window_event_writer: &'a mut bevy::ecs::event::EventWriter<'w, rgis_events::OpenChangeCrsWindow>, - pub bottom_panel_height: &'a mut crate::BottomPanelHeight, + pub bottom_panel_height: &'a mut rgis_units::BottomPanelHeight, } impl BottomPanel<'_, '_> { diff --git a/rgis-ui/src/lib.rs b/rgis-ui/src/lib.rs index 7c33902..cfcaae5 100644 --- a/rgis-ui/src/lib.rs +++ b/rgis-ui/src/lib.rs @@ -33,24 +33,6 @@ trait Window: egui::Widget + SystemParam + Send + Sync { pub struct Plugin; -#[derive(Copy, Clone, Resource)] -pub struct SidePanelWidth(pub f32); - -#[derive(Copy, Clone, Resource)] -pub struct TopPanelHeight(pub f32); - -#[derive(Copy, Clone, Resource)] -pub struct BottomPanelHeight(pub f32); - -#[derive(bevy::ecs::system::SystemParam, Resource)] -pub struct UiMargins<'w, 's> { - pub left: Res<'w, SidePanelWidth>, - pub top: Res<'w, TopPanelHeight>, - pub bottom: Res<'w, BottomPanelHeight>, - #[system_param(ignore)] - marker: marker::PhantomData<&'s usize>, -} - #[derive(Default, Resource)] pub struct MessageWindowState { is_visible: bool, @@ -80,9 +62,9 @@ impl bevy::app::Plugin for Plugin { fn build(&self, app: &mut App) { app.add_plugins(bevy_egui::EguiPlugin) .insert_resource(add_layer_window::SelectedFile(None)) - .insert_resource(TopPanelHeight(0.)) - .insert_resource(BottomPanelHeight(0.)) - .insert_resource(SidePanelWidth(0.)) + .insert_resource(rgis_units::TopPanelHeight(0.)) + .insert_resource(rgis_units::BottomPanelHeight(0.)) + .insert_resource(rgis_units::SidePanelWidth(0.)) .add_event::(); systems::configure(app); diff --git a/rgis-ui/src/side_panel.rs b/rgis-ui/src/side_panel.rs index 083e90b..2fa9cc7 100644 --- a/rgis-ui/src/side_panel.rs +++ b/rgis-ui/src/side_panel.rs @@ -24,7 +24,7 @@ pub(crate) struct SidePanel<'a, 'w> { pub egui_ctx: &'a egui::Context, pub layers: &'a rgis_layers::Layers, pub events: &'a mut Events<'w>, - pub side_panel_width: &'a mut crate::SidePanelWidth, + pub side_panel_width: &'a mut rgis_units::SidePanelWidth, } impl SidePanel<'_, '_> { diff --git a/rgis-ui/src/systems.rs b/rgis-ui/src/systems.rs index aa00585..0988320 100644 --- a/rgis-ui/src/systems.rs +++ b/rgis-ui/src/systems.rs @@ -12,7 +12,7 @@ fn render_bottom_panel( mut open_change_crs_window_event_writer: bevy::ecs::event::EventWriter< rgis_events::OpenChangeCrsWindow, >, - mut bottom_panel_height: ResMut, + mut bottom_panel_height: ResMut, ) { let Ok(mut egui_ctx) = egui_ctx_query.get_single_mut() else { return; @@ -32,7 +32,7 @@ fn render_side_panel( mut egui_ctx_query: Query<&mut EguiContext, With>, layers: Res, mut events: crate::side_panel::Events, - mut side_panel_width: ResMut, + mut side_panel_width: ResMut, ) { let Ok(mut egui_ctx) = egui_ctx_query.get_single_mut() else { return; @@ -283,7 +283,7 @@ fn render_top_panel( mut app_exit_events: ResMut>, mut windows: Query<&mut bevy::window::Window, With>, mut app_settings: ResMut, - mut top_panel_height: ResMut, + mut top_panel_height: ResMut, mut is_debug_window_open: ResMut< crate::IsWindowOpen>, >, diff --git a/rgis-ui/src/top_panel.rs b/rgis-ui/src/top_panel.rs index 53f07b0..9de7078 100644 --- a/rgis-ui/src/top_panel.rs +++ b/rgis-ui/src/top_panel.rs @@ -6,7 +6,7 @@ pub(crate) struct TopPanel<'a, 'w, 's> { pub bevy_egui_ctx: &'a mut bevy_egui::EguiContext, pub window: &'a mut Window, pub app_settings: &'a mut rgis_settings::RgisSettings, - pub top_panel_height: &'a mut crate::TopPanelHeight, + pub top_panel_height: &'a mut rgis_units::TopPanelHeight, pub is_debug_window_open: &'a mut crate::IsWindowOpen>, } diff --git a/rgis-units/src/lib.rs b/rgis-units/src/lib.rs index 6202b3f..b59fe56 100644 --- a/rgis-units/src/lib.rs +++ b/rgis-units/src/lib.rs @@ -6,6 +6,9 @@ clippy::expect_used )] +use std::marker; + +use bevy::prelude::*; use geo_projected::{ProjectedCoord, ProjectedScalar}; // From top-left @@ -123,3 +126,21 @@ impl ScreenSize { } } } + +#[derive(Copy, Clone, Resource)] +pub struct SidePanelWidth(pub f32); + +#[derive(Copy, Clone, Resource)] +pub struct TopPanelHeight(pub f32); + +#[derive(Copy, Clone, Resource)] +pub struct BottomPanelHeight(pub f32); + +#[derive(bevy::ecs::system::SystemParam, Resource)] +pub struct UiMargins<'w, 's> { + pub left: Res<'w, SidePanelWidth>, + pub top: Res<'w, TopPanelHeight>, + pub bottom: Res<'w, BottomPanelHeight>, + #[system_param(ignore)] + marker: marker::PhantomData<&'s usize>, +}