diff options
| author | Neil <nyamatongwe@gmail.com> | 2021-03-25 09:20:08 +1100 |
|---|---|---|
| committer | Neil <nyamatongwe@gmail.com> | 2021-03-25 09:20:08 +1100 |
| commit | 20bb1c7c0f6931819745d9756ab14246c20c4e9f (patch) | |
| tree | f7e10e6097b99c44a03a246b07eda940581445cd /cocoa | |
| parent | d3deaacf51e0d459c8025d6a411acf0bc8b17945 (diff) | |
| download | scintilla-mirror-20bb1c7c0f6931819745d9756ab14246c20c4e9f.tar.gz | |
Implement translucent FillRectangle.
Diffstat (limited to 'cocoa')
| -rw-r--r-- | cocoa/PlatCocoa.h | 2 | ||||
| -rw-r--r-- | cocoa/PlatCocoa.mm | 21 |
2 files changed, 23 insertions, 0 deletions
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<CGImageRef>(info); CGContextDrawImage(gc, CGRectMake(0, 0, CGImageGetWidth(pattern), CGImageGetHeight(pattern)), pattern); |
