This commit is contained in:
parent
15b5966108
commit
c886d18134
15 changed files with 2123 additions and 1563 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::mem::replace;
|
||||
|
||||
use cosmic::iced::Executor;
|
||||
use iced::iced::Executor;
|
||||
use miette::{miette, Result};
|
||||
use sqlx::{Connection, SqliteConnection};
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ use std::cmp::Ordering;
|
|||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
use cosmic::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use iced::iced::clipboard::mime::{AllowedMimeTypes, AsMimeTypes};
|
||||
use miette::Result;
|
||||
use tracing::{debug, error};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// use cosmic::dialog::ashpd::url::Url;
|
||||
// use iced::dialog::ashpd::url::Url;
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use iced_video_player::Video;
|
||||
use miette::{miette, Result};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::{collections::HashMap, option::Option, path::PathBuf};
|
||||
|
||||
use cosmic::iced::Executor;
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use iced::iced::Executor;
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
|
|
|
@ -7,8 +7,8 @@ use super::{
|
|||
service_items::ServiceTrait,
|
||||
slide::Slide,
|
||||
};
|
||||
use cosmic::iced::Executor;
|
||||
use crisp::types::{Keyword, Symbol, Value};
|
||||
use iced::iced::Executor;
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::{
|
||||
|
|
236
src/main.rs
236
src/main.rs
|
@ -2,32 +2,25 @@ use clap::{command, Parser};
|
|||
use core::service_items::ServiceItem;
|
||||
use core::slide::*;
|
||||
use core::songs::Song;
|
||||
use cosmic::app::context_drawer::ContextDrawer;
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::iced::keyboard::{Key, Modifiers};
|
||||
use cosmic::iced::window::{Mode, Position};
|
||||
use cosmic::iced::{self, event, window, Length, Padding, Point};
|
||||
use cosmic::iced_futures::Subscription;
|
||||
use cosmic::iced_widget::{column, row};
|
||||
use cosmic::widget::dnd_destination::{
|
||||
dnd_destination, dnd_destination_for_data,
|
||||
};
|
||||
use cosmic::widget::nav_bar::nav_bar_style;
|
||||
use cosmic::widget::segmented_button::Entity;
|
||||
use cosmic::widget::text;
|
||||
use cosmic::widget::tooltip::Position as TPosition;
|
||||
use cosmic::widget::{
|
||||
button, horizontal_space, nav_bar, search_input, tooltip,
|
||||
vertical_space, Space,
|
||||
};
|
||||
use cosmic::widget::{icon, slider};
|
||||
use cosmic::{executor, Application, ApplicationExt, Element};
|
||||
use cosmic::{prelude::*, theme};
|
||||
use cosmic::{widget::Container, Theme};
|
||||
use crisp::types::Value;
|
||||
use iced::keyboard::{Key, Modifiers};
|
||||
use iced::theme::{self, Palette};
|
||||
use iced::widget::tooltip::Position as TPosition;
|
||||
use iced::widget::{
|
||||
button, horizontal_space, slider, text, tooltip, vertical_space,
|
||||
Space,
|
||||
};
|
||||
use iced::widget::{column, row};
|
||||
use iced::window::{Mode, Position};
|
||||
use iced::{self, event, window, Length, Padding, Point};
|
||||
use iced::{color, Subscription};
|
||||
use iced::{executor, Application, Element};
|
||||
use iced::{widget::Container, Theme};
|
||||
use iced::{Settings, Task};
|
||||
use lisp::parse_lisp;
|
||||
use miette::{miette, Result};
|
||||
use rayon::prelude::*;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs::read_to_string;
|
||||
use std::path::PathBuf;
|
||||
use tracing::{debug, level_filters::LevelFilter};
|
||||
|
@ -86,20 +79,19 @@ fn main() -> Result<()> {
|
|||
.is_daemon(true);
|
||||
}
|
||||
|
||||
cosmic::app::run::<App>(settings, args)
|
||||
iced::daemon(move || App::init(args), App::update, App::view)
|
||||
.settings(settings)
|
||||
.subscription(App::subsrciption)
|
||||
.theme(App::theme)
|
||||
.title(App::title)
|
||||
.run()
|
||||
.map_err(|e| miette!("Invalid things... {}", e))
|
||||
}
|
||||
|
||||
fn theme(_state: &App) -> Theme {
|
||||
Theme::dark()
|
||||
}
|
||||
|
||||
struct App {
|
||||
core: Core,
|
||||
nav_model: nav_bar::Model,
|
||||
file: PathBuf,
|
||||
presenter: Presenter,
|
||||
windows: Vec<window::Id>,
|
||||
windows: BTreeMap<window::Id, Window>,
|
||||
service: Vec<ServiceItem>,
|
||||
current_item: (usize, usize),
|
||||
presentation_open: bool,
|
||||
|
@ -119,7 +111,7 @@ enum Message {
|
|||
Library(library::Message),
|
||||
SongEditor(song_editor::Message),
|
||||
File(PathBuf),
|
||||
DndEnter(Entity, Vec<String>),
|
||||
DndEnter(Vec<String>),
|
||||
DndDrop,
|
||||
OpenWindow,
|
||||
CloseWindow(Option<window::Id>),
|
||||
|
@ -130,7 +122,7 @@ enum Message {
|
|||
Quit,
|
||||
Key(Key, Modifiers),
|
||||
None,
|
||||
DndLeave(Entity),
|
||||
DndLeave(),
|
||||
EditorToggle(bool),
|
||||
SearchFocus,
|
||||
ChangeServiceItem(usize),
|
||||
|
@ -139,30 +131,42 @@ enum Message {
|
|||
AppendServiceItem(ServiceItem),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Window {
|
||||
title: String,
|
||||
scale_input: String,
|
||||
current_scale: f64,
|
||||
theme: Theme,
|
||||
}
|
||||
|
||||
impl Default for Window {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
title: Default::default(),
|
||||
scale_input: Default::default(),
|
||||
current_scale: Default::default(),
|
||||
theme: App::theme(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const HEADER_SPACE: u16 = 6;
|
||||
|
||||
impl cosmic::Application for App {
|
||||
type Executor = executor::Default;
|
||||
type Flags = Cli;
|
||||
type Message = Message;
|
||||
impl App {
|
||||
const APP_ID: &'static str = "lumina";
|
||||
fn core(&self) -> &Core {
|
||||
&self.core
|
||||
}
|
||||
fn core_mut(&mut self) -> &mut Core {
|
||||
&mut self.core
|
||||
}
|
||||
fn init(
|
||||
core: Core,
|
||||
input: Self::Flags,
|
||||
) -> (Self, Task<Self::Message>) {
|
||||
fn init(input: Cli) -> (Self, Task<Self::Message>) {
|
||||
debug!("init");
|
||||
let nav_model = nav_bar::Model::default();
|
||||
|
||||
let mut windows = vec![];
|
||||
|
||||
let mut batch = vec![];
|
||||
let mut windows = BTreeMap::new();
|
||||
if input.ui {
|
||||
windows.push(core.main_window_id().unwrap());
|
||||
let settings = window::Settings {
|
||||
..Default::default()
|
||||
};
|
||||
let (id, open) = window::open(settings);
|
||||
batch.push(open);
|
||||
|
||||
windows.insert(id, Window::default());
|
||||
}
|
||||
|
||||
let items = match read_to_string(input.file) {
|
||||
|
@ -202,8 +206,6 @@ impl cosmic::Application for App {
|
|||
|
||||
let mut app = App {
|
||||
presenter,
|
||||
core,
|
||||
nav_model,
|
||||
service: items,
|
||||
file: PathBuf::default(),
|
||||
windows,
|
||||
|
@ -219,8 +221,6 @@ impl cosmic::Application for App {
|
|||
library_dragged_item: None,
|
||||
};
|
||||
|
||||
let mut batch = vec![];
|
||||
|
||||
if input.ui {
|
||||
debug!("main view");
|
||||
batch.push(app.update_title())
|
||||
|
@ -235,39 +235,34 @@ impl cosmic::Application for App {
|
|||
(app, batch)
|
||||
}
|
||||
|
||||
/// Allows COSMIC to integrate with your application's [`nav_bar::Model`].
|
||||
fn nav_model(&self) -> Option<&nav_bar::Model> {
|
||||
Some(&self.nav_model)
|
||||
}
|
||||
|
||||
fn nav_bar(&self) -> Option<Element<cosmic::Action<Message>>> {
|
||||
fn nav_bar(&self) -> Option<Element<Message>> {
|
||||
if !self.core().nav_bar_active() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// let nav_model = self.nav_model()?;
|
||||
|
||||
// let mut nav = cosmic::widget::nav_bar(nav_model, |id| {
|
||||
// cosmic::Action::Cosmic(cosmic::app::Action::NavBar(id))
|
||||
// let mut nav = iced::widget::nav_bar(nav_model, |id| {
|
||||
// iced::Action::Iced(iced::app::Action::NavBar(id))
|
||||
// })
|
||||
// .on_dnd_drop::<ServiceItem>(|entity, data, action| {
|
||||
// debug!(?entity);
|
||||
// debug!(?data);
|
||||
// debug!(?action);
|
||||
// cosmic::Action::App(Message::DndDrop)
|
||||
// iced::Action::App(Message::DndDrop)
|
||||
// })
|
||||
// .on_dnd_enter(|entity, data| {
|
||||
// debug!("entered");
|
||||
// cosmic::Action::App(Message::DndEnter(entity, data))
|
||||
// iced::Action::App(Message::DndEnter(entity, data))
|
||||
// })
|
||||
// .on_dnd_leave(|entity| {
|
||||
// debug!("left");
|
||||
// cosmic::Action::App(Message::DndLeave(entity))
|
||||
// iced::Action::App(Message::DndLeave(entity))
|
||||
// })
|
||||
// .drag_id(DragId::new())
|
||||
// .on_context(|id| {
|
||||
// cosmic::Action::Cosmic(
|
||||
// cosmic::app::Action::NavBarContext(id),
|
||||
// iced::Action::Iced(
|
||||
// iced::app::Action::NavBarContext(id),
|
||||
// )
|
||||
// })
|
||||
// .context_menu(None)
|
||||
|
@ -301,30 +296,30 @@ impl cosmic::Application for App {
|
|||
},
|
||||
}
|
||||
})
|
||||
.class(cosmic::theme::style::Button::HeaderBar)
|
||||
.class(iced::theme::style::Button::HeaderBar)
|
||||
.padding(5)
|
||||
.width(Length::Fill)
|
||||
.on_press(cosmic::Action::App(Message::ChangeServiceItem(index)));
|
||||
.on_press(iced::Action::App(Message::ChangeServiceItem(index)));
|
||||
let tooltip = tooltip(button,
|
||||
text::body(item.kind.to_string()),
|
||||
TPosition::Right);
|
||||
dnd_destination(tooltip, vec!["application/service-item".into()])
|
||||
.data_received_for::<ServiceItem>( move |item| {
|
||||
if let Some(item) = item {
|
||||
cosmic::Action::App(Message::AddServiceItem(index, item))
|
||||
iced::Action::App(Message::AddServiceItem(index, item))
|
||||
} else {
|
||||
cosmic::Action::None
|
||||
iced::Action::None
|
||||
}
|
||||
}).on_drop(move |x, y| {
|
||||
debug!(x, y);
|
||||
cosmic::Action::App(Message::AddServiceItemDrop(index))
|
||||
iced::Action::App(Message::AddServiceItemDrop(index))
|
||||
}).on_finish(move |mime, data, action, x, y| {
|
||||
debug!(mime, ?data, ?action, x, y);
|
||||
let Ok(item) = ServiceItem::try_from((data, mime)) else {
|
||||
return cosmic::Action::None;
|
||||
return iced::Action::None;
|
||||
};
|
||||
debug!(?item);
|
||||
cosmic::Action::App(Message::AddServiceItem(index, item))
|
||||
iced::Action::App(Message::AddServiceItem(index, item))
|
||||
})
|
||||
.into()
|
||||
});
|
||||
|
@ -339,11 +334,11 @@ impl cosmic::Application for App {
|
|||
)
|
||||
.data_received_for::<ServiceItem>(|item| {
|
||||
if let Some(item) = item {
|
||||
cosmic::Action::App(Message::AppendServiceItem(
|
||||
iced::Action::App(Message::AppendServiceItem(
|
||||
item,
|
||||
))
|
||||
} else {
|
||||
cosmic::Action::None
|
||||
iced::Action::None
|
||||
}
|
||||
})
|
||||
.on_finish(
|
||||
|
@ -352,10 +347,10 @@ impl cosmic::Application for App {
|
|||
let Ok(item) =
|
||||
ServiceItem::try_from((data, mime))
|
||||
else {
|
||||
return cosmic::Action::None;
|
||||
return iced::Action::None;
|
||||
};
|
||||
debug!(?item);
|
||||
cosmic::Action::App(Message::AddServiceItem(
|
||||
iced::Action::App(Message::AddServiceItem(
|
||||
end_index, item,
|
||||
))
|
||||
}
|
||||
|
@ -375,16 +370,6 @@ impl cosmic::Application for App {
|
|||
Some(container.into())
|
||||
}
|
||||
|
||||
/// Called when a navigation item is selected.
|
||||
fn on_nav_select(
|
||||
&mut self,
|
||||
id: nav_bar::Id,
|
||||
) -> Task<Self::Message> {
|
||||
self.nav_model.activate(id);
|
||||
// debug!(?id);
|
||||
self.update_title()
|
||||
}
|
||||
|
||||
fn header_start(&self) -> Vec<Element<Self::Message>> {
|
||||
vec![]
|
||||
}
|
||||
|
@ -429,7 +414,7 @@ impl cosmic::Application for App {
|
|||
)
|
||||
.spacing(5),
|
||||
)
|
||||
.class(cosmic::theme::style::Button::HeaderBar)
|
||||
.class(iced::theme::style::Button::HeaderBar)
|
||||
.on_press(Message::EditorToggle(
|
||||
self.editor_mode.is_none(),
|
||||
)),
|
||||
|
@ -454,7 +439,7 @@ impl cosmic::Application for App {
|
|||
)
|
||||
.spacing(5),
|
||||
)
|
||||
.class(cosmic::theme::style::Button::HeaderBar)
|
||||
.class(iced::theme::style::Button::HeaderBar)
|
||||
.on_press({
|
||||
if self.presentation_open {
|
||||
Message::CloseWindow(
|
||||
|
@ -483,7 +468,7 @@ impl cosmic::Application for App {
|
|||
)
|
||||
.spacing(5),
|
||||
)
|
||||
.class(cosmic::theme::style::Button::HeaderBar)
|
||||
.class(iced::theme::style::Button::HeaderBar)
|
||||
.on_press(Message::LibraryToggle),
|
||||
"Open Library",
|
||||
TPosition::Bottom,
|
||||
|
@ -556,9 +541,8 @@ impl cosmic::Application for App {
|
|||
|
||||
fn context_drawer(
|
||||
&self,
|
||||
) -> Option<
|
||||
cosmic::app::context_drawer::ContextDrawer<Self::Message>,
|
||||
> {
|
||||
) -> Option<iced::app::context_drawer::ContextDrawer<Self::Message>>
|
||||
{
|
||||
ContextDrawer {
|
||||
title: Some("Context".into()),
|
||||
header_actions: vec![],
|
||||
|
@ -588,9 +572,7 @@ impl cosmic::Application for App {
|
|||
match self.song_editor.update(message) {
|
||||
song_editor::Action::Task(task) => {
|
||||
task.map(|m| {
|
||||
cosmic::Action::App(Message::SongEditor(
|
||||
m,
|
||||
))
|
||||
iced::Action::App(Message::SongEditor(m))
|
||||
})
|
||||
}
|
||||
song_editor::Action::UpdateSong(song) => {
|
||||
|
@ -615,7 +597,7 @@ impl cosmic::Application for App {
|
|||
match self.presenter.update(message) {
|
||||
presenter::Action::Task(task) => task.map(|m| {
|
||||
// debug!("Should run future");
|
||||
cosmic::Action::App(Message::Present(m))
|
||||
iced::Action::App(Message::Present(m))
|
||||
}),
|
||||
presenter::Action::None => Task::none(),
|
||||
presenter::Action::NextSlide => {
|
||||
|
@ -644,7 +626,7 @@ impl cosmic::Application for App {
|
|||
match action {
|
||||
presenter::Action::Task(task) => {
|
||||
tasks.push(task.map(|m| {
|
||||
cosmic::Action::App(
|
||||
iced::Action::App(
|
||||
Message::Present(m),
|
||||
)
|
||||
}))
|
||||
|
@ -665,16 +647,15 @@ impl cosmic::Application for App {
|
|||
match action {
|
||||
presenter::Action::Task(
|
||||
task,
|
||||
) => {
|
||||
tasks
|
||||
.push(task.map(|m| {
|
||||
cosmic::Action::App(
|
||||
) => tasks.push(task.map(
|
||||
|m| {
|
||||
iced::Action::App(
|
||||
Message::Present(
|
||||
m,
|
||||
),
|
||||
)
|
||||
}))
|
||||
}
|
||||
},
|
||||
)),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
@ -703,7 +684,7 @@ impl cosmic::Application for App {
|
|||
match action {
|
||||
presenter::Action::Task(task) => {
|
||||
tasks.push(task.map(|m| {
|
||||
cosmic::Action::App(
|
||||
iced::Action::App(
|
||||
Message::Present(m),
|
||||
)
|
||||
}))
|
||||
|
@ -739,16 +720,15 @@ impl cosmic::Application for App {
|
|||
match action {
|
||||
presenter::Action::Task(
|
||||
task,
|
||||
) => {
|
||||
tasks
|
||||
.push(task.map(|m| {
|
||||
cosmic::Action::App(
|
||||
) => tasks.push(task.map(
|
||||
|m| {
|
||||
iced::Action::App(
|
||||
Message::Present(
|
||||
m,
|
||||
),
|
||||
)
|
||||
}))
|
||||
}
|
||||
},
|
||||
)),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
@ -769,7 +749,7 @@ impl cosmic::Application for App {
|
|||
}
|
||||
library::Action::Task(task) => {
|
||||
return task.map(|message| {
|
||||
cosmic::Action::App(Message::Library(
|
||||
iced::Action::App(Message::Library(
|
||||
message,
|
||||
))
|
||||
});
|
||||
|
@ -834,9 +814,7 @@ impl cosmic::Application for App {
|
|||
);
|
||||
|
||||
spawn_window.map(|id| {
|
||||
cosmic::Action::App(Message::WindowOpened(
|
||||
id, None,
|
||||
))
|
||||
iced::Action::App(Message::WindowOpened(id, None))
|
||||
})
|
||||
}
|
||||
Message::CloseWindow(id) => {
|
||||
|
@ -849,7 +827,7 @@ impl cosmic::Application for App {
|
|||
Message::WindowOpened(id, _) => {
|
||||
debug!(?id, "Window opened");
|
||||
if self.cli_mode
|
||||
|| id > self.core.main_window_id().expect("Cosmic core seems to be missing a main window, was this started in cli mode?")
|
||||
|| id > self.core.main_window_id().expect("Iced core seems to be missing a main window, was this started in cli mode?")
|
||||
{
|
||||
self.presentation_open = true;
|
||||
if let Some(video) = &mut self.presenter.video {
|
||||
|
@ -884,7 +862,7 @@ impl cosmic::Application for App {
|
|||
self.library_open = !self.library_open;
|
||||
Task::none()
|
||||
}
|
||||
Message::Quit => cosmic::iced::exit(),
|
||||
Message::Quit => iced::iced::exit(),
|
||||
Message::DndEnter(entity, data) => {
|
||||
debug!(?entity);
|
||||
debug!(?data);
|
||||
|
@ -1106,7 +1084,7 @@ impl cosmic::Application for App {
|
|||
|
||||
impl App
|
||||
where
|
||||
Self: cosmic::Application,
|
||||
Self: iced::Application,
|
||||
{
|
||||
fn active_page_title(&self) -> &str {
|
||||
let Some(label) =
|
||||
|
@ -1135,13 +1113,13 @@ where
|
|||
self.windows.push(id);
|
||||
_ = self.set_window_title("Lumina Presenter".to_owned(), id);
|
||||
spawn_window.map(|id| {
|
||||
cosmic::Action::App(Message::WindowOpened(id, None))
|
||||
iced::Action::App(Message::WindowOpened(id, None))
|
||||
})
|
||||
}
|
||||
|
||||
fn add_library(&mut self) -> Task<Message> {
|
||||
Task::perform(async move { Library::new().await }, |x| {
|
||||
cosmic::Action::App(Message::AddLibrary(x))
|
||||
iced::Action::App(Message::AddLibrary(x))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1163,7 +1141,7 @@ where
|
|||
// |x| {
|
||||
// let len = x.len();
|
||||
// debug!(len, "to append: ");
|
||||
// cosmic::Action::App(Message::AppendService(x))
|
||||
// iced::Action::App(Message::AppendService(x))
|
||||
// },
|
||||
// )
|
||||
// }
|
||||
|
@ -1212,6 +1190,20 @@ where
|
|||
_ => Task::none(),
|
||||
}
|
||||
}
|
||||
|
||||
fn theme() -> Theme {
|
||||
Theme::custom(
|
||||
"Snazzy",
|
||||
Palette {
|
||||
background: color!(0x282a36),
|
||||
text: color!(0xe2e4e5),
|
||||
primary: color!(0x57c7ff),
|
||||
success: color!(0x5af78e),
|
||||
warning: color!(0xff9f43),
|
||||
danger: color!(0xff5c57),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::RangeInclusive;
|
||||
|
||||
use cosmic::iced::Length;
|
||||
use iced::Length;
|
||||
|
||||
struct DoubleSlider<'a, T, Message> {
|
||||
range: RangeInclusive<T>,
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
use cosmic::{
|
||||
iced::{
|
||||
alignment::Vertical, clipboard::dnd::DndAction,
|
||||
futures::FutureExt, Background, Border, Color, Length,
|
||||
},
|
||||
iced_core::widget::tree::State,
|
||||
iced_widget::{column, row as rowm, text as textm},
|
||||
use iced::{
|
||||
advanced::widget::{tree::State, Widget},
|
||||
alignment::Vertical,
|
||||
futures::FutureExt,
|
||||
theme,
|
||||
widget::{
|
||||
button, container, horizontal_space, icon, mouse_area,
|
||||
responsive, row, scrollable, text, text_input, Container,
|
||||
DndSource, Space, Widget,
|
||||
button, container, horizontal_space, mouse_area, responsive,
|
||||
row, scrollable, text, text_input, Container, Space,
|
||||
},
|
||||
Element, Task,
|
||||
widget::{column, row as rowm, text as textm},
|
||||
Background, Border, Color, Element, Length, Task,
|
||||
};
|
||||
use miette::{IntoDiagnostic, Result};
|
||||
use sqlx::{pool::PoolConnection, Sqlite, SqlitePool};
|
||||
|
@ -332,19 +329,21 @@ impl<'a> Library {
|
|||
match self.library_hovered {
|
||||
Some(lib) => Background::Color(
|
||||
if lib == model.kind {
|
||||
t.cosmic().button.hover.into()
|
||||
t.iced().button.hover.into()
|
||||
} else {
|
||||
t.cosmic().button.base.into()
|
||||
t.iced().button.base.into()
|
||||
},
|
||||
),
|
||||
None => Background::Color(
|
||||
t.cosmic().button.base.into(),
|
||||
t.iced().button.base.into(),
|
||||
),
|
||||
}
|
||||
})
|
||||
.border(Border::default().rounded(
|
||||
t.cosmic().corner_radii.radius_s,
|
||||
))
|
||||
.border(
|
||||
Border::default().rounded(
|
||||
t.iced().corner_radii.radius_s,
|
||||
),
|
||||
)
|
||||
})
|
||||
.center_x(Length::Fill)
|
||||
.center_y(Length::Shrink);
|
||||
|
@ -456,12 +455,9 @@ impl<'a> Library {
|
|||
.center_x(Length::Fill);
|
||||
let subtext = container(responsive(|size| {
|
||||
let color: Color = if item.background().is_some() {
|
||||
theme::active().cosmic().accent_text_color().into()
|
||||
theme::active().iced().accent_text_color().into()
|
||||
} else {
|
||||
theme::active()
|
||||
.cosmic()
|
||||
.destructive_text_color()
|
||||
.into()
|
||||
theme::active().iced().destructive_text_color().into()
|
||||
};
|
||||
text::body(elide_text(item.subtext(), size.width))
|
||||
.center()
|
||||
|
@ -490,9 +486,9 @@ impl<'a> Library {
|
|||
if model.kind == library
|
||||
&& selected == index as i32
|
||||
{
|
||||
t.cosmic().accent.selected.into()
|
||||
t.iced().accent.selected.into()
|
||||
} else {
|
||||
t.cosmic().button.base.into()
|
||||
t.iced().button.base.into()
|
||||
}
|
||||
} else if let Some((library, hovered)) =
|
||||
self.hovered_item
|
||||
|
@ -500,17 +496,17 @@ impl<'a> Library {
|
|||
if model.kind == library
|
||||
&& hovered == index as i32
|
||||
{
|
||||
t.cosmic().button.hover.into()
|
||||
t.iced().button.hover.into()
|
||||
} else {
|
||||
t.cosmic().button.base.into()
|
||||
t.iced().button.base.into()
|
||||
}
|
||||
} else {
|
||||
t.cosmic().button.base.into()
|
||||
t.iced().button.base.into()
|
||||
},
|
||||
))
|
||||
.border(
|
||||
Border::default()
|
||||
.rounded(t.cosmic().corner_radii.radius_m),
|
||||
.rounded(t.iced().corner_radii.radius_m),
|
||||
)
|
||||
})
|
||||
.into()
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
use miette::{IntoDiagnostic, Result};
|
||||
use std::{fs::File, io::BufReader, path::PathBuf, sync::Arc};
|
||||
|
||||
use cosmic::{
|
||||
iced::{
|
||||
alignment::Horizontal,
|
||||
border,
|
||||
font::{Family, Stretch, Style, Weight},
|
||||
Background, Border, Color, ContentFit, Font, Length, Shadow,
|
||||
Vector,
|
||||
use iced::{
|
||||
alignment::Horizontal,
|
||||
border,
|
||||
font::{Family, Stretch, Style, Weight},
|
||||
widget::{
|
||||
container, image, mouse_area, responsive, scrollable, text,
|
||||
Column, Container, Row, Space,
|
||||
},
|
||||
iced_widget::{
|
||||
widget::{
|
||||
rich_text,
|
||||
scrollable::{
|
||||
scroll_to, AbsoluteOffset, Direction, Scrollbar,
|
||||
},
|
||||
span, stack, vertical_rule,
|
||||
},
|
||||
prelude::*,
|
||||
widget::{
|
||||
container, image, mouse_area, responsive, scrollable, text,
|
||||
Column, Container, Id, Row, Space,
|
||||
},
|
||||
Task,
|
||||
Background, Border, Color, ContentFit, Font, Length, Shadow,
|
||||
Task, Vector,
|
||||
};
|
||||
use iced_video_player::{gst_pbutils, Position, Video, VideoPlayer};
|
||||
use iced_video_player::{Position, Video, VideoPlayer};
|
||||
use rodio::{Decoder, OutputStream, Sink};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use url::Url;
|
||||
|
@ -168,7 +164,7 @@ impl Presenter {
|
|||
)
|
||||
},
|
||||
scroll_id: Id::unique(),
|
||||
current_font: cosmic::font::default(),
|
||||
current_font: iced::font::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +445,7 @@ impl Presenter {
|
|||
.style(move |t| {
|
||||
let mut style =
|
||||
container::Style::default();
|
||||
let theme = t.cosmic();
|
||||
let theme = t.iced();
|
||||
let hovered = self.hovered_slide
|
||||
== Some((
|
||||
item_index,
|
||||
|
@ -504,7 +500,7 @@ impl Presenter {
|
|||
.padding(10),
|
||||
)
|
||||
.interaction(
|
||||
cosmic::iced::mouse::Interaction::Pointer,
|
||||
iced::iced::mouse::Interaction::Pointer,
|
||||
)
|
||||
.on_move(move |_| {
|
||||
Message::HoveredSlide(Some((
|
||||
|
@ -578,7 +574,7 @@ impl Presenter {
|
|||
// Container::new(container)
|
||||
// .style(move |t| {
|
||||
// let mut style = container::Style::default();
|
||||
// let theme = t.cosmic();
|
||||
// let theme = t.iced();
|
||||
// let hovered = self.hovered_slide == slide_id;
|
||||
// style.background = Some(Background::Color(
|
||||
// if is_current_slide {
|
||||
|
@ -617,7 +613,7 @@ impl Presenter {
|
|||
// .height(100)
|
||||
// .padding(10),
|
||||
// )
|
||||
// .interaction(cosmic::iced::mouse::Interaction::Pointer)
|
||||
// .interaction(iced::iced::mouse::Interaction::Pointer)
|
||||
// .on_move(move |_| Message::HoveredSlide(slide_id))
|
||||
// .on_exit(Message::HoveredSlide(-1))
|
||||
// .on_press(Message::SlideChange(slide.clone()));
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
use std::{io, path::PathBuf};
|
||||
|
||||
use cosmic::{
|
||||
iced::{Color, Font, Length, Size},
|
||||
prelude::*,
|
||||
use iced::{
|
||||
widget::{
|
||||
self,
|
||||
canvas::{self, Program, Stroke},
|
||||
container, Canvas,
|
||||
},
|
||||
Renderer,
|
||||
Color, Font, Length, Renderer, Size,
|
||||
};
|
||||
use tracing::debug;
|
||||
|
||||
|
@ -51,14 +49,14 @@ pub enum SlideError {
|
|||
|
||||
#[derive(Debug, Default)]
|
||||
struct EditorProgram {
|
||||
mouse_button_pressed: Option<cosmic::iced::mouse::Button>,
|
||||
mouse_button_pressed: Option<iced::iced::mouse::Button>,
|
||||
}
|
||||
|
||||
impl SlideEditor {
|
||||
pub fn view<'a>(
|
||||
&'a self,
|
||||
font: Font,
|
||||
) -> cosmic::Element<'a, SlideWidget> {
|
||||
) -> iced::Element<'a, SlideWidget> {
|
||||
container(
|
||||
widget::canvas(&self.program)
|
||||
.height(Length::Fill)
|
||||
|
@ -68,9 +66,9 @@ impl SlideEditor {
|
|||
}
|
||||
}
|
||||
|
||||
/// Ensure to use the `cosmic::Theme and cosmic::Renderer` here
|
||||
/// Ensure to use the `iced::Theme and iced::Renderer` here
|
||||
/// or else it will not compile
|
||||
impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
||||
impl<'a> Program<SlideWidget, iced::Theme, iced::Renderer>
|
||||
for EditorProgram
|
||||
{
|
||||
type State = ();
|
||||
|
@ -79,9 +77,9 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
&self,
|
||||
state: &Self::State,
|
||||
renderer: &Renderer,
|
||||
theme: &cosmic::Theme,
|
||||
bounds: cosmic::iced::Rectangle,
|
||||
cursor: cosmic::iced_core::mouse::Cursor,
|
||||
theme: &iced::Theme,
|
||||
bounds: iced::iced::Rectangle,
|
||||
cursor: iced::iced_core::mouse::Cursor,
|
||||
) -> Vec<canvas::Geometry<Renderer>> {
|
||||
// We prepare a new `Frame`
|
||||
let mut frame = canvas::Frame::new(renderer, bounds.size());
|
||||
|
@ -90,7 +88,7 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
// We create a `Path` representing a simple circle
|
||||
let circle = canvas::Path::circle(frame.center(), 50.0);
|
||||
let border = canvas::Path::rectangle(
|
||||
cosmic::iced::Point { x: 10.0, y: 10.0 },
|
||||
iced::iced::Point { x: 10.0, y: 10.0 },
|
||||
Size::new(frame_rect.width, frame_rect.height),
|
||||
);
|
||||
|
||||
|
@ -117,18 +115,18 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
&self,
|
||||
_state: &mut Self::State,
|
||||
event: canvas::Event,
|
||||
bounds: cosmic::iced::Rectangle,
|
||||
_cursor: cosmic::iced_core::mouse::Cursor,
|
||||
bounds: iced::iced::Rectangle,
|
||||
_cursor: iced::iced_core::mouse::Cursor,
|
||||
) -> (canvas::event::Status, Option<SlideWidget>) {
|
||||
match event {
|
||||
canvas::Event::Mouse(event) => match event {
|
||||
cosmic::iced::mouse::Event::CursorEntered => {
|
||||
iced::iced::mouse::Event::CursorEntered => {
|
||||
debug!("cursor entered")
|
||||
}
|
||||
cosmic::iced::mouse::Event::CursorLeft => {
|
||||
iced::iced::mouse::Event::CursorLeft => {
|
||||
debug!("cursor left")
|
||||
}
|
||||
cosmic::iced::mouse::Event::CursorMoved {
|
||||
iced::iced::mouse::Event::CursorMoved {
|
||||
position,
|
||||
} => {
|
||||
if bounds.x < position.x
|
||||
|
@ -139,16 +137,16 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
debug!(?position, "cursor moved");
|
||||
}
|
||||
}
|
||||
cosmic::iced::mouse::Event::ButtonPressed(button) => {
|
||||
iced::iced::mouse::Event::ButtonPressed(button) => {
|
||||
// self.mouse_button_pressed = Some(button);
|
||||
debug!(?button, "mouse button pressed")
|
||||
}
|
||||
cosmic::iced::mouse::Event::ButtonReleased(
|
||||
button,
|
||||
) => debug!(?button, "mouse button released"),
|
||||
cosmic::iced::mouse::Event::WheelScrolled {
|
||||
delta,
|
||||
} => debug!(?delta, "scroll wheel"),
|
||||
iced::iced::mouse::Event::ButtonReleased(button) => {
|
||||
debug!(?button, "mouse button released")
|
||||
}
|
||||
iced::iced::mouse::Event::WheelScrolled { delta } => {
|
||||
debug!(?delta, "scroll wheel")
|
||||
}
|
||||
},
|
||||
canvas::Event::Touch(event) => debug!("test"),
|
||||
canvas::Event::Keyboard(event) => debug!("test"),
|
||||
|
@ -159,9 +157,9 @@ impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
|||
fn mouse_interaction(
|
||||
&self,
|
||||
_state: &Self::State,
|
||||
_bounds: cosmic::iced::Rectangle,
|
||||
_cursor: cosmic::iced_core::mouse::Cursor,
|
||||
) -> cosmic::iced_core::mouse::Interaction {
|
||||
cosmic::iced_core::mouse::Interaction::default()
|
||||
_bounds: iced::iced::Rectangle,
|
||||
_cursor: iced::iced_core::mouse::Cursor,
|
||||
) -> iced::iced_core::mouse::Interaction {
|
||||
iced::iced_core::mouse::Interaction::default()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,17 @@
|
|||
use std::{io, path::PathBuf};
|
||||
|
||||
use cosmic::{
|
||||
dialog::file_chooser::open::Dialog,
|
||||
iced::{
|
||||
font::{Family, Stretch, Style, Weight},
|
||||
Font, Length,
|
||||
},
|
||||
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
||||
iced_widget::row,
|
||||
use dirs::font_dir;
|
||||
use iced::{
|
||||
advanced::graphics::text::cosmic_text::fontdb,
|
||||
font::{Family, Stretch, Style, Weight},
|
||||
theme,
|
||||
widget::row,
|
||||
widget::{
|
||||
button, column, combo_box, container, horizontal_space, icon,
|
||||
button, column, combo_box, container, horizontal_space,
|
||||
scrollable, text, text_editor, text_input,
|
||||
},
|
||||
Element, Task,
|
||||
Element, Font, Length, Task,
|
||||
};
|
||||
use dirs::font_dir;
|
||||
use iced_video_player::Video;
|
||||
use tracing::{debug, error};
|
||||
|
||||
|
@ -133,7 +129,7 @@ impl SongEditor {
|
|||
audio: PathBuf::new(),
|
||||
background: None,
|
||||
video: None,
|
||||
current_font: cosmic::font::default(),
|
||||
current_font: iced::font::default(),
|
||||
ccli: "8".to_owned(),
|
||||
slide_state: SlideEditor::default(),
|
||||
}
|
||||
|
@ -283,7 +279,7 @@ impl SongEditor {
|
|||
]
|
||||
.into(),
|
||||
])
|
||||
.spacing(theme::active().cosmic().space_l());
|
||||
.spacing(theme::active().iced().space_l());
|
||||
column.into()
|
||||
}
|
||||
|
||||
|
@ -317,7 +313,7 @@ impl SongEditor {
|
|||
// .collect();
|
||||
// scrollable(
|
||||
// column::with_children(slides)
|
||||
// .spacing(theme::active().cosmic().space_l()),
|
||||
// .spacing(theme::active().iced().space_l()),
|
||||
// )
|
||||
// .height(Length::Fill)
|
||||
// .width(Length::Fill)
|
||||
|
@ -401,7 +397,7 @@ order",
|
|||
)
|
||||
},
|
||||
)
|
||||
.width(theme::active().cosmic().space_xxl());
|
||||
.width(theme::active().iced().space_xxl());
|
||||
|
||||
let background_selector = button::icon(
|
||||
icon::from_name("folder-pictures-symbolic").scale(2),
|
||||
|
|
|
@ -4,13 +4,10 @@ use std::{
|
|||
};
|
||||
|
||||
use colors_transform::Rgb;
|
||||
use cosmic::{
|
||||
iced::{
|
||||
font::{Style, Weight},
|
||||
Length, Size,
|
||||
},
|
||||
prelude::*,
|
||||
use iced::{
|
||||
font::{Style, Weight},
|
||||
widget::{container, svg::Handle, Svg},
|
||||
Length, Size,
|
||||
};
|
||||
use tracing::error;
|
||||
|
||||
|
@ -46,11 +43,11 @@ pub struct Font {
|
|||
size: u8,
|
||||
}
|
||||
|
||||
impl From<cosmic::font::Font> for Font {
|
||||
fn from(value: cosmic::font::Font) -> Self {
|
||||
impl From<iced::font::Font> for Font {
|
||||
fn from(value: iced::font::Font) -> Self {
|
||||
Self {
|
||||
name: match value.family {
|
||||
cosmic::iced::font::Family::Name(name) => {
|
||||
iced::iced::font::Family::Name(name) => {
|
||||
name.to_string()
|
||||
}
|
||||
_ => "Quicksand Bold".into(),
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use cosmic::iced::advanced::layout::{self, Layout};
|
||||
use cosmic::iced::advanced::renderer;
|
||||
use cosmic::iced::advanced::widget::{self, Widget};
|
||||
use cosmic::iced::border;
|
||||
use cosmic::iced::mouse;
|
||||
use cosmic::iced::{Color, Element, Length, Rectangle, Size};
|
||||
use femtovg::renderer::WGPURenderer;
|
||||
use femtovg::{Canvas, TextContext};
|
||||
use iced::iced::advanced::layout::{self, Layout};
|
||||
use iced::iced::advanced::renderer;
|
||||
use iced::iced::advanced::widget::{self, Widget};
|
||||
use iced::iced::border;
|
||||
use iced::iced::mouse;
|
||||
use iced::iced::{Color, Element, Length, Rectangle, Size};
|
||||
|
||||
pub struct SlideText {
|
||||
text: String,
|
||||
|
@ -23,7 +23,7 @@ impl SlideText {
|
|||
});
|
||||
let surface =
|
||||
instance.create_surface(window.clone()).unwrap();
|
||||
let adapter = cosmic::iced::wgpu::util::initialize_adapter_from_env_or_default(&instance, Some(&surface))
|
||||
let adapter = iced::iced::wgpu::util::initialize_adapter_from_env_or_default(&instance, Some(&surface))
|
||||
.await
|
||||
.expect("Failed to find an appropriate adapter");
|
||||
let (device, queue) = adapter
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue