mirror of
https://github.com/aljazceru/notedeck.git
synced 2026-01-15 06:14:20 +01:00
Just take an egui::Context instead of an eframe::CreationContext. This should make it easier to test the app via egui::Context::default(); Signed-off-by: William Casarin <jb55@jb55.com>
77 lines
2.1 KiB
Rust
77 lines
2.1 KiB
Rust
use crate::{
|
|
app_size_handler::AppSizeHandler,
|
|
app_style::{create_custom_style, dark_mode, desktop_font_size, light_mode, mobile_font_size},
|
|
fonts::setup_fonts,
|
|
storage::DataPath,
|
|
};
|
|
|
|
use eframe::NativeOptions;
|
|
|
|
//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);
|
|
|
|
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),
|
|
..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 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])
|
|
})
|
|
}
|
|
|
|
pub fn setup_cc(ctx: &egui::Context, is_mobile: bool, light: bool) {
|
|
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(light_mode())
|
|
} else {
|
|
ctx.set_visuals(dark_mode(is_mobile));
|
|
}
|
|
|
|
ctx.set_style(if is_mobile {
|
|
create_custom_style(ctx, mobile_font_size)
|
|
} else {
|
|
create_custom_style(ctx, desktop_font_size)
|
|
});
|
|
}
|