summaryrefslogtreecommitdiff
path: root/src/Fl_Graphics_Driver.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-02-25 11:06:54 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2021-02-25 11:07:07 +0100
commit5bd467fa17be55397f433dddc065b57cbb7a0615 (patch)
tree6698febfde050bf76f84873ea749b031467d7cbb /src/Fl_Graphics_Driver.cxx
parentbef46b5cb82464713a117b9bdb920735d1b7de37 (diff)
Add fl_remove_scale()/fl_restore_scale() to transiently draw without scaling factor.
This new API is a response to this message in fltk.general : Can custom box type functions handle their own high-DPI screen scaling?
Diffstat (limited to 'src/Fl_Graphics_Driver.cxx')
-rw-r--r--src/Fl_Graphics_Driver.cxx19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx
index 2f687e151..00eaf5a15 100644
--- a/src/Fl_Graphics_Driver.cxx
+++ b/src/Fl_Graphics_Driver.cxx
@@ -626,6 +626,9 @@ void Fl_Graphics_Driver::overlay_rect(int x, int y, int w , int h) {
loop(x, y, x+w-1, y, x+w-1, y+h-1, x, y+h-1);
}
+float Fl_Graphics_Driver::remove_scale() { return 1.f;}
+
+void Fl_Graphics_Driver::restore_scale(float) { }
/**
\}
@@ -976,4 +979,20 @@ void Fl_Scalable_Graphics_Driver::draw_image_mono_unscaled(Fl_Draw_Image_Cb cb,
void Fl_Scalable_Graphics_Driver::transformed_vertex0(float x, float y) {}
+float Fl_Scalable_Graphics_Driver::remove_scale() {
+ float s = scale();
+ if (s != 1.f) {
+ push_no_clip();
+ scale(1.f);
+ }
+ return s;
+}
+
+void Fl_Scalable_Graphics_Driver::restore_scale(float s) {
+ if (s != 1.f) {
+ scale(s);
+ pop_clip();
+ }
+}
+
#endif