Revision: 28833
http://sourceforge.net/p/bibdesk/svn/28833
Author: hofman
Date: 2024-03-11 10:24:09 +0000 (Mon, 11 Mar 2024)
Log Message:
-----------
remember some constraints as ivars
Modified Paths:
--------------
trunk/bibdesk/BDSKStatusBar.h
trunk/bibdesk/BDSKStatusBar.m
Modified: trunk/bibdesk/BDSKStatusBar.h
===================================================================
--- trunk/bibdesk/BDSKStatusBar.h 2024-03-09 17:59:16 UTC (rev 28832)
+++ trunk/bibdesk/BDSKStatusBar.h 2024-03-11 10:24:09 UTC (rev 28833)
@@ -59,6 +59,9 @@
NSImageCell *iconCell;
NSProgressIndicator *progressIndicator;
NSMutableArray *icons;
+ NSLayoutConstraint *leadingConstraint;
+ NSLayoutConstraint *trailingConstraint;
+ NSLayoutConstraint *progressTrailingConstraint;
__weak id<BDSKStatusBarDelegate> delegate;
CGFloat leftMargin;
CGFloat rightMargin;
Modified: trunk/bibdesk/BDSKStatusBar.m
===================================================================
--- trunk/bibdesk/BDSKStatusBar.m 2024-03-09 17:59:16 UTC (rev 28832)
+++ trunk/bibdesk/BDSKStatusBar.m 2024-03-11 10:24:09 UTC (rev 28833)
@@ -82,12 +82,11 @@
[textField setTranslatesAutoresizingMaskIntoConstraints:NO];
[textField
setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow
forOrientation:NSLayoutConstraintOrientationHorizontal];
[self addSubview:textField];
- NSArray *constraints = @[
- [[textField leadingAnchor] constraintEqualToAnchor:[self
leadingAnchor] constant:LEFT_MARGIN + TEXT_INSET],
- [[self trailingAnchor] constraintEqualToAnchor:[textField
trailingAnchor] constant:RIGHT_MARGIN + TEXT_INSET],
- [[textField centerYAnchor] constraintEqualToAnchor:[self
centerYAnchor]]];
- [[constraints objectAtIndex:1] setPriority:499.0];
- [NSLayoutConstraint activateConstraints:constraints];
+ leadingConstraint = [[textField leadingAnchor]
constraintEqualToAnchor:[self leadingAnchor] constant:LEFT_MARGIN + TEXT_INSET];
+ trailingConstraint = [[self trailingAnchor]
constraintEqualToAnchor:[textField trailingAnchor] constant:RIGHT_MARGIN +
TEXT_INSET];
+ [trailingConstraint setPriority:499.0];
+ NSLayoutConstraint *centerYConstraint = [[textField centerYAnchor]
constraintEqualToAnchor:[self centerYAnchor]];
+ [NSLayoutConstraint activateConstraints:@[leadingConstraint,
trailingConstraint, centerYConstraint]];
iconCell = [[NSImageCell alloc] init];
@@ -304,15 +303,15 @@
- (void)setLeftMargin:(CGFloat)margin {
leftMargin = margin;
- [[self constraintWithFirstItem:textField
firstAttribute:NSLayoutAttributeLeading] setConstant:[self fullLeftMargin]];
+ [leadingConstraint setConstant:[self fullLeftMargin]];
[self setNeedsDisplay:YES];
}
- (void)setRightMargin:(CGFloat)margin {
rightMargin = margin;
- [[self constraintWithSecondItem:textField
secondAttribute:NSLayoutAttributeTrailing] setConstant:[self fullRightMargin]];
+ [trailingConstraint setConstant:[self fullRightMargin]];
if (progressIndicator)
- [[self constraintWithSecondItem:progressIndicator
secondAttribute:NSLayoutAttributeTrailing] setConstant:rightMargin +
[progressIndicator alignmentRectInsets].right];
+ [progressTrailingConstraint setConstant:rightMargin +
[progressIndicator alignmentRectInsets].right];
}
#pragma mark Icons
@@ -332,7 +331,7 @@
[icons addObject:[[BDSKStatusBarIcon alloc]
initWithIdentifier:identifier image:icon toolTip:toolTip parent:self]];
[self rebuildToolTips];
[self setNeedsDisplay:YES];
- [[self constraintWithSecondItem:textField
secondAttribute:NSLayoutAttributeTrailing] setConstant:[self fullRightMargin]];
+ [trailingConstraint setConstant:[self fullRightMargin]];
}
- (void)removeIconWithIdentifier:(NSString *)identifier {
@@ -342,7 +341,7 @@
[icons removeObjectAtIndex:i];
[self rebuildToolTips];
[self setNeedsDisplay:YES];
- [[self constraintWithSecondItem:textField
secondAttribute:NSLayoutAttributeTrailing] setConstant:[self fullRightMargin]];
+ [trailingConstraint setConstant:[self fullRightMargin]];
break;
}
}
@@ -404,8 +403,9 @@
[progressIndicator stopAnimation:nil];
[progressIndicator removeFromSuperview];
progressIndicator = nil;
+ progressTrailingConstraint = nil;
- [[self constraintWithSecondItem:textField
secondAttribute:NSLayoutAttributeTrailing] setConstant:[self fullRightMargin]];
+ [trailingConstraint setConstant:[self fullRightMargin]];
} else {
if ((NSInteger)[progressIndicator style] == style)
return;
@@ -422,11 +422,11 @@
[progressIndicator setIndeterminate:style ==
BDSKProgressIndicatorStyleIndeterminate];
[self addSubview:progressIndicator];
- [NSLayoutConstraint activateConstraints:@[
- [[self trailingAnchor] constraintEqualToAnchor:[progressIndicator
trailingAnchor] constant:rightMargin + [progressIndicator
alignmentRectInsets].right],
- [[progressIndicator centerYAnchor] constraintEqualToAnchor:[self
centerYAnchor]]]];
+ progressTrailingConstraint = [[self trailingAnchor]
constraintEqualToAnchor:[progressIndicator trailingAnchor] constant:rightMargin
+ [progressIndicator alignmentRectInsets].right];
+ NSLayoutConstraint *centerYConstraint = [[progressIndicator
centerYAnchor] constraintEqualToAnchor:[self centerYAnchor]];
+ [NSLayoutConstraint activateConstraints:@[progressTrailingConstraint,
centerYConstraint]];
- [[self constraintWithSecondItem:textField
secondAttribute:NSLayoutAttributeTrailing] setConstant:[self fullRightMargin]];
+ [trailingConstraint setConstant:[self fullRightMargin]];
[progressIndicator startAnimation:nil];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit