media/viewer: fullscreen transition animations
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
use crate::{
|
||||
column::Columns,
|
||||
nav::{RouterAction, RouterType},
|
||||
options::AppOptions,
|
||||
route::Route,
|
||||
timeline::{
|
||||
thread::{
|
||||
@@ -18,6 +17,7 @@ use notedeck::{
|
||||
get_wallet_for, note::ZapTargetAmount, Accounts, GlobalWallet, Images, NoteAction, NoteCache,
|
||||
NoteZapTargetOwned, UnknownIds, ZapAction, ZapTarget, ZappingError, Zaps,
|
||||
};
|
||||
use notedeck_ui::media::MediaViewerFlags;
|
||||
use tracing::error;
|
||||
|
||||
pub struct NewNotes {
|
||||
@@ -54,7 +54,6 @@ fn execute_note_action(
|
||||
zaps: &mut Zaps,
|
||||
images: &mut Images,
|
||||
view_state: &mut ViewState,
|
||||
app_options: &mut AppOptions,
|
||||
router_type: RouterType,
|
||||
ui: &mut egui::Ui,
|
||||
col: usize,
|
||||
@@ -160,7 +159,10 @@ fn execute_note_action(
|
||||
media_action.on_view_media(|medias| {
|
||||
view_state.media_viewer.media_info = medias.clone();
|
||||
tracing::debug!("on_view_media {:?}", &medias);
|
||||
app_options.set(AppOptions::FullscreenMedia, true);
|
||||
view_state
|
||||
.media_viewer
|
||||
.flags
|
||||
.set(MediaViewerFlags::Open, true);
|
||||
});
|
||||
|
||||
media_action.process_default_media_actions(images)
|
||||
@@ -191,7 +193,6 @@ pub fn execute_and_process_note_action(
|
||||
zaps: &mut Zaps,
|
||||
images: &mut Images,
|
||||
view_state: &mut ViewState,
|
||||
app_options: &mut AppOptions,
|
||||
ui: &mut egui::Ui,
|
||||
) -> Option<RouterAction> {
|
||||
let router_type = {
|
||||
@@ -217,7 +218,6 @@ pub fn execute_and_process_note_action(
|
||||
zaps,
|
||||
images,
|
||||
view_state,
|
||||
app_options,
|
||||
router_type,
|
||||
ui,
|
||||
col,
|
||||
|
||||
@@ -23,7 +23,7 @@ use notedeck::{
|
||||
Images, JobsCache, Localization, UnknownIds,
|
||||
};
|
||||
use notedeck_ui::{
|
||||
media::{MediaViewer, MediaViewerState},
|
||||
media::{MediaViewer, MediaViewerFlags, MediaViewerState},
|
||||
NoteOptions,
|
||||
};
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
@@ -368,12 +368,7 @@ fn render_damus(
|
||||
render_damus_desktop(damus, app_ctx, ui)
|
||||
};
|
||||
|
||||
fullscreen_media_viewer_ui(
|
||||
ui,
|
||||
&mut damus.options,
|
||||
&mut damus.view_state.media_viewer,
|
||||
app_ctx.img_cache,
|
||||
);
|
||||
fullscreen_media_viewer_ui(ui, &mut damus.view_state.media_viewer, app_ctx.img_cache);
|
||||
|
||||
// We use this for keeping timestamps and things up to date
|
||||
ui.ctx().request_repaint_after(Duration::from_secs(5));
|
||||
@@ -386,33 +381,35 @@ fn render_damus(
|
||||
/// an image is clicked
|
||||
fn fullscreen_media_viewer_ui(
|
||||
ui: &mut egui::Ui,
|
||||
options: &mut AppOptions,
|
||||
viewer_state: &mut MediaViewerState,
|
||||
state: &mut MediaViewerState,
|
||||
img_cache: &mut Images,
|
||||
) {
|
||||
if !options.contains(AppOptions::FullscreenMedia) || viewer_state.media_info.medias.is_empty() {
|
||||
if !state.should_show(ui) {
|
||||
if state.scene_rect.is_some() {
|
||||
// if we shouldn't show yet we will have a scene
|
||||
// rect, then we should clear it for next time
|
||||
tracing::debug!("fullscreen_media_viewer_ui: resetting scene rect");
|
||||
state.scene_rect = None;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Close it?
|
||||
if ui.input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
fullscreen_media_close(options, viewer_state);
|
||||
fullscreen_media_close(state);
|
||||
return;
|
||||
}
|
||||
|
||||
let resp = MediaViewer::new(viewer_state)
|
||||
.fullscreen(true)
|
||||
.ui(img_cache, ui);
|
||||
let resp = MediaViewer::new(state).fullscreen(true).ui(img_cache, ui);
|
||||
|
||||
if resp.clicked() {
|
||||
fullscreen_media_close(options, viewer_state);
|
||||
fullscreen_media_close(state);
|
||||
}
|
||||
}
|
||||
|
||||
/// Close the fullscreen media player. This also resets the scene_rect state
|
||||
fn fullscreen_media_close(options: &mut AppOptions, state: &mut MediaViewerState) {
|
||||
options.set(AppOptions::FullscreenMedia, false);
|
||||
state.scene_rect = None;
|
||||
fn fullscreen_media_close(state: &mut MediaViewerState) {
|
||||
state.flags.set(MediaViewerFlags::Open, false);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -460,7 +460,6 @@ fn process_render_nav_action(
|
||||
ctx.zaps,
|
||||
ctx.img_cache,
|
||||
&mut app.view_state,
|
||||
&mut app.options,
|
||||
ui,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -16,9 +16,6 @@ bitflags! {
|
||||
|
||||
/// Should we scroll to top on the active column?
|
||||
const ScrollToTop = 1 << 3;
|
||||
|
||||
/// Are we showing fullscreen media?
|
||||
const FullscreenMedia = 1 << 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user