Updated eframe to fix cargo audit issues
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Sebastian 2022-06-15 20:43:37 +02:00
parent 1f8249dead
commit a26ff950c1
5 changed files with 693 additions and 538 deletions

View File

@ -1,4 +1,9 @@
pipeline:
audit:
image: dbrgn/cargo-audit
commands:
- cargo audit
build:
image: rust:bullseye
commands:

1165
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ clap = {version = "3.1.8", features = ["cargo"]}
indicatif = "0.16.2"
hound = "3.4.0"
image = "0.24.0"
eframe = {version = "0.16.0", optional = true}
eframe = {version = "0.18.0", optional = true}
rfd = "0.7.0"
thiserror = "1.0.30"

View File

@ -76,18 +76,24 @@ fn main() {
.value_of_os("wavfile")
.expect("No input file given")
.to_str()
.unwrap();
.unwrap()
.to_string();
let output_file = matches
.value_of_os("pngfile")
.expect("No output file given")
.to_str()
.unwrap();
.unwrap()
.to_string();
if matches.is_present("nogui") {
cli::decode(input_file, output_file);
cli::decode(&input_file, &output_file);
} else {
let app = DecoderApp::new(input_file, output_file);
let native_options = eframe::NativeOptions::default();
eframe::run_native(Box::new(app), native_options);
eframe::run_native(
"APT-Decoder",
native_options,
Box::new(move |_cc| Box::new(DecoderApp::new(&input_file, &output_file))),
);
}
}

View File

@ -1,9 +1,11 @@
use std::sync::{Arc, Mutex};
use eframe::egui;
use eframe::egui::text_edit::TextEdit;
use eframe::egui::widgets::{Button, ProgressBar};
use eframe::egui::ColorImage;
use eframe::egui::Visuals;
use eframe::egui::{Color32, RichText};
use eframe::{egui, epi};
use decoder;
use errors::DecoderError;
@ -18,7 +20,7 @@ enum DecoderRunState {
struct DecoderJobState {
update_steps: u32,
progress: f32,
texture: Option<egui::TextureId>,
texture: Option<egui::TextureHandle>,
run_state: DecoderRunState,
error: Option<DecoderError>,
}
@ -57,23 +59,10 @@ impl DecoderApp {
}
}
impl epi::App for DecoderApp {
fn name(&self) -> &str {
"APT Decoder"
}
/// Called once before the first frame.
fn setup(
&mut self,
_ctx: &egui::CtxRef,
_frame: &epi::Frame,
_storage: Option<&dyn epi::Storage>,
) {
}
impl eframe::App for DecoderApp {
/// Called each time the UI needs repainting, which may be many times per second.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
fn update(&mut self, ctx: &egui::CtxRef, frame: &epi::Frame) {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let Self {
input_path,
output_path,
@ -89,6 +78,7 @@ impl epi::App for DecoderApp {
}
}
ctx.set_visuals(Visuals::dark());
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("APT-Decoder");
@ -130,16 +120,13 @@ impl epi::App for DecoderApp {
.add_enabled(!state.is_running(), Button::new("Decode"))
.clicked()
{
let frame = frame.clone();
let ctx = ctx.clone();
let decoding_state = decoding_state.clone();
let input_path = input_path.clone();
let output_path = output_path.clone();
state.error = None;
state.run_state = DecoderRunState::RUNNING;
if let Some(old_texture) = state.texture {
frame.free_texture(old_texture);
}
state.texture = None;
std::thread::spawn(move || {
@ -150,17 +137,15 @@ impl epi::App for DecoderApp {
state.progress = progress;
let size = [image.width() as _, image.height() as _];
let epi_img = epi::Image::from_rgba_unmultiplied(
let color_img = ColorImage::from_rgba_unmultiplied(
size,
image.as_flat_samples().as_slice(),
);
if let Some(old_texture) = state.texture {
frame.free_texture(old_texture);
}
state.texture = Some(frame.alloc_texture(epi_img));
state.texture =
Some(ctx.load_texture("decoded-image", color_img));
frame.request_repaint();
ctx.request_repaint();
return (state.is_running(), state.update_steps);
});
@ -172,7 +157,7 @@ impl epi::App for DecoderApp {
_ => None,
};
frame.request_repaint();
ctx.request_repaint();
});
}
if ui
@ -199,7 +184,7 @@ impl epi::App for DecoderApp {
let image_size = ui.available_size();
state.update_steps = image_size[1] as u32;
if let Some(texture) = state.texture {
if let Some(texture) = &state.texture {
ui.image(texture, image_size);
}
});