feat(player): show some image

This commit is contained in:
Christoph J. Scherr 2024-08-23 01:00:52 +02:00
parent b4667faf5d
commit 66f70eea52
4 changed files with 23 additions and 8 deletions

View File

@ -23,7 +23,11 @@ eframe = { version = "0.28.1", optional = false }
egui = { version = "0.28.1", optional = false }
egui_extras = { version = "0.28.1", features = ["image"] }
human-panic = "2.0.1"
image = "0.25.2"
image = { version = "0.25.2", default-features = true, features = [
"jpeg",
"png",
] }
libpt = { version = "0.6.0", features = ["cli", "full"] }
thiserror = "1.0.63"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

View File

@ -46,8 +46,8 @@ impl Player {
app.gui_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([400.0, 300.0])
.with_min_inner_size([300.0, 220.0])
.with_inner_size([900.0, 700.0])
.with_min_inner_size([500.0, 320.0])
.with_icon(Player::load_icon()),
..Default::default()
};

View File

@ -1,4 +1,4 @@
use egui::{IconData, ScrollArea};
use egui::{include_image, IconData, ScrollArea};
use egui_extras::{Column, Table, TableBuilder};
use libpt::log::trace;
@ -161,6 +161,8 @@ impl Player {
impl eframe::App for Player {
/// Called each time the UI needs repainting, which may be many times per second.
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui_extras::install_image_loaders(ctx); // apperently it's okay to have this every update
// as it's only done once? sus
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
self.top_panel(ui, ctx);
});

View File

@ -1,6 +1,6 @@
use egui::Color32;
use egui::{Color32, ImageSource};
use super::Entry;
use super::{Entry, ICON_RAW};
pub struct ShowBox {
entry: Entry,
@ -19,7 +19,16 @@ impl ShowBox {
impl egui::Widget for ShowBox {
fn ui(mut self, ui: &mut egui::Ui) -> egui::Response {
ui.vertical_centered(|ui| ui.button("i dont get it").union(ui.label("caption")))
ui.vertical_centered(|ui| {
ui.add(
egui::Image::new(ImageSource::Bytes {
uri: std::borrow::Cow::Borrowed("fuck you"),
bytes: egui::load::Bytes::Static(ICON_RAW),
})
.rounding(5.0),
);
ui.button("i dont get it").union(ui.label("caption"))
})
.response
}
}