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:
@@ -14,13 +14,12 @@ use egui::{
|
||||
};
|
||||
use enostr::{FilledKeypair, FullKeypair, NoteId, Pubkey, RelayPool};
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
use notedeck::media::gif::ensure_latest_texture;
|
||||
use notedeck::{get_render_state, JobsCache, PixelDimensions, RenderState};
|
||||
|
||||
use notedeck_ui::{
|
||||
app_images,
|
||||
blur::PixelDimensions,
|
||||
context_menu::{input_context, PasteBehavior},
|
||||
gif::{handle_repaint, retrieve_latest_texture},
|
||||
images::{get_render_state, RenderState},
|
||||
jobs::JobsCache,
|
||||
note::render_note_preview,
|
||||
NoteOptions, ProfilePic,
|
||||
};
|
||||
@@ -471,7 +470,7 @@ impl<'a, 'd> PostView<'a, 'd> {
|
||||
self.note_context.img_cache,
|
||||
cache_type,
|
||||
url,
|
||||
notedeck_ui::images::ImageType::Content(Some((width, height))),
|
||||
notedeck::ImageType::Content(Some((width, height))),
|
||||
);
|
||||
|
||||
render_post_view_media(
|
||||
@@ -595,12 +594,10 @@ fn render_post_view_media(
|
||||
.to_points(ui.pixels_per_point())
|
||||
.to_vec();
|
||||
|
||||
let texture_handle = handle_repaint(
|
||||
ui,
|
||||
retrieve_latest_texture(url, render_state.gifs, renderable_media),
|
||||
);
|
||||
let texture_handle =
|
||||
ensure_latest_texture(ui, url, render_state.gifs, renderable_media);
|
||||
let img_resp = ui.add(
|
||||
egui::Image::new(texture_handle)
|
||||
egui::Image::new(&texture_handle)
|
||||
.max_size(size)
|
||||
.corner_radius(12.0),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user