feat(app_images): add module to manage static app image assets

This commit is contained in:
Fernando López Guevara
2025-06-04 19:52:04 -03:00
committed by William Casarin
parent 48f17f91b8
commit 36667bc024
19 changed files with 358 additions and 160 deletions

View File

@@ -3,6 +3,7 @@ use crate::{fonts, theme};
use eframe::NativeOptions;
use egui::ThemePreference;
use notedeck::{AppSizeHandler, DataPath};
use notedeck_ui::app_images;
use tracing::info;
pub fn setup_chrome(ctx: &egui::Context, args: &notedeck::Args, theme: ThemePreference) {
@@ -53,9 +54,7 @@ pub fn generate_native_options(paths: DataPath) -> NativeOptions {
.with_fullsize_content_view(true)
.with_titlebar_shown(false)
.with_title_shown(false)
.with_icon(std::sync::Arc::new(
eframe::icon_data::from_png_bytes(app_icon()).expect("icon"),
));
.with_icon(std::sync::Arc::new(app_images::app_icon()));
if let Some(window_size) = AppSizeHandler::new(&paths).get_app_size() {
builder.with_inner_size(window_size)
@@ -68,9 +67,8 @@ pub fn generate_native_options(paths: DataPath) -> NativeOptions {
// for 3d widgets
depth_buffer: 24,
window_builder: Some(window_builder),
viewport: egui::ViewportBuilder::default().with_icon(std::sync::Arc::new(
eframe::icon_data::from_png_bytes(app_icon()).expect("icon"),
)),
viewport: egui::ViewportBuilder::default()
.with_icon(std::sync::Arc::new(app_images::app_icon())),
..Default::default()
}
}
@@ -89,10 +87,6 @@ fn generate_native_options_with_builder_modifiers(
}
}
pub fn app_icon() -> &'static [u8; 271986] {
std::include_bytes!("../../../assets/damus-app-icon.png")
}
pub fn generate_mobile_emulator_native_options() -> eframe::NativeOptions {
generate_native_options_with_builder_modifiers(|builder| {
builder
@@ -100,6 +94,6 @@ pub fn generate_mobile_emulator_native_options() -> eframe::NativeOptions {
.with_titlebar_shown(false)
.with_title_shown(false)
.with_inner_size([405.0, 915.0])
.with_icon(eframe::icon_data::from_png_bytes(app_icon()).expect("icon"))
.with_icon(app_images::app_icon())
})
}