adding keyboard navigation to the presenter
This commit is contained in:
parent
4e0a7713e5
commit
7de3d8e5bc
48
src/main.rs
48
src/main.rs
|
@ -1,6 +1,7 @@
|
||||||
use clap::{command, Parser};
|
use clap::{command, Parser};
|
||||||
use cosmic::app::{Core, Settings, Task};
|
use cosmic::app::{Core, Settings, Task};
|
||||||
use cosmic::dialog::ashpd::url::Url;
|
use cosmic::dialog::ashpd::url::Url;
|
||||||
|
use cosmic::iced::keyboard::Key;
|
||||||
use cosmic::iced::window::Position;
|
use cosmic::iced::window::Position;
|
||||||
use cosmic::iced::{self, event, window, ContentFit, Font, Length, Point};
|
use cosmic::iced::{self, event, window, ContentFit, Font, Length, Point};
|
||||||
use cosmic::iced_core::id;
|
use cosmic::iced_core::id;
|
||||||
|
@ -18,7 +19,9 @@ use tracing::{debug, level_filters::LevelFilter};
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
|
||||||
pub mod slide;
|
pub mod slide;
|
||||||
|
pub mod ui;
|
||||||
use slide::*;
|
use slide::*;
|
||||||
|
use ui::presenter::{self, Presenter};
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(name = "lumina", version, about)]
|
#[command(name = "lumina", version, about)]
|
||||||
|
@ -67,12 +70,13 @@ struct App {
|
||||||
core: Core,
|
core: Core,
|
||||||
nav_model: nav_bar::Model,
|
nav_model: nav_bar::Model,
|
||||||
file: PathBuf,
|
file: PathBuf,
|
||||||
|
presenter: Presenter,
|
||||||
windows: Vec<window::Id>,
|
windows: Vec<window::Id>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
enum Message {
|
enum Message {
|
||||||
Enchant(String),
|
Present(presenter::Message),
|
||||||
File(PathBuf),
|
File(PathBuf),
|
||||||
OpenWindow,
|
OpenWindow,
|
||||||
CloseWindow(window::Id),
|
CloseWindow(window::Id),
|
||||||
|
@ -108,6 +112,7 @@ impl cosmic::Application for App {
|
||||||
nav_model,
|
nav_model,
|
||||||
file: input.file,
|
file: input.file,
|
||||||
windows,
|
windows,
|
||||||
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let command;
|
let command;
|
||||||
|
@ -155,6 +160,23 @@ impl cosmic::Application for App {
|
||||||
window::Event::Closed => Some(Message::WindowClosed(id)),
|
window::Event::Closed => Some(Message::WindowClosed(id)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
} else if let iced::Event::Keyboard(key) = event {
|
||||||
|
match key {
|
||||||
|
iced::keyboard::Event::KeyReleased {
|
||||||
|
key,
|
||||||
|
modified_key: _,
|
||||||
|
physical_key: _,
|
||||||
|
location: _,
|
||||||
|
modifiers: _,
|
||||||
|
} => {
|
||||||
|
if key == Key::Named(iced::keyboard::key::Named::ArrowRight) {
|
||||||
|
Some(Message::Present(ui::presenter::Message::NextSlide))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -163,8 +185,9 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
fn update(&mut self, message: Message) -> cosmic::Task<cosmic::app::Message<Message>> {
|
fn update(&mut self, message: Message) -> cosmic::Task<cosmic::app::Message<Message>> {
|
||||||
match message {
|
match message {
|
||||||
Message::Enchant(slide) => {
|
Message::Present(message) => {
|
||||||
debug!(slide);
|
debug!(?message);
|
||||||
|
self.presenter.update(message);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
Message::File(file) => {
|
Message::File(file) => {
|
||||||
|
@ -212,22 +235,9 @@ impl cosmic::Application for App {
|
||||||
|
|
||||||
// View for presentation
|
// View for presentation
|
||||||
fn view_window(&self, _id: window::Id) -> Element<Message> {
|
fn view_window(&self, _id: window::Id) -> Element<Message> {
|
||||||
// let window = self.windows.iter().position(|w| *w == id).unwrap();
|
self.presenter
|
||||||
// if let Some(_window) = self.windows.get(window) {}
|
.view()
|
||||||
// let video = Video::new(&Url::parse("/home/chris/vids/test/camprules2024.mp4").unwrap())
|
.map(|message| Message::Present(message))
|
||||||
let text = text!("This is frodo").size(50);
|
|
||||||
let text = Container::new(text).center(Length::Fill);
|
|
||||||
let image = Container::new(
|
|
||||||
image("/home/chris/pics/frodo.jpg")
|
|
||||||
.content_fit(ContentFit::Cover)
|
|
||||||
.width(Length::Fill)
|
|
||||||
.height(Length::Fill),
|
|
||||||
);
|
|
||||||
// let video = Container::new(VideoPlayer::new(&video))
|
|
||||||
// .width(Length::Fill)
|
|
||||||
// .height(Length::Fill);
|
|
||||||
let stack = stack!(image, text).width(Length::Fill).height(Length::Fill);
|
|
||||||
stack.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue