-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use specs::prelude::*; | ||
use crate::{ | ||
resources::{ | ||
events::{ | ||
GeometryAction, GeometryActionChannel, GeometryActionReader, | ||
SketchEvent, SketchEventChannel | ||
}, | ||
}, | ||
components::Hidden, | ||
}; | ||
|
||
pub struct UnhideAllHandler { | ||
geometry_action_reader: Option<GeometryActionReader>, | ||
} | ||
|
||
impl Default for UnhideAllHandler { | ||
fn default() -> Self { | ||
Self { geometry_action_reader: None } | ||
} | ||
} | ||
|
||
impl<'a> System<'a> for UnhideAllHandler { | ||
type SystemData = ( | ||
Entities<'a>, | ||
Read<'a, GeometryActionChannel>, | ||
Write<'a, SketchEventChannel>, | ||
ReadStorage<'a, Hidden>, | ||
); | ||
|
||
fn setup(&mut self, world: &mut World) { | ||
Self::SystemData::setup(world); | ||
self.geometry_action_reader = Some(world.fetch_mut::<GeometryActionChannel>().register_reader()); | ||
} | ||
|
||
fn run(&mut self, (entities, geometry_actiona_channel, mut sketch_event_channel, hidden): Self::SystemData) { | ||
if let Some(reader_id) = &mut self.geometry_action_reader { | ||
for event in geometry_actiona_channel.read(reader_id) { | ||
match event { | ||
GeometryAction::UnhideAll => { | ||
for (entity, _) in (&entities, &hidden).join() { | ||
sketch_event_channel.single_write(SketchEvent::unhide(entity)); | ||
} | ||
break; | ||
}, | ||
_ => (), | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
mod hide_selected_via_keyboard; | ||
pub use hide_selected_via_keyboard::*; | ||
pub use hide_selected_via_keyboard::*; | ||
|
||
mod unhide_all_via_keyboard; | ||
pub use unhide_all_via_keyboard::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use specs::prelude::*; | ||
use crate::{ | ||
utilities::Key, | ||
resources::{ | ||
InputState, | ||
events::{GeometryAction, GeometryActionChannel}, | ||
}, | ||
}; | ||
|
||
pub struct UnhideAllViaKeyboard; | ||
|
||
impl<'a> System<'a> for UnhideAllViaKeyboard { | ||
type SystemData = ( | ||
Read<'a, InputState>, | ||
Write<'a, GeometryActionChannel>, | ||
); | ||
|
||
fn run(&mut self, (input_state, mut geometry_action_channel): Self::SystemData) { | ||
if input_state.keyboard.just_activated(Key::H) && input_state.keyboard.is_shift_activated() && input_state.keyboard.is_command_activated() { | ||
geometry_action_channel.single_write(GeometryAction::UnhideAll); | ||
} | ||
} | ||
} |