serialize RichText instead
This commit is contained in:
31
src/data.rs
31
src/data.rs
@@ -1,5 +1,16 @@
|
||||
#[derive(PartialEq, Debug, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct TextData {
|
||||
pub help_expr: egui::RichText,
|
||||
pub help_vars: egui::RichText,
|
||||
pub help_panel: egui::RichText,
|
||||
pub help_function: egui::RichText,
|
||||
pub help_other: egui::RichText,
|
||||
pub license_info: egui::RichText,
|
||||
pub welcome: egui::RichText,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct TextDataRaw {
|
||||
pub help_expr: String,
|
||||
pub help_vars: String,
|
||||
pub help_panel: String,
|
||||
@@ -9,7 +20,23 @@ pub struct TextData {
|
||||
pub welcome: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, PartialEq, Debug)]
|
||||
impl TextDataRaw {
|
||||
#[allow(dead_code)]
|
||||
fn into_rich(self) -> TextData {
|
||||
use egui::RichText;
|
||||
TextData {
|
||||
help_expr: RichText::from(self.help_expr),
|
||||
help_vars: RichText::from(self.help_vars),
|
||||
help_panel: RichText::from(self.help_panel),
|
||||
help_function: RichText::from(self.help_function),
|
||||
help_other: RichText::from(self.help_other),
|
||||
license_info: RichText::from(self.license_info),
|
||||
welcome: RichText::from(self.welcome).size(16.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, PartialEq)]
|
||||
pub struct TotalData {
|
||||
pub text: TextData,
|
||||
pub fonts: epaint::text::FontDefinitions,
|
||||
|
||||
@@ -5,8 +5,8 @@ use crate::function_manager::FunctionManager;
|
||||
use crate::misc::{dyn_mut_iter, option_vec_printer};
|
||||
use eframe::App;
|
||||
use egui::{
|
||||
plot::Plot, style::Margin, vec2, Button, CentralPanel, Color32, ComboBox, Context, Frame, Key,
|
||||
Label, Layout, RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
||||
plot::Plot, style::Margin, Button, CentralPanel, Color32, ComboBox, Context, Frame, Key, Label,
|
||||
Layout, RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
||||
};
|
||||
use emath::{Align, Align2};
|
||||
use epaint::Rounding;
|
||||
@@ -367,7 +367,7 @@ impl MathApp {
|
||||
ui.add(Label::new(
|
||||
RichText::new("(and licensed under AGPLv3)").color(Color32::LIGHT_GRAY),
|
||||
))
|
||||
.on_hover_text(&self.text.license_info);
|
||||
.on_hover_text(self.text.license_info.clone());
|
||||
|
||||
// Hyperlink to project's github
|
||||
ui.hyperlink_to(
|
||||
@@ -477,34 +477,34 @@ impl App for MathApp {
|
||||
.collapsible(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.collapsing("Supported Expressions", |ui| {
|
||||
ui.label(&self.text.help_expr);
|
||||
ui.label(self.text.help_expr.clone());
|
||||
});
|
||||
|
||||
ui.collapsing("Supported Constants", |ui| {
|
||||
ui.label(&self.text.help_vars);
|
||||
ui.label(self.text.help_vars.clone());
|
||||
});
|
||||
|
||||
ui.collapsing("Panel", |ui| {
|
||||
ui.label(&self.text.help_panel);
|
||||
ui.label(self.text.help_panel.clone());
|
||||
});
|
||||
|
||||
ui.collapsing("Functions", |ui| {
|
||||
ui.label(&self.text.help_function);
|
||||
ui.label(self.text.help_function.clone());
|
||||
});
|
||||
|
||||
ui.collapsing("Other", |ui| {
|
||||
ui.label(&self.text.help_other);
|
||||
ui.label(self.text.help_other.clone());
|
||||
});
|
||||
});
|
||||
|
||||
// Welcome window
|
||||
Window::new("Welcome!")
|
||||
.open(&mut self.opened.welcome)
|
||||
.anchor(Align2::CENTER_CENTER, vec2(0.0, 0.0))
|
||||
.anchor(Align2::CENTER_CENTER, Vec2::ZERO)
|
||||
.resizable(false)
|
||||
.collapsible(false)
|
||||
.show(ctx, |ui| {
|
||||
ui.label(&self.text.welcome);
|
||||
ui.label(self.text.welcome.clone());
|
||||
});
|
||||
|
||||
// Window with information about the build and current commit
|
||||
|
||||
Reference in New Issue
Block a user