Skip to content
Snippets Groups Projects
Commit 0ab27192 authored by George Nachman's avatar George Nachman
Browse files

Add blend option to allow variable blending of default bg color over...

Add blend option to allow variable blending of default bg color over background image (it used to use the transparency value when transparency was disabled, which if 0 would make lion fullscreen not have a bg image at all)
parent a1f3235e
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
Loading
Loading
@@ -456,6 +456,8 @@ typedef enum {
- (void)setCursorTextColor: (NSColor *)aColor;
- (float)transparency;
- (void)setTransparency:(float)transparency;
- (float)blend;
- (void)setBlend:(float)blend;
- (BOOL)useBoldFont;
- (void)setUseBoldFont:(BOOL)boldFlag;
- (void)setColorTable:(int)index color:(NSColor *)c;
Loading
Loading
@@ -581,5 +583,6 @@ typedef enum {
- (void)continueTailFind;
- (void)printTmuxMessage:(NSString *)message;
- (void)printTmuxCommandOutputToScreen:(NSString *)response;
- (BOOL)_localeIsSupported:(NSString*)theLocale;
 
@end
Loading
Loading
@@ -131,6 +131,7 @@ typedef struct PTYFontInfo PTYFontInfo;
 
// transparency
double transparency;
double blend;
 
// data source
VT100Screen *dataSource;
Loading
Loading
@@ -469,7 +470,9 @@ typedef struct PTYFontInfo PTYFontInfo;
 
// transparency
- (double)transparency;
- (double)blend;
- (void)setTransparency:(double)fVal;
- (void)setBlend:(double)blend;
- (BOOL)useTransparency;
 
- (void)setSmartCursorColor:(BOOL)value;
Loading
Loading
Loading
Loading
@@ -432,6 +432,7 @@ typedef enum { CURSOR_UNDERLINE, CURSOR_VERTICAL, CURSOR_BOX } ITermCursorType;
IBOutlet NSButton* useBoldFont;
IBOutlet NSButton* useBrightBold;
IBOutlet NSSlider *transparency;
IBOutlet NSSlider *blend;
IBOutlet NSButton* blur;
IBOutlet NSSlider *blurRadius;
IBOutlet NSButton* asciiAntiAliased;
Loading
Loading
Loading
Loading
@@ -115,6 +115,7 @@
#define KEY_USE_BOLD_FONT @"Use Bold Font"
#define KEY_USE_BRIGHT_BOLD @"Use Bright Bold"
#define KEY_TRANSPARENCY @"Transparency"
#define KEY_BLEND @"Blend"
#define KEY_BLUR @"Blur"
#define KEY_BLUR_RADIUS @"Blur Radius"
#define KEY_ANTI_ALIASING @"Anti Aliasing" // DEPRECATED
Loading
Loading
Loading
Loading
@@ -423,6 +423,9 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
horizontalSpacing:[[addressBookEntry objectForKey:KEY_HORIZONTAL_SPACING] floatValue]
verticalSpacing:[[addressBookEntry objectForKey:KEY_VERTICAL_SPACING] floatValue]];
[self setTransparency:[[addressBookEntry objectForKey:KEY_TRANSPARENCY] floatValue]];
const float blend = [addressBookEntry objectForKey:KEY_BLEND] ?
[[addressBookEntry objectForKey:KEY_BLEND] floatValue] : 0.5;
[self setBlend:blend];
 
[WRAPPER addSubview:TEXTVIEW];
[TEXTVIEW setFrame:NSMakeRect(0, VMARGIN, aSize.width, aSize.height - VMARGIN)];
Loading
Loading
@@ -2153,6 +2156,7 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
 
// transparency
[self setTransparency:[[aDict objectForKey:KEY_TRANSPARENCY] floatValue]];
[self setBlend:[[aDict objectForKey:KEY_BLEND] floatValue]];
 
// bold
NSNumber* useBoldFontEntry = [aDict objectForKey:KEY_USE_BOLD_FONT];
Loading
Loading
@@ -2697,6 +2701,11 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
return [TEXTVIEW transparency];
}
 
- (float)blend
{
return [TEXTVIEW blend];
}
- (void)setTransparency:(float)transparency
{
// Limit transparency because fully transparent windows can't be clicked on.
Loading
Loading
@@ -2709,6 +2718,11 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
[TEXTVIEW setTransparency:transparency];
}
 
- (void)setBlend:(float)blendVal
{
[TEXTVIEW setBlend:blendVal];
}
- (void)setColorTable:(int)theIndex color:(NSColor *)theColor
{
[TEXTVIEW setColorTable:theIndex color:theColor];
Loading
Loading
@@ -3818,24 +3832,6 @@ static long long timeInTenthsOfSeconds(struct timeval t)
return theLocale;
}
 
- (BOOL)_localeIsSupported:(NSString*)theLocale
{
// Keep a copy of the current locale setting for this process
char* backupLocale = setlocale(LC_CTYPE, NULL);
// Try to set it to the proposed locale
BOOL supported;
if (setlocale(LC_CTYPE, [theLocale UTF8String])) {
supported = YES;
} else {
supported = NO;
}
// Restore locale and return
setlocale(LC_CTYPE, backupLocale);
return supported;
}
- (NSString*)_lang
{
NSString* theLocale = [self _getLocale];
Loading
Loading
@@ -3962,4 +3958,22 @@ static long long timeInTenthsOfSeconds(struct timeval t)
}
}
 
- (BOOL)_localeIsSupported:(NSString*)theLocale
{
// Keep a copy of the current locale setting for this process
char* backupLocale = setlocale(LC_CTYPE, NULL);
// Try to set it to the proposed locale
BOOL supported;
if (setlocale(LC_CTYPE, [theLocale UTF8String])) {
supported = YES;
} else {
supported = NO;
}
// Restore locale and return
setlocale(LC_CTYPE, backupLocale);
return supported;
}
@end
Loading
Loading
@@ -4781,6 +4781,17 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[self setNeedsDisplay:YES];
}
 
- (double)blend
{
return blend;
}
- (void)setBlend:(double)fVal
{
blend = MIN(MAX(0.3, fVal), 1);
[self setNeedsDisplay:YES];
}
- (void)setSmartCursorColor:(BOOL)value
{
colorInvertedCursor = value;
Loading
Loading
@@ -5024,10 +5035,19 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[(PTYScrollView *)[self enclosingScrollView] drawBackgroundImageRect:bgRect
toPoint:dest
useTransparency:[self useTransparency]];
}
if (!hasBGImage || ![self useTransparency]) {
// Either draw a normal bg or, if transparency is off, blend the default bg color over the bg image.
if (!hasBGImage && ![self useTransparency]) {
// Blend default bg color
NSColor *aColor = [self colorForCode:ALTSEM_BG_DEFAULT
alternateSemantics:YES
bold:NO
isBackground:YES];
[[aColor colorWithAlphaComponent:1 - blend] set];
NSRectFillUsingOperation(NSMakeRect(dest.x + bgRect.origin.x,
dest.y + bgRect.origin.y,
bgRect.size.width,
bgRect.size.height), NSCompositeSourceOver);
} else {
// No bg image
if (![self useTransparency]) {
alpha = 1;
}
if (!dimOnlyText_) {
Loading
Loading
@@ -5037,8 +5057,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
NSRect fillDest = bgRect;
fillDest.origin.y += fillDest.size.height;
NSRectFillUsingOperation(fillDest,
hasBGImage ? NSCompositeSourceOver : NSCompositeCopy);
NSRectFillUsingOperation(fillDest, NSCompositeCopy);
}
}
 
Loading
Loading
@@ -5051,10 +5070,20 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
[(PTYScrollView *)[self enclosingScrollView] drawBackgroundImageRect:bgRect
toPoint:dest
useTransparency:[self useTransparency]];
}
if (!hasBGImage || ![self useTransparency]) {
// Either draw a normal bg or, if transparency is off, blend the default bg color over the bg image.
if (!hasBGImage && ![self useTransparency]) {
// Blend default bg color over bg iamge.
NSColor *aColor = [self colorForCode:ALTSEM_BG_DEFAULT
alternateSemantics:YES
bold:NO
isBackground:YES];
[[aColor colorWithAlphaComponent:1 - blend] set];
NSRectFillUsingOperation(NSMakeRect(dest.x + bgRect.origin.x,
dest.y + bgRect.origin.y,
bgRect.size.width,
bgRect.size.height),
NSCompositeSourceOver);
} else {
// No bg image
if (![self useTransparency]) {
alpha = 1;
}
if (!dimOnlyText_) {
Loading
Loading
@@ -5062,8 +5091,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
} else {
[[[self defaultBGColor] colorWithAlphaComponent:alpha] set];
}
NSRectFillUsingOperation(bgRect,
hasBGImage ? NSCompositeSourceOver : NSCompositeCopy);
NSRectFillUsingOperation(bgRect, NSCompositeCopy);
}
}
 
