From 7e9d5803e540d48e763b2880b6df6063bde9a785 Mon Sep 17 00:00:00 2001 From: alterdekim Date: Mon, 28 Oct 2024 02:05:55 +0300 Subject: [PATCH] first successful iced commit modified: src/gui/mod.rs --- src/gui/mod.rs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index a3a945b..f5f9085 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -14,7 +14,7 @@ use log::{info, error}; use log::LevelFilter; use env_logger::Builder; use tray_item::{IconSource, TrayItem}; -use iced::{widget::container, Element, Task as Command}; +use iced::{widget::container, window, Element, Settings, Task as Command}; use iced::widget::{button, column, pick_list, radio, text, Column, Container, scrollable}; use crate::tab_button::TabButton; @@ -30,17 +30,7 @@ fn get_configs_dir() -> PathBuf { #[derive(Debug, Clone)] pub enum Message { ButtonPressed(u8), - ButtonReleased -} - - - - - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -enum Filter { - All, - Something + ChangeUI } @@ -60,6 +50,10 @@ enum App { } impl App { + pub fn new() -> (Self, Command) { + (Self::Preloaded, Command::done(Message::ChangeUI)) + } + pub fn view(&self) -> Element { match self { App::Preloaded => { @@ -71,30 +65,24 @@ impl App { } } - pub fn update(&mut self, message: Message) { + pub fn update(&mut self, message: Message) -> Command { match self { App::Preloaded => { - info!("LOOL"); let mut panel = TabPanel::new(); panel.push_tab(TabButton::new("First", 0), Tab::new()); *self = App::Loaded(State { tab_panel: panel }); + return Command::done(Message::ChangeUI); } App::Loaded(state) => { - info!("cry"); state.tab_panel.update(message); } } - } -} - -impl std::default::Default for App { - fn default() -> Self { - Self::Preloaded + Command::none() } } fn main() -> iced::Result { iced::application("title", App::update, App::view) .window_size((640.0, 480.0)) - .run() + .run_with(App::new) } \ No newline at end of file