diff --git a/src/gui/Layout.cpp b/src/gui/Layout.cpp index fe673ab6..67ccf861 100644 --- a/src/gui/Layout.cpp +++ b/src/gui/Layout.cpp @@ -436,6 +436,15 @@ void Layout::scrollRelativ(int x, int y) this->scrollVertical->scroll(y); } +void Layout::scrollAbs(int x, int y) +{ + XOJ_CHECK_TYPE(Layout); + + // TODO Check if really working + this->scrollHorizontal->setValue(x); + this->scrollVertical->setValue(y); +} + double Layout::getVisiblePageTop(size_t page) { XOJ_CHECK_TYPE(Layout); diff --git a/src/gui/Layout.h b/src/gui/Layout.h index fafc33ee..6fffa18f 100644 --- a/src/gui/Layout.h +++ b/src/gui/Layout.h @@ -19,6 +19,12 @@ class PageView; class XournalView; +/** + * @brief The Layout manager for the XournalWidget + * + * This class manages the layout of the PageView%s contained + * in the XournalWidget + */ class Layout : public ScrollbarListener { public: @@ -26,10 +32,35 @@ public: virtual ~Layout(); public: + /** + * Adjusts the layout size to the given values + */ void setSize(int widgetWidth, int widgetHeight); + + /** + * Increases the adjustments by the given amounts + */ void scrollRelativ(int x, int y); + + /** + * Changes the adjustments by absolute amounts (for pinch-to-zoom) + */ + void scrollAbs(int x, int y); + + /** + * Handle a scroll event + */ bool scrollEvent(GdkEventScroll* event); + + /** + * Changes the adjustments in such a way as to make sure that + * the given Rectangle is visible + * + * @remark If the given Rectangle won't fit into the scrolled window + * then only its top left corner will be visible + */ void ensureRectIsVisible(int x, int y, int width, int height); + double getVisiblePageTop(size_t page); double getDisplayHeight(); diff --git a/src/gui/XournalView.cpp b/src/gui/XournalView.cpp index 9b0fe1af..5e4734ef 100644 --- a/src/gui/XournalView.cpp +++ b/src/gui/XournalView.cpp @@ -791,11 +791,7 @@ void XournalView::pageInserted(size_t page) Layout* layout = gtk_xournal_get_layout(this->widget); layout->layoutPages(); -#if GTK3_ENABLED - layout->updateCurrentPage(); -#else layout->checkSelectedPage(); -#endif } double XournalView::getZoom() diff --git a/src/gui/widgets/XournalWidget.h b/src/gui/widgets/XournalWidget.h index 0179029a..67b8833a 100644 --- a/src/gui/widgets/XournalWidget.h +++ b/src/gui/widgets/XournalWidget.h @@ -15,9 +15,9 @@ G_BEGIN_DECLS -#define GTK_XOURNAL(obj) GTK_CHECK_CAST(obj, gtk_xournal_get_type (), GtkXournal) +#define GTK_XOURNAL(obj) G_TYPE_CHECK_INSTANCE_CAST(obj, gtk_xournal_get_type (), GtkXournal) #define GTK_XOURNAL_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_xournal_get_type(), GtkXournalClass) -#define GTK_IS_XOURNAL(obj) GTK_CHECK_TYPE(obj, gtk_xournal_get_type()) +#define GTK_IS_XOURNAL(obj) G_TYPE_CHECK_INSTANCE_TYPE(obj, gtk_xournal_get_type()) class EditSelection; class Layout;