Merge pull request #392 from andreasb242/scaling

Prepared for High DPI and fixed memory error
presentation
andreasb242 7 years ago committed by GitHub
commit 4f9af45379
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/gui/PageView.cpp
  2. 2
      src/gui/PageView.h
  3. 7
      src/gui/widgets/XournalWidget.cpp

@ -887,11 +887,11 @@ bool XojPageView::actionDelete()
return false;
}
bool XojPageView::paintPage(cairo_t* cr, GdkRectangle* rect)
bool XojPageView::paintPage(cairo_t* cr, GdkRectangle* rect, double scalingFactor)
{
XOJ_CHECK_TYPE(XojPageView);
static const char* txtLoading = _C("Loading...");
static const string txtLoading = _("Loading...");
double zoom = xournal->getZoom();
@ -914,10 +914,10 @@ bool XojPageView::paintPage(cairo_t* cr, GdkRectangle* rect)
cairo_set_source_rgb(cr2, 0.5, 0.5, 0.5);
cairo_select_font_face(cr2, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr2, 32.0);
cairo_text_extents(cr2, txtLoading, &ex);
cairo_text_extents(cr2, txtLoading.c_str(), &ex);
cairo_move_to(cr2, (page->getWidth() - ex.width) / 2 - ex.x_bearing,
(page->getHeight() - ex.height) / 2 - ex.y_bearing);
cairo_show_text(cr2, txtLoading);
cairo_show_text(cr2, txtLoading.c_str());
cairo_destroy(cr2);
rerenderPage();

@ -145,7 +145,7 @@ public: // event handler
* This method actually repaints the XojPageView, triggering
* a rerender call if necessary
*/
bool paintPage(cairo_t* cr, GdkRectangle* rect);
bool paintPage(cairo_t* cr, GdkRectangle* rect, double scalingFactor);
public: // listener
void rectChanged(Rectangle& rect);

@ -738,6 +738,11 @@ static gboolean gtk_xournal_draw(GtkWidget* widget, cairo_t* cr)
Rectangle clippingRect(x1 - 10, y1 - 10, x2 - x1 + 20, y2 - y1 + 20);
// This scaling factor is an int, but e.g. Ubuntu allow to configure
// float values in the settings, may this settings can be used
// but probably reported by another function
double scalingFactor = gtk_widget_get_scale_factor(widget);
while (it.hasNext())
{
XojPageView* pv = it.next();
@ -757,7 +762,7 @@ static gboolean gtk_xournal_draw(GtkWidget* widget, cairo_t* cr)
cairo_save(cr);
cairo_translate(cr, px, py);
pv->paintPage(cr, NULL);
pv->paintPage(cr, NULL, scalingFactor);
cairo_restore(cr);
}

Loading…
Cancel
Save