change name and work on gui

This commit is contained in:
2025-04-12 18:27:22 +02:00
parent 258bdecc05
commit 129c51791e
6 changed files with 36 additions and 32 deletions

View File

@@ -1,14 +1,12 @@
use eframe::egui;
pub struct Omelt {
name: String,
age: u32,
text: String,
}
impl Default for Omelt {
fn default() -> Self {
Self {
name: "Arthur".to_owned(),
age: 42,
text: "Test of text.".to_owned(),
}
}
}
@@ -16,17 +14,11 @@ impl Default for Omelt {
impl eframe::App for Omelt {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.horizontal(|ui| {
let name_label = ui.label("Your name: ");
ui.text_edit_singleline(&mut self.name)
.labelled_by(name_label.id);
});
ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age"));
if ui.button("Increment").clicked() {
self.age += 1;
}
ui.label(format!("Hello '{}', age {}", self.name, self.age));
ui.heading("Omelt");
ui.add_sized(
ui.available_size(),
egui::TextEdit::multiline(&mut self.text).code_editor(),
);
});
}
}

View File

@@ -51,6 +51,7 @@ fn main() -> std::io::Result<()> {
after_compression.write_all(string.as_bytes())?;
to_compress.seek(SeekFrom::Start(0))?;
let map = tree_to_map(&mut tree, true);
eprintln!("map = {:?}", map);
let trad = body_to_bin(&mut to_compress, map);
let trad_bin = string_to_binary(&trad);
let len_body = trad.len() as u32;
@@ -69,7 +70,7 @@ fn main() -> std::io::Result<()> {
let mut to_print = File::open(f)?;
if is_valid_file(&mut to_print) {
let untranslate = string_translate(&mut to_print);
eprintln!("untranslate = {}", untranslate);
println!("{}", untranslate);
} else {
println!("Error oppening file, check type file !")
}
@@ -110,16 +111,14 @@ fn main() -> std::io::Result<()> {
}
None => {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
viewport: egui::ViewportBuilder::default().with_inner_size([640.0, 480.0]),
..Default::default()
};
let _ = eframe::run_native(
"My egui App",
"Omelt",
options,
Box::new(|cc| {
Box::new(|_| {
// This gives us image support:
egui_extras::install_image_loaders(&cc.egui_ctx);
Ok(Box::<Omelt>::default())
}),
);

View File

@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::collections::VecDeque;
use std::fmt;
pub struct Node {
pub val: Option<char>,
@@ -8,6 +9,15 @@ pub struct Node {
pub n: i32,
pub path: String,
}
impl fmt::Debug for Node {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Node")
.field("Val", &self.val)
.field("n", &self.n)
.field("path", &self.path)
.finish()
}
}
impl PartialEq for Node {
fn eq(&self, other: &Self) -> bool {
self.n == other.n
@@ -91,7 +101,9 @@ pub fn create_tree(mut nodes: Vec<Node>) -> Node {
new_root.insert(l, r);
//nodes.push(new_root);
match nodes.binary_search(&new_root) {
Ok(_) => {}
Ok(pos) => {
nodes.insert(pos, new_root);
}
Err(pos) => {
nodes.insert(pos, new_root);
}