Fix for issue #192: focus box drawing incorrectly on OSX (e.g. 10.10.5) at scales >100%

This commit is contained in:
ManoloFLTK 2021-02-21 18:08:33 +01:00
parent f2faab9ba3
commit 842cbf0f10
2 changed files with 15 additions and 0 deletions

View File

@ -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);

View File

@ -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);