-
-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 Fix launcher crash; gui refactor (#2320)
- Loading branch information
Showing
15 changed files
with
284 additions
and
299 deletions.
There are no files selected for viewing
This file was deleted.
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
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
4 changes: 2 additions & 2 deletions
4
...ashboard/basic_components/button_group.rs → ...mmon/src/basic_components/button_group.rs
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
2 changes: 2 additions & 0 deletions
2
...ard/src/dashboard/basic_components/mod.rs → alvr/gui_common/src/basic_components/mod.rs
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,7 +1,9 @@ | ||
mod button_group; | ||
mod modal; | ||
mod switch; | ||
mod tooltip; | ||
|
||
pub use button_group::*; | ||
pub use modal::*; | ||
pub use switch::*; | ||
pub use tooltip::*; |
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,56 @@ | ||
use egui::{Align, Align2, Context, Layout, Ui, Window}; | ||
use std::fmt::{self, Display, Formatter}; | ||
|
||
#[derive(Clone, PartialEq)] | ||
pub enum ModalButton { | ||
Ok, | ||
Cancel, | ||
Close, | ||
Custom(String), | ||
} | ||
|
||
impl Display for ModalButton { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
match self { | ||
ModalButton::Ok => write!(f, "OK"), | ||
ModalButton::Cancel => write!(f, "Cancel"), | ||
ModalButton::Close => write!(f, "Close"), | ||
ModalButton::Custom(text) => write!(f, "{}", text), | ||
} | ||
} | ||
} | ||
|
||
pub fn modal( | ||
context: &Context, | ||
title: &str, | ||
content: Option<impl FnOnce(&mut Ui)>, | ||
buttons: &[ModalButton], | ||
) -> Option<ModalButton> { | ||
let mut response = None; | ||
|
||
Window::new(title) | ||
.anchor(Align2::CENTER_CENTER, (0.0, 0.0)) | ||
.collapsible(false) | ||
.resizable(false) | ||
.show(context, |ui| { | ||
ui.vertical_centered_justified(|ui| { | ||
if let Some(content) = content { | ||
ui.add_space(10.0); | ||
content(ui); | ||
ui.add_space(10.0); | ||
} | ||
|
||
ui.columns(buttons.len(), |cols| { | ||
for (idx, response_type) in buttons.iter().enumerate() { | ||
cols[idx].with_layout(Layout::top_down_justified(Align::Center), |ui| { | ||
if ui.button(response_type.to_string()).clicked() { | ||
response = Some(response_type.clone()); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
response | ||
} |
2 changes: 1 addition & 1 deletion
2
.../src/dashboard/basic_components/switch.rs → ...gui_common/src/basic_components/switch.rs
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
2 changes: 1 addition & 1 deletion
2
...src/dashboard/basic_components/tooltip.rs → ...ui_common/src/basic_components/tooltip.rs
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 +1,32 @@ | ||
mod basic_components; | ||
pub mod theme; | ||
|
||
pub use basic_components::*; | ||
|
||
use std::{ops::Deref, sync::atomic::AtomicUsize}; | ||
|
||
pub fn get_id() -> usize { | ||
static NEXT_ID: AtomicUsize = AtomicUsize::new(0); | ||
|
||
NEXT_ID.fetch_add(1, std::sync::atomic::Ordering::Relaxed) | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct DisplayString { | ||
pub id: String, | ||
pub display: String, | ||
} | ||
|
||
impl From<(String, String)> for DisplayString { | ||
fn from((id, display): (String, String)) -> Self { | ||
Self { id, display } | ||
} | ||
} | ||
|
||
impl Deref for DisplayString { | ||
type Target = String; | ||
|
||
fn deref(&self) -> &String { | ||
&self.id | ||
} | ||
} |
Oops, something went wrong.