mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
PDFViewer: Add actions to rotate the displayed PDF
This implements the rotate cw/ccw actions in PDFViewer. Since the rendered pages are stored in a HashMap for caching, the bitmap is wrapped in a struct with the current rotation. This way the caching works as expected while zooming, and a new bitmap is rendered when the page is rotated.
This commit is contained in:
parent
cecbed467b
commit
eb97617ff0
4 changed files with 36 additions and 7 deletions
|
@ -52,6 +52,7 @@ public:
|
|||
void zoom_in();
|
||||
void zoom_out();
|
||||
void reset_zoom();
|
||||
void rotate(int degrees);
|
||||
|
||||
protected:
|
||||
PDFViewer();
|
||||
|
@ -64,14 +65,20 @@ protected:
|
|||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
private:
|
||||
struct RenderedPage {
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
int rotation;
|
||||
};
|
||||
|
||||
RefPtr<Gfx::Bitmap> get_rendered_page(u32 index);
|
||||
RefPtr<Gfx::Bitmap> render_page(const PDF::Page&);
|
||||
|
||||
RefPtr<PDF::Document> m_document;
|
||||
u32 m_current_page_index { 0 };
|
||||
Vector<HashMap<u32, RefPtr<Gfx::Bitmap>>> m_rendered_page_list;
|
||||
Vector<HashMap<u32, RenderedPage>> m_rendered_page_list;
|
||||
|
||||
u8 m_zoom_level { initial_zoom_level };
|
||||
|
||||
Gfx::IntPoint m_pan_starting_position;
|
||||
int m_rotations { 0 };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue