#ifndef _FM_PREVIEW_MENU_H_ #define _FM_PREVIEW_MENU_H_ #include #include /** * Full-screen preview of images and MP4 videos. L/R go to the previous and next * previewable file of the folder, Cross pauses a video, Circle closes. Images * support swipe navigation, pinch zoom, mirroring and vertical inversion. */ class PreviewMenu { public: PreviewMenu(paf::ui::Widget *parentRoot, const paf::vector &paths, int32_t index); ~PreviewMenu(); /** Worker-thread side of loading an image. */ void LoadImageJob(); /** Runs on the main thread, once per frame, while a video is open. */ void OnVideoFrame(); void OnImageTouch(); void OnOptions(); void OnOption(int32_t index); /** Closes the page on the next frame. */ void Close(); void SeekVideo(int32_t deltaMs); private: void Open(int32_t index); void StopVideo(); bool StartVideo(const char *path); void ShowError(); void ApplyImageTransform(); enum { OptionTag = 0x50525657 }; paf::ui::Widget *m_parentRoot; paf::ui::Scene *m_root; paf::ui::Widget *m_plane; paf::ui::BusyIndicator *m_busy; paf::ui::Text *m_title; paf::ui::Text *m_error; paf::vector m_paths; int32_t m_index; volatile int32_t m_loadId; int32_t m_jobId; paf::string m_jobPath; int32_t m_player; bool m_videoActive; bool m_imageActive; bool m_paused; bool m_frameShown; uint32_t *m_rgba; int32_t m_videoW; int32_t m_videoH; paf::intrusive_ptr m_videoSurf; paf::ui::Widget *m_controls; paf::ui::Widget *m_time; paf::ui::Widget *m_barFill; uint64_t m_duration; uint32_t m_frameCounter; bool m_touchActive; bool m_pinchActive; float m_touchStartX; float m_touchStartY; float m_touchLastX; float m_touchLastY; float m_pinchStart; float m_pinchScale; float m_imageScale; float m_imageInitialScale; float m_imageX; float m_imageY; bool m_flipX; bool m_flipY; }; #endif