Skip to content

Commit

Permalink
Changing the toolbar images be more standardized. The progress bar is…
Browse files Browse the repository at this point in the history
… also completely changed. In fullscreen mode the bezel now resembles Quicktime Xs.
  • Loading branch information
Alexander Rauchfuss committed Nov 14, 2009
1 parent d0766a7 commit bb18646
Show file tree
Hide file tree
Showing 37 changed files with 2,861 additions and 634 deletions.
20 changes: 11 additions & 9 deletions Custom Controls/TSSTCRTProgressBar.m
Expand Up @@ -53,6 +53,8 @@ - (void) dealloc
[self removeObserver: self forKeyPath: @"leftToRight"];
[self removeObserver: self forKeyPath: @"currentValue"];
[self removeObserver: self forKeyPath: @"maxValue"];
[self removeTrackingArea: [[self trackingAreas] objectAtIndex: 0]];

[super dealloc];
}

Expand Down Expand Up @@ -180,15 +182,15 @@ - (void)drawRect:(NSRect)rect

- (void)setFrameSize:(NSSize)size
{
int width = size.width - [self horizontalMargin] * 2;
/* This is to make sure that the width allows the progress
tick marks to allign properly. */
if(width % 2)
{
++width;
}

[self setProgressRect: NSMakeRect([self horizontalMargin] , 4.5, width, size.height - 9)];
// int width = size.width - [self horizontalMargin] * 2;
// /* This is to make sure that the width allows the progress
// tick marks to allign properly. */
// if(width % 2)
// {
// ++width;
// }
//
// [self setProgressRect: NSMakeRect([self horizontalMargin] , 4.5, width, size.height - 9)];
[super setFrameSize: size];
}

Expand Down
128 changes: 50 additions & 78 deletions Custom Controls/TSSTFullscreenProgressBar.m
Expand Up @@ -14,13 +14,6 @@

@implementation TSSTFullscreenProgressBar

+ (void)initialize
{
stringAttirbutes = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSFont fontWithName: @"Lucida Grande" size: 10], NSFontAttributeName,
[NSColor colorWithCalibratedWhite: 0.8 alpha: 1.0], NSForegroundColorAttributeName,
nil] retain];
}

- (id)initWithFrame:(NSRect)frame
{
Expand All @@ -29,97 +22,76 @@ - (id)initWithFrame:(NSRect)frame
{
[self setLeftToRight: YES];
[self setFrameSize: frame.size];
[self setHorizontalMargin: 35];
[self setHorizontalMargin: 1];
}
return self;
}


