Using background color attribute on entries to dispaly colorized images

This commit is contained in:
michael starke
2017-11-10 16:44:17 +01:00
parent a5161190d3
commit 6e73a390bb
6 changed files with 51 additions and 15 deletions

View File

@@ -35,6 +35,8 @@ typedef NS_ENUM(NSInteger, MPIconDownloadStatus) {
@interface MPIconSelectViewController () <NSCollectionViewDelegate>
/* UI properties */
@property (weak) IBOutlet NSColorWell *foregroundColorWell;
@property (weak) IBOutlet NSColorWell *backgroundColorWell;
@property (weak) IBOutlet MPCollectionView *iconCollectionView;
@property (weak) IBOutlet NSButton *imageButton;
@property (weak) IBOutlet NSButton *downloadIconButton;
@@ -63,6 +65,18 @@ typedef NS_ENUM(NSInteger, MPIconDownloadStatus) {
[menu addItem:[[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"DELETE", @"") action:@selector(deleteIcon:) keyEquivalent:@""]];
self.iconCollectionView.menu = menu;
KPKEntry *entry = [self.representedObject asEntry];
if(entry) {
self.foregroundColorWell.enabled = YES;
self.foregroundColorWell.color = entry.foregroundColor ? entry.foregroundColor : NSColor.clearColor;
self.backgroundColorWell.enabled = YES;
self.backgroundColorWell.color = entry.backgroundColor ? entry.backgroundColor : NSColor.clearColor;
}
else {
self.foregroundColorWell.enabled = NO;
self.backgroundColorWell.enabled = NO;
}
[self _updateCollectionViewContent];
}