diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-21 18:08:33 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2021-02-21 18:08:33 +0100 |
| commit | 842cbf0f1023f798362ab77aef34da23a24490b7 (patch) | |
| tree | b636994a685d22312b0b21a8cd761db44bf1f065 /src/drivers | |
| parent | f2faab9ba3cbef1f01944ab136b84093b8281584 (diff) | |
Fix for issue #192: focus box drawing incorrectly on OSX (e.g. 10.10.5) at scales >100%
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H index 76edc4134..b61761d6f 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H @@ -95,6 +95,7 @@ protected: // --- implementation is in src/fl_rect.cxx which includes src/cfg_gfx/quartz_rect.cxx void point(int x, int y); void rect(int x, int y, int w, int h); + void focus_rect(int x, int y, int w, int h); void rectf(int x, int y, int w, int h); void line(int x, int y, int x1, int y1); void line(int x, int y, int x1, int y1, int x2, int y2); diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx index b238e9a9b..52b8c7f65 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx @@ -17,6 +17,7 @@ #include <FL/Fl.H> #include <FL/platform.H> +#include <math.h> /** @@ -42,6 +43,19 @@ void Fl_Quartz_Graphics_Driver::rect(int x, int y, int w, int h) { if ( (!has_feature(PRINTER)) && quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(gc_, false); } +void Fl_Quartz_Graphics_Driver::focus_rect(int x, int y, int w, int h) +{ + CGContextSaveGState(gc_); + float s = scale(); + CGContextScaleCTM(gc_, 1/s, 1/s); + CGFloat lw = (s >= 1 ? floor(s) : 1); + CGContextSetLineWidth(gc_, lw); + CGFloat dots[2] = {lw, lw}; + CGContextSetLineDash(gc_, 0, dots, 2); + CGContextStrokeRect(gc_, CGRectMake(x*s, y*s, (w-1)*s, (h-1)*s)); + CGContextRestoreGState(gc_); +} + void Fl_Quartz_Graphics_Driver::rectf(int x, int y, int w, int h) { if (w<=0 || h<=0) return; CGRect rect = CGRectMake(x - 0.5, y - 0.5, w , h); |
