Skip to content

Commit

Permalink
remove rgis-ui dep in rgis-camera
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Nov 11, 2024
1 parent 5e31e53 commit 2578a07
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 31 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion rgis-camera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
4 changes: 2 additions & 2 deletions rgis-camera/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn handle_change_crs_event(
bevy::ecs::query::With<bevy::render::camera::Camera>,
>,
windows: Query<&Window, With<PrimaryWindow>>,
ui_margins: rgis_ui::UiMargins,
ui_margins: rgis_units::UiMargins,
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let Some(event) = change_crs_event_reader.read().last() else {
return Ok(());
Expand Down Expand Up @@ -142,7 +142,7 @@ fn center_camera(
bevy::ecs::query::With<bevy::render::camera::Camera>,
>,
windows: Query<&Window, With<PrimaryWindow>>,
ui_margins: rgis_ui::UiMargins,
ui_margins: rgis_units::UiMargins,
) {
let Ok(window) = windows.get_single() else {
return;
Expand Down
2 changes: 1 addition & 1 deletion rgis-ui/src/bottom_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_, '_> {
Expand Down
24 changes: 3 additions & 21 deletions rgis-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<events::OpenOperationWindowEvent>();

systems::configure(app);
Expand Down
2 changes: 1 addition & 1 deletion rgis-ui/src/side_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_, '_> {
Expand Down
6 changes: 3 additions & 3 deletions rgis-ui/src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::BottomPanelHeight>,
mut bottom_panel_height: ResMut<rgis_units::BottomPanelHeight>,
) {
let Ok(mut egui_ctx) = egui_ctx_query.get_single_mut() else {
return;
Expand All @@ -32,7 +32,7 @@ fn render_side_panel(
mut egui_ctx_query: Query<&mut EguiContext, With<PrimaryWindow>>,
layers: Res<rgis_layers::Layers>,
mut events: crate::side_panel::Events,
mut side_panel_width: ResMut<crate::SidePanelWidth>,
mut side_panel_width: ResMut<rgis_units::SidePanelWidth>,
) {
let Ok(mut egui_ctx) = egui_ctx_query.get_single_mut() else {
return;
Expand Down Expand Up @@ -283,7 +283,7 @@ fn render_top_panel(
mut app_exit_events: ResMut<bevy::ecs::event::Events<bevy::app::AppExit>>,
mut windows: Query<&mut bevy::window::Window, With<PrimaryWindow>>,
mut app_settings: ResMut<rgis_settings::RgisSettings>,
mut top_panel_height: ResMut<crate::TopPanelHeight>,
mut top_panel_height: ResMut<rgis_units::TopPanelHeight>,
mut is_debug_window_open: ResMut<
crate::IsWindowOpen<crate::debug_window::DebugWindow<'static, 'static>>,
>,
Expand Down
2 changes: 1 addition & 1 deletion rgis-ui/src/top_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::debug_window::DebugWindow<'w, 's>>,
}

Expand Down
21 changes: 21 additions & 0 deletions rgis-units/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
clippy::expect_used
)]

use std::marker;

use bevy::prelude::*;
use geo_projected::{ProjectedCoord, ProjectedScalar};

// From top-left
Expand Down Expand Up @@ -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>,
}

0 comments on commit 2578a07

Please sign in to comment.