Skip to content
This repository
Browse code

fixed a drag and drop issue related to focusing another window; added…

… layoutSubviews method to PXListViewCell; added reloadRowAtIndex method; removed PXLog log messages
  • Loading branch information...
commit 91307a86dd4c67bc039cc042b39de80e0944a459 1 parent c0c719a
Jiva DeVoe authored April 27, 2011 alexrozanski committed May 02, 2011
1  Classes/PXListView+Private.h
@@ -38,5 +38,6 @@ typedef NSInteger PXIsDragStartResult;
38 38
 - (void)enqueueCell:(PXListViewCell*)cell;
39 39
 
40 40
 - (void)contentViewBoundsDidChange:(NSNotification*)notification;
  41
+-(void)layoutCellsForResizeEvent;
41 42
 
42 43
 @end
38  Classes/PXListView+UserInteraction.m
@@ -218,8 +218,8 @@ - (void)handleMouseDown:(NSEvent*)theEvent inCell:(PXListViewCell*)theCell // Ce
218 218
 - (void)handleMouseDownOutsideCells: (NSEvent*)theEvent
219 219
 {
220 220
 #pragma unused(theEvent)
221  
-	[[self window] makeFirstResponder: self];
222  
-    
  221
+    //[[self window] makeFirstResponder: self];
  222
+    //
223 223
 	if( _allowsEmptySelection )
224 224
 		[self deselectRows];
225 225
 	else if( _numberOfRows > 1 )
@@ -336,7 +336,6 @@ -(void)	setShowsDropHighlight: (BOOL)inState
336 336
 
337 337
 -(NSUInteger)	indexOfRowAtPoint: (NSPoint)pos returningProposedDropHighlight: (PXListViewDropHighlight*)outDropHighlight
338 338
 {
339  
-	PXLog( @"====================" );
340 339
 	*outDropHighlight = PXListViewDropOn;
341 340
 	
342 341
 	if( _numberOfRows > 0 )
@@ -346,14 +345,12 @@ -(NSUInteger)	indexOfRowAtPoint: (NSPoint)pos returningProposedDropHighlight: (P
346 345
 		{
347 346
 			if( _cellYOffsets[x] > pos.y )
348 347
 			{
349  
-				PXLog( @"cellYOffset[%ld] = %f > %f", x, _cellYOffsets[x], pos.y );
350 348
 				break;
351 349
 			}
352 350
 			
353 351
 			idx = x;
354 352
 		}
355 353
 		
356  
-		PXLog( @"idx = %ld", idx );
357 354
 		
358 355
 		CGFloat		cellHeight = 0,
359 356
         cellOffset = 0,
@@ -363,8 +360,6 @@ -(NSUInteger)	indexOfRowAtPoint: (NSPoint)pos returningProposedDropHighlight: (P
363 360
 			cellOffset = _cellYOffsets[idx];
364 361
 			nextCellOffset = _cellYOffsets[idx+1];
365 362
 			cellHeight = nextCellOffset -cellOffset;
366  
-			if( cellHeight < 0 )
367  
-				PXLog( @"Urk. (1)" );
368 363
 		}
369 364
 		else if( idx < _numberOfRows && _numberOfRows > 0 )	// drag is somewhere close to or beyond end of list.
370 365
 		{
@@ -372,8 +367,6 @@ -(NSUInteger)	indexOfRowAtPoint: (NSPoint)pos returningProposedDropHighlight: (P
372 367
 			cellHeight = [theCell frame].size.height;
373 368
 			cellOffset = [theCell frame].origin.y;
374 369
 			nextCellOffset = cellOffset +cellHeight;
375  
-			if( cellHeight < 0 )
376  
-				PXLog( @"Urk. (2)" );
377 370
 		}
378 371
 		else if( idx >= _numberOfRows && _numberOfRows > 0 )	// drag is somewhere close to or beyond end of list.
379 372
 		{
@@ -381,24 +374,17 @@ -(NSUInteger)	indexOfRowAtPoint: (NSPoint)pos returningProposedDropHighlight: (P
381 374
 			cellOffset = [[self documentView] frame].size.height;
382 375
 			nextCellOffset = cellOffset;
383 376
 			idx = NSUIntegerMax;
384  
-			if( cellHeight < 0 )
385  
-				PXLog( @"Urk. (3)" );
386 377
 		}
387 378
         
388  
-		PXLog( @"cellHeight = %f", cellHeight );
389 379
 		if( pos.y < (cellOffset +(cellHeight / 6.0)) )
390 380
 		{
391 381
 			*outDropHighlight = PXListViewDropAbove;
392  
-			PXLog( @"*** ABOVE %ld", idx );
393 382
 		}
394 383
 		else if( pos.y > (nextCellOffset -(cellHeight / 6.0)) )
395 384
 		{
396 385
 			idx++;
397 386
 			*outDropHighlight = PXListViewDropAbove;
398  
-			PXLog( @"*** ABOVE %ld (below %d)", idx, idx -1 );
399 387
 		}
400  
-		else
401  
-			PXLog( @"*** ON %ld", idx );
402 388
 		
403 389
 		if( idx > _numberOfRows )
404 390
 			idx = NSUIntegerMax;
@@ -407,7 +393,6 @@ -(NSUInteger)	indexOfRowAtPoint: (NSPoint)pos returningProposedDropHighlight: (P
407 393
 	}
408 394
 	else
409 395
 	{
410  
-		PXLog( @"*** ON %d", NSUIntegerMax );
411 396
 		return NSUIntegerMax;
412 397
 	}
413 398
 }
@@ -433,8 +418,6 @@ -(PXListViewCell*)	cellForDropHighlight: (PXListViewDropHighlight*)dhl row: (NSU
433 418
 
434 419
 - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
435 420
 {
436  
-	PXLog( @"draggingEntered" );
437  
-	
438 421
 	NSDragOperation	theOperation = NSDragOperationNone;
439 422
 	
440 423
 	NSUInteger				oldDropRow = _dropRow;
@@ -443,14 +426,11 @@ - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
443 426
 	if( [_delegate respondsToSelector: @selector(listView:validateDrop:proposedRow:proposedDropHighlight:)] )
444 427
 	{
445 428
 		NSPoint		dragMouse = [[self documentView] convertPoint: [sender draggingLocation] fromView: nil];
446  
-		PXLog( @"dragMouse = %@", NSStringFromPoint(dragMouse) );
447 429
 		_dropRow = [self indexOfRowAtPoint: dragMouse returningProposedDropHighlight: &_dropHighlight];
448 430
 		
449 431
 		theOperation = [_delegate listView: self validateDrop: sender proposedRow: _dropRow
450 432
                      proposedDropHighlight: _dropHighlight];
451 433
 	}
452  
-    
453  
-	PXLog( @"op = %lu, row = %ld, hl = %lu", theOperation, _dropRow, _dropHighlight );
454 434
 	
455 435
 	if( theOperation != NSDragOperationNone )
456 436
 	{
@@ -463,14 +443,9 @@ - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
463 443
 			[oldCell setDropHighlight: PXListViewDropNowhere];
464 444
 			[newCell setDropHighlight: _dropHighlight];
465 445
 			PXListViewDropHighlight	dropHL = ((_dropRow == _numberOfRows) ? PXListViewDropAbove : PXListViewDropOn);
466  
-			PXLog( @"TOTAL DROP %s", dropHL == PXListViewDropOn ? "on" : "above" );
467 446
 			[[self documentView] setDropHighlight: dropHL];
468 447
 		}
469  
-		else
470  
-			PXLog(@"TOTAL DROP unchanged");
471 448
 	}
472  
-	else
473  
-		PXLog( @"TOTAL DROP NOWHERE" );
474 449
 	
475 450
 	return theOperation;
476 451
 }
@@ -478,8 +453,6 @@ - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
478 453
 
479 454
 - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender /* if the destination responded to draggingEntered: but not to draggingUpdated: the return value from draggingEntered: is used */
480 455
 {
481  
-	PXLog( @"draggingUpdated" );
482  
-	
483 456
 	NSDragOperation	theOperation = NSDragOperationNone;
484 457
 	
485 458
 	NSUInteger				oldDropRow = _dropRow;
@@ -488,15 +461,12 @@ - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender /* if the destina
488 461
 	if( [_delegate respondsToSelector: @selector(listView:validateDrop:proposedRow:proposedDropHighlight:)] )
489 462
 	{
490 463
 		NSPoint		dragMouse = [[self documentView] convertPoint: [sender draggingLocation] fromView: nil];
491  
-		PXLog( @"dragMouse = %@", NSStringFromPoint(dragMouse) );
492 464
 		_dropRow = [self indexOfRowAtPoint: dragMouse returningProposedDropHighlight: &_dropHighlight];
493 465
 		
494 466
 		theOperation = [_delegate listView: self validateDrop: sender proposedRow: _dropRow
495 467
                      proposedDropHighlight: _dropHighlight];
496 468
 	}
497 469
 	
498  
-	NSLog( @"op = %lu, row = %ld, hl = %lu", theOperation, _dropRow, _dropHighlight );
499  
-	
500 470
 	if( theOperation != NSDragOperationNone )
501 471
 	{
502 472
 		if( oldDropRow != _dropRow
@@ -508,15 +478,11 @@ - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender /* if the destina
508 478
 			[oldCell setDropHighlight: PXListViewDropNowhere];
509 479
 			[newCell setDropHighlight: _dropHighlight];
510 480
 			PXListViewDropHighlight	dropHL = ((_dropRow == _numberOfRows) ? PXListViewDropAbove : PXListViewDropOn);
511  
-			NSLog( @"TOTAL DROP %s", dropHL == PXListViewDropOn ? "on" : "above" );
512 481
 			[[self documentView] setDropHighlight: dropHL];
513 482
 		}
514  
-		else
515  
-			PXLog(@"TOTAL DROP unchanged");
516 483
 	}
517 484
 	else
518 485
 	{
519  
-		PXLog( @"TOTAL DROP NOWHERE" );
520 486
 		[self setShowsDropHighlight: NO];
521 487
 	}
522 488
 	
3  Classes/PXListView.h
@@ -60,10 +60,13 @@
60 60
 @property (nonatomic, assign) BOOL usesLiveResize;
61 61
 
62 62
 - (void)reloadData;
  63
+-(void)reloadRowAtIndex:(NSInteger)inIndex;
63 64
 
64 65
 - (PXListViewCell*)dequeueCellWithReusableIdentifier:(NSString*)identifier;
65 66
 
66 67
 - (NSArray*)visibleCells;
  68
+-(PXListViewCell *)cellForRowAtIndex:(NSUInteger)inIndex;
  69
+
67 70
 - (NSRange)visibleRange;
68 71
 - (NSRect)rectOfRow:(NSUInteger)row;
69 72
 - (void)deselectRows;
15  Classes/PXListView.m
@@ -106,6 +106,13 @@ - (void)setDelegate:(id<PXListViewDelegate>)delegate
106 106
     }
107 107
 }
108 108
 
  109
+-(void)reloadRowAtIndex:(NSInteger)inIndex;
  110
+{
  111
+    [self cacheCellLayout];
  112
+    [self layoutCells];
  113
+    //[self layoutCellsForResizeEvent];
  114
+}
  115
+
109 116
 - (void)reloadData
110 117
 {
111 118
 	id <PXListViewDelegate> delegate = [self delegate];
@@ -235,6 +242,11 @@ - (PXListViewCell*)visibleCellForRow:(NSUInteger)row
235 242
 	return outCell;
236 243
 }
237 244
 
  245
+-(PXListViewCell *)cellForRowAtIndex:(NSUInteger)inIndex
  246
+{
  247
+    return [self visibleCellForRow:inIndex];
  248
+}
  249
+
238 250
 - (NSArray*)visibleCellsForRowIndexes:(NSIndexSet*)rows
239 251
 {
240 252
 	NSMutableArray *theCells = [NSMutableArray array];
@@ -494,6 +506,7 @@ - (void)layoutCells
494 506
 	{
495 507
 		NSInteger row = [cell row];
496 508
 		[cell setFrame:[self rectOfRow:row]];
  509
+        [cell layoutSubviews];
497 510
 	}
498 511
 	
499 512
 	NSRect bounds = [self bounds];
@@ -598,6 +611,7 @@ - (void)viewWillStartLiveResize
598 611
     if([self usesLiveResize])
599 612
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowSizing:) name:NSSplitViewDidResizeSubviewsNotification object:self.superview];
600 613
 }
  614
+
601 615
 -(void)layoutCellsForResizeEvent 
602 616
 {
603 617
     //Change the layout of the cells
@@ -627,6 +641,7 @@ -(void)layoutCellsForResizeEvent
627 641
     
628 642
     _currentRange = [self visibleRange];
629 643
 }
  644
+
630 645
 -(void)viewDidEndLiveResize
631 646
 {
632 647
     [super viewDidEndLiveResize];
2  Classes/PXListViewCell.h
@@ -35,4 +35,6 @@
35 35
 - (id)initWithReusableIdentifier:(NSString*)identifier;
36 36
 - (void)prepareForReuse;
37 37
 
  38
+-(void)layoutSubviews;
  39
+
38 40
 @end
8  Classes/PXListViewCell.m
@@ -144,6 +144,14 @@ - (void)prepareForReuse
144 144
 	_dropHighlight = PXListViewDropNowhere;
145 145
 }
146 146
 
  147
+
  148
+#pragma mark layout
  149
+
  150
+-(void)layoutSubviews;
  151
+{
  152
+    
  153
+}
  154
+
147 155
 #pragma mark -
148 156
 #pragma mark Accessibility
149 157
 

0 notes on commit 91307a8

Please sign in to comment.
Something went wrong with that request. Please try again.