From a8fe10cf88e757f59057fdaf51637d26ab3019aa Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 30 Nov 2017 16:14:13 +0000 Subject: 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 --- src/Fl_cocoa.mm | 2 +- src/drivers/Cocoa/Fl_Cocoa_Printer_Driver.mm | 11 +++++++++++ src/drivers/Cocoa/Fl_Cocoa_Window_Driver.H | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3