mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 18:02:05 -05:00
PDFViewer: Update the page number when scrolling between pages
This commit is contained in:
parent
395bee07e0
commit
4f0a75224c
3 changed files with 9 additions and 0 deletions
|
@ -90,6 +90,8 @@ void PDFViewer::mousewheel_event(GUI::MouseEvent& event)
|
|||
if (scrollbar.value() == scrollbar.max()) {
|
||||
if (m_current_page_index < m_document->get_page_count() - 1) {
|
||||
m_current_page_index++;
|
||||
if (on_page_change)
|
||||
on_page_change(m_current_page_index);
|
||||
scrollbar.set_value(0);
|
||||
}
|
||||
} else {
|
||||
|
@ -99,6 +101,8 @@ void PDFViewer::mousewheel_event(GUI::MouseEvent& event)
|
|||
if (scrollbar.value() == 0) {
|
||||
if (m_current_page_index > 0) {
|
||||
m_current_page_index--;
|
||||
if (on_page_change)
|
||||
on_page_change(m_current_page_index);
|
||||
scrollbar.set_value(scrollbar.max());
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -47,6 +47,8 @@ public:
|
|||
ALWAYS_INLINE const RefPtr<PDF::Document>& document() const { return m_document; }
|
||||
void set_document(RefPtr<PDF::Document>);
|
||||
|
||||
Function<void(u32 new_page)> on_page_change;
|
||||
|
||||
protected:
|
||||
PDFViewer();
|
||||
|
||||
|
|
|
@ -30,6 +30,9 @@ PDFViewerWidget::PDFViewerWidget()
|
|||
m_sidebar->set_fixed_width(0);
|
||||
|
||||
m_viewer = splitter.add<PDFViewer>();
|
||||
m_viewer->on_page_change = [&](auto new_page) {
|
||||
m_page_text_box->set_current_number(new_page + 1);
|
||||
};
|
||||
}
|
||||
|
||||
void PDFViewerWidget::initialize_menubar(GUI::Menubar& menubar)
|
||||
|
|
Loading…
Add table
Reference in a new issue