mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
PDFViewer: Enable panning with middle mouse button
Enable the use of the middle mouse button for panning in PDFViewer.
This commit is contained in:
parent
3af71c406d
commit
56bec4968c
Notes:
sideshowbarker
2024-07-17 21:32:24 +09:00
Author: https://github.com/metmo Commit: https://github.com/SerenityOS/serenity/commit/56bec4968c9 Pull-request: https://github.com/SerenityOS/serenity/pull/11653
2 changed files with 28 additions and 0 deletions
|
@ -113,6 +113,29 @@ void PDFViewer::mousewheel_event(GUI::MouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void PDFViewer::mousedown_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (event.button() == GUI::MouseButton::Middle) {
|
||||
m_pan_starting_position = to_content_position(event.position());
|
||||
set_override_cursor(Gfx::StandardCursor::Drag);
|
||||
}
|
||||
}
|
||||
|
||||
void PDFViewer::mouseup_event(GUI::MouseEvent&)
|
||||
{
|
||||
set_override_cursor(Gfx::StandardCursor::None);
|
||||
}
|
||||
|
||||
void PDFViewer::mousemove_event(GUI::MouseEvent& event)
|
||||
{
|
||||
if (event.buttons() & GUI::MouseButton::Middle) {
|
||||
auto delta = to_content_position(event.position()) - m_pan_starting_position;
|
||||
horizontal_scrollbar().decrease_slider_by(delta.x());
|
||||
vertical_scrollbar().decrease_slider_by(delta.y());
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void PDFViewer::timer_event(Core::TimerEvent&)
|
||||
{
|
||||
// Clear the bitmap vector of all pages except the current page
|
||||
|
|
|
@ -58,6 +58,9 @@ protected:
|
|||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousewheel_event(GUI::MouseEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
private:
|
||||
|
@ -69,4 +72,6 @@ private:
|
|||
Vector<HashMap<u32, RefPtr<Gfx::Bitmap>>> m_rendered_page_list;
|
||||
|
||||
u8 m_zoom_level { initial_zoom_level };
|
||||
|
||||
Gfx::IntPoint m_pan_starting_position;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue