From 75e3c0b6f16363d3babe9bc1d650cbfe550dc4bb Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 26 Sep 2013 17:26:36 +1000 Subject: Fixed appearance of outlines of alpha rectangles. --- cocoa/PlatCocoa.mm | 24 ++++++++++++++++++------ doc/ScintillaHistory.html | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index c5fba7533..a58b2c9c0 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -594,18 +594,30 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi } void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int /*cornerSize*/, ColourDesired fill, int alphaFill, - ColourDesired /*outline*/, int /*alphaOutline*/, int /*flags*/) + ColourDesired outline, int alphaOutline, int /*flags*/) { if ( gc ) { - ColourDesired colour( fill.AsLong() ); - // Snap rectangle boundaries to nearest int rc.left = lround(rc.left); rc.right = lround(rc.right); // Set the Fill color to match - CGContextSetRGBFillColor( gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, colour.GetBlue() / 255.0, alphaFill / 255.0 ); - CGRect rect = PRectangleToCGRect( rc ); - CGContextFillRect( gc, rect ); + CGContextSetRGBFillColor( gc, fill.GetRed() / 255.0, fill.GetGreen() / 255.0, fill.GetBlue() / 255.0, alphaFill / 255.0 ); + PRectangle rcFill = rc; + if ((fill == outline) && (alphaFill == alphaOutline)) { + // Optimization for simple case + CGRect rect = PRectangleToCGRect( rcFill ); + CGContextFillRect( gc, rect ); + } else { + rcFill.left += 1.0; + rcFill.top += 1.0; + rcFill.right -= 1.0; + rcFill.bottom -= 1.0; + CGRect rect = PRectangleToCGRect( rcFill ); + CGContextFillRect( gc, rect ); + CGContextSetRGBStrokeColor( gc, outline.GetRed() / 255.0, outline.GetGreen() / 255.0, outline.GetBlue() / 255.0, alphaOutline / 255.0 ); + CGContextAddRect( gc, CGRectMake( rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1 ) ); + CGContextStrokePath( gc ); + } } } diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index c724505e5..978ce03d7 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -480,6 +480,10 @@ On Cocoa, memory leak fixed for MarginView.
  • + On Cocoa, fixed appearance of alpha rectangles so that outline uses specified colour and alpha. + This makes INDIC_STRAIGHTBOX look correct and INDIC_ROUNDBOX is only missing rounded corners. +
  • +
  • On Cocoa, drag image fixed when view scrolled.
  • -- cgit v1.2.3