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

Draw a dotted outline around a maximized session.

parent 94ea3865
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -470,6 +470,9 @@ typedef struct PTYFontInfo PTYFontInfo;
endX:(int *)endx
endY:(int *)endy;
 
- (double)perceivedBrightness:(NSColor*)c;
- (void)drawOutlineInRect:(NSRect)rect topOnly:(BOOL)topOnly;
@end
 
//
Loading
Loading
@@ -566,6 +569,5 @@ typedef enum {
// Returns true if any onscreen char is blinking.
- (BOOL)_markChangedSelectionAndBlinkDirty:(BOOL)redrawBlink width:(int)width;
 
- (double)_perceivedBrightness:(NSColor*)c;
@end
 
Loading
Loading
@@ -443,7 +443,7 @@ static CGFloat PerceivedBrightness(CGFloat r, CGFloat g, CGFloat b) {
[color retain];
defaultBGColor = color;
PTYScroller *scroller = (PTYScroller*)[[[dataSource session] SCROLLVIEW] verticalScroller];
BOOL isDark = ([self _perceivedBrightness:color] < kBackgroundConsideredDarkThreshold);
BOOL isDark = ([self perceivedBrightness:color] < kBackgroundConsideredDarkThreshold);
backgroundBrightness_ = PerceivedBrightness([color redComponent], [color greenComponent], [color blueComponent]);
[scroller setHasDarkBackground:isDark];
[self setNeedsDisplay:YES];
Loading
Loading
@@ -1523,6 +1523,53 @@ static BOOL RectsEqual(NSRect* a, NSRect* b) {
operation:NSCompositeSourceOver
fraction:flashing_];
}
[self drawOutlineInRect:rect topOnly:NO];
}
- (void)drawOutlineInRect:(NSRect)rect topOnly:(BOOL)topOnly
{
if ([[[dataSource session] tab] hasMaximizedPane]) {
NSColor *color;
double brightness = [self perceivedBrightness:[self defaultBGColor]];
if (brightness > 0.5) {
color = [NSColor colorWithCalibratedWhite:pow(brightness - 0.5, 2)
alpha:1];
} else {
color = [NSColor colorWithCalibratedWhite:0.5 + pow(brightness, 2) alpha:1];
}
NSRect frame = [self visibleRect];
if (!topOnly) {
if (frame.origin.y < VMARGIN) {
frame.size.height += (VMARGIN - frame.origin.y);
frame.origin.y -= (VMARGIN - frame.origin.y);
}
}
NSBezierPath *path = [[[NSBezierPath alloc] init] autorelease];
CGFloat left = frame.origin.x + 0.5;
CGFloat right = frame.origin.x + frame.size.width - 0.5;
CGFloat top = frame.origin.y + 0.5;
CGFloat bottom = frame.origin.y + frame.size.height - 0.5;
if (topOnly) {
[path moveToPoint:NSMakePoint(left, top + VMARGIN)];
[path lineToPoint:NSMakePoint(left, top)];
[path lineToPoint:NSMakePoint(right, top)];
[path lineToPoint:NSMakePoint(right, top + VMARGIN)];
} else {
[path moveToPoint:NSMakePoint(left, top + VMARGIN)];
[path lineToPoint:NSMakePoint(left, top)];
[path lineToPoint:NSMakePoint(right, top)];
[path lineToPoint:NSMakePoint(right, bottom)];
[path lineToPoint:NSMakePoint(left, bottom)];
[path lineToPoint:NSMakePoint(left, top + VMARGIN)];
}
CGFloat dashPattern[2] = { 5, 5 };
[path setLineDash:dashPattern count:2 phase:0];
[color set];
[path stroke];
}
}
 
- (void)drawRect:(NSRect)rect to:(NSPoint*)toOrigin
Loading
Loading
@@ -4379,6 +4426,11 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
return [self contentFromX:x1 Y:yStart ToX:x2 Y:y2 pad: YES];
}
 
- (double)perceivedBrightness:(NSColor*) c
{
return PerceivedBrightness([c redComponent], [c greenComponent], [c blueComponent]);
}
@end
 
//
Loading
Loading
@@ -4595,11 +4647,6 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
return newRuns;
}
 
- (double)_perceivedBrightness:(NSColor*) c
{
return PerceivedBrightness([c redComponent], [c greenComponent], [c blueComponent]);
}
- (NSColor*)colorWithRed:(double)r green:(double)g blue:(double)b alpha:(double)a withPerceivedBrightness:(CGFloat)t
{
/*
Loading
Loading
@@ -5617,7 +5664,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
 
- (double)_brightnessOfCharBackground:(screen_char_t)c
{
return [self _perceivedBrightness:[[self _charBackground:c] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]];
return [self perceivedBrightness:[[self _charBackground:c] colorUsingColorSpaceName:NSCalibratedRGBColorSpace]];
}
 
// Return the value in 'values' closest to target.
Loading
Loading
@@ -5764,7 +5811,7 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
}
 
NSMutableArray* constraints = [NSMutableArray arrayWithCapacity:2];
CGFloat bgBrightness = [self _perceivedBrightness:[bgColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]];
CGFloat bgBrightness = [self perceivedBrightness:[bgColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]];
if (x1 > 0) {
[constraints addObject:[NSNumber numberWithDouble:[self _brightnessOfCharBackground:theLine[x1 - 1]]]];
}
Loading
Loading
@@ -5843,8 +5890,8 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
alternateSemantics:fgAlt
bold:screenChar.bold
isBackground:NO] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
CGFloat fgBrightness = [self _perceivedBrightness:proposedForeground];
CGFloat bgBrightness = [self _perceivedBrightness:[bgColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]];
CGFloat fgBrightness = [self perceivedBrightness:proposedForeground];
CGFloat bgBrightness = [self perceivedBrightness:[bgColor colorUsingColorSpaceName:NSCalibratedRGBColorSpace]];
NSColor* overrideColor = nil;
if (!frameOnly && fabs(fgBrightness - bgBrightness) < 0.5) {
// foreground and background are very similar. Just use black and
Loading
Loading
Loading
Loading
@@ -39,6 +39,8 @@
[self frame].size.width,
VMARGIN)
toPoint:NSMakePoint(0, VMARGIN)];
[child_ drawOutlineInRect:rect topOnly:YES];
}
 
- (void)addSubview:(PTYTextView*)child
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