diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-25 11:06:54 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-25 11:07:07 +0100 |
| commit | 5bd467fa17be55397f433dddc065b57cbb7a0615 (patch) | |
| tree | 6698febfde050bf76f84873ea749b031467d7cbb /src/drivers/Quartz | |
| parent | bef46b5cb82464713a117b9bdb920735d1b7de37 (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/drivers/Quartz')
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H | 2 | ||||
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H index b61761d6f..7e4aab962 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H @@ -188,6 +188,8 @@ protected: void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d); #endif virtual void overlay_rect(int x, int y, int w , int h); + virtual float remove_scale(); + virtual void restore_scale(float); }; class Fl_Quartz_Printer_Graphics_Driver : public Fl_Quartz_Graphics_Driver { diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index 9d82d5c73..acabf6e73 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -17,6 +17,7 @@ #include <config.h> #include "Fl_Quartz_Graphics_Driver.H" #include "../Darwin/Fl_Darwin_System_Driver.H" +#include "../../Fl_Screen_Driver.H" #include <FL/platform.H> #include <FL/fl_draw.H> #include <FL/Fl_Image_Surface.H> @@ -158,3 +159,19 @@ void Fl_Quartz_Graphics_Driver::cache_size(Fl_Image *img, int &width, int &heigh width *= 2 * scale(); height *= 2 * scale(); } + +float Fl_Quartz_Graphics_Driver::remove_scale() { + float s = scale(); + if (s != 1.f && Fl_Display_Device::display_device()->is_current()) { + Fl::screen_driver()->scale(0, 1.f); + CGContextScaleCTM(gc_, 1/s, 1/s); + } + return s; +} + +void Fl_Quartz_Graphics_Driver::restore_scale(float s) { + if (s != 1.f && Fl_Display_Device::display_device()->is_current()) { + Fl::screen_driver()->scale(0, s); + CGContextScaleCTM(gc_, s, s); + } +} |
