Skip to content

Commit

Permalink
rle byte controls
Browse files Browse the repository at this point in the history
  • Loading branch information
SymmetricChaos committed Nov 22, 2024
1 parent db14510 commit 7a02c81
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 52 deletions.
1 change: 1 addition & 0 deletions src/code_panel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ mod pgp_controls;
mod primoral_controls;
mod punycode_controls;
mod repetition_controls;
mod rle_byte_controls;
mod rle_controls;
mod romaji_controls;
mod roman_numeral_controls;
Expand Down
61 changes: 13 additions & 48 deletions src/code_panel/rle_byte_controls.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use crate::ui_elements::UiElements;

use super::CodeFrame;
use codes::compression::{run_length::RunLengthEncoding, run_length_bytes::RunLengthEncodingBytes};
use crate::ui_elements::UiElements;
use codes::compression::run_length_bytes::{RleMethod, RunLengthEncodingBytes};

pub struct RleFrame {
byte_code: RunLengthEncodingBytes,
code: RunLengthEncodingBytes,
}

impl Default for RleFrame {
fn default() -> Self {
Self {
byte_code: Default::default(),
code: Default::default(),
}
}
}
Expand All @@ -22,54 +21,20 @@ impl CodeFrame for RleFrame {
"https://github.com/SymmetricChaos/crypto-gui/blob/master/codes/src/compression/run_length_bytes.rs",
);

ui.group(|ui| {
ui.subheading("Mode");
ui.horizontal(|ui| {
ui.selectable_value(&mut self.code.method, RleMethod::OneByte, "One Byte");
ui.selectable_value(&mut self.code.method, RleMethod::Leb128, "LEB128");
});
});

// {
// let this = &mut *ui;
// let mut changed = false;
// egui::CollapsingHeader::new("Input Format")
// .default_open(true)
// .show(this, |ui| {
// ui.label(
// "Input can be text, hexadecimal, Base64, or binary. All interpreted as bytes.",
// );
// ui.horizontal(|ui| {
// for variant in ByteFormat::iter() {
// if ui
// .selectable_value(&mut self.byte_code., variant, variant.to_string())
// .clicked()
// {
// changed = true;
// }
// }
// });
// });

// this.add_space(8.0);

// egui::CollapsingHeader::new("Output Format")
// .default_open(true)
// .show(this, |ui| {
// ui.label(
// "Output can be text, hexadecimal, Base64, or binary. All interpreted as bytes.",
// );
// ui.horizontal(|ui| {
// for variant in ByteFormat::iter() {
// if ui
// .selectable_value(output, variant, variant.to_string())
// .clicked()
// {
// changed = true;
// }
// }
// });
// });
// changed
// };
ui.byte_io_mode_cipher(&mut self.code.input_format, &mut self.code.output_format);

ui.add_space(16.0);
}

fn code(&self) -> &dyn codes::traits::Code {
&self.text_code
&self.code
}
}
6 changes: 2 additions & 4 deletions src/code_panel/rle_controls.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use crate::ui_elements::UiElements;

use super::CodeFrame;
use codes::compression::{run_length::RunLengthEncoding, run_length_bytes::RunLengthEncodingBytes};
use codes::compression::run_length::RunLengthEncoding;

pub struct RleFrame {
text_code: RunLengthEncoding,
Expand All @@ -20,7 +18,7 @@ impl CodeFrame for RleFrame {
ui.hyperlink_to(
"see the code",
"https://github.com/SymmetricChaos/crypto-gui/blob/master/codes/src/compression/run_length.rs",
);
);
ui.add_space(16.0);
}

Expand Down

0 comments on commit 7a02c81

Please sign in to comment.