Use app_creation for common app setup functions
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
committed by
William Casarin
parent
a927c56870
commit
80b76c5381
10
src/app.rs
10
src/app.rs
@@ -1,7 +1,8 @@
|
|||||||
use crate::abbrev;
|
use crate::abbrev;
|
||||||
|
use crate::app_creation::setup_cc;
|
||||||
use crate::colors;
|
use crate::colors;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::fonts::{setup_fonts, NamedFontFamily};
|
use crate::fonts::NamedFontFamily;
|
||||||
use crate::frame_history::FrameHistory;
|
use crate::frame_history::FrameHistory;
|
||||||
use crate::images::fetch_img;
|
use crate::images::fetch_img;
|
||||||
use crate::imgcache::ImageCache;
|
use crate::imgcache::ImageCache;
|
||||||
@@ -441,12 +442,7 @@ impl Damus {
|
|||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
|
|
||||||
setup_fonts(&cc.egui_ctx);
|
setup_cc(cc);
|
||||||
|
|
||||||
cc.egui_ctx
|
|
||||||
.set_pixels_per_point(cc.egui_ctx.pixels_per_point() + 0.2);
|
|
||||||
|
|
||||||
egui_extras::install_image_loaders(&cc.egui_ctx);
|
|
||||||
|
|
||||||
let mut timelines: Vec<Timeline> = vec![];
|
let mut timelines: Vec<Timeline> = vec![];
|
||||||
let initial_limit = 100;
|
let initial_limit = 100;
|
||||||
|
|||||||
25
src/app_creation.rs
Normal file
25
src/app_creation.rs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#![warn(clippy::all, rust_2018_idioms)]
|
#![warn(clippy::all, rust_2018_idioms)]
|
||||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
||||||
use notedeck::Damus;
|
use notedeck::Damus;
|
||||||
|
use notedeck::app_creation::generate_native_options;
|
||||||
|
|
||||||
|
|
||||||
// Entry point for wasm
|
// Entry point for wasm
|
||||||
//#[cfg(target_arch = "wasm32")]
|
//#[cfg(target_arch = "wasm32")]
|
||||||
@@ -13,17 +15,9 @@ async fn main() {
|
|||||||
// Log to stdout (if you run with `RUST_LOG=debug`).
|
// Log to stdout (if you run with `RUST_LOG=debug`).
|
||||||
tracing_subscriber::fmt::init();
|
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(
|
let _res = eframe::run_native(
|
||||||
"Damus NoteDeck",
|
"Damus NoteDeck",
|
||||||
native_options,
|
generate_native_options(),
|
||||||
Box::new(|cc| Box::new(Damus::new(cc, ".", std::env::args().collect()))),
|
Box::new(|cc| Box::new(Damus::new(cc, ".", std::env::args().collect()))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ mod profile;
|
|||||||
mod key_parsing;
|
mod key_parsing;
|
||||||
mod login_manager;
|
mod login_manager;
|
||||||
mod account_login_view;
|
mod account_login_view;
|
||||||
|
mod app_creation;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|||||||
Reference in New Issue
Block a user