summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2015-07-21 12:12:37 +0000
committerManolo Gouy <Manolo>2015-07-21 12:12:37 +0000
commite7291b373c7f16bb5c6fa582bf5f31854013c9ad (patch)
tree1c36c6b9e4038af7b86f711af75e312aa5724e2b /src
parent4f6903eed535ec276e70ee00d67d952fb92c8bdb (diff)
Under Mac OS 10.11 beta, fl_xyline(init,int,int) and fl_yxline(init,int,int) produce bizarre graphics just after
processing a mouse or keyboard event (they are OK in other cases). We fix that by filling a rectangle instead of stroking along a line (and hope the public 10.11 will have fixed that). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10803 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_rect.cxx44
1 files changed, 28 insertions, 16 deletions
diff --git a/src/fl_rect.cxx b/src/fl_rect.cxx
index ff217db34..189bca7a7 100644
--- a/src/fl_rect.cxx
+++ b/src/fl_rect.cxx
@@ -202,16 +202,21 @@ void Fl_Graphics_Driver::xyline(int x, int y, int x1) {
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x1+1, y);
#elif defined(__APPLE_QUARTZ__)
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x1, y);
- CGContextStrokePath(fl_gc);
- if (Fl_Display_Device::high_resolution()) {
- /* On retina displays, all xyline() and yxline() functions produce lines that are half-unit
- (or one pixel) too short at both ends. This is corrected by filling at both ends rectangles
- of size one unit by line-width.
- */
- CGContextFillRect(fl_gc, CGRectMake(x-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
- CGContextFillRect(fl_gc, CGRectMake(x1-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ if (fl_mac_os_version >= 101100) {
+ // bizarrely, the line drawing does not always work with 10.11, draw a thin rectangle instead
+ CGContextFillRect(fl_gc, CGRectMake((x1>x?x:x1) - 0.5, y - fl_quartz_line_width_/2, (x1>x?x1-x:x-x1)+1, fl_quartz_line_width_));
+ } else {
+ CGContextMoveToPoint(fl_gc, x, y);
+ CGContextAddLineToPoint(fl_gc, x1, y);
+ CGContextStrokePath(fl_gc);
+ if (Fl_Display_Device::high_resolution()) {
+ /* On retina displays, all xyline() and yxline() functions produce lines that are half-unit
+ (or one pixel) too short at both ends. This is corrected by filling at both ends rectangles
+ of size one unit by line-width.
+ */
+ CGContextFillRect(fl_gc, CGRectMake(x-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ CGContextFillRect(fl_gc, CGRectMake(x1-0.5 , y - fl_quartz_line_width_/2, 1 , fl_quartz_line_width_));
+ }
}
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
#else
@@ -287,12 +292,19 @@ void Fl_Graphics_Driver::yxline(int x, int y, int y1) {
MoveToEx(fl_gc, x, y, 0L); LineTo(fl_gc, x, y1);
#elif defined(__APPLE_QUARTZ__)
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, true);
- CGContextMoveToPoint(fl_gc, x, y);
- CGContextAddLineToPoint(fl_gc, x, y1);
- CGContextStrokePath(fl_gc);
- if (Fl_Display_Device::high_resolution()) {
- CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
- CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1));
+ if (fl_mac_os_version >= 101100) {
+ // bizarrely, the line drawing does not always work with 10.11, draw a thin rectangle instead
+ CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, (y>y1?y1:y) - 0.5,
+ fl_quartz_line_width_ , (y>y1?y-y1:y1-y)+1));
+ }
+ else {
+ CGContextMoveToPoint(fl_gc, x, y);
+ CGContextAddLineToPoint(fl_gc, x, y1);
+ CGContextStrokePath(fl_gc);
+ if (Fl_Display_Device::high_resolution()) {
+ CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y-0.5, fl_quartz_line_width_, 1));
+ CGContextFillRect(fl_gc, CGRectMake(x - fl_quartz_line_width_/2, y1-0.5, fl_quartz_line_width_, 1));
+ }
}
if (USINGQUARTZPRINTER || fl_quartz_line_width_ > 1.5f) CGContextSetShouldAntialias(fl_gc, false);
#else