- (void)drawRect:(NSRect)rect
{
/* Drawing The border and background for the progress bar. */
/* First the high contrast gradient to make the whole thing seem sunken */

/* The outline of the actual progress bar. */
[[NSColor colorWithCalibratedWhite: 0.8 alpha: 1] set];
[NSBezierPath setDefaultLineWidth: 2];
[NSBezierPath setDefaultLineJoinStyle: NSRoundLineJoinStyle];
NSBezierPath * outlinePath = roundedRectWithCornerRadius(progressRect, 3);
[outlinePath stroke];

NSRect bounds = [self bounds];

NSRect barRect = bounds;
/* The 4 is half the height of the progress bar */
barRect.origin.y = NSHeight(bounds)/2 - 4.5;
barRect.origin.x = NSMinX(bounds) + 0.5;
barRect.size.height = 8;
barRect.size.width -= 2;
NSRect fillRect = NSInsetRect(barRect, 1, 1);

NSBezierPath * roundedMask = roundedRectWithCornerRadius(barRect, 4);

[NSGraphicsContext saveGraphicsState];
[[NSGraphicsContext currentContext] setShouldAntialias: NO];

/* Now drawing the individual tick marks in the progress bar.
Ticks can start from the right or the left. */
float vertMin = NSMinY(progressRect) + 4;
float vertMax = NSMaxY(progressRect) - 4;
float horizontalPosition;
float cursorPos;
[[NSColor colorWithCalibratedWhite: 0.8 alpha: 1] set];
// [[NSGraphicsContext currentContext] setShouldAntialias: NO];

if(leftToRight)
{
horizontalPosition = NSMinX(progressRect) + 4;
cursorPos = (NSMinX(progressRect) + NSWidth(progressRect) * (currentValue + 1) / maxValue);
for ( ; horizontalPosition < cursorPos; horizontalPosition += 3)
{
[NSBezierPath strokeLineFromPoint: NSMakePoint(horizontalPosition, vertMin)
toPoint: NSMakePoint(horizontalPosition, vertMax)];
}
horizontalPosition -= 1;
}
else
{
horizontalPosition = NSMaxX(progressRect) - 4;
cursorPos = (NSMaxX(progressRect) - NSWidth(progressRect) * (currentValue + 1) / maxValue);
for ( ; horizontalPosition > cursorPos; horizontalPosition -= 3)
{
[NSBezierPath strokeLineFromPoint: NSMakePoint(horizontalPosition, vertMin)
toPoint: NSMakePoint(horizontalPosition, vertMax)];
}
horizontalPosition += 1;
}
NSGradient * shadowGradient = [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceWhite: 0.3 alpha: 1], 0.0,
[NSColor colorWithDeviceWhite: 0.25 alpha: 1], 0.5,
[NSColor colorWithDeviceWhite: 0.2 alpha: 1], 0.5,
[NSColor colorWithDeviceWhite: 0.1 alpha: 1], 1.0, nil];


[shadowGradient drawInBezierPath: roundedMask angle: 90];
roundedMask = roundedRectWithCornerRadius(fillRect, 2.5);
[roundedMask addClip];
[[NSColor blackColor] set];
NSRectFill(fillRect);

[NSGraphicsContext restoreGraphicsState];

NSBezierPath * cursor = [NSBezierPath bezierPath];
NSPoint arrowPoint = NSMakePoint((vertMax - vertMin) / 2, (vertMax + vertMin) / 2);
if(leftToRight)
{
arrowPoint.x += (horizontalPosition + 1);
fillRect.size.width = NSWidth(progressRect) * (currentValue + 1) / maxValue + 8;
}
else
{
arrowPoint.x = (horizontalPosition - arrowPoint.x - 1);
fillRect.size.width = NSWidth(progressRect) * (currentValue + 1) / maxValue + 8;
fillRect.origin.x = NSMinX(barRect) + (NSWidth(barRect) - NSWidth(fillRect));
}

[cursor moveToPoint: NSMakePoint(horizontalPosition, vertMax + 1)];
[cursor lineToPoint: NSMakePoint(horizontalPosition, vertMin - 1)];

if(NSPointInRect(arrowPoint, progressRect))
{
[cursor lineToPoint: arrowPoint];
}

[cursor closePath];
[cursor fill];

float textWidth = [self horizontalMargin];
NSRect bounds = [self bounds];
// initWithColorsAndLocations: [NSColor colorWithCalibratedRed:0.049 green:0.270 blue:0.494 alpha: 1.000], 0.0,
// [NSColor colorWithCalibratedRed:0.105 green:0.556 blue:0.930 alpha: 1.000], 0.5,
// [NSColor colorWithCalibratedRed:0.161 green:0.709 blue:0.975 alpha: 1.000], 0.5,
// [NSColor colorWithCalibratedRed:0.111 green:0.560 blue:0.767 alpha: 1.000], 1.0, nil];
NSGradient * fillGradient = [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceWhite: 0.7 alpha: 1], 0.0,
[NSColor colorWithDeviceWhite: 0.75 alpha: 1], 0.5,
[NSColor colorWithDeviceWhite: 0.8 alpha: 1], 0.5,
[NSColor colorWithDeviceWhite: 0.9 alpha: 1], 1.0, nil];
NSBezierPath * roundFill = roundedRectWithCornerRadius(fillRect, 3);

