feat(icon): make a somewhat fancy custom icon
cargo devel CI / cargo CI (push) Has been cancelled
Details
|
@ -25,3 +25,4 @@ env_logger = "0.10"
|
||||||
serde = "1.0.207"
|
serde = "1.0.207"
|
||||||
libpt = { version = "0.6.0", features = ["cli"] }
|
libpt = { version = "0.6.0", features = ["cli"] }
|
||||||
clap = { version = "4.5.15", features = ["derive"] }
|
clap = { version = "4.5.15", features = ["derive"] }
|
||||||
|
image = "0.25.2"
|
||||||
|
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 422 KiB |
Before Width: | Height: | Size: 314 KiB |
After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 21 KiB |
|
@ -1,21 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "egui Template PWA",
|
"name": "Rollator PWA",
|
||||||
"short_name": "egui-template-pwa",
|
"short_name": "rollator-pwa",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "./icon-256.png",
|
"src": "./icon-256.jpg",
|
||||||
"sizes": "256x256",
|
"sizes": "256x256",
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "./maskable_icon_x512.png",
|
"src": "./icon-512.jpg",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png",
|
|
||||||
"purpose": "any maskable"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "./icon-1024.png",
|
|
||||||
"sizes": "1024x1024",
|
|
||||||
"type": "image/png"
|
"type": "image/png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Before Width: | Height: | Size: 128 KiB |
19
src/app.rs
|
@ -1,4 +1,5 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use egui::IconData;
|
||||||
use libpt::cli::args::HELP_TEMPLATE;
|
use libpt::cli::args::HELP_TEMPLATE;
|
||||||
|
|
||||||
pub const TITLE: &str = "Rollator";
|
pub const TITLE: &str = "Rollator";
|
||||||
|
@ -120,3 +121,21 @@ fn bottom_label(ui: &mut egui::Ui) {
|
||||||
ui.label(".");
|
ui.label(".");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn load_icon() -> IconData {
|
||||||
|
const ICON_RAW: &[u8; 27618] = include_bytes!("../assets/icon-512.jpg");
|
||||||
|
let (icon_rgba, icon_width, icon_height) = {
|
||||||
|
let image = image::load_from_memory(ICON_RAW)
|
||||||
|
.expect("Failed to open icon path")
|
||||||
|
.into_rgba8();
|
||||||
|
let (width, height) = image.dimensions();
|
||||||
|
let rgba = image.into_raw();
|
||||||
|
(rgba, width, height)
|
||||||
|
};
|
||||||
|
|
||||||
|
IconData {
|
||||||
|
rgba: icon_rgba,
|
||||||
|
width: icon_width,
|
||||||
|
height: icon_height,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -8,15 +8,12 @@ mod app;
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
||||||
|
|
||||||
|
let icon = app::load_icon();
|
||||||
let native_options = eframe::NativeOptions {
|
let native_options = eframe::NativeOptions {
|
||||||
viewport: egui::ViewportBuilder::default()
|
viewport: egui::ViewportBuilder::default()
|
||||||
.with_inner_size([400.0, 300.0])
|
.with_inner_size([400.0, 300.0])
|
||||||
.with_min_inner_size([300.0, 220.0])
|
.with_min_inner_size([300.0, 220.0])
|
||||||
.with_icon(
|
.with_icon(icon),
|
||||||
// NOTE: Adding an icon is optional
|
|
||||||
eframe::icon_data::from_png_bytes(&include_bytes!("../assets/icon-256.png")[..])
|
|
||||||
.expect("Failed to load icon"),
|
|
||||||
),
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
|
|