diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 85ec25dcd..194296455 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -179,6 +179,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; unsigned _gridStyleMask; unsigned _numberOfRows; + CPIndexSet _groupRows; CPTableHeaderView _headerView; @@ -319,6 +320,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; _exposedColumns = [CPIndexSet indexSet]; _cachedDataViews = { }; + _groupRows = [CPIndexSet indexSet]; + _tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self]; [_tableDrawView setBackgroundColor:[CPColor clearColor]]; [self addSubview:_tableDrawView]; @@ -2362,6 +2365,22 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; else [dataView unsetThemeState:CPThemeStateSelectedDataView]; + if (_implementedDelegateMethods & CPTableViewDelegate_tableView_isGroupRow_) + { + if([_delegate tableView:self isGroupRow:row]) + { + [_groupRows addIndex:row]; + [dataView setThemeState:CPThemeStateGroupRow]; + } + else + { + [_groupRows removeIndexesInRange:CPMakeRange(row, 1)]; + [dataView unsetThemeState:CPThemeStateGroupRow]; + } + + [self setNeedsDisplay:YES] + } + if (_implementedDelegateMethods & CPTableViewDelegate_tableView_willDisplayView_forTableColumn_row_) [_delegate tableView:self willDisplayView:dataView forTableColumn:tableColumn row:row]; @@ -2517,18 +2536,24 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; firstRow = exposedRows.location, lastRow = CPMaxRange(exposedRows) - 1, colorIndex = MIN(exposedRows.length, colorCount), - heightFilled = 0.0; + heightFilled = 0.0, + groupRowRects = [ ]; while (colorIndex--) { var row = firstRow - firstRow % colorCount + colorIndex, - fillRect = nil; + fillRect = _CGRectMakeZero(); CGContextBeginPath(context); for (; row <= lastRow; row += colorCount) if (row >= firstRow) - CGContextAddRect(context, CGRectIntersection(aRect, fillRect = [self rectOfRow:row])); + { + if (![_groupRows containsIndex:row] && _selectionHighlightStyle !== CPTableViewSelectionHighlightStyleSourceList) + CGContextAddRect(context, CGRectIntersection(aRect, fillRect = [self rectOfRow:row])); + else + groupRowRects.push(CGRectIntersection(aRect, [self rectOfRow:row])); + } if (row - colorCount === lastRow) heightFilled = _CGRectGetMaxY(fillRect); @@ -2540,22 +2565,33 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; } // console.profileEnd("row-paint"); + + + // FIX ME: this is really terrible, it seems like such a hack... var totalHeight = _CGRectGetMaxY(aRect); if (heightFilled >= totalHeight || _rowHeight <= 0.0) + { + [self _drawGroupRowsForRects:groupRowRects]; return; + } var rowHeight = _rowHeight + _intercellSpacing.height, fillRect = _CGRectMake(_CGRectGetMinX(aRect), _CGRectGetMinY(aRect) + heightFilled, _CGRectGetWidth(aRect), rowHeight); for (row = lastRow + 1; heightFilled < totalHeight; ++row) { - CGContextSetFillColor(context, rowColors[row % colorCount]); - CGContextFillRect(context, fillRect); + if(![_groupRows containsIndex:row] && _selectionHighlightStyle !== CPTableViewSelectionHighlightStyleSourceList) + { + CGContextSetFillColor(context, rowColors[row % colorCount]); + CGContextFillRect(context, fillRect); + } heightFilled += rowHeight; fillRect.origin.y += rowHeight; } + + [self _drawGroupRowsForRects:groupRowRects]; } - (void)drawGridInClipRect:(CGRect)aRect @@ -2670,47 +2706,76 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; CGContextBeginPath(context); - var gradientCache = [self selectionGradientColors], - topLineColor = [gradientCache objectForKey:CPSourceListTopLineColor], - bottomLineColor = [gradientCache objectForKey:CPSourceListBottomLineColor], - gradientColor = [gradientCache objectForKey:CPSourceListGradient]; + if (drawGradient) + { + var gradientCache = [self selectionGradientColors], + topLineColor = [gradientCache objectForKey:CPSourceListTopLineColor], + bottomLineColor = [gradientCache objectForKey:CPSourceListBottomLineColor], + gradientColor = [gradientCache objectForKey:CPSourceListGradient]; + } + + var normalSelectionHighlightColor = [self selectionHighlightColor]; + + // dont do these lookups if there are no group rows + if ([_groupRows count]) + { + var topGroupLineColor = [CPColor colorWithCalibratedWhite:212.0 / 255.0 alpha:1.0], + bottomGroupLineColor = [CPColor colorWithCalibratedWhite:185.0 / 255.0 alpha:1.0], + gradientGroupColor = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [212.0 / 255.0, 212.0 / 255.0, 212.0 / 255.0,1.0, 197.0 / 255.0, 197.0 / 255.0, 197.0 / 255.0,1.0], [0,1], 2); + } while (count--) - { - var rowRect = CGRectIntersection(objj_msgSend(self, rectSelector, indexes[count]), aRect); - CGContextAddRect(context, rowRect); + { + var currentIndex = indexes[count], + rowRect = CGRectIntersection(objj_msgSend(self, rectSelector, currentIndex), aRect); - if (drawGradient) + // group rows get the same highlight style as other rows if they're source list... + if (!drawGradient) + var shouldUseGroupGradient = [_groupRows containsIndex:currentIndex]; + + if (drawGradient || shouldUseGroupGradient) { var minX = _CGRectGetMinX(rowRect), minY = _CGRectGetMinY(rowRect), maxX = _CGRectGetMaxX(rowRect), maxY = _CGRectGetMaxY(rowRect) - deltaHeight; - CGContextDrawLinearGradient(context, gradientColor, rowRect.origin, CGPointMake(minX, maxY), 0); + if (!drawGradient) + { + //If there is no source list gradient we need to close the selection path and fill it now + [normalSelectionHighlightColor setFill]; + CGContextClosePath(context); + CGContextFillPath(context); + CGContextBeginPath(context); + } + CGContextAddRect(context, rowRect); + + CGContextDrawLinearGradient(context, (shouldUseGroupGradient) ? gradientGroupColor : gradientColor, rowRect.origin, _CGPointMake(minX, maxY), 0); CGContextClosePath(context); CGContextBeginPath(context); CGContextMoveToPoint(context, minX, minY); CGContextAddLineToPoint(context, maxX, minY); CGContextClosePath(context); - CGContextSetStrokeColor(context, topLineColor); + CGContextSetStrokeColor(context, (shouldUseGroupGradient) ? topGroupLineColor : topLineColor); CGContextStrokePath(context); CGContextBeginPath(context); CGContextMoveToPoint(context, minX, maxY); CGContextAddLineToPoint(context, maxX, maxY - 1); CGContextClosePath(context); - CGContextSetStrokeColor(context, bottomLineColor); + CGContextSetStrokeColor(context, (shouldUseGroupGradient) ? bottomGroupLineColor : bottomLineColor); CGContextStrokePath(context); } + else + CGContextAddRect(context, rowRect); } CGContextClosePath(context); if (!drawGradient) { - [[self selectionHighlightColor] setFill]; + [normalSelectionHighlightColor setFill]; CGContextFillPath(context); } @@ -2719,10 +2784,10 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; for(var i = 0; i < count2; i++) { var rect = objj_msgSend(self, rectSelector, indexes[i]), - minX = CGRectGetMinX(rect) - 0.5, - maxX = CGRectGetMaxX(rect) - 0.5, - minY = CGRectGetMinY(rect) - 0.5, - maxY = CGRectGetMaxY(rect) - 0.5; + minX = _CGRectGetMinX(rect) - 0.5, + maxX = _CGRectGetMaxX(rect) - 0.5, + minY = _CGRectGetMinY(rect) - 0.5, + maxY = _CGRectGetMaxY(rect) - 0.5; if ([_selectedRowIndexes count] >= 1 && gridStyleMask & CPTableViewSolidVerticalGridLineMask) { @@ -2736,7 +2801,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; for (var c = firstExposedColumn; c < exposedColumnCount; c++) { var colRect = [self rectOfColumn:exposedColumnIndexes[c]], - colX = CGRectGetMaxX(colRect) + 0.5; + colX = _CGRectGetMaxX(colRect) + 0.5; CGContextMoveToPoint(context, colX, minY); CGContextAddLineToPoint(context, colX, maxY); @@ -2756,6 +2821,59 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; CGContextStrokePath(context); } +- (void)_drawGroupRowsForRects:(CPArray)rects +{ + if (_selectionHighlightStyle === CPTableViewSelectionHighlightStyleSourceList || !rects.length) + return; + + var context = [[CPGraphicsContext currentContext] graphicsPort], + i = rects.length; + + CGContextBeginPath(context); + + var gradientCache = [self selectionGradientColors], + topLineColor = [CPColor colorWithHexString:"d3d3d3"], + bottomLineColor = [CPColor colorWithHexString:"bebebd"], + gradientColor = CGGradientCreateWithColorComponents(CGColorSpaceCreateDeviceRGB(), [220.0 / 255.0, 220.0 / 255.0, 220.0 / 255.0,1.0, + 199.0 / 255.0, 199.0 / 255.0, 199.0 / 255.0,1.0], [0,1], 2), + drawGradient = YES; + + while (i--) + { + var rowRect = rects[i]; + + CGContextAddRect(context, rowRect); + + if (drawGradient) + { + var minX = CGRectGetMinX(rowRect), + minY = CGRectGetMinY(rowRect), + maxX = CGRectGetMaxX(rowRect), + maxY = CGRectGetMaxY(rowRect); + + CGContextDrawLinearGradient(context, gradientColor, rowRect.origin, CGPointMake(minX, maxY), 0); + CGContextClosePath(context); + + CGContextBeginPath(context); + CGContextMoveToPoint(context, minX, minY); + CGContextAddLineToPoint(context, maxX, minY); + CGContextClosePath(context); + CGContextSetStrokeColor(context, topLineColor); + CGContextStrokePath(context); + + CGContextBeginPath(context); + CGContextMoveToPoint(context, minX, maxY); + CGContextAddLineToPoint(context, maxX, maxY - 1); + CGContextClosePath(context); + CGContextSetStrokeColor(context, bottomLineColor); + CGContextStrokePath(context); + } + } + + CGContextClosePath(context); +} + + - (void)_drawRows:(CPIndexSet)rowsIndexes clipRect:(CGRect)clipRect { var row = [rowsIndexes firstIndex]; @@ -2770,6 +2888,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; - (void)drawRow:(CPInteger)row clipRect:(CGRect)rect { // This method does currently nothing in cappuccino. Can be overriden by subclasses. + } - (void)layoutSubviews diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index a375b4f62..f930cb1ed 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -403,6 +403,7 @@ CPThemeStateHighlighted = CPThemeState("highlighted"); CPThemeStateSelected = CPThemeState("selected"); CPThemeStateTableDataView = CPThemeState("tableDataView"); CPThemeStateSelectedDataView = CPThemeStateSelectedTableDataView = CPThemeState("selectedTableDataView"); +CPThemeStateGroupRow = CPThemeState("CPThemeStateGroupRow"); CPThemeStateBezeled = CPThemeState("bezeled"); CPThemeStateBordered = CPThemeState("bordered"); CPThemeStateEditable = CPThemeState("editable"); diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index 6788fd844..c8b1826f9 100755 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -738,6 +738,13 @@ var themedButtonValues = nil, [@"text-color", [CPColor colorWithCalibratedWhite:51.0 / 255.0 alpha:1.0], CPThemeStateTableDataView], [@"text-color", [CPColor whiteColor], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView], [@"font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView], + + [@"text-color", [CPColor colorWithCalibratedWhite:125.0 / 255.0 alpha:1.0], CPThemeStateTableDataView|CPThemeStateGroupRow], + [@"text-color", [CPColor colorWithCalibratedWhite:1.0 alpha:1.0], CPThemeStateTableDataView|CPThemeStateGroupRow|CPThemeStateSelectedTableDataView], + [@"text-shadow-color", [CPColor whiteColor], CPThemeStateTableDataView|CPThemeStateGroupRow], + [@"text-shadow-offset", CGSizeMake(0,1), CPThemeStateTableDataView|CPThemeStateGroupRow], + [@"text-shadow-color", [CPColor colorWithCalibratedWhite:0.0 alpha:0.6], CPThemeStateTableDataView|CPThemeStateGroupRow|CPThemeStateSelectedTableDataView], + [@"font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateTableDataView|CPThemeStateGroupRow] ]; [self registerThemeValues:themedTextFieldValues forView:textfield]; diff --git a/AppKit/Themes/CommonJS/blendtask.j b/AppKit/Themes/CommonJS/blendtask.j index 168fdbd8d..1cb7ee6f9 100644 --- a/AppKit/Themes/CommonJS/blendtask.j +++ b/AppKit/Themes/CommonJS/blendtask.j @@ -6,7 +6,7 @@ var FILE = require("file"), - TERM = require("term"), + TERM = require("narwhal/term"), task = require("jake").task, filedir = require("jake").filedir, BundleTask = require("objective-j/jake/bundletask").BundleTask; @@ -32,7 +32,7 @@ BlendTask.prototype.infoPlist = function() { var infoPlist = BundleTask.prototype.infoPlist.apply(this, arguments); - infoPlist.setValueForKey("CPKeyedThemes", require("util").unique(this._keyedThemes)); + infoPlist.setValueForKey("CPKeyedThemes", require("narwhal/util").unique(this._keyedThemes)); return infoPlist; } diff --git a/CommonJS/bin/flatten b/CommonJS/bin/flatten index f47fb1e19..7bf829451 100755 --- a/CommonJS/bin/flatten +++ b/CommonJS/bin/flatten @@ -8,12 +8,12 @@ require("narwhal").ensureEngine("rhino"); var FILE = require("file"); var OS = require("os"); -var UTIL = require("util"); +var UTIL = require("narwhal/util"); var CACHEMANIFEST = require("objective-j/cache-manifest"); -var stream = require("term").stream; -var parser = new (require("args").Parser)(); +var stream = require("narwhal/term").stream; +var parser = new (require("narwhal/args").Parser)(); parser.usage("INPUT_PROJECT OUTPUT_PROJECT"); parser.help("Combine a Cappuccino application into a single JavaScript file."); diff --git a/CommonJS/bin/ojdepcheck b/CommonJS/bin/ojdepcheck index a06f4f431..c373f6927 100755 --- a/CommonJS/bin/ojdepcheck +++ b/CommonJS/bin/ojdepcheck @@ -8,8 +8,8 @@ require("narwhal").ensureEngine("rhino"); var FILE = require("file"); -var stream = require("term").stream -var parser = new (require("args").Parser)(); +var stream = require("narwhal/term").stream +var parser = new (require("narwhal/args").Parser)(); parser.usage("INPUT_PROJECT"); parser.help("Checks a project for missing imports."); diff --git a/CommonJS/bin/press b/CommonJS/bin/press index 10b6dadf1..8d1b60025 100755 --- a/CommonJS/bin/press +++ b/CommonJS/bin/press @@ -12,8 +12,8 @@ var OS = require("os"); var CACHEMANIFEST = require("objective-j/cache-manifest"); -var stream = require("term").stream; -var parser = new (require("args").Parser)(); +var stream = require("narwhal/term").stream; +var parser = new (require("narwhal/args").Parser)(); parser.usage("INPUT_PROJECT OUTPUT_PROJECT"); parser.help("Analyze and strip unused files from a Cappuccino project's .sj bundles."); diff --git a/Jakefile b/Jakefile index 47a96d224..9d0427b91 100644 --- a/Jakefile +++ b/Jakefile @@ -4,9 +4,9 @@ require("./common.jake"); var FILE = require("file"), SYSTEM = require("system"), OS = require("os"), - UTIL = require("util"), + UTIL = require("narwhal/util"), jake = require("jake"), - stream = require("term").stream; + stream = require("narwhal/term").stream; var subprojects = ["Objective-J", "CommonJS", "Foundation", "AppKit", "Tools"]; diff --git a/Objective-J/CPLog.js b/Objective-J/CPLog.js index dec1e0f06..3a9e863e4 100644 --- a/Objective-J/CPLog.js +++ b/Objective-J/CPLog.js @@ -182,7 +182,7 @@ GLOBAL(CPLogPrint) = function(aString, aLevel, aTitle, aFormatter) { if (stream === undefined) { try { - stream = require("term").stream; + stream = require("narwhal/term").stream; } catch (e) { stream = null; } diff --git a/Objective-J/CommonJS/bin/cplutil b/Objective-J/CommonJS/bin/cplutil index ceb11c71b..4d489ab0a 100755 --- a/Objective-J/CommonJS/bin/cplutil +++ b/Objective-J/CommonJS/bin/cplutil @@ -5,7 +5,7 @@ var FILE = require("file"), OS = require("os"), ObjectiveJ = require("objective-j"); -var parser = new (require("args").Parser)(); +var parser = new (require("narwhal/args").Parser)(); parser.usage("file..."); parser.help("Cappuccino plist converter."); diff --git a/Objective-J/CommonJS/lib/objective-j.js b/Objective-J/CommonJS/lib/objective-j.js index 444c47806..3bb275a27 100644 --- a/Objective-J/CommonJS/lib/objective-j.js +++ b/Objective-J/CommonJS/lib/objective-j.js @@ -23,7 +23,7 @@ var OBJJ_INCLUDE_PATHS = global.OBJJ_INCLUDE_PATHS = exports.OBJJ_INCLUDE_PATHS exports.objj_frameworks = []; exports.objj_debug_frameworks = []; -var catalog = require("packages").catalog; +var catalog = require("narwhal/packages").catalog; for (var name in catalog) { if (!catalog.hasOwnProperty(name)) diff --git a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js index 13e3d7a8b..e9cca5ee5 100644 --- a/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js +++ b/Objective-J/CommonJS/lib/objective-j/jake/bundletask.js @@ -1,8 +1,8 @@ var FILE = require("file"), OS = require("os"), - UTIL = require("util"), - TERM = require("term"), + UTIL = require("narwhal/util"), + TERM = require("narwhal/term"), Jake = require("jake"), CLEAN = require("jake/clean").CLEAN, CLOBBER = require("jake/clean").CLOBBER, diff --git a/Objective-J/Jakefile b/Objective-J/Jakefile index 58f2de2db..1458c9210 100644 --- a/Objective-J/Jakefile +++ b/Objective-J/Jakefile @@ -24,7 +24,7 @@ require("../common.jake"); var FILE = require("file"), OS = require("os"), - stream = require("term").stream; + stream = require("narwhal/term").stream; //$BUILD_CONFIGURATION_DIR = "../Build" $BROWSER_FILE = FILE.join("Browser", "Objective-J.js"); diff --git a/Tests/Manual/TableTest/GroupRowTest/AppController.j b/Tests/Manual/TableTest/GroupRowTest/AppController.j new file mode 100644 index 000000000..1b9d493a9 --- /dev/null +++ b/Tests/Manual/TableTest/GroupRowTest/AppController.j @@ -0,0 +1,130 @@ +/* + * AppController.j + * GroupRowTest + * + * Created by You on August 27, 2010. + * Copyright 2010, Your Company All rights reserved. + */ + +@import + + +@implementation AppController : CPObject +{ +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], + contentView = [theWindow contentView]; + + tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 400.0)]; + + [tableView setAllowsMultipleSelection:YES]; + [tableView setAllowsColumnSelection:YES]; + [tableView setUsesAlternatingRowBackgroundColors:YES]; + + [tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle]; + [tableView setDelegate:self]; + [tableView setDataSource:self]; + + + var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)]; + [iconView setImageScaling:CPScaleNone]; + var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"]; + [iconColumn setWidth:32.0]; + [iconColumn setMinWidth:32.0]; + [iconColumn setDataView:iconView]; + [tableView addTableColumn:iconColumn]; + + iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)]; + + + for (var i = 1; i <= 5; i++) + { + var column = [[CPTableColumn alloc] initWithIdentifier:String(i)]; + + [[column headerView] setStringValue:"Number " + i]; + + [column setMaxWidth:500.0]; + [column setWidth:200.0]; + + [tableView addTableColumn:column]; + } + + var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) / 2)]; + + [scrollView setDocumentView:tableView]; + [scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + + [contentView addSubview:scrollView]; + + tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 400.0, 400.0)]; + + [tableView setAllowsMultipleSelection:YES]; + [tableView setAllowsColumnSelection:YES]; + + [tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle]; + [tableView setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleSourceList]; + [tableView setDelegate:self]; + [tableView setDataSource:self]; + + + var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)]; + [iconView setImageScaling:CPScaleNone]; + var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"]; + [iconColumn setWidth:32.0]; + [iconColumn setMinWidth:32.0]; + [iconColumn setDataView:iconView]; + [tableView addTableColumn:iconColumn]; + + iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)]; + + + for (var i = 1; i <= 5; i++) + { + var column = [[CPTableColumn alloc] initWithIdentifier:String(i)]; + + [[column headerView] setStringValue:"Number " + i]; + + [column setMaxWidth:500.0]; + [column setWidth:200.0]; + + [tableView addTableColumn:column]; + } + + var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, CGRectGetHeight([contentView bounds]) / 2, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]) / 2)]; + + [scrollView setDocumentView:tableView]; + [scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; + + [contentView addSubview:scrollView]; + + [theWindow orderFront:self]; + +} + +- (int)numberOfRowsInTableView:(CPTableView)atableView +{ + return 500; +} + +- (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRow +{ + if ([aColumn identifier] === "icons") + return iconImage; + + return aRow; +} + +- (BOOL)tableView:(CPTableView)aTableView isGroupRow:(int)aRow +{ + var groups = []; + + for(var i = 0; i < 100; i+=5) + groups.push(i); + + return [groups containsObject:aRow]; +} + +@end diff --git a/Tests/Manual/TableTest/GroupRowTest/Info.plist b/Tests/Manual/TableTest/GroupRowTest/Info.plist new file mode 100644 index 000000000..4b3910a3c --- /dev/null +++ b/Tests/Manual/TableTest/GroupRowTest/Info.plist @@ -0,0 +1,12 @@ + + + + + CPApplicationDelegateClass + AppController + CPBundleName + GroupRowTest + CPPrincipalClass + CPApplication + + diff --git a/Tests/Manual/TableTest/GroupRowTest/Jakefile b/Tests/Manual/TableTest/GroupRowTest/Jakefile new file mode 100644 index 000000000..082dcad38 --- /dev/null +++ b/Tests/Manual/TableTest/GroupRowTest/Jakefile @@ -0,0 +1,93 @@ +/* + * Jakefile + * GroupRowTest + * + * Created by You on August 27, 2010. + * Copyright 2010, Your Company All rights reserved. + */ + +var ENV = require("system").env, + FILE = require("file"), + JAKE = require("jake"), + task = JAKE.task, + FileList = JAKE.FileList, + app = require("cappuccino/jake").app, + configuration = ENV["CONFIG"] || ENV["CONFIGURATION"] || ENV["c"] || "Debug", + OS = require("os"); + +app ("GroupRowTest", function(task) +{ + task.setBuildIntermediatesPath(FILE.join("Build", "GroupRowTest.build", configuration)); + task.setBuildPath(FILE.join("Build", configuration)); + + task.setProductName("GroupRowTest"); + task.setIdentifier("com.yourcompany.GroupRowTest"); + task.setVersion("1.0"); + task.setAuthor("Your Company"); + task.setEmail("feedback @nospam@ yourcompany.com"); + task.setSummary("GroupRowTest"); + task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**"))); + task.setResources(new FileList("Resources/**")); + task.setIndexFilePath("index.html"); + task.setInfoPlistPath("Info.plist"); + + if (configuration === "Debug") + task.setCompilerFlags("-DDEBUG -g"); + else + task.setCompilerFlags("-O"); +}); + +task ("default", ["GroupRowTest"], function() +{ + printResults(configuration); +}); + +task ("build", ["default"]); + +task ("debug", function() +{ + ENV["CONFIGURATION"] = "Debug"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("release", function() +{ + ENV["CONFIGURATION"] = "Release"; + JAKE.subjake(["."], "build", ENV); +}); + +task ("run", ["debug"], function() +{ + OS.system(["open", FILE.join("Build", "Debug", "GroupRowTest", "index.html")]); +}); + +task ("run-release", ["release"], function() +{ + OS.system(["open", FILE.join("Build", "Release", "GroupRowTest", "index.html")]); +}); + +task ("deploy", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Deployment", "GroupRowTest")); + OS.system(["press", "-f", FILE.join("Build", "Release", "GroupRowTest"), FILE.join("Build", "Deployment", "GroupRowTest")]); + printResults("Deployment") +}); + +task ("desktop", ["release"], function() +{ + FILE.mkdirs(FILE.join("Build", "Desktop", "GroupRowTest")); + require("cappuccino/nativehost").buildNativeHost(FILE.join("Build", "Release", "GroupRowTest"), FILE.join("Build", "Desktop", "GroupRowTest", "GroupRowTest.app")); + printResults("Desktop") +}); + +task ("run-desktop", ["desktop"], function() +{ + OS.system([FILE.join("Build", "Desktop", "GroupRowTest", "GroupRowTest.app", "Contents", "MacOS", "NativeHost"), "-i"]); +}); + +function printResults(configuration) +{ + print("----------------------------"); + print(configuration+" app built at path: "+FILE.join("Build", configuration, "GroupRowTest")); + print("----------------------------"); +} diff --git a/Tests/Manual/TableTest/GroupRowTest/Resources/spinner.gif b/Tests/Manual/TableTest/GroupRowTest/Resources/spinner.gif new file mode 100644 index 000000000..06dbc2bc2 Binary files /dev/null and b/Tests/Manual/TableTest/GroupRowTest/Resources/spinner.gif differ diff --git a/Tests/Manual/TableTest/GroupRowTest/index-debug.html b/Tests/Manual/TableTest/GroupRowTest/index-debug.html new file mode 100644 index 000000000..ff76f98ce --- /dev/null +++ b/Tests/Manual/TableTest/GroupRowTest/index-debug.html @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + GroupRowTest + + + + + + + + + + + + + + +
+
+ + + +
+
+ + + diff --git a/Tests/Manual/TableTest/GroupRowTest/index.html b/Tests/Manual/TableTest/GroupRowTest/index.html new file mode 100644 index 000000000..0e4376218 --- /dev/null +++ b/Tests/Manual/TableTest/GroupRowTest/index.html @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + GroupRowTest + + + + + + + + + + + + +
+
+ + + +
+
+ + + + diff --git a/Tests/Manual/TableTest/GroupRowTest/main.j b/Tests/Manual/TableTest/GroupRowTest/main.j new file mode 100644 index 000000000..48ff040f7 --- /dev/null +++ b/Tests/Manual/TableTest/GroupRowTest/main.j @@ -0,0 +1,18 @@ +/* + * AppController.j + * ScrollPerformanceTest + * + * Created by You on August 27, 2010. + * Copyright 2010, Your Company All rights reserved. + */ + +@import +@import + +@import "AppController.j" + + +function main(args, namedArgs) +{ + CPApplicationMain(args, namedArgs); +} diff --git a/Tools/capp/Generate.j b/Tools/capp/Generate.j index 0062ff735..e360500a0 100644 --- a/Tools/capp/Generate.j +++ b/Tools/capp/Generate.j @@ -6,9 +6,9 @@ var OS = require("os"), FILE = require("file"), OBJJ = require("objective-j"); -var stream = require("term").stream; +var stream = require("narwhal/term").stream; -var parser = new (require("args").Parser)(); +var parser = new (require("narwhal/args").Parser)(); parser.usage("DESTINATION_DIRECTORY"); @@ -63,7 +63,7 @@ parser.option("--list-frameworks", "listFrameworks") parser.helpful(); // FIXME: better way to do this: -var CAPP_HOME = require("packages").catalog["cappuccino"].directory; +var CAPP_HOME = require("narwhal/packages").catalog["cappuccino"].directory; var templatesDirectory = FILE.join(CAPP_HOME, "lib", "capp", "Resources", "Templates"); function gen(/*va_args*/) diff --git a/Tools/nib2cib/main.j b/Tools/nib2cib/main.j index ccb1a9f29..f718369a5 100644 --- a/Tools/nib2cib/main.j +++ b/Tools/nib2cib/main.j @@ -33,7 +33,7 @@ var FILE = require("file"); var OS = require("os"); -var parser = new (require("args").Parser)(); +var parser = new (require("narwhal/args").Parser)(); parser.usage("INPUT_FILE [OUTPUT_FILE]"); diff --git a/common.jake b/common.jake index 3607393e4..19f58d1c5 100644 --- a/common.jake +++ b/common.jake @@ -1,8 +1,8 @@ var SYSTEM = require("system"); var FILE = require("file"); var OS = require("os"); -var UTIL = require("util"); -var stream = require("term").stream; +var UTIL = require("narwhal/util"); +var stream = require("narwhal/term").stream; var requiresSudo = false; @@ -15,7 +15,7 @@ function ensurePackageUpToDate(packageName, requiredVersion, options) { options = options || {}; - var packageInfo = require("packages").catalog[packageName]; + var packageInfo = require("narwhal/packages").catalog[packageName]; if (!packageInfo) { if (options.optional) @@ -39,7 +39,7 @@ function ensurePackageUpToDate(packageName, requiredVersion, options) if (!options.noupdate) { - print("Update? yes or no:"); + print("Update? Existing package will be overwritten. yes or no:"); if (!SYSTEM.env["CAPP_AUTO_UPGRADE"] && system.stdin.readLine() !== "yes\n") { print("Jake aborted."); @@ -58,25 +58,35 @@ function ensurePackageUpToDate(packageName, requiredVersion, options) else OS.system(["tusk", "install", "--force", packageName]); } - + + if (options.after) + { + options.after(packageInfo.directory); + } + if (options.message) { - print(options.message) + print(options.message); OS.exit(1); } } // UPDATE THESE TO PICK UP CORRESPONDING CHANGES IN DEPENDENCIES -ensurePackageUpToDate("jake", "0.1.5"); +ensurePackageUpToDate("jake", "0.3"); ensurePackageUpToDate("browserjs", "0.1.1"); ensurePackageUpToDate("shrinksafe", "0.2"); -ensurePackageUpToDate("narwhal", "0.2.2", { +ensurePackageUpToDate("narwhal", "0.3.1", { noupdate : true, - message : "Update Narwhal to 0.2.1 by running bootstrap.sh, or pulling the latest from git (see: http://github.com/280north/narwhal)." + message : "Update Narwhal by re-running bootstrap.sh, or pulling the latest from git (see: http://github.com/280north/narwhal)." }); -ensurePackageUpToDate("narwhal-jsc", "0.1.1", { +ensurePackageUpToDate("narwhal-jsc", "0.3", { optional : true, - message : "Rebuild narwhal-jsc by changing to the narwhal-jsc package directory and running \"make webkit\"." + after : function(dir) { + if (OS.system("cd " + OS.enquote(dir) + " && make webkit")) { + print("Problem building narwhal-jsc."); + OS.exit(1); + } + } }); var JAKE = require("jake"); @@ -163,7 +173,7 @@ function additionalPackages() // checks to see if a path is in the package catalog function packageInCatalog(path) { - var catalog = require("packages").catalog; + var catalog = require("narwhal/packages").catalog; for (var name in catalog) if (String(catalog[name].directory) === String(path)) return true;