idk i'm mad
This commit is contained in:
parent
0974024fe6
commit
102cba5dd5
57
src/main.rs
57
src/main.rs
|
@ -5,6 +5,7 @@ use cosmic::iced::window::{Mode, Position};
|
||||||
use cosmic::iced::{self, event, window, Font, Length, Point};
|
use cosmic::iced::{self, event, window, Font, Length, Point};
|
||||||
use cosmic::iced_core::SmolStr;
|
use cosmic::iced_core::SmolStr;
|
||||||
use cosmic::iced_widget::{column, row, stack};
|
use cosmic::iced_widget::{column, row, stack};
|
||||||
|
use cosmic::prelude::ElementExt;
|
||||||
use cosmic::prelude::*;
|
use cosmic::prelude::*;
|
||||||
use cosmic::widget::tooltip::Position as TPosition;
|
use cosmic::widget::tooltip::Position as TPosition;
|
||||||
use cosmic::widget::{
|
use cosmic::widget::{
|
||||||
|
@ -84,6 +85,7 @@ struct App {
|
||||||
slides: Vec<Slide>,
|
slides: Vec<Slide>,
|
||||||
current_slide: Slide,
|
current_slide: Slide,
|
||||||
presentation_open: bool,
|
presentation_open: bool,
|
||||||
|
cli_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -94,6 +96,7 @@ enum Message {
|
||||||
CloseWindow(Option<window::Id>),
|
CloseWindow(Option<window::Id>),
|
||||||
WindowOpened(window::Id, Option<Point>),
|
WindowOpened(window::Id, Option<Point>),
|
||||||
WindowClosed(window::Id),
|
WindowClosed(window::Id),
|
||||||
|
Quit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cosmic::Application for App {
|
impl cosmic::Application for App {
|
||||||
|
@ -159,6 +162,7 @@ impl cosmic::Application for App {
|
||||||
slides,
|
slides,
|
||||||
current_slide,
|
current_slide,
|
||||||
presentation_open: false,
|
presentation_open: false,
|
||||||
|
cli_mode: !input.ui,
|
||||||
};
|
};
|
||||||
|
|
||||||
let command;
|
let command;
|
||||||
|
@ -294,6 +298,8 @@ impl cosmic::Application for App {
|
||||||
Some(Message::Present(
|
Some(Message::Present(
|
||||||
ui::presenter::Message::PrevSlide,
|
ui::presenter::Message::PrevSlide,
|
||||||
))
|
))
|
||||||
|
} else if key == SmolStr::from("q") {
|
||||||
|
Some(Message::Quit)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -359,7 +365,9 @@ impl cosmic::Application for App {
|
||||||
}
|
}
|
||||||
Message::WindowOpened(id, _) => {
|
Message::WindowOpened(id, _) => {
|
||||||
debug!(?id, "Window opened");
|
debug!(?id, "Window opened");
|
||||||
if id > self.core.main_window_id().unwrap() {
|
if self.cli_mode
|
||||||
|
|| id > self.core.main_window_id().unwrap()
|
||||||
|
{
|
||||||
self.presentation_open = true;
|
self.presentation_open = true;
|
||||||
if let Some(video) = &mut self.presenter.video {
|
if let Some(video) = &mut self.presenter.video {
|
||||||
video.set_muted(false);
|
video.set_muted(false);
|
||||||
|
@ -381,7 +389,7 @@ impl cosmic::Application for App {
|
||||||
self.windows.remove(window);
|
self.windows.remove(window);
|
||||||
// This closes the app if using the cli example
|
// This closes the app if using the cli example
|
||||||
if self.windows.len() == 0 {
|
if self.windows.len() == 0 {
|
||||||
cosmic::iced::exit()
|
self.update(Message::Quit)
|
||||||
} else {
|
} else {
|
||||||
self.presentation_open = false;
|
self.presentation_open = false;
|
||||||
if let Some(video) = &mut self.presenter.video {
|
if let Some(video) = &mut self.presenter.video {
|
||||||
|
@ -390,6 +398,7 @@ impl cosmic::Application for App {
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::Quit => cosmic::iced::exit(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,20 +446,8 @@ impl cosmic::Application for App {
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
let row = row![
|
let slide_preview = Container::new(
|
||||||
Container::new(
|
column![
|
||||||
button::icon(icon_left)
|
|
||||||
.icon_size(128)
|
|
||||||
.tooltip("Previous Slide")
|
|
||||||
.width(128)
|
|
||||||
.on_press(Message::Present(
|
|
||||||
presenter::Message::PrevSlide
|
|
||||||
))
|
|
||||||
)
|
|
||||||
.center_y(Length::Fill)
|
|
||||||
.align_right(Length::Fill)
|
|
||||||
.width(Length::FillPortion(1)),
|
|
||||||
Container::new(column![
|
|
||||||
Responsive::new(|size| {
|
Responsive::new(|size| {
|
||||||
debug!(?size);
|
debug!(?size);
|
||||||
let height = size.width * 9.0 / 16.0;
|
let height = size.width * 9.0 / 16.0;
|
||||||
|
@ -461,6 +458,7 @@ impl cosmic::Application for App {
|
||||||
.map(|m| Message::Present(m)),
|
.map(|m| Message::Present(m)),
|
||||||
)
|
)
|
||||||
.height(height)
|
.height(height)
|
||||||
|
.max_height(height)
|
||||||
.into()
|
.into()
|
||||||
}),
|
}),
|
||||||
Container::new(
|
Container::new(
|
||||||
|
@ -481,9 +479,27 @@ impl cosmic::Application for App {
|
||||||
.padding(5)
|
.padding(5)
|
||||||
)
|
)
|
||||||
.center_x(Length::Fill),
|
.center_x(Length::Fill),
|
||||||
])
|
]
|
||||||
|
.spacing(3),
|
||||||
|
)
|
||||||
|
.center_y(Length::Shrink);
|
||||||
|
|
||||||
|
let row = row![
|
||||||
|
Container::new(
|
||||||
|
button::icon(icon_left)
|
||||||
|
.icon_size(128)
|
||||||
|
.tooltip("Previous Slide")
|
||||||
|
.width(128)
|
||||||
|
.on_press(Message::Present(
|
||||||
|
presenter::Message::PrevSlide
|
||||||
|
))
|
||||||
|
)
|
||||||
.center_y(Length::Fill)
|
.center_y(Length::Fill)
|
||||||
.width(Length::FillPortion(3)),
|
.align_right(Length::Fill)
|
||||||
|
.width(Length::FillPortion(1)),
|
||||||
|
Container::new(slide_preview)
|
||||||
|
.center_y(Length::Fill)
|
||||||
|
.width(Length::FillPortion(3)),
|
||||||
Container::new(
|
Container::new(
|
||||||
button::icon(icon_right)
|
button::icon(icon_right)
|
||||||
.icon_size(128)
|
.icon_size(128)
|
||||||
|
@ -508,10 +524,11 @@ impl cosmic::Application for App {
|
||||||
.slide_preview()
|
.slide_preview()
|
||||||
.map(|m| Message::Present(m))
|
.map(|m| Message::Present(m))
|
||||||
)
|
)
|
||||||
.center_y(Length::Shrink)
|
.center_y(100)
|
||||||
];
|
];
|
||||||
|
|
||||||
column.into()
|
let element: Element<Message> = column.into();
|
||||||
|
element.debug(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// View for presentation
|
// View for presentation
|
||||||
|
|
|
@ -222,10 +222,13 @@ impl Presenter {
|
||||||
Container::new(Space::new(Length::Fill, Length::Fill))
|
Container::new(Space::new(Length::Fill, Length::Fill))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
stack!(container.center(Length::Fill), text)
|
Container::new(
|
||||||
.width(Length::Fill)
|
stack!(container.center(Length::Fill), text)
|
||||||
.height(Length::Fill)
|
.width(Length::Fill)
|
||||||
.into()
|
.height(Length::Fill),
|
||||||
|
)
|
||||||
|
.padding(10)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset_video(&mut self) {
|
fn reset_video(&mut self) {
|
||||||
|
|
Loading…
Reference in a new issue