Revision: 14649
          http://sourceforge.net/p/skim-app/code/14649
Author:   hofman
Date:     2024-11-06 15:32:06 +0000 (Wed, 06 Nov 2024)
Log Message:
-----------
Clip first page number at smaller maximum width, as some documents use the 
title as the first page label

Modified Paths:
--------------
    trunk/SKMainWindowController.m

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2024-11-06 10:19:24 UTC (rev 14648)
+++ trunk/SKMainWindowController.m      2024-11-06 15:32:06 UTC (rev 14649)
@@ -115,8 +115,9 @@
 #define HUGE_SIZE  256.0
 #define FUDGE_SIZE 0.1
 
-#define MAX_PAGE_COLUMN_WIDTH 60.0
-#define MAX_MIN_COLUMN_WIDTH 100.0
+#define MAX_PAGE_COLUMN_WIDTH   80.0
+#define MAX_PAGE_COLUMN_WIDTH_1 50.0
+#define MAX_MIN_COLUMN_WIDTH    100.0
 
 #define SEARCHRESULTS_KEY           @"searchResults"
 #define GROUPEDSEARCHRESULTS_KEY    @"groupedSearchResults"
@@ -705,22 +706,32 @@
     if ([pageLabels count] == 0)
         return;
     
-    NSTableView *tv = [tvs firstObject];
-    NSTableColumn *tableColumn = [tv tableColumnWithIdentifier:PAGE_COLUMNID];
+    NSTableColumn *tableColumn = [[tvs firstObject] 
tableColumnWithIdentifier:PAGE_COLUMNID];
     id cell = [tableColumn dataCell];
     CGFloat labelWidth = 0.0;
     NSString *label = nil;
+    NSString *firstLabel = nil;
+    CGFloat firstLabelWidth = 0.0;
+    CGFloat maxWidth = MAX_PAGE_COLUMN_WIDTH;
     
     for (NSString *aLabel in pageLabels) {
         [cell setStringValue:aLabel];
         CGFloat aLabelWidth = [cell cellSize].width;
-        if (aLabelWidth > labelWidth) {
+        if (firstLabel == nil) {
+            firstLabel = aLabel;
+            firstLabelWidth = aLabelWidth;
+        } else if (aLabelWidth > labelWidth) {
             labelWidth = aLabelWidth;
             label = aLabel;
         }
     }
     
-    for (tv in tvs) {
+    if (firstLabelWidth > labelWidth && labelWidth < MAX_PAGE_COLUMN_WIDTH_1) {
+        label = firstLabel;
+        maxWidth = MAX_PAGE_COLUMN_WIDTH_1;
+    }
+    
+    for (NSTableView *tv in tvs) {
         tableColumn = [tv tableColumnWithIdentifier:PAGE_COLUMNID];
         cell = [tableColumn dataCell];
         [cell setStringValue:label];
@@ -727,7 +738,7 @@
         labelWidth = [cell cellSize].width;
         if ([tv headerView])
             labelWidth = fmax(labelWidth, [[tableColumn headerCell] 
cellSize].width);
-        labelWidth = fmin(ceil(labelWidth), MAX_PAGE_COLUMN_WIDTH);
+        labelWidth = fmin(ceil(labelWidth), maxWidth);
         [tableColumn setMinWidth:labelWidth];
         [tableColumn setMaxWidth:labelWidth];
         [tableColumn setWidth:labelWidth];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to