Introducing Damus Notedeck: a nostr browser
This splits notedeck into: - notedeck - notedeck_chrome - notedeck_columns The `notedeck` crate is the library that `notedeck_chrome` and `notedeck_columns`, use. It contains common functionality related to notedeck apps such as the NoteCache, ImageCache, etc. The `notedeck_chrome` crate is the binary and ui chrome. It is responsible for managing themes, user accounts, signing, data paths, nostrdb, image caches etc. It will eventually have its own ui which has yet to be determined. For now it just manages the browser data, which is passed to apps via a new struct called `AppContext`. `notedeck_columns` is our columns app, with less responsibility now that more things are handled by `notedeck_chrome` There is still much work left to do before this is a proper browser: - process isolation - sandboxing - etc This is the beginning of a new era! We're just getting started. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
79
crates/notedeck_chrome/src/setup.rs
Normal file
79
crates/notedeck_chrome/src/setup.rs
Normal file
@@ -0,0 +1,79 @@
|
||||
use crate::{app_size::AppSizeHandler, fonts, theme};
|
||||
|
||||
use eframe::NativeOptions;
|
||||
use notedeck::DataPath;
|
||||
|
||||
pub fn setup_cc(ctx: &egui::Context, is_mobile: bool, light: bool) {
|
||||
fonts::setup_fonts(ctx);
|
||||
|
||||
//ctx.set_pixels_per_point(ctx.pixels_per_point() + UI_SCALE_FACTOR);
|
||||
//ctx.set_pixels_per_point(1.0);
|
||||
//
|
||||
//
|
||||
//ctx.tessellation_options_mut(|to| to.feathering = false);
|
||||
|
||||
egui_extras::install_image_loaders(ctx);
|
||||
|
||||
if light {
|
||||
ctx.set_visuals(theme::light_mode())
|
||||
} else {
|
||||
ctx.set_visuals(theme::dark_mode(is_mobile));
|
||||
}
|
||||
|
||||
ctx.all_styles_mut(|style| theme::add_custom_style(is_mobile, style));
|
||||
}
|
||||
|
||||
//pub const UI_SCALE_FACTOR: f32 = 0.2;
|
||||
|
||||
pub fn generate_native_options(paths: DataPath) -> NativeOptions {
|
||||
let window_builder = Box::new(move |builder: egui::ViewportBuilder| {
|
||||
let builder = builder
|
||||
.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"),
|
||||
));
|
||||
|
||||
if let Some(window_size) = AppSizeHandler::new(&paths).get_app_size() {
|
||||
builder.with_inner_size(window_size)
|
||||
} else {
|
||||
builder
|
||||
}
|
||||
});
|
||||
|
||||
eframe::NativeOptions {
|
||||
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"),
|
||||
)),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_native_options_with_builder_modifiers(
|
||||
apply_builder_modifiers: fn(egui::ViewportBuilder) -> egui::ViewportBuilder,
|
||||
) -> NativeOptions {
|
||||
let window_builder =
|
||||
Box::new(move |builder: egui::ViewportBuilder| apply_builder_modifiers(builder));
|
||||
|
||||
eframe::NativeOptions {
|
||||
window_builder: Some(window_builder),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
.with_fullsize_content_view(true)
|
||||
.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"))
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user