Fullscreen MediaViewer refactor

- Moved media related logic into notedeck instead of the ui crate,
  since they pertain to Images/ImageCache based systems

- Made RenderableMedia owned to make it less of a nightmware
  to work with and the perf should be negligible

- Added a ImageMetadata cache to Images. This is referenced
  whenever we encounter an image so we don't have to
  redo the work all of the time

- Relpaced our ad-hoc, hand(vibe?)-coded panning and zoom logic
  with the Scene widget, which is explicitly designed for
  this use case

- Extracted and detangle fullscreen media rendering from inside of note
  rendering.  We instead let the application decide what action they
  want to perform when note media is clicked on.

- We add an on_view_media action to MediaAction for the application to
  handle. The Columns app uses this toggle a FullscreenMedia app
  option bits whenever we get a MediaAction::ViewMedis(urls).

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-07-25 13:45:54 -07:00
parent 96ab4ee681
commit 3d18db8fd2
45 changed files with 1284 additions and 1222 deletions

View File

@@ -1,6 +1,7 @@
use crate::{
column::Columns,
nav::{RouterAction, RouterType},
options::AppOptions,
route::Route,
timeline::{
thread::{
@@ -8,6 +9,7 @@ use crate::{
},
ThreadSelection, TimelineCache, TimelineKind,
},
view_state::ViewState,
};
use enostr::{NoteId, Pubkey, RelayPool};
@@ -51,6 +53,8 @@ fn execute_note_action(
global_wallet: &mut GlobalWallet,
zaps: &mut Zaps,
images: &mut Images,
view_state: &mut ViewState,
app_options: &mut AppOptions,
router_type: RouterType,
ui: &mut egui::Ui,
col: usize,
@@ -153,7 +157,12 @@ fn execute_note_action(
}
},
NoteAction::Media(media_action) => {
media_action.process(images);
media_action.on_view_media(|medias| {
view_state.media_viewer.urls = medias;
app_options.set(AppOptions::FullscreenMedia, true);
});
media_action.process_default_media_actions(images)
}
}
@@ -180,6 +189,8 @@ pub fn execute_and_process_note_action(
global_wallet: &mut GlobalWallet,
zaps: &mut Zaps,
images: &mut Images,
view_state: &mut ViewState,
app_options: &mut AppOptions,
ui: &mut egui::Ui,
) -> Option<RouterAction> {
let router_type = {
@@ -204,6 +215,8 @@ pub fn execute_and_process_note_action(
global_wallet,
zaps,
images,
view_state,
app_options,
router_type,
ui,
col,