Revision: 30086
http://sourceforge.net/p/bibdesk/svn/30086
Author: hofman
Date: 2026-02-28 22:14:26 +0000 (Sat, 28 Feb 2026)
Log Message:
-----------
reuse buttons for flag fields if possible
Modified Paths:
--------------
trunk/bibdesk/BDSKEditor.m
Modified: trunk/bibdesk/BDSKEditor.m
===================================================================
--- trunk/bibdesk/BDSKEditor.m 2026-02-28 22:02:25 UTC (rev 30085)
+++ trunk/bibdesk/BDSKEditor.m 2026-02-28 22:14:26 UTC (rev 30086)
@@ -3359,37 +3359,41 @@
- (CGFloat)addButtonToCollectionviewItem:(BDSKEditorCollectionViewItem *)item {
NSString *field = [item representedObject];
NSView *view = [item view];
- NSButton *button = nil;
+ NSButton *button = [item button];
- [[item button] removeFromSuperview];
- [item setButton:nil];
+ if (button == nil || [button isKindOfClass:[BDSKRatingButton class]] !=
[field isRatingField]) {
+ [button removeFromSuperview];
+
+ if ([field isRatingField]) {
+ button = [[BDSKRatingButton alloc] init];
+ } else {
+ button = [[NSButton alloc] init];
+ [button setButtonType:NSButtonTypeSwitch];
+ }
+
+ [button setImagePosition:NSImageLeft];
+ [button setAlignment:NSTextAlignmentLeft];
+
+ [button setTarget:self];
+ [button setAction:@selector(changeFlag:)];
+ [button setTranslatesAutoresizingMaskIntoConstraints:NO];
+
+ [view addSubview:button];
+ [NSLayoutConstraint activateConstraints:@[
+ [[button leadingAnchor] constraintEqualToAnchor:[view
leadingAnchor] constant:6.0],
+ [[view trailingAnchor] constraintEqualToAnchor:[button
trailingAnchor] constant:6.0],
+ [[button centerYAnchor] constraintEqualToAnchor:[view
centerYAnchor]]]];
+
+ [item setButton:button];
+ }
- if ([field isRatingField]) {
- button = [[BDSKRatingButton alloc] init];
- } else {
- button = [[NSButton alloc] init];
- [button setButtonType:NSButtonTypeSwitch];
+ if ([field isRatingField] == NO)
[button setAllowsMixedState:[field isTriStateField]];
- }
- [button setImagePosition:NSImageLeft];
- [button setAlignment:NSTextAlignmentLeft];
-
[[button cell] setRepresentedObject:field];
[button setTitle:[field localizedFieldName]];
- [button setTarget:self];
- [button setAction:@selector(changeFlag:)];
[button setEnabled:editorFlags.isEditable];
[button setIntegerValue:[publication integerValueOfField:field]];
- [button setTranslatesAutoresizingMaskIntoConstraints:NO];
- [view addSubview:button];
- [NSLayoutConstraint activateConstraints:@[
- [[button leadingAnchor] constraintEqualToAnchor:[view leadingAnchor]
constant:6.0],
- [[view trailingAnchor] constraintEqualToAnchor:[button trailingAnchor]
constant:6.0],
- [[button centerYAnchor] constraintEqualToAnchor:[view
centerYAnchor]]]];
-
- [item setButton:button];
-
return [view fittingSize].width;
}
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