-
-
Save darwin/2d17b0a74125de9f4c847e5bacfbf941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
long goodWidthForColumn(TColumnViewPtr self, NSInteger column) { | |
NSBrowserTableViewPtrOrNil browserTable = [self browserTableViewAtIndex:column]; | |
if (!browserTable) { | |
AUTO_LOG(@"no browser table => bail out"); | |
return 0; | |
} | |
auto numberOfRows = [browserTable numberOfRows]; | |
if (numberOfRows == 0) { | |
AUTO_LOG(@"column=%ld numberOfRows=%ld => bail out", column, numberOfRows); | |
return 0; | |
} | |
TColumnViewControllerPtr controller = [self controller]; | |
if (!controller) { | |
AUTO_LOG(@"no controller => bail out"); | |
return 0; | |
} | |
auto width = [controller sizeToFitWidthOfColumn:column forRange:NSMakeRange(0, numberOfRows)]; | |
AUTO_LOG(@"column=%ld numberOfRows=%ld width=%f", column, numberOfRows, width); | |
// ad-hoc 20px addition to really make sure nothing remains shortened, sizeToFitWidthOfColumn probably does not reflect scrollbars | |
// this can be tricky because width measurement is affected by System Preferences -> General -> scrollbar settings and also by Finder's state, | |
// for example if you are in a drobox folder, those file badge icons take up some extra space, sizeToFitWidthOfColumn does not account for that | |
// and Finder (10.11) itself behaves inconsistently (when double-clicking on resizing gripper) | |
// see support email from Colin Callahan <***redacted***@***.com> | |
int correction = intAutoWidthCorrection(); | |
if (!correction) { | |
correction = 20; // default correction | |
} | |
width += correction; | |
width = [PLUGIN $clampWidth:width]; | |
return width; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment