From 20bb1c7c0f6931819745d9756ab14246c20c4e9f Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 25 Mar 2021 09:20:08 +1100 Subject: Implement translucent FillRectangle. --- cocoa/PlatCocoa.h | 2 ++ cocoa/PlatCocoa.mm | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'cocoa') diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index b918e5ed0..98a9b11ed 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -60,6 +60,7 @@ private: /** Set the CGContext's fill colour to the specified desired colour. */ void FillColour(const ColourDesired &back); + void FillColour(ColourAlpha fill); // 24-bit RGB+A bitmap data constants @@ -95,6 +96,7 @@ public: void Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; void FillRectangle(PRectangle rc, ColourDesired back) override; + void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index f84a335aa..a4f01c5c6 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -479,6 +479,17 @@ void SurfaceImpl::PenColour(ColourDesired fore) { //-------------------------------------------------------------------------------------------------- +void SurfaceImpl::FillColour(ColourAlpha fill) { + // Set the Fill color to match + CGContextSetRGBFillColor(gc, + fill.GetRedComponent(), + fill.GetGreenComponent(), + fill.GetBlueComponent(), + fill.GetAlphaComponent()); +} + +//-------------------------------------------------------------------------------------------------- + void SurfaceImpl::FillColour(const ColourDesired &back) { if (gc) { ColourDesired colour(back.AsInteger()); @@ -662,6 +673,16 @@ void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) { //-------------------------------------------------------------------------------------------------- +void SurfaceImpl::FillRectangle(PRectangle rc, Fill fill) { + if (gc) { + FillColour(fill.colour); + CGRect rect = PRectangleToCGRect(rc); + CGContextFillRect(gc, rect); + } +} + +//-------------------------------------------------------------------------------------------------- + static void drawImageRefCallback(void *info, CGContextRef gc) { CGImageRef pattern = static_cast(info); CGContextDrawImage(gc, CGRectMake(0, 0, CGImageGetWidth(pattern), CGImageGetHeight(pattern)), pattern); -- cgit v1.2.3