[fillGradient drawInBezierPath: roundFill angle: 90];

NSRect rightStringRect = NSMakeRect(NSMaxX(progressRect), NSMinY(bounds), textWidth, NSHeight(bounds));
NSRect leftStringRect = NSMakeRect(0, NSMinY(bounds), textWidth, NSHeight(bounds));
[fillGradient release];
[shadowGradient release];

NSString * progressString = [NSString stringWithFormat: @"%i", currentValue + 1];
NSSize stringSize = [progressString sizeWithAttributes: stringAttirbutes];
NSRect stringRect = rectWithSizeCenteredInRect(stringSize, leftToRight ? leftStringRect : rightStringRect );
[progressString drawInRect: stringRect withAttributes: stringAttirbutes];

NSString * totalString = [NSString stringWithFormat: @"%i", maxValue];
stringSize = [totalString sizeWithAttributes: stringAttirbutes];
stringRect = rectWithSizeCenteredInRect(stringSize, leftToRight ? rightStringRect : leftStringRect );
[totalString drawInRect: stringRect withAttributes: stringAttirbutes];
[NSGraphicsContext restoreGraphicsState];

}

- (void)setFrameSize:(NSSize)size
{
[self setProgressRect: NSMakeRect([self horizontalMargin] ,0, size.width, size.height)];
[super setFrameSize: size];
}


@end
39 changes: 18 additions & 21 deletions Custom Windows/Bezel/TSSTBezelWindow.m
Expand Up @@ -17,14 +17,24 @@ @implementation TSSTBezelWindow

- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask | NSNonactivatingPanelMask backing: bufferingType defer: flag];
self = [super initWithContentRect: contentRect styleMask: NSBorderlessWindowMask backing: bufferingType defer: flag];
if(self)
{
[self setOpaque: NO];
// [self setOpaque: YES];
}
return self;
}

- (BOOL)canBecomeKeyWindow
{
return YES;
}

//- (BOOL)acceptsMouseMovedEvents
//{
// return YES;
//}


@end

Expand All @@ -36,27 +46,14 @@ - (void)drawRect:(NSRect)aRect
{
[[NSColor clearColor] set];
NSRectFill(aRect);

NSRect bounds = [self bounds];
NSBezierPath * bezelBackgroundPath = [NSBezierPath bezierPath];
[bezelBackgroundPath moveToPoint: NSMakePoint(0,0)];
[bezelBackgroundPath appendBezierPathWithArcFromPoint: NSMakePoint(0 , NSMaxY(bounds))
toPoint: NSMakePoint(NSMidX(bounds), NSMaxY(bounds))
radius: 5];
[bezelBackgroundPath appendBezierPathWithArcFromPoint: NSMakePoint(NSMaxX(bounds) , NSMaxY(bounds))
toPoint: NSMakePoint(NSMaxX(bounds), NSMidY(bounds))
radius: 5];
[bezelBackgroundPath lineToPoint: NSMakePoint(NSMaxX(bounds), NSMinY(bounds))];
[bezelBackgroundPath closePath];

[[NSColor colorWithCalibratedWhite: 0 alpha: 0.8] set];
[bezelBackgroundPath fill];

[bezelBackgroundPath addClip];
[[NSColor colorWithCalibratedWhite: 0.8 alpha: 1] set];
[bezelBackgroundPath setLineWidth: 3];
[bezelBackgroundPath stroke];
NSGradient * polishedGradient = [[NSGradient alloc] initWithColorsAndLocations: [NSColor colorWithDeviceWhite: 0.3 alpha: 1], 0.0,
[NSColor colorWithDeviceWhite: 0.25 alpha: 1], 0.5,
[NSColor colorWithDeviceWhite: 0.2 alpha: 1], 0.5,
[NSColor colorWithDeviceWhite: 0.1 alpha: 1], 1.0, nil];

[polishedGradient drawInRect: bounds angle: 270];
[polishedGradient release];
}


Expand Down

0 comments on commit bb18646

Please sign in to comment.