|
commit 842cbf0f1023f798362ab77aef34da23a24490b7
Author: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Sun Feb 21 18:08:33 2021 +0100
Commit: ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Sun Feb 21 18:08:33 2021 +0100
Fix for issue #192: focus box drawing incorrectly on OSX (e.g. 10.10.5) at scales >100%
src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H | 1 +
src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
index 76edc41..b61761d 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
+++ 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 src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
index b238e9a..52b8c7f 100644
--- src/drivers/Quartz/Fl_Quartz_Graphics_Driver_rect.cxx
+++ 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);
[ Direct Link to Message ] | |