made padding, shaddows depend on zoom mode

presentation
rolandlo 5 years ago
parent 8acef4bfd0
commit f9b5e5ceb5
  1. 16
      src/control/zoom/ZoomControl.cpp
  2. 69
      src/gui/Layout.cpp
  3. 5
      src/gui/widgets/XournalWidget.cpp

@ -142,6 +142,8 @@ void ZoomControl::setZoom100Value(double zoom100Val) {
auto ZoomControl::updateZoomFitValue(size_t pageNo) -> bool { return updateZoomFitValue(getVisibleRect(), pageNo); } auto ZoomControl::updateZoomFitValue(size_t pageNo) -> bool { return updateZoomFitValue(getVisibleRect(), pageNo); }
constexpr double SPACE_FOR_SCROLLBARS = 10.0;
auto ZoomControl::updateZoomFitValue(const Rectangle<double>& widget_rect, size_t pageNo) -> bool { auto ZoomControl::updateZoomFitValue(const Rectangle<double>& widget_rect, size_t pageNo) -> bool {
if (pageNo == 0) { if (pageNo == 0) {
pageNo = view->getCurrentPage(); pageNo = view->getCurrentPage();
@ -151,7 +153,7 @@ auto ZoomControl::updateZoomFitValue(const Rectangle<double>& widget_rect, size_
return false; 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) { if (zoom_fit_width < this->zoomMin || zoom_fit_width > this->zoomMax) {
return false; return false;
} }
@ -174,8 +176,8 @@ auto ZoomControl::updateZoomPresentationValue(size_t pageNo) -> bool {
} }
Rectangle widget_rect = getVisibleRect(); Rectangle widget_rect = getVisibleRect();
double zoom_fit_width = widget_rect.width / (page->getWidth()); double zoom_fit_width = widget_rect.width / page->getWidth();
double zoom_fit_height = widget_rect.height / (page->getHeight()); double zoom_fit_height = widget_rect.height / page->getHeight();
double zoom_presentation = zoom_fit_width < zoom_fit_height ? zoom_fit_width : zoom_fit_height; double zoom_presentation = zoom_fit_width < zoom_fit_height ? zoom_fit_width : zoom_fit_height;
if (zoom_presentation < this->zoomMin) { if (zoom_presentation < this->zoomMin) {
return false; return false;
@ -243,13 +245,9 @@ void ZoomControl::setZoomPresentationMode(bool isZoomPresentationMode) {
auto ZoomControl::isZoomPresentationMode() const -> bool { return this->zoomPresentationMode; } auto ZoomControl::isZoomPresentationMode() const -> bool { return this->zoomPresentationMode; }
void ZoomControl::setZoomStep(double zoomStep) { void ZoomControl::setZoomStep(double zoomStep) { this->zoomStep = zoomStep * this->zoom100Value; }
this->zoomStep = zoomStep * this->zoom100Value;
}
void ZoomControl::setZoomStepScroll(double zoomStep) { void ZoomControl::setZoomStepScroll(double zoomStep) { this->zoomStepScroll = zoomStep * this->zoom100Value; }
this->zoomStepScroll = zoomStep * this->zoom100Value;
}
void ZoomControl::pageSizeChanged(size_t page) { void ZoomControl::pageSizeChanged(size_t page) {
updateZoomPresentationValue(page); updateZoomPresentationValue(page);

@ -13,17 +13,17 @@
/** /**
* Padding outside the pages, including shadow * 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 * 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 * 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) { 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() { 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(); auto* settings = view->getControl()->getSettings();
size_t len = view->viewPages.size(); size_t len = view->viewPages.size();
mapper.configureFromSettings(len, settings); 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. // add space around the entire page area to accomodate older Wacom tablets with limited sense area.
size_t const vPadding = size_t const vPadding = sumIf(padding, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace());
sumIf(XOURNAL_PADDING, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace()); size_t const hPadding = sumIf(padding, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace());
size_t const hPadding =
sumIf(XOURNAL_PADDING, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace());
minWidth = 2 * hPadding + (widthCols.size() - 1) * XOURNAL_PADDING_BETWEEN; minWidth = 2 * hPadding + (widthCols.size() - 1) * paddingBetween;
minHeight = 2 * vPadding + (heightRows.size() - 1) * XOURNAL_PADDING_BETWEEN; minHeight = 2 * vPadding + (heightRows.size() - 1) * paddingBetween;
minWidth = std::accumulate(begin(widthCols), end(widthCols), minWidth); minWidth = std::accumulate(begin(widthCols), end(widthCols), minWidth);
minHeight = std::accumulate(begin(heightRows), end(heightRows), minHeight); minHeight = std::accumulate(begin(heightRows), end(heightRows), minHeight);
@ -173,6 +182,16 @@ void Layout::layoutPages(int width, int height) {
} }
valid = false; 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(); size_t const len = this->view->viewPages.size();
Settings* settings = this->view->getControl()->getSettings(); 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. // add space around the entire page area to accomodate older Wacom tablets with limited sense area.
int64_t const v_padding = int64_t const v_padding = sumIf(padding, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace());
sumIf(XOURNAL_PADDING, settings->getAddVerticalSpaceAmount(), settings->getAddVerticalSpace());
int64_t const h_padding = int64_t const h_padding =
sumIf(XOURNAL_PADDING, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace()); sumIf(padding, settings->getAddHorizontalSpaceAmount(), settings->getAddHorizontalSpace());
int64_t const centeringXBorder = static_cast<int64_t>(width - minWidth) / 2; int64_t const centeringXBorder = static_cast<int64_t>(width - minWidth) / 2;
int64_t const centeringYBorder = static_cast<int64_t>(height - minHeight) / 2; int64_t const centeringYBorder = static_cast<int64_t>(height - minHeight) / 2;
@ -221,15 +239,15 @@ void Layout::layoutPages(int width, int height) {
// pair pages mode // pair pages mode
if (c % 2 == 0) { if (c % 2 == 0) {
// align right // align right
paddingLeft = XOURNAL_PADDING_BETWEEN - XOURNAL_ROOM_FOR_SHADOW + columnPadding; paddingLeft = paddingBetween - roomForShadow + columnPadding;
paddingRight = XOURNAL_ROOM_FOR_SHADOW; paddingRight = roomForShadow;
} else { // align left } else { // align left
paddingLeft = XOURNAL_ROOM_FOR_SHADOW; paddingLeft = roomForShadow;
paddingRight = XOURNAL_PADDING_BETWEEN - XOURNAL_ROOM_FOR_SHADOW + columnPadding; paddingRight = paddingBetween - roomForShadow + columnPadding;
} }
} else { // not paired page mode - center } else { // not paired page mode - center
paddingLeft = XOURNAL_PADDING_BETWEEN / 2 + columnPadding / 2; // center justify paddingLeft = paddingBetween / 2 + columnPadding / 2; // center justify
paddingRight = XOURNAL_PADDING_BETWEEN - paddingLeft + columnPadding / 2; paddingRight = paddingBetween - paddingLeft + columnPadding / 2;
} }
x += paddingLeft; x += paddingLeft;
@ -240,23 +258,23 @@ void Layout::layoutPages(int width, int height) {
x += vDisplayWidth + paddingRight; x += vDisplayWidth + paddingRight;
} }
} else { } else {
x += this->widthCols[c] + XOURNAL_PADDING_BETWEEN; x += this->widthCols[c] + paddingBetween;
} }
} }
x = borderX; x = borderX;
y += this->heightRows[r] + XOURNAL_PADDING_BETWEEN; y += this->heightRows[r] + paddingBetween;
} }
int64_t totalWidth = borderX; int64_t totalWidth = borderX;
for (auto&& widthCol: this->widthCols) { for (auto&& widthCol: this->widthCols) {
// accumulated - absolute pixel location for use by getViewAt() and updateVisibility() // accumulated - absolute pixel location for use by getViewAt() and updateVisibility()
totalWidth += widthCol + XOURNAL_PADDING_BETWEEN; totalWidth += widthCol + paddingBetween;
widthCol = totalWidth; widthCol = totalWidth;
} }
int64_t totalHeight = borderY; int64_t totalHeight = borderY;
for (auto&& heightRow: this->heightRows) { for (auto&& heightRow: this->heightRows) {
totalHeight += heightRow + XOURNAL_PADDING_BETWEEN; totalHeight += heightRow + paddingBetween;
heightRow = totalHeight; heightRow = totalHeight;
} }
} }
@ -285,8 +303,9 @@ void Layout::scrollAbs(double x, double y) {
void Layout::ensureRectIsVisible(int x, int y, int width, int height) { void Layout::ensureRectIsVisible(int x, int y, int width, int height) {
gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x, x + width); int offset = (this->view->getControl()->getSettings()->isPresentationMode()) ? 0 : XOURNAL_PADDING / 2;
gtk_adjustment_clamp_page(scrollHandling->getVertical(), y, y + height); gtk_adjustment_clamp_page(scrollHandling->getHorizontal(), x - offset, x + width + 2 * offset);
gtk_adjustment_clamp_page(scrollHandling->getVertical(), y - offset, y + height + 2 * offset);
} }

@ -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, static void gtk_xournal_draw_shadow(GtkXournal* xournal, cairo_t* cr, int left, int top, int width, int height,
bool selected) { bool selected) {
return;
if (selected) { if (selected) {
Shadow::drawShadow(cr, left - 2, top - 2, width + 4, height + 4); 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; 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_save(cr);
cairo_translate(cr, px, py); cairo_translate(cr, px, py);

Loading…
Cancel
Save