use libtalma::iced::{self, Command, widget::{column, text}, Application};
mod fonts;
mod input;
fn main() -> iced::Result {
let settings = iced::settings::Settings {
window: iced::window::Settings {
position: iced::window::Position::Centered,
visible: true,
resizable: false,
decorations: false,
transparent: true,
level: iced::window::Level::AlwaysOnTop,
..Default::default()
},
..libtalma::window_settings(())
};
Gandalf::run(settings)
}
enum GandalfState {
Exec,
Calc,
Light,
}
struct Gandalf {
state: GandalfState,
}
#[derive(Debug)]
pub enum Message {
Exit,
}
impl Application for Gandalf {
type Theme = iced::Theme;
type Flags = ();
type Message = Message;
type Executor = iced::executor::Default;
fn new(_flags: Self::Flags) -> (Self, iced::Command<Self::Message>) {
(Gandalf {
state: GandalfState::Exec,
}, Command::none())
}
fn title(&self) -> String {
String::from("gandalf")
}
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
match message {
Message::Exit => iced::window::close(iced::window::Id::MAIN),
}
}
fn subscription(&self) -> iced::Subscription<Self::Message> {
iced::keyboard::on_key_press(|key_code, modifiers| {
if modifiers.command() {
return None;
}
input::handle(key_code)
})
}
fn view(&self) -> iced::Element<'_, Self::Message> {
column![
text("libtalma").size(64)
]
.padding(20)
.align_items(iced::Alignment::Center)
.into()
}
}