From 53555087a709a7a10df7e8a411f9cac0c07afd44 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Thu, 21 Aug 2025 11:58:03 -0500 Subject: [PATCH] fix slide_editor not building --- src/ui/slide_editor.rs | 56 ++++++++++++++++++--------- src/ui/song_editor.rs | 87 +++++++++++++++++++++++------------------- 2 files changed, 84 insertions(+), 59 deletions(-) diff --git a/src/ui/slide_editor.rs b/src/ui/slide_editor.rs index d05d2af..32cfda4 100644 --- a/src/ui/slide_editor.rs +++ b/src/ui/slide_editor.rs @@ -1,23 +1,27 @@ use std::{io, path::PathBuf}; use cosmic::{ - iced::{Color, Font}, + iced::{Color, Font, Length}, + prelude::*, widget::{ self, canvas::{self, Program, Stroke}, + container, Canvas, }, Renderer, }; +use tracing::debug; #[derive(Debug, Default)] struct State { cache: canvas::Cache, } -#[derive(Debug)] -struct SlideEditor<'a> { - state: &'a State, - font: &'a Font, +#[derive(Debug, Default)] +pub struct SlideEditor { + state: State, + font: Font, + program: EditorProgram, } #[derive(Debug, Clone)] @@ -45,23 +49,33 @@ pub enum SlideError { IOError(io::ErrorKind), } -impl State { +#[derive(Debug, Default)] +struct EditorProgram {} + +impl SlideEditor { pub fn view<'a>( &'a self, - font: &'a Font, - ) -> cosmic::iced::Element<'a, SlideWidget> { - widget::canvas(SlideEditor { state: self, font }).into() + font: Font, + ) -> cosmic::Element<'a, SlideWidget> { + container( + widget::canvas(&self.program) + .height(Length::Fill) + .width(Length::Fill), + ) + .into() } } -impl<'a> Program for SlideEditor<'a> { +impl<'a> Program + for EditorProgram +{ type State = (); fn draw( &self, state: &Self::State, renderer: &Renderer, - theme: &cosmic::iced_runtime::core::Theme, + theme: &cosmic::Theme, bounds: cosmic::iced::Rectangle, cursor: cosmic::iced_core::mouse::Cursor, ) -> Vec> { @@ -93,23 +107,27 @@ impl<'a> Program for SlideEditor<'a> { ) -> (canvas::event::Status, Option) { match event { canvas::Event::Mouse(event) => match event { - cosmic::iced::mouse::Event::CursorEntered => todo!(), - cosmic::iced::mouse::Event::CursorLeft => todo!(), + cosmic::iced::mouse::Event::CursorEntered => { + debug!("cursor entered") + } + cosmic::iced::mouse::Event::CursorLeft => { + debug!("cursor left") + } cosmic::iced::mouse::Event::CursorMoved { position, - } => todo!(), + } => debug!(?position, "cursor moved"), cosmic::iced::mouse::Event::ButtonPressed(button) => { - todo!() + debug!(?button, "mouse button pressed") } cosmic::iced::mouse::Event::ButtonReleased( button, - ) => todo!(), + ) => debug!(?button, "mouse button released"), cosmic::iced::mouse::Event::WheelScrolled { delta, - } => todo!(), + } => debug!(?delta, "scroll wheel"), }, - canvas::Event::Touch(event) => todo!(), - canvas::Event::Keyboard(event) => todo!(), + canvas::Event::Touch(event) => debug!("test"), + canvas::Event::Keyboard(event) => debug!("test"), } (canvas::event::Status::Ignored, None) } diff --git a/src/ui/song_editor.rs b/src/ui/song_editor.rs index b175e3d..89ebf89 100644 --- a/src/ui/song_editor.rs +++ b/src/ui/song_editor.rs @@ -21,6 +21,7 @@ use tracing::{debug, error}; use crate::{ core::{service_items::ServiceTrait, songs::Song}, + ui::slide_editor::{self, SlideEditor}, Background, BackgroundKind, }; @@ -45,6 +46,7 @@ pub struct SongEditor { video: Option