From 265a41034226e80992b87e8ef3a865fab1a5ecd7 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Thu, 4 Feb 2010 21:24:38 -0500 Subject: [PATCH 1/7] Changed the default text color for table column data views to match Aristo. --- AppKit/CPTableColumn.j | 1 + 1 file changed, 1 insertion(+) diff --git a/AppKit/CPTableColumn.j b/AppKit/CPTableColumn.j index 4b7f9a03f..1742c4956 100644 --- a/AppKit/CPTableColumn.j +++ b/AppKit/CPTableColumn.j @@ -75,6 +75,7 @@ CPTableColumnUserResizingMask = 2; [self setHeaderView:header]; var textDataView = [CPTextField new]; + [textDataView setValue:[CPColor colorWithHexString:@"333333"] forThemeAttribute:@"text-color"]; [textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateHighlighted]; [textDataView setValue:[CPFont boldSystemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateHighlighted]; [self setDataView:textDataView]; From e8b74ece72207bbf00af950217df3da6ac18a678 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Sat, 6 Feb 2010 17:29:19 -0500 Subject: [PATCH 2/7] Fixed tableview begin drag/drop behavior to be more cocoa like. --- AppKit/CPTableView.j | 114 +++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 53 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index a9dbdca09..acdf9ce42 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -190,6 +190,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; SEL _doubleAction; unsigned _columnAutoResizingStyle; + CGPoint _originalMouseDownPoint; BOOL _verticalMotionCanDrag; unsigned _destinationDragStyle; BOOL _isSelectingSession; @@ -2275,18 +2276,20 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; else _selectionAnchorRow = row; + + //set ivars for startTrackingPoint and time... + _startTrackingPoint = aPoint; + _startTrackingTimestamp = new Date(); - - if (_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_) { - _startTrackingPoint = aPoint; - _startTrackingTimestamp = new Date(); + if (_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_) _trackingPointMovedOutOfClickSlop = NO; - } // if the table has drag support then we use mouseUp to select a single row. // otherwise it uses mouse down. - if(!(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) + if (!(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) + { [self _updateSelectionWithMouseAtRow:row]; + } [[self window] makeFirstResponder:self]; return YES; @@ -2310,56 +2313,61 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; - (BOOL)continueTracking:(CGPoint)lastPoint at:(CGPoint)aPoint { var row = [self rowAtPoint:aPoint]; - + console.log(_startTrackingPoint); // begin the drag is the datasource lets us, we've move at least +-3px vertical or horizontal, or we're dragging from selected rows and we haven't begun a drag session - if - ( - !_isSelectingSession && - (_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_) && - ( - (lastPoint.x - aPoint.x > 3 || (_verticalMotionCanDrag && ABS(lastPoint.y - aPoint.y) > 3)) - || ([_selectedRowIndexes containsIndex:row]) - ) - ) + if(!_isSelectingSession && _implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_) { - if ([_selectedRowIndexes containsIndex:row]) - _draggedRowIndexes = [[CPIndexSet alloc] initWithIndexSet:_selectedRowIndexes]; - else - _draggedRowIndexes = [CPIndexSet indexSetWithIndex:row]; - - - //ask the datasource for the data - var pboard = [CPPasteboard pasteboardWithName:CPDragPboard]; - - if ([self canDragRowsWithIndexes:_draggedRowIndexes atPoint:aPoint] && [_dataSource tableView:self writeRowsWithIndexes:_draggedRowIndexes toPasteboard:pboard]) + if ( + (ABS(_startTrackingPoint.x - aPoint.x) > 4 || (_verticalMotionCanDrag && ABS(_startTrackingPoint.y - aPoint.y) > 4)) || + ([_selectedRowIndexes containsIndex:row]) + ) { - var currentEvent = [CPApp currentEvent], - offset = CPPointMakeZero(), - tableColumns = [_tableColumns objectsAtIndexes:_exposedColumns]; - - // We deviate from the default Cocoa implementation here by asking for a view in stead of an image - // We support both, but the view prefered over the image because we can mimic the rows we are dragging - // by re-creating the data views for the dragged rows - var view = [self dragViewForRowsWithIndexes:_draggedRowIndexes - tableColumns:tableColumns - event:currentEvent - offset:offset]; - - if (!view) - { - var image = [self dragImageForRowsWithIndexes:_draggedRowIndexes - tableColumns:tableColumns - event:currentEvent - offset:offset]; - view = [[CPImageView alloc] initWithFrame:CPMakeRect(0, 0, [image size].width, [image size].height)]; - [view setImage:image]; - } - - var bounds = [view bounds]; - var viewLocation = CPPointMake(aPoint.x - CGRectGetWidth(bounds)/2 + offset.x, aPoint.y - CGRectGetHeight(bounds)/2 + offset.y); - [self dragView:view at:viewLocation offset:CPPointMakeZero() event:[CPApp currentEvent] pasteboard:pboard source:self slideBack:YES]; - - return NO; + if ([_selectedRowIndexes containsIndex:row]) + _draggedRowIndexes = [[CPIndexSet alloc] initWithIndexSet:_selectedRowIndexes]; + else + _draggedRowIndexes = [CPIndexSet indexSetWithIndex:row]; + + + //ask the datasource for the data + var pboard = [CPPasteboard pasteboardWithName:CPDragPboard]; + + if ([self canDragRowsWithIndexes:_draggedRowIndexes atPoint:aPoint] && [_dataSource tableView:self writeRowsWithIndexes:_draggedRowIndexes toPasteboard:pboard]) + { + var currentEvent = [CPApp currentEvent], + offset = CPPointMakeZero(), + tableColumns = [_tableColumns objectsAtIndexes:_exposedColumns]; + + // We deviate from the default Cocoa implementation here by asking for a view in stead of an image + // We support both, but the view prefered over the image because we can mimic the rows we are dragging + // by re-creating the data views for the dragged rows + var view = [self dragViewForRowsWithIndexes:_draggedRowIndexes + tableColumns:tableColumns + event:currentEvent + offset:offset]; + + if (!view) + { + var image = [self dragImageForRowsWithIndexes:_draggedRowIndexes + tableColumns:tableColumns + event:currentEvent + offset:offset]; + view = [[CPImageView alloc] initWithFrame:CPMakeRect(0, 0, [image size].width, [image size].height)]; + [view setImage:image]; + } + + var bounds = [view bounds]; + var viewLocation = CPPointMake(aPoint.x - CGRectGetWidth(bounds)/2 + offset.x, aPoint.y - CGRectGetHeight(bounds)/2 + offset.y); + [self dragView:view at:viewLocation offset:CPPointMakeZero() event:[CPApp currentEvent] pasteboard:pboard source:self slideBack:YES]; + _originalMouseDownPoint = nil; + + return NO; + } + } + console.log("First drag conditions failed!"); + if (ABS(_startTrackingPoint.x - aPoint.x) < 5 && ABS(_startTrackingPoint.y - aPoint.y) < 5) + { + console.log("here"); + return YES; } } From f590c63e3327968d9e1d86bd2ed604c8b447c569 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Sat, 6 Feb 2010 17:36:20 -0500 Subject: [PATCH 3/7] Cleaned up tableview logs. --- AppKit/CPTableView.j | 4 ---- 1 file changed, 4 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index acdf9ce42..c2b95c8c1 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2287,9 +2287,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; // if the table has drag support then we use mouseUp to select a single row. // otherwise it uses mouse down. if (!(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) - { [self _updateSelectionWithMouseAtRow:row]; - } [[self window] makeFirstResponder:self]; return YES; @@ -2313,7 +2311,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; - (BOOL)continueTracking:(CGPoint)lastPoint at:(CGPoint)aPoint { var row = [self rowAtPoint:aPoint]; - console.log(_startTrackingPoint); // begin the drag is the datasource lets us, we've move at least +-3px vertical or horizontal, or we're dragging from selected rows and we haven't begun a drag session if(!_isSelectingSession && _implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_) { @@ -2363,7 +2360,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; return NO; } } - console.log("First drag conditions failed!"); if (ABS(_startTrackingPoint.x - aPoint.x) < 5 && ABS(_startTrackingPoint.y - aPoint.y) < 5) { console.log("here"); From 47bd6e5ce3d87c361973b024f2b3c3ce396892c2 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Sat, 6 Feb 2010 17:53:40 -0500 Subject: [PATCH 4/7] Further cleanup of code and logs in the tableview. --- AppKit/CPTableView.j | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index c2b95c8c1..a4f47f9f9 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2355,16 +2355,13 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; var bounds = [view bounds]; var viewLocation = CPPointMake(aPoint.x - CGRectGetWidth(bounds)/2 + offset.x, aPoint.y - CGRectGetHeight(bounds)/2 + offset.y); [self dragView:view at:viewLocation offset:CPPointMakeZero() event:[CPApp currentEvent] pasteboard:pboard source:self slideBack:YES]; - _originalMouseDownPoint = nil; + _startTrackingPoint = nil; return NO; } } - if (ABS(_startTrackingPoint.x - aPoint.x) < 5 && ABS(_startTrackingPoint.y - aPoint.y) < 5) - { - console.log("here"); + else if (ABS(_startTrackingPoint.x - aPoint.x) < 5 && ABS(_startTrackingPoint.y - aPoint.y) < 5) return YES; - } } _isSelectingSession = YES; From cd3e2fbbb87218208366ebcc44e9ed1c1cf35bc7 Mon Sep 17 00:00:00 2001 From: Francisco Ryan Tolmasky I Date: Sat, 6 Feb 2010 17:13:03 -0800 Subject: [PATCH 5/7] Fix for cplutil. Reviewed by me. --- Objective-J/CommonJS/bin/cplutil | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Objective-J/CommonJS/bin/cplutil b/Objective-J/CommonJS/bin/cplutil index 000e7d1be..22826b724 100755 --- a/Objective-J/CommonJS/bin/cplutil +++ b/Objective-J/CommonJS/bin/cplutil @@ -3,7 +3,7 @@ var FILE = require("file"); var SYSTEM = require("system"); var OS = require("os"); -var OBJJ = require("objective-j"); +var CFPropertyList = require("objective-j").CFPropertyList; var parser = new (require("args").Parser)(); @@ -13,8 +13,8 @@ parser.help("Cappuccino plist converter."); parser.option("-c", "--convert", "format") .help("rewrite property list files in format") .choices({ - "280north1" : OBJJ.kCFPropertyList280NorthFormat_v1_0, - "xml1": OBJJ.kCFPropertyListXMLFormat_v1_0 + "280north1" : CFPropertyList.Format280North_v1_0, + "xml1": CFPropertyList.FormatXML_v1_0 }); parser.option("-l", "--lint", "lint") @@ -50,15 +50,13 @@ exports.main = function(args) if (typeof options.format !== "undefined" || options.lint) { ok = true; - options.args.forEach(function(filePath) { - var data = new OBJJ.objj_data(); - data.string = FILE.read(filePath, { charset:"UTF-8" }); + options.args.forEach(function(filePath) + { + var plistObject = CFPropertyList.propertyListFromString(FILE.read(filePath, { charset:"UTF-8" })); - var plistObject = OBJJ.CPPropertyListCreateFromData(data); if (!plistObject) { - // FIXME: more useful error messages - SYSTEM.stderr.print(filePath + ": parse error"); + SYSTEM.stderr.print("Could not recognize format of plist at " + filePath); ok = false; return; } @@ -70,13 +68,13 @@ exports.main = function(args) } else { - data = OBJJ.CPPropertyListCreateData(plistObject, options.format); + var encodedString = CFPropertyList.stringFromPropertyList(plistObject); // outextension? if (options.outPath === "-") - SYSTEM.stdout.write(data.string); + SYSTEM.stdout.write(encodedString); else - FILE.write(options.outPath || filePath, data.string, { charset:"UTF-8" }); + FILE.write(options.outPath || filePath, encodedString, { charset:"UTF-8" }); } }); } From e6a0caa1640597eee7f3de12af4d011eecd9ea13 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Sat, 6 Feb 2010 17:46:32 -0800 Subject: [PATCH 6/7] cplutil wasn't converting. CFPropertyList couldn't output XML correctly. --- Objective-J/CFPropertyList.js | 6 +++--- Objective-J/CommonJS/bin/cplutil | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Objective-J/CFPropertyList.js b/Objective-J/CFPropertyList.js index d98ebf0a1..b8743f415 100644 --- a/Objective-J/CFPropertyList.js +++ b/Objective-J/CFPropertyList.js @@ -126,7 +126,7 @@ CFPropertyListSerializers[CFPropertyList.FormatXML_v1_0] = "real": function(/*Float*/ aFloat) { - return "" + anInteger + ""; + return "" + aFloat + ""; }, "array": function(/*Array*/ anArray, /*Object*/ serializers) @@ -138,7 +138,7 @@ CFPropertyListSerializers[CFPropertyList.FormatXML_v1_0] = for (; index < count; ++index) string += serializePropertyList(anArray[index], serializers); - return ""; + return string+""; }, "dictionary": function(/*CFDictionary*/ aDictionary, /*Object*/ serializers) @@ -156,7 +156,7 @@ CFPropertyListSerializers[CFPropertyList.FormatXML_v1_0] = string += serializePropertyList(aDictionary.valueForKey(key), serializers); } - return ""; + return string+""; } } diff --git a/Objective-J/CommonJS/bin/cplutil b/Objective-J/CommonJS/bin/cplutil index 22826b724..4a745c1f4 100755 --- a/Objective-J/CommonJS/bin/cplutil +++ b/Objective-J/CommonJS/bin/cplutil @@ -68,7 +68,7 @@ exports.main = function(args) } else { - var encodedString = CFPropertyList.stringFromPropertyList(plistObject); + var encodedString = CFPropertyList.stringFromPropertyList(plistObject, options.format); // outextension? if (options.outPath === "-") From 632251b16c34fb075cc818f10518b897d9f35fa1 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Sat, 6 Feb 2010 18:31:20 -0800 Subject: [PATCH 7/7] Infinite recursion error. --- Foundation/CPURLConnection.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index 584620477..ed9502382 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -282,7 +282,7 @@ var CPURLConnectionDelegate = nil; { CPLog.warn("[CPURLConnecton sendSynchronousRequest:returningResponse:error:] is deprecated, using [CPURLConnecton sendSynchronousRequest:returningResponse:] instead."); - return [self sendSynchronousRequest:aRequest returningResponse:aURLResponse error:NULL]; + return [self sendSynchronousRequest:aRequest returningResponse:aURLResponse]; } - (HTTPRequest)_XMLHTTPRequest