-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editor: work area tabs and package node selection
- Loading branch information
1 parent
9509401
commit 0080f5e
Showing
9 changed files
with
250 additions
and
59 deletions.
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,8 @@ | ||
use opensi_core::Package; | ||
|
||
pub fn package_tab(package: &mut Package, ui: &mut egui::Ui) { | ||
ui.vertical(|ui| { | ||
ui.label(&package.id); | ||
ui.label(package.name.clone().unwrap_or_default()); | ||
}); | ||
} |
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,7 @@ | ||
use opensi_core::Question; | ||
|
||
use crate::utils::todo_label; | ||
|
||
pub fn question_tab(_question: &mut Question, ui: &mut egui::Ui) { | ||
todo_label(ui); | ||
} |
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,7 @@ | ||
use opensi_core::Round; | ||
|
||
use crate::utils::todo_label; | ||
|
||
pub fn round_tab(_round: &mut Round, ui: &mut egui::Ui) { | ||
todo_label(ui); | ||
} |
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,7 @@ | ||
use opensi_core::Theme; | ||
|
||
use crate::utils::todo_label; | ||
|
||
pub fn theme_tab(_theme: &mut Theme, ui: &mut egui::Ui) { | ||
todo_label(ui); | ||
} |
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,36 @@ | ||
use std::{borrow::Cow, fmt::Display}; | ||
|
||
use opensi_core::{Package, PackageNode}; | ||
|
||
/// A generic error label. | ||
pub fn error_label(error: impl Display, ui: &mut egui::Ui) { | ||
let text = egui::RichText::new(error.to_string()).color(egui::Color32::RED).size(24.0); | ||
ui.add(egui::Label::new(text).selectable(true).wrap()); | ||
} | ||
|
||
/// A stub todo label. | ||
pub fn todo_label(ui: &mut egui::Ui) { | ||
let text = | ||
egui::RichText::new("TODO").background_color(egui::Color32::YELLOW).strong().size(24.0); | ||
ui.add(egui::Label::new(text).selectable(false).extend()); | ||
} | ||
|
||
/// Utility method to get a button name for a [`PackageNode`]. | ||
pub fn node_name<'a>(node: PackageNode, package: &'a Package) -> Cow<'a, str> { | ||
match node { | ||
PackageNode::Round { index } => package | ||
.get_round(index) | ||
.map(|round| round.name.as_str()) | ||
.unwrap_or("<Неизвестный раунд>") | ||
.into(), | ||
PackageNode::Theme { round_index, index } => package | ||
.get_theme(round_index, index) | ||
.map(|theme| theme.name.as_str()) | ||
.unwrap_or("<Неизвестная тема>") | ||
.into(), | ||
PackageNode::Question { round_index, theme_index, index } => package | ||
.get_question(round_index, theme_index, index) | ||
.map(|question| format!("🗛 ({})", question.price).into()) | ||
.unwrap_or("<Неизвестный вопрос>".into()), | ||
} | ||
} |
Oops, something went wrong.