Loading
Loading
@@ -5075,10 +5103,16 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
if (hasBGImage) {
[(PTYScrollView *)[self enclosingScrollView] drawBackgroundImageRect:bgRect
useTransparency:[self useTransparency]];
}
if (!hasBGImage || ![self useTransparency]) {
// Blend default bg color over bg iamge.
NSColor *aColor = [self colorForCode:ALTSEM_BG_DEFAULT
alternateSemantics:YES
bold:NO
isBackground:YES];
[[aColor colorWithAlphaComponent:1 - blend] set];
NSRectFillUsingOperation(bgRect, NSCompositeSourceOver);
} else {
// Either draw a normal bg or, if transparency is off, blend the default bg color over the bg image.
if (!hasBGImage && ![self useTransparency]) {
if (![self useTransparency]) {
alpha = 1;
}
if (!dimOnlyText_) {
Loading
Loading
@@ -5086,7 +5120,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
} else {
[[[self defaultBGColor] colorWithAlphaComponent:alpha] set];
}
NSRectFillUsingOperation(bgRect, hasBGImage?NSCompositeSourceOver:NSCompositeCopy);
NSRectFillUsingOperation(bgRect, NSCompositeCopy);
}
}
 
Loading
Loading
@@ -6054,16 +6088,30 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
toPoint:NSMakePoint(toPoint->x + rightMargin.origin.x,
toPoint->y + rightMargin.size.height)
useTransparency:[self useTransparency]];
} else {
// Blend default bg color over bg iamge.
[[aColor colorWithAlphaComponent:1 - blend] set];
NSRectFillUsingOperation(NSMakeRect(toPoint->x + leftMargin.origin.x,
toPoint->y + leftMargin.origin.y,
leftMargin.size.width,
leftMargin.size.height), NSCompositeSourceOver);
NSRectFillUsingOperation(NSMakeRect(toPoint->x + rightMargin.origin.x,
toPoint->y + rightMargin.origin.y,
rightMargin.size.width,
rightMargin.size.height), NSCompositeSourceOver);
} else {
[scrollView drawBackgroundImageRect:leftMargin
useTransparency:[self useTransparency]];
[scrollView drawBackgroundImageRect:rightMargin
useTransparency:[self useTransparency]];
}
}
if (!hasBGImage || ![self useTransparency]) {
// Blend fg over bgimage (because transparency is off), or there is no
// bg image and just draw the fg.
// Blend default bg color over bg iamge.
[[aColor colorWithAlphaComponent:1 - blend] set];
NSRectFillUsingOperation(leftMargin, NSCompositeSourceOver);
NSRectFillUsingOperation(rightMargin, NSCompositeSourceOver);
}
[aColor set];
} else {
// No BG image
if (toPoint) {
NSRectFill(NSMakeRect(toPoint->x + leftMargin.origin.x,
toPoint->y,
Loading
Loading
@@ -6202,17 +6250,15 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
NSRectFillUsingOperation(bgRect,
hasBGImage ? NSCompositeSourceOver : NSCompositeCopy);
} else if (hasBGImage) {
// There is a bg image and no special background on it. Blend in the
// default background color. But don't blend in the bg color if transparency is on.
// There is a bg image and no special background on it. Blend
// in the default background color.
aColor = [self colorForCode:ALTSEM_BG_DEFAULT
alternateSemantics:YES
bold:NO
isBackground:YES];
aColor = [aColor colorWithAlphaComponent:selectedAlpha];
aColor = [aColor colorWithAlphaComponent:1 - blend];
[aColor set];
if (![self useTransparency]) {
NSRectFillUsingOperation(bgRect, NSCompositeSourceOver);
}
NSRectFillUsingOperation(bgRect, NSCompositeSourceOver);
}
 
// Draw red stripes in the background if sending input to all sessions
Loading
Loading
Loading
Loading
@@ -618,6 +618,7 @@ static float versionNumber;
[initialText setContinuous:YES];
[blurRadius setContinuous:YES];
[transparency setContinuous:YES];
[blend setContinuous:YES];
[dimmingAmount setContinuous:YES];
[minimumContrast setContinuous:YES];
 
Loading
Loading
@@ -1495,6 +1496,7 @@ static float versionNumber;
[dict setObject:[NSNumber numberWithInt:WINDOW_TYPE_TOP] forKey:KEY_WINDOW_TYPE];
[dict setObject:[NSNumber numberWithInt:25] forKey:KEY_ROWS];
[dict setObject:[NSNumber numberWithFloat:0.3] forKey:KEY_TRANSPARENCY];
[dict setObject:[NSNumber numberWithFloat:0.5] forKey:KEY_BLEND];
[dict setObject:[NSNumber numberWithFloat:2.0] forKey:KEY_BLUR_RADIUS];
[dict setObject:[NSNumber numberWithBool:YES] forKey:KEY_BLUR];
[dict setObject:[NSNumber numberWithInt:-1] forKey:KEY_SCREEN];
Loading
Loading
@@ -2729,6 +2731,12 @@ static float versionNumber;
}
 
[transparency setFloatValue:[[dict objectForKey:KEY_TRANSPARENCY] floatValue]];
if ([dict objectForKey:KEY_BLEND]) {
[blend setFloatValue:[[dict objectForKey:KEY_BLEND] floatValue]];
} else {
// Old clients used transparency for blending
[blend setFloatValue:[[dict objectForKey:KEY_TRANSPARENCY] floatValue]];
}
[blurRadius setFloatValue:[dict objectForKey:KEY_BLUR_RADIUS] ? [[dict objectForKey:KEY_BLUR_RADIUS] floatValue] : 2.0];
[blur setState:[[dict objectForKey:KEY_BLUR] boolValue] ? NSOnState : NSOffState];
if ([dict objectForKey:KEY_ASCII_ANTI_ALIASED]) {
Loading
Loading
@@ -3162,6 +3170,7 @@ static float versionNumber;
[newDict setObject:[NSNumber numberWithBool:([useBoldFont state]==NSOnState)] forKey:KEY_USE_BOLD_FONT];
[newDict setObject:[NSNumber numberWithBool:([useBrightBold state]==NSOnState)] forKey:KEY_USE_BRIGHT_BOLD];
[newDict setObject:[NSNumber numberWithFloat:[transparency floatValue]] forKey:KEY_TRANSPARENCY];
[newDict setObject:[NSNumber numberWithFloat:[blend floatValue]] forKey:KEY_BLEND];
[newDict setObject:[NSNumber numberWithFloat:[blurRadius floatValue]] forKey:KEY_BLUR_RADIUS];
[newDict setObject:[NSNumber numberWithBool:([blur state]==NSOnState)] forKey:KEY_BLUR];
[newDict setObject:[NSNumber numberWithBool:([asciiAntiAliased state]==NSOnState)] forKey:KEY_ASCII_ANTI_ALIASED];
Loading
Loading
@@ -4083,6 +4092,7 @@ static float versionNumber;
KEY_SCREEN,
KEY_SPACE,
KEY_TRANSPARENCY,
KEY_BLEND,
KEY_BLUR_RADIUS,
KEY_BLUR,
KEY_BACKGROUND_IMAGE_LOCATION,
Loading
Loading
Loading
Loading
@@ -2105,7 +2105,8 @@ NSString *sessionsKey = @"sessions";
aTabViewItem = [[TABVIEW tabViewItemAtIndex:0] retain];
PTYTab* theTab = [aTabViewItem identifier];
for (PTYSession* aSession in [theTab sessions]) {
[aSession setTransparency:[[[aSession addressBookEntry] objectForKey:KEY_TRANSPARENCY] floatValue]];
[aSession setTransparency:[[[aSession addressBookEntry]
objectForKey:KEY_TRANSPARENCY] floatValue]];
}
// remove from our window
PtyLog(@"toggleFullScreenMode - remove tab %d from old window", i);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment