Refactor drawPathComponentCellWithFrame:...

This commit is contained in:
Gregory John Casamento 2020-05-07 05:29:47 -04:00
parent 9c84decf5f
commit e0357ebffe

View file

@ -953,43 +953,49 @@
// NSPathComponentCell
- (void) drawPathComponentCellWithFrame: (NSRect)f
- (void) drawPathComponentCellWithFrame: (NSRect)frame
inView: (NSPathControl *)pc
withCell: (NSPathComponentCell *)cell
isLastComponent: (BOOL)lc
isLastComponent: (BOOL)last
{
NSImage *i = [cell image];
NSURL *u = [cell URL];
NSString *string = [[u path] lastPathComponent];
NSRect textFrame = f;
NSRect imgFrame = f;
NSRect arrowFrame = f;
NSImage *img = [cell image];
NSURL *url = [cell URL];
NSString *string = [[url path] lastPathComponent];
NSRect textFrame = frame;
NSRect imgFrame = frame;
NSRect arrowFrame = frame;
NSImage *arrowImage = [NSImage imageNamed: @"NSMenuArrow"];
NSPathStyle s = [pc pathStyle];
if (s == NSPathStyleStandard || s == NSPathStyleNavigationBar)
NSPathStyle style= [pc pathStyle];
NSRect newFrame = frame;
if (style == NSPathStylePopUp)
{
/*
if (s == NSPathStyleNavigationBar)
{
[[NSColor lightGrayColor] set];
NSRectFill(f);
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(f, 1);
}
*/
// Modify positions...
textFrame.origin.x += 25.0; // the width of the image plus a few pixels.
textFrame.origin.y += 3.0; // center with the image...
imgFrame.size.width = 20.0;
imgFrame.size.height = 20.0;
arrowFrame.origin.x += f.size.width - 20.0;
arrowFrame.size.width = 8.0;
arrowFrame.size.height = 8.0;
arrowFrame.origin.y += 5.0;
newFrame = [pc frame];
// Reset coodinates.
newFrame.origin.x = 0.0;
newFrame.origin.y = 0.0;
// Use control frame...
textFrame = newFrame;
imgFrame = newFrame;
arrowFrame = newFrame;
}
// Modify positions...
imgFrame.size.width = 17.0;
imgFrame.size.height = 17.0;
textFrame.origin.x += imgFrame.size.width + 5.0; // the width of the image plus a few pixels.
textFrame.origin.y += 5.0; // center with the image...
arrowFrame.origin.x += newFrame.size.width - 17.0;
arrowFrame.size.width = 8.0;
arrowFrame.size.height = 8.0;
arrowFrame.origin.y += 5.0;
if (style== NSPathStyleStandard || style== NSPathStyleNavigationBar)
{
// Draw the image...
[i drawInRect: imgFrame];
[img drawInRect: imgFrame];
// Draw the text...
[[NSColor textColor] set];
@ -997,42 +1003,23 @@
withAttributes: nil];
// Draw the arrow...
if (lc == NO)
if (last == NO)
{
[arrowImage drawInRect: arrowFrame];
}
}
else // can only be PopUp...
else if (style == NSPathStylePopUp)
{
if (lc == YES)
if (last == YES)
{
NSRect newFrame = [pc frame];
arrowImage = [NSImage imageNamed: @"common_ArrowDown"];
// Reset coodinates.
newFrame.origin.x = 0.0;
newFrame.origin.y = 0.0;
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(newFrame, .5);
// Use control frame...
textFrame = newFrame;
imgFrame = newFrame;
arrowFrame = newFrame;
// Modify positions...
textFrame.origin.x += 25.0; // the width of the image plus a few pixels.
textFrame.origin.y += 3.0; // center with the image...
imgFrame.size.width = 20.0;
imgFrame.size.height = 20.0;
arrowFrame.origin.x += newFrame.size.width - 20.0;
arrowFrame.size.width = 8.0;
arrowFrame.size.height = 8.0;
arrowFrame.origin.y += 5.0;
// Draw border...
[[NSColor controlShadowColor] set];
NSFrameRectWithWidth(newFrame, 1.0);
// Draw the image...
[i drawInRect: imgFrame];
[img drawInRect: imgFrame];
// Draw the text...
[[NSColor textColor] set];