Files
notedeck/crates/notedeck_columns/src/view_state.rs
William Casarin 3d18db8fd2 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>
2025-07-28 08:57:57 -07:00

35 lines
1.0 KiB
Rust

use std::collections::HashMap;
use enostr::Pubkey;
use crate::deck_state::DeckState;
use crate::login_manager::AcquireKeyState;
use crate::ui::search::SearchQueryState;
use enostr::ProfileState;
use notedeck_ui::media::MediaViewerState;
/// Various state for views
///
/// TODO(jb55): we likely want to encapsulate these better,
/// or at least document where they are used
#[derive(Default)]
pub struct ViewState {
pub login: AcquireKeyState,
pub id_to_deck_state: HashMap<egui::Id, DeckState>,
pub id_state_map: HashMap<egui::Id, AcquireKeyState>,
pub id_string_map: HashMap<egui::Id, String>,
pub searches: HashMap<egui::Id, SearchQueryState>,
pub pubkey_to_profile_state: HashMap<Pubkey, ProfileState>,
/// Keeps track of what urls we are actively viewing in the
/// fullscreen media viewier, as well as any other state we want to
/// keep track of
pub media_viewer: MediaViewerState,
}
impl ViewState {
pub fn login_mut(&mut self) -> &mut AcquireKeyState {
&mut self.login
}
}