Skip to content

Commit

Permalink
fix preferences not being loaded correctly and add option to start in…
Browse files Browse the repository at this point in the history
… fullscreen
  • Loading branch information
Kl4rry committed Jun 30, 2024
1 parent df0a10d commit e493161
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/app/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub static PREFERENCES: Mutex<Preferences> = Mutex::new(Preferences::new());

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Preferences {
pub open_in_fullscreen: bool,
pub min_svg_size: u32,
pub zoom_speed: f32,
pub jpeg_quality: u8,
Expand All @@ -20,6 +21,7 @@ pub struct Preferences {
impl Preferences {
const fn new() -> Self {
Self {
open_in_fullscreen: false,
min_svg_size: 1000,
zoom_speed: 1.0,
jpeg_quality: 80,
Expand Down Expand Up @@ -55,6 +57,12 @@ impl App {
.open(&mut open)
.show(ctx, |ui| {
egui::Grid::new("preferences grid").show(ui, |ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| {
ui.label("Open in fullscreen: ");
});
ui.add(egui::Checkbox::new(&mut preferences.open_in_fullscreen, ""));
ui.end_row();

ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| {
ui.label("Zoom Speed: ");
});
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ impl<'a> WindowHandler<'a> {
let event_loop: EventLoop<UserEvent> = EventLoopBuilder::with_user_event().build().unwrap();
let proxy = event_loop.create_proxy();

let fullscreen = if fullscreen {
let fullscreen = if fullscreen || config.preferences.open_in_fullscreen {
Some(Fullscreen::Borderless(None))
} else {
None
};

*PREFERENCES.lock().unwrap() = config.preferences;

let builder = WindowBuilder::new()
.with_title(String::from("Simp"))
.with_visible(false)
Expand Down

0 comments on commit e493161

Please sign in to comment.