Revision: 26025
          http://sourceforge.net/p/bibdesk/svn/26025
Author:   hofman
Date:     2021-05-21 15:58:17 +0000 (Fri, 21 May 2021)
Log Message:
-----------
Move option layout code directly to windowControllerDidLoadNib

Modified Paths:
--------------
    trunk/bibdesk/BDSKTemplateDocument.m

Modified: trunk/bibdesk/BDSKTemplateDocument.m
===================================================================
--- trunk/bibdesk/BDSKTemplateDocument.m        2021-05-21 15:08:50 UTC (rev 
26024)
+++ trunk/bibdesk/BDSKTemplateDocument.m        2021-05-21 15:58:17 UTC (rev 
26025)
@@ -222,6 +222,14 @@
     return @"TemplateDocument";
 }
 
+static inline void makeEqualWidths(NSArray *views) {
+    CGFloat width = 0.0;
+    for (NSView *view in views)
+        width = fmax(width, [view intrinsicContentSize].width);
+    for (NSView *view in views)
+        [view addConstraint:[NSLayoutConstraint constraintWithItem:view 
attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil 
attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]];
+}
+
 - (void)windowControllerDidLoadNib:(NSWindowController *)aController {
     [super windowControllerDidLoadNib:aController];
     
@@ -237,7 +245,14 @@
     [specialTokenField setObjectValue:specialTokens];
     [itemTemplateTokenField setTokenizingCharacterSet:[NSCharacterSet 
characterSetWithCharactersInString:@""]];
     
-    [self layoutControls];
+    makeEqualWidths(firstLabels);
+    makeEqualWidths(secondLabels);
+    makeEqualWidths(firstControls);
+    makeEqualWidths(secondControls);
+    CGFloat width = [fieldOptionsView fittingSize].width;
+    [appendingOptionsView addConstraint:[NSLayoutConstraint 
constraintWithItem:appendingOptionsView attribute:NSLayoutAttributeWidth 
relatedBy:NSLayoutRelationEqual toItem:nil 
attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]];
+    [textOptionsView addConstraint:[NSLayoutConstraint 
constraintWithItem:textOptionsView attribute:NSLayoutAttributeWidth 
relatedBy:NSLayoutRelationEqual toItem:nil 
attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]];
+    [tableViewSplitView addConstraint:[NSLayoutConstraint 
constraintWithItem:tableViewSplitView attribute:NSLayoutAttributeWidth 
relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil 
attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width + 8.0]];
     
     [self updateTextViews];
     
@@ -252,7 +267,7 @@
 #pragma clang diagnostic pop
     
     NSTableColumn *tableColumn = [tableView 
tableColumnWithIdentifier:@"pubType"];
-    CGFloat width = NSWidth([[[tableView enclosingScrollView] contentView] 
visibleRect]) - 2.0 * [tableView intercellSpacing].width - [[tableView 
tableColumnWithIdentifier:@"included"] width];
+    width = NSWidth([[[tableView enclosingScrollView] contentView] 
visibleRect]) - 2.0 * [tableView intercellSpacing].width - [[tableView 
tableColumnWithIdentifier:@"included"] width];
     [tableColumn setWidth:fmax(width, [tableColumn minWidth])];
     
        [fieldField setFormatter:[[[BDSKFieldNameFormatter alloc] init] 
autorelease]];
@@ -854,32 +869,6 @@
     }
 }
 
-static inline CGFloat largestWidth(NSArray *views) {
-    CGFloat width = 0.0;
-    for (NSView *view in views)
-        width = fmax(width, [view intrinsicContentSize].width);
-    return width;
-}
-
-static inline void addWidthConstraints(NSArray *views, CGFloat width) {
-    for (NSView *view in views)
-        [view addConstraint:[NSLayoutConstraint constraintWithItem:view 
attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil 
attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width]];
-}
-
-- (void)layoutControls {
-    CGFloat width = largestWidth(firstLabels);
-    addWidthConstraints(firstLabels, width);
-    width = largestWidth(secondLabels);
-    addWidthConstraints(secondLabels, width);
-    width = largestWidth(firstControls);
-    addWidthConstraints(firstControls, width);
-    width = largestWidth(secondControls);
-    addWidthConstraints(secondControls, width);
-    width = [fieldOptionsView fittingSize].width;
-    addWidthConstraints([NSArray arrayWithObjects:appendingOptionsView, 
textOptionsView, nil], width);
-    [tableViewSplitView addConstraint:[NSLayoutConstraint 
constraintWithItem:tableViewSplitView attribute:NSLayoutAttributeWidth 
relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil 
attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:width + 8.0]];
-}
-
 #pragma mark KVO and Undo
 
 - (void)startObservingTypeTemplate:(BDSKTypeTemplate *)template {

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



_______________________________________________
Bibdesk-commit mailing list
Bibdesk-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to