major cleanups
This commit is contained in:
parent
f8a1297857
commit
cce932400a
22
Cargo.lock
generated
22
Cargo.lock
generated
@ -242,13 +242,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.4.0"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1aca418a974d83d40a0c1f0c5cba6ff4bc28d8df099109ca459a2118d40b6322"
|
||||
checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 1.0.109",
|
||||
"syn 2.0.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -697,7 +697,7 @@ checksum = "0bd4b30a6560bbd9b4620f4de34c3f14f60848e58a9b7216801afcb4c7b31c3c"
|
||||
[[package]]
|
||||
name = "ecolor"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"serde",
|
||||
@ -706,7 +706,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.21.3"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@ -729,7 +729,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"accesskit",
|
||||
"ahash",
|
||||
@ -742,7 +742,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.21.1"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"android-activity",
|
||||
"arboard",
|
||||
@ -757,7 +757,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@ -777,7 +777,7 @@ checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"serde",
|
||||
@ -797,7 +797,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.21.0"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#638dd4c2a0da939d67d32bc87ae5bf9f32b4c947"
|
||||
source = "git+https://github.com/titaniumtown/egui.git#b1372da7e9343c12c8b1648c8c2b649ca9b3c96a"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"ahash",
|
||||
@ -844,7 +844,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "exmex"
|
||||
version = "0.17.0"
|
||||
source = "git+https://github.com/bertiqwerty/exmex.git?branch=main#cc02696cae7cae4688b918b51426540eb643b585"
|
||||
source = "git+https://github.com/bertiqwerty/exmex.git?branch=main#d30aec8c0f2d15a87f7ea2ba8a25ece1991e893f"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"num",
|
||||
|
||||
4
build.rs
4
build.rs
@ -13,8 +13,6 @@ use epaint::{
|
||||
|
||||
use run_script::ScriptOptions;
|
||||
|
||||
include!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/data.rs"));
|
||||
|
||||
include!(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/src/unicode_helper.rs"
|
||||
@ -146,7 +144,7 @@ fn main() {
|
||||
]),
|
||||
};
|
||||
|
||||
let data = bincode::serialize(&TotalData { fonts }).unwrap();
|
||||
let data = bincode::serialize(&fonts).unwrap();
|
||||
|
||||
let zstd_levels = zstd::compression_level_range();
|
||||
let data_compressed =
|
||||
|
||||
@ -14,6 +14,8 @@ pub const BUILD_INFO: &str = formatc!(
|
||||
&build::RUST_VERSION[6..],
|
||||
);
|
||||
|
||||
pub const FONT_SIZE: f32 = 14.0;
|
||||
|
||||
// Default values
|
||||
/// Default minimum X value to display
|
||||
pub const DEFAULT_MIN_X: f64 = -10.0;
|
||||
|
||||
@ -1,6 +0,0 @@
|
||||
pub const FONT_SIZE: f32 = 14.0;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, PartialEq)]
|
||||
pub struct TotalData {
|
||||
pub fonts: epaint::text::FontDefinitions,
|
||||
}
|
||||
@ -87,7 +87,7 @@ impl FunctionManager {
|
||||
|
||||
let available_width = ui.available_width();
|
||||
let mut remove_i: Option<usize> = None;
|
||||
let target_size = vec2(available_width, crate::data::FONT_SIZE);
|
||||
let target_size = vec2(available_width, crate::consts::FONT_SIZE);
|
||||
for (i, (te_id, function)) in self.functions.iter_mut().map(|(a, b)| (*a, b)).enumerate() {
|
||||
let mut new_string = function.autocomplete.string.clone();
|
||||
function.update_string(&new_string);
|
||||
@ -190,7 +190,7 @@ impl FunctionManager {
|
||||
|
||||
/// The y offset multiplier of the `buttons_area` area
|
||||
const BUTTONS_Y_OFFSET: f32 = 1.32;
|
||||
const Y_OFFSET: f32 = crate::data::FONT_SIZE * BUTTONS_Y_OFFSET;
|
||||
const Y_OFFSET: f32 = crate::consts::FONT_SIZE * BUTTONS_Y_OFFSET;
|
||||
|
||||
widgets_ontop(ui, create_id(i as u64), &re, Y_OFFSET, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
extern crate static_assertions;
|
||||
|
||||
mod consts;
|
||||
mod data;
|
||||
mod function_entry;
|
||||
mod function_manager;
|
||||
mod math_app;
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
extern crate static_assertions;
|
||||
|
||||
mod consts;
|
||||
mod data;
|
||||
mod function_entry;
|
||||
mod function_manager;
|
||||
mod math_app;
|
||||
|
||||
@ -191,7 +191,7 @@ impl MathApp {
|
||||
}
|
||||
}
|
||||
|
||||
fn decompress_data() -> crate::data::TotalData {
|
||||
fn decompress_fonts() -> epaint::text::FontDefinitions {
|
||||
let mut data = Vec::new();
|
||||
let _ = ruzstd::StreamingDecoder::new(
|
||||
&mut const { include_bytes!(concat!(env!("OUT_DIR"), "/compressed_data")).as_slice() },
|
||||
@ -224,23 +224,23 @@ impl MathApp {
|
||||
bincode::deserialize(data.as_slice()).expect("unable to deserialize bincode")
|
||||
}
|
||||
|
||||
#[cfg(target = "wasm32")]
|
||||
let data: crate::data::TotalData = if let Some(Ok(data)) =
|
||||
get_storage_decompressed().map(|data| bincode::deserialize(data.as_slice()))
|
||||
{
|
||||
data
|
||||
} else {
|
||||
decompress_data()
|
||||
};
|
||||
|
||||
#[cfg(not(target = "wasm32"))]
|
||||
let data: crate::data::TotalData = decompress_data();
|
||||
|
||||
tracing::info!("Reading assets...");
|
||||
tracing::info!("Reading fonts...");
|
||||
|
||||
// Initialize fonts
|
||||
// This used to be in the `update` method, but (after a ton of digging) this actually caused OOMs. that was a pain to debug
|
||||
cc.egui_ctx.set_fonts(data.fonts);
|
||||
cc.egui_ctx.set_fonts({
|
||||
#[cfg(target = "wasm32")]
|
||||
if let Some(Ok(data)) =
|
||||
get_storage_decompressed().map(|data| bincode::deserialize(data.as_slice()))
|
||||
{
|
||||
data
|
||||
} else {
|
||||
decompress_fonts()
|
||||
}
|
||||
|
||||
#[cfg(not(target = "wasm32"))]
|
||||
decompress_fonts()
|
||||
});
|
||||
|
||||
// Set dark mode by default
|
||||
// cc.egui_ctx.set_visuals(crate::style::style());
|
||||
@ -395,7 +395,7 @@ impl MathApp {
|
||||
}
|
||||
|
||||
// Only render if there's enough space
|
||||
if ui.available_height() > crate::data::FONT_SIZE {
|
||||
if ui.available_height() > crate::consts::FONT_SIZE {
|
||||
ui.with_layout(Layout::bottom_up(Align::Min), |ui| {
|
||||
// Contents put in reverse order from bottom to top due to the 'buttom_up' layout
|
||||
|
||||
@ -591,9 +591,11 @@ impl App for MathApp {
|
||||
.data_aspect(1.0)
|
||||
.include_y(0)
|
||||
.show(ui, |plot_ui| {
|
||||
let bounds = plot_ui.plot_bounds();
|
||||
let min_x: f64 = bounds.min()[0];
|
||||
let max_x: f64 = bounds.max()[0];
|
||||
let (min_x, max_x): (f64, f64) = {
|
||||
let bounds = plot_ui.plot_bounds();
|
||||
(bounds.min()[0], bounds.max()[0])
|
||||
};
|
||||
|
||||
let min_max_changed =
|
||||
(min_x != self.settings.min_x) | (max_x != self.settings.max_x);
|
||||
let did_zoom = (max_x - min_x).abs()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user