From a70c9917112625d399c612680bde5101d5c651a2 Mon Sep 17 00:00:00 2001 From: arabian Date: Sun, 6 Jul 2025 21:08:50 +0300 Subject: [PATCH] new app::run function --- src/app.rs | 26 +++++++++++++++++++++++++- src/main.rs | 20 +------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/app.rs b/src/app.rs index 36506e8..4cb9ccc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,4 +1,4 @@ -use eframe::{CreationContext, Frame}; +use eframe::{CreationContext, Frame, NativeOptions}; use egui::{ Button, CentralPanel, ComboBox, Context, Label, ScrollArea, Separator, Slider, TextEdit, Ui, Vec2, @@ -455,3 +455,27 @@ impl eframe::App for App { CentralPanel::default().show(ctx, |ui| self.upd(ui, ctx, frame)); } } + +pub fn run() -> Result<(), eframe::Error> { + let options = NativeOptions { + vsync: true, + centered: true, + hardware_acceleration: eframe::HardwareAcceleration::Preferred, + + viewport: egui::ViewportBuilder::default() + .with_app_id("ru.arabianq.pwsp") + .with_inner_size(Vec2::new(800.0, 600.0)) + .with_min_inner_size(Vec2::new(400.0, 400.0)), + + ..Default::default() + }; + + eframe::run_native( + "PipeWire SoundPad", + options, + Box::new(|cc| { + egui_material_icons::initialize(&cc.egui_ctx); + Ok(Box::new(App::new(cc))) + }), + ) +} diff --git a/src/main.rs b/src/main.rs index d84e661..3f6b4cc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,28 +1,10 @@ -use eframe::NativeOptions; -use egui::Vec2; use std::fs; -use std::fs::create_dir; mod app; fn main() -> Result<(), eframe::Error> { create_dirs(); - - let mut options = NativeOptions { - ..Default::default() - }; - options.viewport.min_inner_size = Some(Vec2::new(400.0, 400.0)); - options.vsync = true; - options.hardware_acceleration = eframe::HardwareAcceleration::Preferred; - - eframe::run_native( - "PipeWire SoundPad", - options, - Box::new(|cc| { - egui_material_icons::initialize(&cc.egui_ctx); - Ok(Box::new(app::App::new(cc))) - }), - ) + app::run() } fn create_dirs() {