summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2019-06-28 11:45:10 +0000
committerTavmjong Bah <tavmjong@free.fr>2019-06-29 12:01:19 +0000
commit6a6362ce76f32b0f3a2ca2670b63bc6f730554b5 (patch)
tree89656c93412b97358dfe3ae3c8e8c0df5c596ff4 /src
parentReimplement ruler in C++. (diff)
downloadinkscape-6a6362ce76f32b0f3a2ca2670b63bc6f730554b5.tar.gz
inkscape-6a6362ce76f32b0f3a2ca2670b63bc6f730554b5.zip
Fix rendering on high DPI screens.
Diffstat (limited to 'src')
-rw-r--r--src/ui/widget/ink-ruler.cpp15
-rw-r--r--src/ui/widget/ink-ruler.h4
2 files changed, 11 insertions, 8 deletions
diff --git a/src/ui/widget/ink-ruler.cpp b/src/ui/widget/ink-ruler.cpp
index 258add614..14fe50c8b 100644
--- a/src/ui/widget/ink-ruler.cpp
+++ b/src/ui/widget/ink-ruler.cpp
@@ -63,7 +63,7 @@ Ruler::set_unit(Inkscape::Util::Unit const *unit)
if (_unit != unit) {
_unit = unit;
- draw_scale(); // Update backing store.
+ _backing_store_valid = false;
queue_draw();
}
}
@@ -81,7 +81,7 @@ Ruler::set_range(const double& lower, const double& upper)
_max_size = 1;
}
- draw_scale(); // Update backing store.
+ _backing_store_valid = false;
queue_draw();
}
}
@@ -180,8 +180,9 @@ Ruler::get_preferred_height_vfunc (int& minimum_height, int& natural_height) con
// is a border, We calculate tick position ignoring border width at ends of ruler but move the
// ticks and position marker inside the border.
bool
-Ruler::draw_scale()
+Ruler::draw_scale(const::Cairo::RefPtr<::Cairo::Context>& cr_in)
{
+
// Get style information
Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context();
Gtk::Border border = style_context->get_border(get_state_flags());
@@ -196,13 +197,15 @@ Ruler::draw_scale()
Gtk::Allocation allocation = get_allocation();
int awidth = allocation.get_width();
int aheight = allocation.get_height();
+
// if (allocation.get_x() != 0 || allocation.get_y() != 0) {
// std::cerr << "Ruler::draw_scale: maybe we do have to handle allocation x and y! "
// << " x: " << allocation.get_x() << " y: " << allocation.get_y() << std::endl;
// }
- // Create backing store
- _backing_store = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, awidth, aheight);
+ // Create backing store (need surface_in to get scale factor correct).
+ Cairo::RefPtr<Cairo::Surface> surface_in = cr_in->get_target();
+ _backing_store = Cairo::Surface::create(surface_in, Cairo::CONTENT_COLOR_ALPHA, awidth, aheight);
// Get context
Cairo::RefPtr<::Cairo::Context> cr = ::Cairo::Context::create(_backing_store);
@@ -426,7 +429,7 @@ bool
Ruler::on_draw(const::Cairo::RefPtr<::Cairo::Context>& cr) {
if (!_backing_store_valid) {
- draw_scale();
+ draw_scale (cr);
}
cr->set_source (_backing_store, 0, 0);
diff --git a/src/ui/widget/ink-ruler.h b/src/ui/widget/ink-ruler.h
index 6009d727a..0b9f9af5a 100644
--- a/src/ui/widget/ink-ruler.h
+++ b/src/ui/widget/ink-ruler.h
@@ -41,7 +41,7 @@ public:
void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const override;
protected:
- bool draw_scale();
+ bool draw_scale(const Cairo::RefPtr<::Cairo::Context>& cr);
void draw_marker(const Cairo::RefPtr<::Cairo::Context>& cr);
Cairo::RectangleInt marker_rect();
bool on_draw(const::Cairo::RefPtr<::Cairo::Context>& cr) override;
@@ -59,7 +59,7 @@ private:
bool _backing_store_valid;
- Cairo::RefPtr<::Cairo::ImageSurface> _backing_store;
+ Cairo::RefPtr<::Cairo::Surface> _backing_store;
Cairo::RectangleInt _rect;
};