summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2017-11-30 16:14:13 +0000
committerManolo Gouy <Manolo>2017-11-30 16:14:13 +0000
commita8fe10cf88e757f59057fdaf51637d26ab3019aa (patch)
treeed147eec7b4190a92d24c513f4ae73f3f24d9355 /src
parent08f72d626c9e506cf05fadd2e037e72e97bb95cf (diff)
MacOS: use rounded bottom corners when drawing windows
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12574 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_cocoa.mm2
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm11
-rw-r--r--src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H1
3 files changed, 13 insertions, 1 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index 4479198cc..cb0cb1cea 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -4287,7 +4287,7 @@ int Fl_Cocoa_Window_Driver::decorated_h()
}
// clip the graphics context to rounded corners
-static void clip_to_rounded_corners(CGContextRef gc, int w, int h) {
+void Fl_Cocoa_Window_Driver::clip_to_rounded_corners(CGContextRef gc, int w, int h) {
const CGFloat radius = 7.5;
CGContextMoveToPoint(gc, 0, 0);
CGContextAddLineToPoint(gc, 0, h - radius);
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
index 60406525f..38c3075c5 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
+++ b/src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm
@@ -423,7 +423,18 @@ void Fl_Cocoa_Printer_Driver::draw_decorated_window(Fl_Window *win, int x_offset
delete image;
CGContextRelease(gc);
}
+ bool clip_corners = fl_mac_os_version >= 100600 && to_quartz && !win->parent();
+ if (clip_corners) {
+ CGContextRef gc = (CGContextRef)driver()->gc();
+ CGContextSaveGState(gc);
+ CGContextTranslateCTM(gc, x_offset, y_offset + bt );
+ Fl_Cocoa_Window_Driver::clip_to_rounded_corners(gc, win->w(), win->h());
+ CGContextTranslateCTM(gc, -x_offset, -y_offset - bt);
+ }
this->print_widget(win, x_offset, y_offset + bt);
+ if (clip_corners) {
+ CGContextRestoreGState((CGContextRef)driver()->gc());
+ }
return;
}
Fl_Display_Device::display_device()->set_current(); // send win to front and make it current
diff --git a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
index f91f66060..1f58e2c16 100644
--- a/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
+++ b/src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H
@@ -77,6 +77,7 @@ public:
CGContextRef gc; // graphics context
NSCursor *cursor;
static void q_release_context(Fl_Cocoa_Window_Driver *x = 0); // free all resources associated with gc
+ static void clip_to_rounded_corners(CGContextRef gc, int w, int h);
void set_key_window();
bool mapped_to_retina(); // is window mapped to retina display?
void mapped_to_retina(bool); // sets whether window is mapped to retina display