From f33acbd9af3e99c5af96a3fe45e0a1c89066963f Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Sun, 23 Aug 2020 14:33:30 -0700 Subject: [PATCH 1/9] Support a fullscreen/presentation view with no padding. --- src/control/zoom/ZoomControl.cpp | 5 +++-- src/gui/Layout.cpp | 5 +++-- src/gui/widgets/XournalWidget.cpp | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/control/zoom/ZoomControl.cpp b/src/control/zoom/ZoomControl.cpp index 52e3a579..71894a96 100644 --- a/src/control/zoom/ZoomControl.cpp +++ b/src/control/zoom/ZoomControl.cpp @@ -174,8 +174,9 @@ auto ZoomControl::updateZoomPresentationValue(size_t pageNo) -> bool { } Rectangle widget_rect = getVisibleRect(); - double zoom_fit_width = widget_rect.width / (page->getWidth() + 14.0); - double zoom_fit_height = widget_rect.height / (page->getHeight() + 14.0); + //printf("[updateZoomPresentationValue] %f %f %f %f\n", widget_rect.width, widget_rect.height, page->getWidth(), page->getHeight()); + double zoom_fit_width = widget_rect.width / (page->getWidth()); + double zoom_fit_height = widget_rect.height / (page->getHeight()); double zoom_presentation = zoom_fit_width < zoom_fit_height ? zoom_fit_width : zoom_fit_height; if (zoom_presentation < this->zoomMin) { return false; diff --git a/src/gui/Layout.cpp b/src/gui/Layout.cpp index e346f93b..e80bcec6 100644 --- a/src/gui/Layout.cpp +++ b/src/gui/Layout.cpp @@ -13,7 +13,7 @@ /** * Padding outside the pages, including shadow */ -constexpr size_t const XOURNAL_PADDING = 10; +constexpr size_t const XOURNAL_PADDING = 0; /** * Allowance for shadow between page pairs in paired page mode @@ -23,7 +23,7 @@ constexpr size_t const XOURNAL_ROOM_FOR_SHADOW = 3; /** * Padding between the pages */ -constexpr size_t const XOURNAL_PADDING_BETWEEN = 15; +constexpr size_t const XOURNAL_PADDING_BETWEEN = 0; Layout::Layout(XournalView* view, ScrollHandling* scrollHandling): view(view), scrollHandling(scrollHandling) { @@ -173,6 +173,7 @@ void Layout::layoutPages(int width, int height) { } valid = false; + //printf("[layoutPages] %i %i\n", width, height); size_t const len = this->view->viewPages.size(); Settings* settings = this->view->getControl()->getSettings(); diff --git a/src/gui/widgets/XournalWidget.cpp b/src/gui/widgets/XournalWidget.cpp index 2e0640d1..9203bdb4 100644 --- a/src/gui/widgets/XournalWidget.cpp +++ b/src/gui/widgets/XournalWidget.cpp @@ -219,6 +219,7 @@ static void gtk_xournal_realize(GtkWidget* widget) { static void gtk_xournal_draw_shadow(GtkXournal* xournal, cairo_t* cr, int left, int top, int width, int height, bool selected) { + return; if (selected) { Shadow::drawShadow(cr, left - 2, top - 2, width + 4, height + 4); From 7234b2922e0bb773fc078a29337441868ead2b72 Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Wed, 26 Aug 2020 17:26:04 -0700 Subject: [PATCH 2/9] Fullscreen now works. Accelerators do not. --- src/control/FullscreenHandler.cpp | 49 ++++++++++++---------- src/control/zoom/ZoomControl.cpp | 2 +- src/gui/Layout.cpp | 13 ++++-- src/gui/MainWindow.cpp | 8 ++-- src/gui/XournalView.cpp | 5 +++ src/gui/scroll/ScrollHandlingXournalpp.cpp | 5 +++ ui/main.glade | 2 +- 7 files changed, 53 insertions(+), 31 deletions(-) diff --git a/src/control/FullscreenHandler.cpp b/src/control/FullscreenHandler.cpp index b5256fb1..dde94c54 100644 --- a/src/control/FullscreenHandler.cpp +++ b/src/control/FullscreenHandler.cpp @@ -27,26 +27,29 @@ void FullscreenHandler::hideWidget(MainWindow* win, const string& widgetName) { // 1px is used by GTK GtkWidget* mainMenubar = win->get("mainMenubar"); - GtkWidget* mainBox = win->get("mainBox"); if (mainMenubar == nullptr || !gtk_widget_is_visible(mainMenubar)) { // Menu not visible (global menu or something like this) return; } - // Remove menu from parent - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(mainMenubar)), mainMenubar); + gtk_widget_hide(mainMenubar); + menubarHidden = true; - GtkWidget* fix = gtk_invisible_new(); + // // Remove menu from parent + // gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(mainMenubar)), mainMenubar); - gtk_widget_set_size_request(fix, 0, 0); - gtk_fixed_put(GTK_FIXED(fix), mainMenubar, 0, 0); + // GtkWidget* fix = gtk_invisible_new(); - gtk_widget_show(fix); + // gtk_widget_set_size_request(fix, 0, 0); + // gtk_fixed_put(GTK_FIXED(fix), mainMenubar, 0, 0); - gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0); + // gtk_widget_show(fix); - menubarHidden = true; + // GtkWidget* mainBox = win->get("mainBox"); + // gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0); + + // menubarHidden = true; return; } @@ -76,24 +79,28 @@ void FullscreenHandler::disableFullscreen(MainWindow* win) { if (this->menubarHidden) { GtkWidget* mainMenubar = win->get("mainMenubar"); - GtkWidget* mainBox = win->get("mainBox"); - GtkWidget* parent = gtk_widget_get_parent(mainMenubar); + gtk_widget_show(mainMenubar); + menubarHidden = false; - // Remove menu from parent - gtk_container_remove(GTK_CONTAINER(parent), mainMenubar); - gtk_box_pack_start(GTK_BOX(mainBox), mainMenubar, false, true, 0); + // GtkWidget* mainBox = win->get("mainBox"); + // GtkWidget* parent = gtk_widget_get_parent(mainMenubar); - GValue value = G_VALUE_INIT; - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, 0); - gtk_container_child_set_property(GTK_CONTAINER(mainBox), mainMenubar, "position", &value); + // // Remove menu from parent + // gtk_container_remove(GTK_CONTAINER(parent), mainMenubar); + // gtk_box_pack_start(GTK_BOX(mainBox), mainMenubar, false, true, 0); - // not needed, will be recreated next time - gtk_widget_destroy(parent); - menubarHidden = false; + // GValue value = G_VALUE_INIT; + // g_value_init(&value, G_TYPE_INT); + // g_value_set_int(&value, 0); + // gtk_container_child_set_property(GTK_CONTAINER(mainBox), mainMenubar, "position", &value); + + // // not needed, will be recreated next time + // gtk_widget_destroy(parent); + + // menubarHidden = false; } } diff --git a/src/control/zoom/ZoomControl.cpp b/src/control/zoom/ZoomControl.cpp index 71894a96..683f6455 100644 --- a/src/control/zoom/ZoomControl.cpp +++ b/src/control/zoom/ZoomControl.cpp @@ -174,7 +174,7 @@ auto ZoomControl::updateZoomPresentationValue(size_t pageNo) -> bool { } Rectangle widget_rect = getVisibleRect(); - //printf("[updateZoomPresentationValue] %f %f %f %f\n", widget_rect.width, widget_rect.height, page->getWidth(), page->getHeight()); + printf("[updateZoomPresentationValue] %f %f %f %f\n", widget_rect.width, widget_rect.height, page->getWidth(), page->getHeight()); double zoom_fit_width = widget_rect.width / (page->getWidth()); double zoom_fit_height = widget_rect.height / (page->getHeight()); double zoom_presentation = zoom_fit_width < zoom_fit_height ? zoom_fit_width : zoom_fit_height; diff --git a/src/gui/Layout.cpp b/src/gui/Layout.cpp index e80bcec6..5ffa3ab0 100644 --- a/src/gui/Layout.cpp +++ b/src/gui/Layout.cpp @@ -18,7 +18,7 @@ constexpr size_t const XOURNAL_PADDING = 0; /** * Allowance for shadow between page pairs in paired page mode */ -constexpr size_t const XOURNAL_ROOM_FOR_SHADOW = 3; +constexpr size_t const XOURNAL_ROOM_FOR_SHADOW = 0; /** * Padding between the pages @@ -149,6 +149,7 @@ void Layout::recalculate() { XojPageView* v = view->viewPages[pageIdx]; widthCols[c] = std::max(widthCols[c], v->getDisplayWidth()); heightRows[r] = std::max(heightRows[r], v->getDisplayHeight()); + //printf("[Layout::recalculate] %lu %lu %u %u\n", r, c, widthCols[c], heightRows[r]); } // add space around the entire page area to accomodate older Wacom tablets with limited sense area. @@ -163,6 +164,8 @@ void Layout::recalculate() { minWidth = std::accumulate(begin(widthCols), end(widthCols), minWidth); minHeight = std::accumulate(begin(heightRows), end(heightRows), minHeight); + + printf("[Layout::recalculate] %zu %zu\n", minWidth, minHeight); setLayoutSize(minWidth, minHeight); valid = true; } @@ -173,7 +176,7 @@ void Layout::layoutPages(int width, int height) { } valid = false; - //printf("[layoutPages] %i %i\n", width, height); + printf("[layoutPages] %i %i\n", width, height); size_t const len = this->view->viewPages.size(); Settings* settings = this->view->getControl()->getSettings(); @@ -286,8 +289,10 @@ void Layout::scrollAbs(double x, double y) { void Layout::ensureRectIsVisible(int x, int y, int width, int height) { - gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x - 5, x + width + 10); - gtk_adjustment_clamp_page(scrollHandling->getVertical(), y - 5, y + height + 10); + // gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x - 5, x + width + 10); + // gtk_adjustment_clamp_page(scrollHandling->getVertical(), y - 5, y + height + 10); + gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x, x + width); + gtk_adjustment_clamp_page(scrollHandling->getVertical(), y, y + height); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e45ed28d..31f9c1fb 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -460,10 +460,10 @@ auto MainWindow::onKeyPressCallback(GtkWidget* widget, GdkEventKey* event, MainW // editing text - give that control return false; } - if (event->keyval == GDK_KEY_Escape) { - win->getControl()->getSearchBar()->showSearchBar(false); - return true; - } + // if (event->keyval == GDK_KEY_Escape) { + // win->getControl()->getSearchBar()->showSearchBar(false); + // return true; + // } return false; diff --git a/src/gui/XournalView.cpp b/src/gui/XournalView.cpp index 2a0469f0..ab70811f 100644 --- a/src/gui/XournalView.cpp +++ b/src/gui/XournalView.cpp @@ -138,6 +138,8 @@ auto XournalView::onKeyPressEvent(GdkEventKey* event) -> bool { if (event->keyval == GDK_KEY_Escape || event->keyval == GDK_KEY_F11) { if (control->isFullscreen()) { control->setFullscreen(false); + control->setViewPresentationMode(false); + control->getWindow()->setToolbarVisible(true); return true; } } @@ -147,6 +149,7 @@ auto XournalView::onKeyPressEvent(GdkEventKey* event) -> bool { if (!control->isFullscreen()) { control->setViewPresentationMode(true); control->setFullscreen(true); + control->getWindow()->setToolbarVisible(false); return true; } } @@ -397,6 +400,8 @@ void XournalView::scrollTo(size_t pageNo, double yDocument) { layout->ensureRectIsVisible(x, y, width, height); + printf("[XournalView::scrollTo] %d %d %d %d\n", x, y, width, height); + // Select the page control->firePageSelected(pageNo); } diff --git a/src/gui/scroll/ScrollHandlingXournalpp.cpp b/src/gui/scroll/ScrollHandlingXournalpp.cpp index 8b47e659..f2089b50 100644 --- a/src/gui/scroll/ScrollHandlingXournalpp.cpp +++ b/src/gui/scroll/ScrollHandlingXournalpp.cpp @@ -21,6 +21,9 @@ auto ScrollHandlingXournalpp::getPreferredHeight() -> int { return 400; } void ScrollHandlingXournalpp::translate(cairo_t* cr, double& x1, double& x2, double& y1, double& y2) { double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); + + printf("[ScrollHandlingXournalpp::translate] %f, %f\n", h, v); + cairo_translate(cr, -h, -v); x1 += h; @@ -34,6 +37,8 @@ void ScrollHandlingXournalpp::translate(double& x, double& y) { double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); + printf("[ScrollHandlingXournalpp::translate] %f, %f\n", h, v); + x += h; y += v; } diff --git a/ui/main.glade b/ui/main.glade index 9e3a3d82..3f1f5a4e 100644 --- a/ui/main.glade +++ b/ui/main.glade @@ -2274,7 +2274,7 @@ searchBar - True + False False vertical From 142a6be0eb62547725ede881f0b5892075cb0440 Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Sun, 15 Nov 2020 22:21:08 -0700 Subject: [PATCH 3/9] Replace comments with preprocessor commands --- src/control/FullscreenHandler.cpp | 51 ++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/control/FullscreenHandler.cpp b/src/control/FullscreenHandler.cpp index dde94c54..58f7e617 100644 --- a/src/control/FullscreenHandler.cpp +++ b/src/control/FullscreenHandler.cpp @@ -33,24 +33,25 @@ void FullscreenHandler::hideWidget(MainWindow* win, const string& widgetName) { return; } + #if 1 gtk_widget_hide(mainMenubar); - menubarHidden = true; - - // // Remove menu from parent - // gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(mainMenubar)), mainMenubar); + #else + // Remove menu from parent + gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(mainMenubar)), mainMenubar); - // GtkWidget* fix = gtk_invisible_new(); + GtkWidget* fix = gtk_invisible_new(); - // gtk_widget_set_size_request(fix, 0, 0); - // gtk_fixed_put(GTK_FIXED(fix), mainMenubar, 0, 0); + gtk_widget_set_size_request(fix, 0, 0); + gtk_fixed_put(GTK_FIXED(fix), mainMenubar, 0, 0); - // gtk_widget_show(fix); + gtk_widget_show(fix); - // GtkWidget* mainBox = win->get("mainBox"); - // gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0); + GtkWidget* mainBox = win->get("mainBox"); + gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0); - // menubarHidden = true; + #endif + menubarHidden = true; return; } } @@ -80,27 +81,29 @@ void FullscreenHandler::disableFullscreen(MainWindow* win) { if (this->menubarHidden) { GtkWidget* mainMenubar = win->get("mainMenubar"); + #if 1 gtk_widget_show(mainMenubar); - menubarHidden = false; + #else - // GtkWidget* mainBox = win->get("mainBox"); + GtkWidget* mainBox = win->get("mainBox"); - // GtkWidget* parent = gtk_widget_get_parent(mainMenubar); + GtkWidget* parent = gtk_widget_get_parent(mainMenubar); - // // Remove menu from parent - // gtk_container_remove(GTK_CONTAINER(parent), mainMenubar); - // gtk_box_pack_start(GTK_BOX(mainBox), mainMenubar, false, true, 0); + // Remove menu from parent + gtk_container_remove(GTK_CONTAINER(parent), mainMenubar); + gtk_box_pack_start(GTK_BOX(mainBox), mainMenubar, false, true, 0); - // GValue value = G_VALUE_INIT; - // g_value_init(&value, G_TYPE_INT); - // g_value_set_int(&value, 0); - // gtk_container_child_set_property(GTK_CONTAINER(mainBox), mainMenubar, "position", &value); + GValue value = G_VALUE_INIT; + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, 0); + gtk_container_child_set_property(GTK_CONTAINER(mainBox), mainMenubar, "position", &value); - // // not needed, will be recreated next time - // gtk_widget_destroy(parent); + // not needed, will be recreated next time + gtk_widget_destroy(parent); - // menubarHidden = false; + #endif + menubarHidden = false; } } From 313ac06bedf871d153af90a21c45acfe7ec79406 Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Sun, 15 Nov 2020 22:39:21 -0700 Subject: [PATCH 4/9] Remove debug messages and comments --- src/control/FullscreenHandler.cpp | 2 +- src/control/zoom/ZoomControl.cpp | 1 - src/gui/Layout.cpp | 6 ------ src/gui/MainWindow.cpp | 5 ----- src/gui/XournalView.cpp | 2 -- src/gui/scroll/ScrollHandlingXournalpp.cpp | 4 ---- 6 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/control/FullscreenHandler.cpp b/src/control/FullscreenHandler.cpp index 58f7e617..d7211d84 100644 --- a/src/control/FullscreenHandler.cpp +++ b/src/control/FullscreenHandler.cpp @@ -46,7 +46,7 @@ void FullscreenHandler::hideWidget(MainWindow* win, const string& widgetName) { gtk_widget_show(fix); - GtkWidget* mainBox = win->get("mainBox"); + GtkWidget* mainBox = win->get("mainBox"); gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0); #endif diff --git a/src/control/zoom/ZoomControl.cpp b/src/control/zoom/ZoomControl.cpp index 683f6455..4539bd00 100644 --- a/src/control/zoom/ZoomControl.cpp +++ b/src/control/zoom/ZoomControl.cpp @@ -174,7 +174,6 @@ auto ZoomControl::updateZoomPresentationValue(size_t pageNo) -> bool { } Rectangle widget_rect = getVisibleRect(); - printf("[updateZoomPresentationValue] %f %f %f %f\n", widget_rect.width, widget_rect.height, page->getWidth(), page->getHeight()); double zoom_fit_width = widget_rect.width / (page->getWidth()); double zoom_fit_height = widget_rect.height / (page->getHeight()); double zoom_presentation = zoom_fit_width < zoom_fit_height ? zoom_fit_width : zoom_fit_height; diff --git a/src/gui/Layout.cpp b/src/gui/Layout.cpp index 5ffa3ab0..fcf7780e 100644 --- a/src/gui/Layout.cpp +++ b/src/gui/Layout.cpp @@ -149,7 +149,6 @@ void Layout::recalculate() { XojPageView* v = view->viewPages[pageIdx]; widthCols[c] = std::max(widthCols[c], v->getDisplayWidth()); heightRows[r] = std::max(heightRows[r], v->getDisplayHeight()); - //printf("[Layout::recalculate] %lu %lu %u %u\n", r, c, widthCols[c], heightRows[r]); } // add space around the entire page area to accomodate older Wacom tablets with limited sense area. @@ -164,8 +163,6 @@ void Layout::recalculate() { minWidth = std::accumulate(begin(widthCols), end(widthCols), minWidth); minHeight = std::accumulate(begin(heightRows), end(heightRows), minHeight); - - printf("[Layout::recalculate] %zu %zu\n", minWidth, minHeight); setLayoutSize(minWidth, minHeight); valid = true; } @@ -176,7 +173,6 @@ void Layout::layoutPages(int width, int height) { } valid = false; - printf("[layoutPages] %i %i\n", width, height); size_t const len = this->view->viewPages.size(); Settings* settings = this->view->getControl()->getSettings(); @@ -289,8 +285,6 @@ void Layout::scrollAbs(double x, double y) { void Layout::ensureRectIsVisible(int x, int y, int width, int height) { - // gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x - 5, x + width + 10); - // gtk_adjustment_clamp_page(scrollHandling->getVertical(), y - 5, y + height + 10); gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x, x + width); gtk_adjustment_clamp_page(scrollHandling->getVertical(), y, y + height); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 0629491c..8b4b9423 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -497,11 +497,6 @@ auto MainWindow::onKeyPressCallback(GtkWidget* widget, GdkEventKey* event, MainW // editing text - give that control return false; } - // if (event->keyval == GDK_KEY_Escape) { - // win->getControl()->getSearchBar()->showSearchBar(false); - // return true; - // } - return false; } diff --git a/src/gui/XournalView.cpp b/src/gui/XournalView.cpp index 0902936f..86982453 100644 --- a/src/gui/XournalView.cpp +++ b/src/gui/XournalView.cpp @@ -401,8 +401,6 @@ void XournalView::scrollTo(size_t pageNo, double yDocument) { layout->ensureRectIsVisible(x, y, width, height); - printf("[XournalView::scrollTo] %d %d %d %d\n", x, y, width, height); - // Select the page control->firePageSelected(pageNo); } diff --git a/src/gui/scroll/ScrollHandlingXournalpp.cpp b/src/gui/scroll/ScrollHandlingXournalpp.cpp index f2089b50..0c05ff6e 100644 --- a/src/gui/scroll/ScrollHandlingXournalpp.cpp +++ b/src/gui/scroll/ScrollHandlingXournalpp.cpp @@ -22,8 +22,6 @@ void ScrollHandlingXournalpp::translate(cairo_t* cr, double& x1, double& x2, dou double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); - printf("[ScrollHandlingXournalpp::translate] %f, %f\n", h, v); - cairo_translate(cr, -h, -v); x1 += h; @@ -37,8 +35,6 @@ void ScrollHandlingXournalpp::translate(double& x, double& y) { double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); - printf("[ScrollHandlingXournalpp::translate] %f, %f\n", h, v); - x += h; y += v; } From 2f8e13bd354847976760a99b0aa1b7191268f85e Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Sun, 15 Nov 2020 22:40:38 -0700 Subject: [PATCH 5/9] Remove whitespace --- src/gui/scroll/ScrollHandlingXournalpp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/scroll/ScrollHandlingXournalpp.cpp b/src/gui/scroll/ScrollHandlingXournalpp.cpp index 0c05ff6e..b0d1e36f 100644 --- a/src/gui/scroll/ScrollHandlingXournalpp.cpp +++ b/src/gui/scroll/ScrollHandlingXournalpp.cpp @@ -34,7 +34,6 @@ void ScrollHandlingXournalpp::translate(cairo_t* cr, double& x1, double& x2, dou void ScrollHandlingXournalpp::translate(double& x, double& y) { double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); - x += h; y += v; } From dcc09cd004393bd796b58e0597cf95f8191653b6 Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Sun, 15 Nov 2020 22:41:29 -0700 Subject: [PATCH 6/9] Remove whitespace --- src/gui/scroll/ScrollHandlingXournalpp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/scroll/ScrollHandlingXournalpp.cpp b/src/gui/scroll/ScrollHandlingXournalpp.cpp index b0d1e36f..8b47e659 100644 --- a/src/gui/scroll/ScrollHandlingXournalpp.cpp +++ b/src/gui/scroll/ScrollHandlingXournalpp.cpp @@ -21,7 +21,6 @@ auto ScrollHandlingXournalpp::getPreferredHeight() -> int { return 400; } void ScrollHandlingXournalpp::translate(cairo_t* cr, double& x1, double& x2, double& y1, double& y2) { double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); - cairo_translate(cr, -h, -v); x1 += h; @@ -34,6 +33,7 @@ void ScrollHandlingXournalpp::translate(cairo_t* cr, double& x1, double& x2, dou void ScrollHandlingXournalpp::translate(double& x, double& y) { double h = gtk_adjustment_get_value(adjHorizontal); double v = gtk_adjustment_get_value(adjVertical); + x += h; y += v; } From 8acef4bfd0500c540a4108a696a450eec15c5bf1 Mon Sep 17 00:00:00 2001 From: "Reed A. Cartwright" Date: Sun, 15 Nov 2020 22:45:58 -0700 Subject: [PATCH 7/9] Clean up diff. --- src/control/FullscreenHandler.cpp | 49 ++----------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) diff --git a/src/control/FullscreenHandler.cpp b/src/control/FullscreenHandler.cpp index d7211d84..81541a3d 100644 --- a/src/control/FullscreenHandler.cpp +++ b/src/control/FullscreenHandler.cpp @@ -21,36 +21,13 @@ void FullscreenHandler::hideWidget(MainWindow* win, const string& widgetName) { } if ("mainMenubar" == widgetName) { - // If the menu is hidden, shortcuts are not working anymore - // therefore the menu is not hidden, it's displayed, but invisible - // this costs 1px at the bottom, even if the preferred size is 0px, - // 1px is used by GTK - GtkWidget* mainMenubar = win->get("mainMenubar"); if (mainMenubar == nullptr || !gtk_widget_is_visible(mainMenubar)) { // Menu not visible (global menu or something like this) return; } - - #if 1 gtk_widget_hide(mainMenubar); - #else - // Remove menu from parent - gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(mainMenubar)), mainMenubar); - - GtkWidget* fix = gtk_invisible_new(); - - gtk_widget_set_size_request(fix, 0, 0); - gtk_fixed_put(GTK_FIXED(fix), mainMenubar, 0, 0); - - gtk_widget_show(fix); - - GtkWidget* mainBox = win->get("mainBox"); - gtk_box_pack_end(GTK_BOX(mainBox), fix, false, false, 0); - - #endif - menubarHidden = true; return; } @@ -80,29 +57,9 @@ void FullscreenHandler::disableFullscreen(MainWindow* win) { if (this->menubarHidden) { GtkWidget* mainMenubar = win->get("mainMenubar"); - - #if 1 - gtk_widget_show(mainMenubar); - #else - - GtkWidget* mainBox = win->get("mainBox"); - - GtkWidget* parent = gtk_widget_get_parent(mainMenubar); - - // Remove menu from parent - gtk_container_remove(GTK_CONTAINER(parent), mainMenubar); - gtk_box_pack_start(GTK_BOX(mainBox), mainMenubar, false, true, 0); - - - GValue value = G_VALUE_INIT; - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, 0); - gtk_container_child_set_property(GTK_CONTAINER(mainBox), mainMenubar, "position", &value); - - // not needed, will be recreated next time - gtk_widget_destroy(parent); - - #endif + if(mainMenubar != nullptr) { + gtk_widget_show(mainMenubar); + } menubarHidden = false; } } From f9b5e5ceb5037ed2d520b73658167b044da2e2b2 Mon Sep 17 00:00:00 2001 From: rolandlo Date: Thu, 26 Nov 2020 17:58:37 +0100 Subject: [PATCH 8/9] made padding, shaddows depend on zoom mode --- src/control/zoom/ZoomControl.cpp | 16 ++++--- src/gui/Layout.cpp | 69 ++++++++++++++++++++----------- src/gui/widgets/XournalWidget.cpp | 5 ++- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/control/zoom/ZoomControl.cpp b/src/control/zoom/ZoomControl.cpp index 4539bd00..b0294d3c 100644 --- a/src/control/zoom/ZoomControl.cpp +++ b/src/control/zoom/ZoomControl.cpp @@ -142,6 +142,8 @@ void ZoomControl::setZoom100Value(double zoom100Val) { auto ZoomControl::updateZoomFitValue(size_t pageNo) -> bool { return updateZoomFitValue(getVisibleRect(), pageNo); } +constexpr double SPACE_FOR_SCROLLBARS = 10.0; + auto ZoomControl::updateZoomFitValue(const Rectangle& widget_rect, size_t pageNo) -> bool { if (pageNo == 0) { pageNo = view->getCurrentPage(); @@ -151,7 +153,7 @@ auto ZoomControl::updateZoomFitValue(const Rectangle& widget_rect, size_ return false; } - double zoom_fit_width = widget_rect.width / (page->getWidth() + 20.0); + double zoom_fit_width = widget_rect.width / (page->getWidth() + SPACE_FOR_SCROLLBARS); if (zoom_fit_width < this->zoomMin || zoom_fit_width > this->zoomMax) { return false; } @@ -174,8 +176,8 @@ auto ZoomControl::updateZoomPresentationValue(size_t pageNo) -> bool { } Rectangle widget_rect = getVisibleRect(); - double zoom_fit_width = widget_rect.width / (page->getWidth()); - double zoom_fit_height = widget_rect.height / (page->getHeight()); + double zoom_fit_width = widget_rect.width / page->getWidth(); + double zoom_fit_height = widget_rect.height / page->getHeight(); double zoom_presentation = zoom_fit_width < zoom_fit_height ? zoom_fit_width : zoom_fit_height; if (zoom_presentation < this->zoomMin) { return false; @@ -243,13 +245,9 @@ void ZoomControl::setZoomPresentationMode(bool isZoomPresentationMode) { auto ZoomControl::isZoomPresentationMode() const -> bool { return this->zoomPresentationMode; } -void ZoomControl::setZoomStep(double zoomStep) { - this->zoomStep = zoomStep * this->zoom100Value; -} +void ZoomControl::setZoomStep(double zoomStep) { this->zoomStep = zoomStep * this->zoom100Value; } -void ZoomControl::setZoomStepScroll(double zoomStep) { - this->zoomStepScroll = zoomStep * this->zoom100Value; -} +void ZoomControl::setZoomStepScroll(double zoomStep) { this->zoomStepScroll = zoomStep * this->zoom100Value; } void ZoomControl::pageSizeChanged(size_t page) { updateZoomPresentationValue(page); diff --git a/src/gui/Layout.cpp b/src/gui/Layout.cpp index fcf7780e..897bd3bf 100644 --- a/src/gui/Layout.cpp +++ b/src/gui/Layout.cpp @@ -13,17 +13,17 @@ /** * Padding outside the pages, including shadow */ -constexpr size_t const XOURNAL_PADDING = 0; +constexpr size_t const XOURNAL_PADDING = 10; /** * Allowance for shadow between page pairs in paired page mode */ -constexpr size_t const XOURNAL_ROOM_FOR_SHADOW = 0; +constexpr size_t const XOURNAL_ROOM_FOR_SHADOW = 3; /** * Padding between the pages */ -constexpr size_t const XOURNAL_PADDING_BETWEEN = 0; +constexpr size_t const XOURNAL_PADDING_BETWEEN = 15; Layout::Layout(XournalView* view, ScrollHandling* scrollHandling): view(view), scrollHandling(scrollHandling) { @@ -133,6 +133,17 @@ inline auto sumIf(size_t base, size_t addend, bool predicate) -> size_t { void Layout::recalculate() { + size_t padding = 0; + size_t paddingBetween = 0; + size_t roomForShadow = 0; + + if (!view->getControl()->getZoomControl()->isZoomPresentationMode()) { + padding = XOURNAL_PADDING; + paddingBetween = XOURNAL_PADDING_BETWEEN; + roomForShadow = XOURNAL_ROOM_FOR_SHADOW; + } + + auto* settings = view->getControl()->getSettings(); size_t len = view->viewPages.size(); mapper.configureFromSettings(len, settings); @@ -152,13 +163,11 @@ void Layout::recalculate() { } // add space around the entire page area to accomodate older Wacom tablets with limited sense area. - size_t const vPadding = - sumIf(XOURNAL_PADDING, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace()); - size_t const hPadding = - sumIf(XOURNAL_PADDING, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace()); + size_t const vPadding = sumIf(padding, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace()); + size_t const hPadding = sumIf(padding, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace()); - minWidth = 2 * hPadding + (widthCols.size() - 1) * XOURNAL_PADDING_BETWEEN; - minHeight = 2 * vPadding + (heightRows.size() - 1) * XOURNAL_PADDING_BETWEEN; + minWidth = 2 * hPadding + (widthCols.size() - 1) * paddingBetween; + minHeight = 2 * vPadding + (heightRows.size() - 1) * paddingBetween; minWidth = std::accumulate(begin(widthCols), end(widthCols), minWidth); minHeight = std::accumulate(begin(heightRows), end(heightRows), minHeight); @@ -173,6 +182,16 @@ void Layout::layoutPages(int width, int height) { } valid = false; + size_t padding = 0; + size_t paddingBetween = 0; + size_t roomForShadow = 0; + + if (!view->getControl()->getZoomControl()->isZoomPresentationMode()) { + padding = XOURNAL_PADDING; + paddingBetween = XOURNAL_PADDING_BETWEEN; + roomForShadow = XOURNAL_ROOM_FOR_SHADOW; + } + size_t const len = this->view->viewPages.size(); Settings* settings = this->view->getControl()->getSettings(); @@ -184,10 +203,9 @@ void Layout::layoutPages(int width, int height) { // add space around the entire page area to accomodate older Wacom tablets with limited sense area. - int64_t const v_padding = - sumIf(XOURNAL_PADDING, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace()); + int64_t const v_padding = sumIf(padding, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace()); int64_t const h_padding = - sumIf(XOURNAL_PADDING, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace()); + sumIf(padding, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace()); int64_t const centeringXBorder = static_cast(width - minWidth) / 2; int64_t const centeringYBorder = static_cast(height - minHeight) / 2; @@ -221,15 +239,15 @@ void Layout::layoutPages(int width, int height) { // pair pages mode if (c % 2 == 0) { // align right - paddingLeft = XOURNAL_PADDING_BETWEEN - XOURNAL_ROOM_FOR_SHADOW + columnPadding; - paddingRight = XOURNAL_ROOM_FOR_SHADOW; + paddingLeft = paddingBetween - roomForShadow + columnPadding; + paddingRight = roomForShadow; } else { // align left - paddingLeft = XOURNAL_ROOM_FOR_SHADOW; - paddingRight = XOURNAL_PADDING_BETWEEN - XOURNAL_ROOM_FOR_SHADOW + columnPadding; + paddingLeft = roomForShadow; + paddingRight = paddingBetween - roomForShadow + columnPadding; } - } else { // not paired page mode - center - paddingLeft = XOURNAL_PADDING_BETWEEN / 2 + columnPadding / 2; // center justify - paddingRight = XOURNAL_PADDING_BETWEEN - paddingLeft + columnPadding / 2; + } else { // not paired page mode - center + paddingLeft = paddingBetween / 2 + columnPadding / 2; // center justify + paddingRight = paddingBetween - paddingLeft + columnPadding / 2; } x += paddingLeft; @@ -240,23 +258,23 @@ void Layout::layoutPages(int width, int height) { x += vDisplayWidth + paddingRight; } } else { - x += this->widthCols[c] + XOURNAL_PADDING_BETWEEN; + x += this->widthCols[c] + paddingBetween; } } x = borderX; - y += this->heightRows[r] + XOURNAL_PADDING_BETWEEN; + y += this->heightRows[r] + paddingBetween; } int64_t totalWidth = borderX; for (auto&& widthCol: this->widthCols) { // accumulated - absolute pixel location for use by getViewAt() and updateVisibility() - totalWidth += widthCol + XOURNAL_PADDING_BETWEEN; + totalWidth += widthCol + paddingBetween; widthCol = totalWidth; } int64_t totalHeight = borderY; for (auto&& heightRow: this->heightRows) { - totalHeight += heightRow + XOURNAL_PADDING_BETWEEN; + totalHeight += heightRow + paddingBetween; heightRow = totalHeight; } } @@ -285,8 +303,9 @@ void Layout::scrollAbs(double x, double y) { void Layout::ensureRectIsVisible(int x, int y, int width, int height) { - gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x, x + width); - gtk_adjustment_clamp_page(scrollHandling->getVertical(), y, y + height); + int offset = (this->view->getControl()->getSettings()->isPresentationMode()) ? 0 : XOURNAL_PADDING / 2; + gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x - offset, x + width + 2 * offset); + gtk_adjustment_clamp_page(scrollHandling->getVertical(), y - offset, y + height + 2 * offset); } diff --git a/src/gui/widgets/XournalWidget.cpp b/src/gui/widgets/XournalWidget.cpp index 2cc333e3..16d8b2c1 100644 --- a/src/gui/widgets/XournalWidget.cpp +++ b/src/gui/widgets/XournalWidget.cpp @@ -223,7 +223,6 @@ static void gtk_xournal_realize(GtkWidget* widget) { static void gtk_xournal_draw_shadow(GtkXournal* xournal, cairo_t* cr, int left, int top, int width, int height, bool selected) { - return; if (selected) { Shadow::drawShadow(cr, left - 2, top - 2, width + 4, height + 4); @@ -302,7 +301,9 @@ static auto gtk_xournal_draw(GtkWidget* widget, cairo_t* cr) -> gboolean { continue; } - gtk_xournal_draw_shadow(xournal, cr, px, py, pw, ph, pv->isSelected()); + if (!xournal->view->getControl()->getZoomControl()->isZoomPresentationMode()) { + gtk_xournal_draw_shadow(xournal, cr, px, py, pw, ph, pv->isSelected()); + } cairo_save(cr); cairo_translate(cr, px, py); From f04879a36f2560a292a8cdb98439ec27605c63bd Mon Sep 17 00:00:00 2001 From: rolandlo Date: Thu, 26 Nov 2020 18:04:35 +0100 Subject: [PATCH 9/9] fix clang format --- src/control/FullscreenHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/control/FullscreenHandler.cpp b/src/control/FullscreenHandler.cpp index 81541a3d..4725dd0b 100644 --- a/src/control/FullscreenHandler.cpp +++ b/src/control/FullscreenHandler.cpp @@ -57,7 +57,7 @@ void FullscreenHandler::disableFullscreen(MainWindow* win) { if (this->menubarHidden) { GtkWidget* mainMenubar = win->get("mainMenubar"); - if(mainMenubar != nullptr) { + if (mainMenubar != nullptr) { gtk_widget_show(mainMenubar); } menubarHidden = false;