-
Notifications
You must be signed in to change notification settings - Fork 55
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
26 changed files
with
418 additions
and
573 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod completion_edit; | ||
mod nao_path_completion_edit; | ||
mod segmented_control; | ||
|
||
pub use completion_edit::CompletionEdit; | ||
pub use nao_path_completion_edit::{NaoPathCompletionEdit, PathFilter}; | ||
pub use segmented_control::SegmentedControl; |
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,53 @@ | ||
use crate::CompletionEdit; | ||
|
||
use communication::client::PathsEvent; | ||
use egui::{Id, Response, Ui, Widget}; | ||
|
||
pub enum PathFilter { | ||
Readable, | ||
Writable, | ||
} | ||
|
||
pub struct NaoPathCompletionEdit<'ui> { | ||
id: Id, | ||
paths_events: PathsEvent, | ||
path: &'ui mut String, | ||
filter: PathFilter, | ||
} | ||
|
||
impl<'ui> NaoPathCompletionEdit<'ui> { | ||
pub fn new( | ||
id_salt: impl Into<Id>, | ||
paths_events: PathsEvent, | ||
path: &'ui mut String, | ||
filter: PathFilter, | ||
) -> Self { | ||
Self { | ||
id: id_salt.into(), | ||
paths_events, | ||
path, | ||
filter, | ||
} | ||
} | ||
|
||
fn list_paths(&self) -> Vec<String> { | ||
match self.paths_events.as_ref() { | ||
Some(Ok(paths)) => paths | ||
.iter() | ||
.filter_map(|(path, entry)| match self.filter { | ||
PathFilter::Readable if entry.is_readable => Some(path.clone()), | ||
PathFilter::Writable if entry.is_writable => Some(path.clone()), | ||
_ => None, | ||
}) | ||
.collect(), | ||
_ => Vec::new(), | ||
} | ||
} | ||
} | ||
|
||
impl<'ui> Widget for NaoPathCompletionEdit<'ui> { | ||
fn ui(self, ui: &mut Ui) -> Response { | ||
let paths = self.list_paths(); | ||
ui.add(CompletionEdit::new(self.id, &paths, self.path)) | ||
} | ||
} |
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
Oops, something went wrong.