aboutsummaryrefslogtreecommitdiffhomepage
path: root/cocoa
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-03-25 11:16:04 +1100
committerNeil <nyamatongwe@gmail.com>2021-03-25 11:16:04 +1100
commit3d45c4bf974b6fdcce9712bbd3f0071a9618b89f (patch)
tree0e648f92f248247953cc6e0e4bed30e83c443765 /cocoa
parent921df6efca5b385790a2806f8b8844becb36e773 (diff)
downloadscintilla-mirror-3d45c4bf974b6fdcce9712bbd3f0071a9618b89f.tar.gz
Translucent text.
Diffstat (limited to 'cocoa')
-rw-r--r--cocoa/PlatCocoa.h20
-rw-r--r--cocoa/PlatCocoa.mm30
2 files changed, 28 insertions, 22 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index f8a941f95..d11b52336 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -124,19 +124,19 @@ public:
void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) override;
std::unique_ptr<IScreenLineLayout> Layout(const IScreenLine *screenLine) override;
- void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidths(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthText(const Font *font_, std::string_view text) override;
- void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore,
- ColourDesired back) override;
- void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourDesired fore) override;
+ void DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore,
+ ColourAlpha back) override;
+ void DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text, ColourAlpha fore) override;
void MeasureWidthsUTF8(const Font *font_, std::string_view text, XYPOSITION *positions) override;
XYPOSITION WidthTextUTF8(const Font *font_, std::string_view text) override;
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 4020c3f09..aba1fa810 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -1454,7 +1454,7 @@ std::unique_ptr<IScreenLineLayout> SurfaceImpl::Layout(const IScreenLine *screen
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
DrawTextTransparent(rc, font_, ybase, text, fore);
}
@@ -1462,7 +1462,7 @@ void SurfaceImpl::DrawTextNoClip(PRectangle rc, const Font *font_, XYPOSITION yb
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextClipped(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
CGContextSaveGState(gc);
CGContextClipToRect(gc, PRectangleToCGRect(rc));
DrawTextNoClip(rc, font_, ybase, text, fore, back);
@@ -1527,14 +1527,17 @@ CFStringEncoding EncodingFromCharacterSet(bool unicode, int characterSet) {
}
void SurfaceImpl::DrawTextTransparent(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
QuartzTextStyle *style = TextStyleFromFont(font_);
if (!style) {
return;
}
CFStringEncoding encoding = EncodingFromCharacterSet(UnicodeMode(), style->getCharacterSet());
- ColourDesired colour(fore.AsInteger());
- CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0, colour.GetGreen()/255.0, colour.GetBlue()/255.0, 1.0);
+
+ CGColorRef color = CGColorCreateGenericRGB(fore.GetRedComponent(),
+ fore.GetGreenComponent(),
+ fore.GetBlueComponent(),
+ fore.GetAlphaComponent());
style->setCTStyleColour(color);
@@ -1623,32 +1626,35 @@ XYPOSITION SurfaceImpl::WidthText(const Font *font_, std::string_view text) {
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextNoClipUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
FillRectangle(rc, back);
- DrawTextTransparent(rc, font_, ybase, text, fore);
+ DrawTextTransparentUTF8(rc, font_, ybase, text, fore);
}
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextClippedUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore, ColourDesired back) {
+ ColourAlpha fore, ColourAlpha back) {
CGContextSaveGState(gc);
CGContextClipToRect(gc, PRectangleToCGRect(rc));
- DrawTextNoClip(rc, font_, ybase, text, fore, back);
+ DrawTextNoClipUTF8(rc, font_, ybase, text, fore, back);
CGContextRestoreGState(gc);
}
//--------------------------------------------------------------------------------------------------
void SurfaceImpl::DrawTextTransparentUTF8(PRectangle rc, const Font *font_, XYPOSITION ybase, std::string_view text,
- ColourDesired fore) {
+ ColourAlpha fore) {
QuartzTextStyle *style = TextStyleFromFont(font_);
if (!style) {
return;
}
const CFStringEncoding encoding = kCFStringEncodingUTF8;
- ColourDesired colour(fore.AsInteger());
- CGColorRef color = CGColorCreateGenericRGB(colour.GetRed()/255.0, colour.GetGreen()/255.0, colour.GetBlue()/255.0, 1.0);
+
+ CGColorRef color = CGColorCreateGenericRGB(fore.GetRedComponent(),
+ fore.GetGreenComponent(),
+ fore.GetBlueComponent(),
+ fore.GetAlphaComponent());
style->setCTStyleColour(color);