#+TITLE: The Task list for Lumina
#+FILETAGS: :project:dev:
#+CATEGORY: dev


* TODO [#A] Add Action system
This will be based on each slide having the ability to activate an action (i.e. OBS scene switch, OBS start or stop) when it is active.

This is working but the right click context menu is all the way on the edge of the ui so you can't control all the slides. It also needs a lot of help in making the system more robust and potentially lest reliant on the Presenter struct itself.

* TODO [#A] Make sure that adding, deleting and editing items in each model is working correctly

Let's build some tests that ensure that these functions are working for the models. Make sure the models are built in such a way as to make sure that they are testable and work fast for the user.

By making the db functions take the vector of items in the model, we can drain the model, pass an owned version of those items to the async db function(adding, updating, deleting, etc) and then return an updated list of the items back in the Result.

We should probably return a tuple with the original vector of items in case the db function fails somehow.

* TODO [#B] Font in the song editor doesn't always use the original version
There seems to be some issue with fontdb not able to decipher all the versions of some fonts that are OTF and then end up loading the wrong ones in some issues.

* TODO [#B] Find a way to use auth-token in tests for ci
If I can find out how to use my secrets in ci that would free up more tests, but I could also just turn that test off for the CI so that it won't constantly fail for now
* TODO [#C] Rename menu actions to menu commands and build a reverse hashmap for settings to map commands to key-binding such that we can allow for remapping them on the fly.

* TODO [#B] Saving and loading font awareness
Someday we should make the saving and loading to be aware of the fonts on the system and find a way to embed them into the save file.

* TODO [#B] Develop ui for settings

* TODO [#B] Develop library system for slides that are more than images or video i.e. content

* TODO [#C] Use orgize as a file parser and allow for orgdown files to represent a presentation.
Orgize has some very nice features that will let me determine what things are in an orgdown file and thus take said file and turn it into a presentation.

After looking more and more at how the orgize docs describe things and the testing platform found at: https://poiscript.github.io/orgize/ I believe this will work. The main things are that I can possibly decide how to interpret certain pieces of orgdown to mean certain things in lumina. Essentially a properties drawer or tag can indicate backgrounds and other info for the slides or songs and then the notes blocks can indicate text that shouldn't be printed into the slide, thus allowing a single orgdown document to illustrate both an entire presentation, but also the notes and plan for the presenter.

I could potentially do the same with markdown, but since this is for me first, I'll use orgdown because I enjoy the syntax a lot more.

* TODO [#C] Allow for a way to split the presentation up with a right click menu for the presentation preview row.

* TODO [#C] Text could be built by using SVG instead of the text element. Maybe I could construct my own text element even
This does almost work. There is a clear amount of lag or rather hang up since switching to the =text_svg=  element. I think I may only keep it till I can figure out how to do strokes and shadows in iced's normal text element.

Actually, what if we just made the svg at load/creation time and stored it in the file system for later, then load the entire songs svg's into memory during the presentation to speed things up? Would that be faster than creating them at on the fly? Is it the creation of them that is slow or the rendering?

** SVG performs badly
Since SVG's apparently run poorly in iced, instead I'll need to see about either creating a new text element, or teaching Iced to render strokes and shadows on text.

** Fork Cryoglyph
This fork will render text 3 times. Once for the text, once for the stroke, once for the shadow. This will only be used in the slides and therefore should not be much of a performance hit since we will only be render 3 copies of the given text. This should not be bad performance since it's not a large amount of text.

This also means in our custom widget with our custom fork, we can animate each individually perhaps.

** Actually.....
I tried out a way of generating the svg and rasterizing it ahead of time and then storing it in the file system to be cached. This works out very well. The text is one whole image for a slides text that gets layered on top of the background, but it works out well for now.

The problem with this approach is that every change to a song's text or font metrics means we need to rebuild all the text items for that song. I need to think of a way for the text generation to be done asynchronously so that the ui isn't locked up.

I bet this is tricking up the loading mechanism. Loading only grabs all the backgrounds and audio pieces, not the text_svg pieces. So maybe it should so that the generator can run again and grab the same pieces from the filesystem rather than recreate them. This gets extra tricky because we may have fonts that are missing when loading a file. In such a case the loading mechanism ought to suggest to the user to grab those fonts and then perhaps load the cached file while being extra clear that any changes will mess up the text since they no longer possess the font that is in the loaded file. Maybe what we can do is during save, save a copy of all the fonts as well and then during load check to see if the computer has them, if they don't offer to install them on the spot such that they can use the font as is. I wonder if we are allowed to pass fonts around that way.

** Made this slightly faster
Since strings are allocated on the heap, I've changed how to construct the svg string a bit, but honestly, it doesn't matter too much because most of the performance cost seems to be in rendering the string using resvg. So, this can still be something that get's fixed later, and I believe that fix will come in the form of a multi-channel signed distance field wgpu rendered text eventually. We can work on this much later though.

* TODO [#C] Make the presenter more modular so things are easier to change. This is vague...

* TODO [#C] Figure out why the Video element seems to have problems when moving the mouse around

* DONE [#A] Create a view of all slides in a PDF presenation

* DONE [#A] Develop DnD for library items
This is limited by the fact that I need to develop this in cosmic. I am honestly thinking that I'll need to build my own drag and drop system or at least work with system76 to fix their dnd system on other systems.

This needs lots more attention

* DONE [#A] File saving and loading
Need to make sure we can save a file with all files archived in it and load it back up.

This is giving me a lot of thoughts...
1. That saving and loading needs to know about fonts as well.
2. That TextSvgs should likely be saved as well since the other machines may not always have the same fonts.
3. That means that TextSvg should have a path option that could hold the cached svg that has already been rendered and that this gets changed to the loaded files directory rather than using the default cache directory.

* DONE [#A] Add removal and reordering of service_items
Reordering is finished
* DONE [#A] Change return type of all components to an Action enum instead of the Task<Message> type [0%] [0/0]
** DONE Library
** DONE SongEditor
** DONE Presenter

* DONE [#A] Need to fix tests now that the basic app is working
Lots of them have been tweaked to be completing now, but there is more work to do and several need to likely be a lot more robust.

Still failing 4 tests, all to do with the db or lisp. I might throw out the lisp code at some point tho. I keep thinking that a better alternative would be to have a markdown serialization system such that you can write slides in markdown somehow and they would be able to be loaded.

* DONE [#A] Make sure updating verse updates the lyrics too
[[file:~/dev/lumina-iced/src/core/songs.rs::old_verse = verse;]]

This is necessary so that the entire song gets changed and we can propogate those changes then back to the db.

There is likely some work that still needs to be done here, I believe I am somehow deleting some of my verses.
* DONE [#A] Need to fixup how songs are edited in the editors
Currently the song is cloned many times to pass around and then finally get updated in DB. Instead, we need to edit the song directly in the editor and after it's been changed appropriatel, run the update_song method to get the current song and create slides from it and then update it in the DB.

* DONE [#B] Functions for text alignments
This will need to be matched on for the =TextAlignment= from the user

* DONE Move text_generation function to be asynchronous so that UI doesn't lock up during song editing.
* DONE Build a presentation editor

* DONE Build library to see all available songs, images, videos, presentations, and slides
** DONE Develop ui for libraries
I've got the library basic layer done, I need to develop a way to open the libraries accordion button and then show the list of items in the library
** DONE Need to do search and creation systems yet

* DONE [#B] Build editors for each possible item
** DONE Develop ui for editors

* DONE [#B] Find a way to load and discover every font on the system for slide building
This may not be necessary since it is possible to create a font using =Box::leak()=.
#+begin_src rust
let font = self.current_slide.font().into_boxed_str();
let family = Family::Name(Box::leak(font));
let weight = Weight::Normal;
let stretch = Stretch::Normal;
let style = Style::Normal;
let font = Font {
    family,
    weight,
    stretch,
    style,
};
#+end_src

This code creates a font by leaking the Box to a ='static &str=. I just am not sure if the &str stays around in memory after the view function. If it does, then it's not on the stack anymore and should be fine, but if it isn't cleaned up then we will have a memory leak.

Krimzin on Discord told me that maybe the =update= method is a better place for this Box to be created or updated and then maybe I could generate the view from there.

* DONE Build an image editor
* DONE Use Rich Text instead of normal text for slides
This will make it so that we can add styling to the text like borders and backgrounds or highlights. Maybe in the future it'll add shadows too.
* DONE Build a video editor
* DONE Check into =mupdf-rs= for loading PDF's.

* DONE Build Menu
* DONE Find a way for text to pass through a service item to a slide i.e. content piece
This proved easier by just creating the =Slide= first and inserting it into the =ServiceItem=.
