notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 80b76c5381e22d4e98e77207c949269ee735168e
parent a927c56870fa898944561b8b75bdee25d038ae81
Author: kernelkind <kernelkind@gmail.com>
Date:   Mon,  1 Apr 2024 11:04:49 -0400

Use app_creation for common app setup functions

Signed-off-by: kernelkind <kernelkind@gmail.com>

Diffstat:
Msrc/app.rs | 10+++-------
Asrc/app_creation.rs | 25+++++++++++++++++++++++++
Msrc/bin/notedeck.rs | 12+++---------
Msrc/lib.rs | 1+
4 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/src/app.rs b/src/app.rs @@ -1,7 +1,8 @@ use crate::abbrev; +use crate::app_creation::setup_cc; use crate::colors; use crate::error::Error; -use crate::fonts::{setup_fonts, NamedFontFamily}; +use crate::fonts::NamedFontFamily; use crate::frame_history::FrameHistory; use crate::images::fetch_img; use crate::imgcache::ImageCache; @@ -441,12 +442,7 @@ impl Damus { //} // - setup_fonts(&cc.egui_ctx); - - cc.egui_ctx - .set_pixels_per_point(cc.egui_ctx.pixels_per_point() + 0.2); - - egui_extras::install_image_loaders(&cc.egui_ctx); + setup_cc(cc); let mut timelines: Vec<Timeline> = vec![]; let initial_limit = 100; diff --git a/src/app_creation.rs b/src/app_creation.rs @@ -0,0 +1,25 @@ +use crate::fonts::setup_fonts; +use eframe::NativeOptions; + +pub const UI_SCALE_FACTOR: f32 = 0.2; + +pub fn generate_native_options() -> NativeOptions { + let window_builder = Box::new(|builder: egui::ViewportBuilder| { + builder + .with_fullsize_content_view(true) + .with_titlebar_shown(false) + .with_title_shown(false) + }); + let mut native_options = eframe::NativeOptions::default(); + native_options.window_builder = Some(window_builder); + native_options +} + +pub fn setup_cc(cc: &eframe::CreationContext<'_>) { + setup_fonts(&cc.egui_ctx); + + cc.egui_ctx + .set_pixels_per_point(cc.egui_ctx.pixels_per_point() + UI_SCALE_FACTOR); + + egui_extras::install_image_loaders(&cc.egui_ctx); +} diff --git a/src/bin/notedeck.rs b/src/bin/notedeck.rs @@ -1,6 +1,8 @@ #![warn(clippy::all, rust_2018_idioms)] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release use notedeck::Damus; +use notedeck::app_creation::generate_native_options; + // Entry point for wasm //#[cfg(target_arch = "wasm32")] @@ -13,17 +15,9 @@ async fn main() { // Log to stdout (if you run with `RUST_LOG=debug`). tracing_subscriber::fmt::init(); - let window_builder = Box::new(|builder: egui::ViewportBuilder| { - builder.with_fullsize_content_view(true) - .with_titlebar_shown(false) - .with_title_shown(false) - }); - let mut native_options = eframe::NativeOptions::default(); - native_options.window_builder = Some(window_builder); - let _res = eframe::run_native( "Damus NoteDeck", - native_options, + generate_native_options(), Box::new(|cc| Box::new(Damus::new(cc, ".", std::env::args().collect()))), ); } diff --git a/src/lib.rs b/src/lib.rs @@ -21,6 +21,7 @@ mod profile; mod key_parsing; mod login_manager; mod account_login_view; +mod app_creation; #[cfg(test)] #[macro_use]