This commit is contained in:
Simon Gardling
2023-03-24 10:33:01 -04:00
parent 592a67a304
commit 3d1260ec5f
7 changed files with 35 additions and 52 deletions

View File

@@ -95,7 +95,7 @@ impl FunctionManager {
let mut movement: Movement = Movement::default();
let size_multiplier = vec2(1.0, {
let had_focus = ui.ctx().memory(|x| x.has_focus(te_id));
let had_focus = ui.memory(|x| x.has_focus(te_id));
(ui.ctx().animate_bool(te_id, had_focus) * 1.5) + 1.0
});
@@ -115,7 +115,7 @@ impl FunctionManager {
);
// Only keep valid chars
new_string.retain(|c| crate::misc::is_valid_char(c));
new_string.retain(crate::misc::is_valid_char);
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
let animate_bool = ui.ctx().animate_bool(te_id, re.has_focus());
@@ -136,13 +136,13 @@ impl FunctionManager {
}
// Put here so these key presses don't interact with other elements
let (enter_pressed, tab_pressed) = ui.input_mut(|x| {
(
x.consume_key(Modifiers::NONE, Key::Enter),
x.consume_key(Modifiers::NONE, Key::Tab),
)
let movement_complete_action = ui.input_mut(|x| {
x.consume_key(Modifiers::NONE, Key::Enter)
| x.consume_key(Modifiers::NONE, Key::Tab)
| x.key_pressed(Key::ArrowRight)
});
if enter_pressed | tab_pressed | ui.input(|x| x.key_pressed(Key::ArrowRight)) {
if movement_complete_action {
movement = Movement::Complete;
}

View File

@@ -27,7 +27,7 @@ mod widgets;
#[cfg(not(target_arch = "wasm32"))]
fn main() -> eframe::Result<()> {
let subscriber = tracing_subscriber::FmtSubscriber::builder()
.with_max_level(tracing::Level::TRACE)
.with_max_level(tracing::Level::INFO)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");

View File

@@ -1,15 +1,11 @@
use crate::{
consts::*,
function_entry::Riemann,
function_manager::FunctionManager,
misc::{option_vec_printer, HashBytesHelper},
consts::*, function_entry::Riemann, function_manager::FunctionManager, misc::option_vec_printer,
};
use eframe::App;
use egui::{
plot::Plot, style::Margin, Button, CentralPanel, ComboBox, Context, Frame, Key, Layout,
SidePanel, TopBottomPanel, Vec2, Window,
plot::Plot, style::Margin, Button, CentralPanel, Color32, ComboBox, Context, DragValue, Frame,
Key, Layout, SidePanel, TopBottomPanel, Ui, Vec2, Window,
};
use egui::{DragValue, Ui};
use emath::{Align, Align2};
use epaint::Rounding;
use instant::Instant;
@@ -558,6 +554,7 @@ impl App for MathApp {
inner_margin: Margin::symmetric(0.0, 0.0),
rounding: Rounding::none(),
// fill: crate::style::STYLE.window_fill(),
fill: Color32::from_gray(27),
..Frame::none()
})
.show(ctx, |ui| {

View File

@@ -127,23 +127,16 @@ pub fn newtons_method(
}
/// Inputs `Vec<Option<T>>` and outputs a `String` containing a pretty representation of the Vector
pub fn option_vec_printer<T: ToString>(data: &[Option<T>]) -> String
where
T: ToString,
{
[
"[",
&data
.iter()
.map(move |x| {
x.as_ref()
.map(|x_1| x_1.to_string())
.unwrap_or_else(|| "None".to_owned())
})
.join(", "),
"]",
]
.concat()
pub fn option_vec_printer<T: ToString>(data: &[Option<T>]) -> String {
let formatted: String = data
.into_iter()
.map(|item| match item {
Some(x) => x.to_string(),
None => "None".to_owned(),
})
.join(", ");
format!("[{}]", formatted)
}
/// Returns a vector of length `max_i` starting at value `min_x` with step of `step`