Skip to content

Commit

Permalink
[overview] Add Overview to the Nimbus root project.
Browse files Browse the repository at this point in the history
  • Loading branch information
jverkoey committed Aug 4, 2011
1 parent aebf7a9 commit 5d9eee5
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 395 deletions.
365 changes: 365 additions & 0 deletions src/Nimbus.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

361 changes: 0 additions & 361 deletions src/overview/NimbusOverview.xcodeproj/project.pbxproj

This file was deleted.

2 changes: 2 additions & 0 deletions src/overview/src/NIOverview.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
*/
extern void _NSSetLogCStringFunction(void(*)(const char *, unsigned, BOOL));

void NIOverviewLogMethod(const char* message, unsigned length, BOOL withSyslogBanner);


///////////////////////////////////////////////////////////////////////////////////////////////////
/**
Expand Down
20 changes: 11 additions & 9 deletions src/overview/src/NIOverviewGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import "NIOverviewGraphView.h"

#import <QuartzCore/QuartzCore.h>


///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -30,7 +32,7 @@ - (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.opaque = NO;
self.layer.borderWidth = 1;
self.layer.borderColor = [UIColor colorWithWhite:1 alpha:0.2].CGColor;
self.layer.borderColor = [UIColor colorWithWhite:1 alpha:0.2f].CGColor;
}
return self;
}
Expand All @@ -42,19 +44,19 @@ - (void)drawGraphWithContext:(CGContextRef)context {

CGFloat xRange = [self.dataSource graphViewXRange:self];
CGFloat yRange = [self.dataSource graphViewYRange:self];

[self.dataSource resetPointIterator];

CGContextSetLineWidth(context, 1);
CGContextSetShouldAntialias(context, YES);

BOOL isFirstPoint = YES;
CGPoint point = CGPointZero;
while ([self.dataSource nextPointInGraphView:self point:&point]) {
CGPoint scaledPoint = CGPointMake(point.x / xRange, point.y / yRange);
CGPoint plotPoint = CGPointMake(floorf(scaledPoint.x * contentSize.width) - 0.5f,
contentSize.height
- floorf((scaledPoint.y * 0.8 + 0.1)
- floorf((scaledPoint.y * 0.8f + 0.1f)
* contentSize.height) - 0.5f);
if (!isFirstPoint) {
CGContextAddLineToPoint(context, plotPoint.x, plotPoint.y);
Expand All @@ -63,7 +65,7 @@ - (void)drawGraphWithContext:(CGContextRef)context {
isFirstPoint = NO;
}

CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1 alpha:0.6].CGColor);
CGContextSetStrokeColorWithColor(context, [UIColor colorWithWhite:1 alpha:0.6f].CGColor);
CGContextStrokePath(context);

[self.dataSource resetEventIterator];
Expand Down Expand Up @@ -92,16 +94,16 @@ - (void)drawRect:(CGRect)rect {

[self drawGraphWithContext:context];

CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:1 alpha:0.2].CGColor);
CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:1 alpha:0.2f].CGColor);
CGContextFillRect(context, bounds);

CGGradientRef glossGradient = nil;
CGColorSpaceRef colorspace = nil;
size_t numberOfLocations = 2;
CGFloat locations[2] = { 0.0, 1.0 };
CGFloat locations[2] = { 0.0f, 1.0f };
CGFloat components[8] = {
1.0, 1.0, 1.0, 0.35,
1.0, 1.0, 1.0, 0.06
1.0f, 1.0f, 1.0f, 0.35f,
1.0f, 1.0f, 1.0f, 0.06f
};

colorspace = CGColorSpaceCreateDeviceRGB();
Expand Down
8 changes: 4 additions & 4 deletions src/overview/src/NIOverviewLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ - (void)dealloc {


///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithLog:(NSString *)log {
- (id)initWithLog:(NSString *)logText {
if ((self = [super initWithTimestamp:[NSDate date]])) {
_log = [log copy];
_log = [logText copy];
}

return self;
Expand All @@ -170,13 +170,13 @@ - (id)initWithLog:(NSString *)log {
///////////////////////////////////////////////////////////////////////////////////////////////////
@implementation NIOverviewEventLogEntry

@synthesize type = _type;
@synthesize type = _eventType;


///////////////////////////////////////////////////////////////////////////////////////////////////
- (id)initWithType:(NSInteger)type {
if ((self = [super initWithTimestamp:[NSDate date]])) {
_type = type;
_eventType = type;
}

return self;
Expand Down
34 changes: 18 additions & 16 deletions src/overview/src/NIOverviewPageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ - (UILabel *)label {
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:12];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor colorWithWhite:0 alpha:0.5];
label.shadowColor = [UIColor colorWithWhite:0 alpha:0.5f];
label.shadowOffset = CGSizeMake(0, 1);

return label;
Expand All @@ -78,7 +78,7 @@ - (id)initWithFrame:(CGRect)frame {
_titleLabel = [[[UILabel alloc] init] autorelease];
_titleLabel.backgroundColor = [UIColor clearColor];
_titleLabel.font = [UIFont boldSystemFontOfSize:11];
_titleLabel.textColor = [UIColor colorWithWhite:1 alpha:0.8];
_titleLabel.textColor = [UIColor colorWithWhite:1 alpha:0.8f];
[self addSubview:_titleLabel];
}
return self;
Expand Down Expand Up @@ -208,7 +208,7 @@ - (CGFloat)graphViewXRange:(NIOverviewGraphView *)graphView {
NIOverviewLogEntry* firstEntry = [deviceLogs firstObject];
NIOverviewLogEntry* lastEntry = [deviceLogs lastObject];
NSTimeInterval interval = [lastEntry.timestamp timeIntervalSinceDate:firstEntry.timestamp];
return interval;
return (CGFloat)interval;
}


Expand Down Expand Up @@ -256,7 +256,7 @@ - (BOOL)nextEventInGraphView: (NIOverviewGraphView *)graphView
NIOverviewEventLogEntry* entry = [_eventEnumerator nextObject];
if (nil != entry) {
NSTimeInterval interval = [entry.timestamp timeIntervalSinceDate:[self initialTimestamp]];
*xValue = interval;
*xValue = (CGFloat)interval;
*color = [sEventColors objectAtIndex:entry.type];
}
return nil != entry;
Expand Down Expand Up @@ -330,7 +330,7 @@ - (CGFloat)graphViewYRange:(NIOverviewGraphView *)graphView {
}
unsigned long long range = maxY - minY;
_minMemory = minY;
return ((double)range / 1024.0 / 1024.0);
return (CGFloat)((double)range / 1024.0 / 1024.0);
}


Expand All @@ -355,7 +355,9 @@ - (BOOL)nextPointInGraphView: (NIOverviewGraphView *)graphView
NIOverviewDeviceLogEntry* entry = [_enumerator nextObject];
if (nil != entry) {
NSTimeInterval interval = [entry.timestamp timeIntervalSinceDate:[self initialTimestamp]];
*point = CGPointMake(interval, ((double)(entry.bytesOfFreeMemory - _minMemory)) / 1024.0 / 1024.0);
*point = CGPointMake((CGFloat)interval,
(CGFloat)(((double)(entry.bytesOfFreeMemory - _minMemory))
/ 1024.0 / 1024.0));
}
return nil != entry;
}
Expand Down Expand Up @@ -428,7 +430,7 @@ - (CGFloat)graphViewYRange:(NIOverviewGraphView *)graphView {
}
unsigned long long range = maxY - minY;
_minDiskUse = minY;
return ((double)range / 1024.0 / 1024.0);
return (CGFloat)((double)range / 1024.0 / 1024.0);
}


Expand All @@ -454,7 +456,7 @@ - (BOOL)nextPointInGraphView: (NIOverviewGraphView *)graphView
NSTimeInterval interval = [entry.timestamp timeIntervalSinceDate:[self initialTimestamp]];
double difference = ((double)entry.bytesOfFreeDiskSpace / 1024.0 / 1024.0
- (double)_minDiskUse / 1024.0 / 1024.0);
*point = CGPointMake(interval, difference);
*point = CGPointMake((CGFloat)interval, (CGFloat)difference);
}
return nil != entry;
}
Expand Down Expand Up @@ -486,7 +488,7 @@ - (UILabel *)label {

label.font = [UIFont boldSystemFontOfSize:11];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor colorWithWhite:0 alpha:0.5];
label.shadowColor = [UIColor colorWithWhite:0 alpha:0.5f];
label.shadowOffset = CGSizeMake(0, 1);
label.backgroundColor = [UIColor clearColor];
label.lineBreakMode = UILineBreakModeWordWrap;
Expand All @@ -501,14 +503,14 @@ - (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.pageTitle = NSLocalizedString(@"Logs", @"Overview Page Title: Logs");

self.titleLabel.textColor = [UIColor colorWithWhite:1 alpha:0.5];
self.titleLabel.textColor = [UIColor colorWithWhite:1 alpha:0.5f];

_logScrollView = [[[UIScrollView alloc] initWithFrame:self.bounds] autorelease];
_logScrollView.showsHorizontalScrollIndicator = NO;
_logScrollView.alwaysBounceVertical = YES;
_logScrollView.contentInset = kPagePadding;

_logScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2];
_logScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.2f];

[self addSubview:_logScrollView];

Expand Down Expand Up @@ -630,7 +632,7 @@ - (UILabel *)label {

label.font = [UIFont boldSystemFontOfSize:11];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor colorWithWhite:0 alpha:0.5];
label.shadowColor = [UIColor colorWithWhite:0 alpha:0.5f];
label.shadowOffset = CGSizeMake(0, 1);
label.backgroundColor = [UIColor clearColor];
label.lineBreakMode = UILineBreakModeWordWrap;
Expand All @@ -643,9 +645,9 @@ - (UILabel *)label {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)updateLabels {
_warningLogLevelLabel.textColor = [_warningLogLevelLabel.textColor colorWithAlphaComponent:
(NIMaxLogLevel >= NILOGLEVEL_WARNING) ? 1 : 0.6];
(NIMaxLogLevel >= NILOGLEVEL_WARNING) ? 1 : 0.6f];
_infoLogLevelLabel.textColor = [_infoLogLevelLabel.textColor colorWithAlphaComponent:
(NIMaxLogLevel >= NILOGLEVEL_INFO) ? 1 : 0.6];
(NIMaxLogLevel >= NILOGLEVEL_INFO) ? 1 : 0.6f];
}


Expand All @@ -654,7 +656,7 @@ - (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.pageTitle = NSLocalizedString(@"Max Log Level", @"Overview Page Title: Max Log Level");

self.titleLabel.textColor = [UIColor colorWithWhite:1 alpha:0.5];
self.titleLabel.textColor = [UIColor colorWithWhite:1 alpha:0.5f];

_logLevelSlider = [[[UISlider alloc] init] autorelease];
_logLevelSlider.minimumValue = 1;
Expand Down Expand Up @@ -720,7 +722,7 @@ - (void)layoutSubviews {
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)didChangeSliderValue:(UISlider *)slider {
slider.value = roundf(slider.value);
NIMaxLogLevel = round(slider.value);
NIMaxLogLevel = lround(slider.value);

[self updateLabels];
}
Expand Down
7 changes: 5 additions & 2 deletions src/overview/src/NIOverviewSwizzling.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@ - (CGRect)_statusBarFrame;

@end

CGFloat NIOverviewStatusBarHeight(void);
void NIOverviewSwizzleMethods(void);


///////////////////////////////////////////////////////////////////////////////////////////////////
CGFloat NIOverviewStatusBarHeight() {
CGFloat NIOverviewStatusBarHeight(void) {
CGRect statusBarFrame = [[UIApplication sharedApplication] _statusBarFrame];
CGFloat statusBarHeight = MIN(statusBarFrame.size.width, statusBarFrame.size.height);
return statusBarHeight;
}


///////////////////////////////////////////////////////////////////////////////////////////////////
void NIOverviewSwizzleMethods() {
void NIOverviewSwizzleMethods(void) {
NISwapInstanceMethods([UIViewController class],
@selector(_statusBarHeightForCurrentInterfaceOrientation),
@selector(__statusBarHeightForCurrentInterfaceOrientation));
Expand Down
6 changes: 3 additions & 3 deletions src/overview/src/NIOverviewView.m
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ - (CGSize)contentSizeForPagingScrollView {


///////////////////////////////////////////////////////////////////////////////////////////////////
- (CGRect)frameForPageAtIndex:(NSInteger)index {
- (CGRect)frameForPageAtIndex:(NSInteger)pageIndex {
// We have to use our paging scroll view's bounds, not frame, to calculate the page
// placement. When the device is in landscape orientation, the frame will still be in
// portrait because the pagingScrollView is the root view controller's view, so its
Expand All @@ -121,7 +121,7 @@ - (CGRect)frameForPageAtIndex:(NSInteger)index {
// We need to counter the extra spacing added to the paging scroll view in
// frameForPagingScrollView:
pageFrame.size.width -= self.pageHorizontalMargin * 2;
pageFrame.origin.x = (bounds.size.width * index) + self.pageHorizontalMargin;
pageFrame.origin.x = (bounds.size.width * pageIndex) + self.pageHorizontalMargin;

return pageFrame;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ - (void)setTranslucent:(BOOL)translucent {
: UIScrollViewIndicatorStyleDefault);

self.backgroundColor = (_translucent
? [UIColor colorWithWhite:0 alpha:0.5]
? [UIColor colorWithWhite:0 alpha:0.5f]
: [UIColor colorWithPatternImage:_backgroundImage]);
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/overview/unittests/NimbusOverviewTests-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.nimbus.overview.unittests</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
</dict>
</plist>

0 comments on commit 5d9eee5

Please sign in to comment.