Skip to content

Commit

Permalink
Make this build warning-free with latest SDK.
Browse files Browse the repository at this point in the history
  • Loading branch information
uliwitness committed Aug 28, 2016
1 parent d270403 commit eeb816e
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions UKFinderIconCell/UKFinderIconCell.m
Expand Up @@ -320,6 +320,8 @@ -(float) textSizeForBox: (NSRect)box

case NSImageLeft:
case NSImageRight:
case NSImageLeading:
case NSImageTrailing:
sz = truncf(box.size.height / 8);
break;

Expand Down Expand Up @@ -396,6 +398,8 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView
case NSImageOnly:
case NSImageLeft:
case NSImageRight:
case NSImageLeading:
case NSImageTrailing:
case NSImageOverlaps:
break;
}
Expand Down Expand Up @@ -429,7 +433,7 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView

imgSize = [NSImage scaledSize: [image size] toFitSize: box.size];

if( imagePos == NSImageLeft || imagePos == NSImageRight )
if( imagePos == NSImageLeft || imagePos == NSImageRight || imagePos == NSImageLeading || imagePos == NSImageTrailing )
titleHReduce = imgSize.width +(UKFIC_SELBOX_HORZMARGIN +UKFIC_SELBOX_OUTLINE_WIDTH) *2;

// Truncate string if needed:
Expand All @@ -439,6 +443,17 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView
// Calculate rectangle for text:
txSize = [displayTitle sizeWithAttributes: attrs];

NSCellImagePosition actualPos = imagePos;
NSUserInterfaceLayoutDirection layoutDir = [[NSApplication sharedApplication] userInterfaceLayoutDirection];
if( imagePos == NSImageLeading && layoutDir == NSUserInterfaceLayoutDirectionLeftToRight )
actualPos = NSImageLeft;
else if( imagePos == NSImageLeading && layoutDir == NSUserInterfaceLayoutDirectionRightToLeft )
actualPos = NSImageRight;
else if( imagePos == NSImageTrailing && layoutDir == NSUserInterfaceLayoutDirectionLeftToRight )
actualPos = NSImageRight;
else if( imagePos == NSImageTrailing && layoutDir == NSUserInterfaceLayoutDirectionRightToLeft )
actualPos = NSImageLeft;

if( imagePos == NSImageAbove // Finder icon view (big, title below image).
|| imagePos == NSImageBelow ) // Title *above* image.
{
Expand All @@ -452,7 +467,9 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView
-UKFIC_TEXT_VERTMARGIN ); // Give us some room around our text.
}
else if( imagePos == NSImageLeft
|| imagePos == NSImageRight )
|| imagePos == NSImageRight
|| imagePos == NSImageLeading
|| imagePos == NSImageTrailing )
{
textBox.size = txSize;
textBox.origin.y += truncf((box.size.height -txSize.height) / 2); // Center our text vertically in cell.
Expand Down Expand Up @@ -483,6 +500,14 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView
imgBox.size.width -= textBgBox.size.width;
break;

case NSImageLeading:
imgBox.size.width -= textBgBox.size.width;
break;

case NSImageTrailing:
imgBox.size.width -= textBgBox.size.width;
break;

case NSNoImage:
case NSImageOnly:
case NSImageOverlaps:
Expand All @@ -491,7 +516,9 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView
}

if( imagePos == NSImageRight
|| imagePos == NSImageLeft )
|| imagePos == NSImageLeft
|| imagePos == NSImageLeading
|| imagePos == NSImageTrailing )
imgBox = NSInsetRect( imgBox, UKFIC_SELBOX_VERTMARGIN +UKFIC_SELBOX_OUTLINE_WIDTH,
UKFIC_SELBOX_HORZMARGIN +UKFIC_SELBOX_OUTLINE_WIDTH );
else
Expand All @@ -509,12 +536,12 @@ -(void) drawInteriorWithFrame:(NSRect)box inView:(NSView *)aView
imgBox.origin.x += truncf(diff/2); // Center narrower box in cell.
}

if( imagePos == NSImageLeft )
if( actualPos == NSImageLeft )
{
textBox.origin.x += imgBox.size.width +truncf(textBox.size.height /2) +(UKFIC_TEXT_VERTMARGIN *3);
textBgBox.origin.x += imgBox.size.width +truncf(textBox.size.height /2) +(UKFIC_TEXT_VERTMARGIN *3);
}
else if( imagePos == NSImageRight )
else if( actualPos == NSImageRight )
{
imgBox.origin.x = box.origin.x +box.size.width -imgBox.size.width -UKFIC_SELBOX_HORZMARGIN;
textBox.origin.x -= imgBox.size.width +(UKFIC_TEXT_VERTMARGIN *3);
Expand Down Expand Up @@ -974,4 +1001,4 @@ -(NSFont*) fontAtBestSize
}

return currString;
}
}

0 comments on commit eeb816e

Please sign in to comment.