From 9b16d3624e91cd5100a7bb94980b4cf9537e1d52 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 14 Jan 2015 17:15:37 -0800 Subject: [PATCH] Fixed: showcase of themes are broken Previously the showcase of the themes were broken. This was due to a change of the CPCollectionView, previously we used to use the delegate collectionViewDidChange. This delegate method has been removed. We now use an observer on the selectionIndexes. --- AppKit/Themes/BlendKit/BKShowcaseController.j | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/AppKit/Themes/BlendKit/BKShowcaseController.j b/AppKit/Themes/BlendKit/BKShowcaseController.j index 99e0d0b05..5a57393fd 100644 --- a/AppKit/Themes/BlendKit/BKShowcaseController.j +++ b/AppKit/Themes/BlendKit/BKShowcaseController.j @@ -137,22 +137,27 @@ var BKLearnMoreToolbarItemIdentifier = @"BKLearnMoreToolbarItemId [theWindow setFullPlatformWindow:YES]; [theWindow makeKeyAndOrderFront:self]; + + [_themesCollectionView addObserver:self forKeyPath:@"selectionIndexes" options:CPKeyValueObservingOptionNew | CPKeyValueObservingOptionInitial context:nil]; } -- (void)collectionViewDidChangeSelection:(CPCollectionView)aCollectionView +- (void)observeValueForKeyPath:(CPString)keyPath ofObject:(id)object change:(CPDictionary)change context:(void)context { - var themeDescriptorClass = _themeDescriptorClasses[[[aCollectionView selectionIndexes] firstIndex]], - itemSize = [themeDescriptorClass itemSize]; + if (object == _themesCollectionView && keyPath == @"selectionIndexes") + { + var themeDescriptorClass = _themeDescriptorClasses[[[object selectionIndexes] firstIndex]], + itemSize = [themeDescriptorClass itemSize]; - // Make room for label and apply a minimum size. - itemSize.width = MAX(100.0, itemSize.width + 20.0); - itemSize.height = MAX(100.0, itemSize.height + 30.0); + // Make room for label and apply a minimum size. + itemSize.width = MAX(100.0, itemSize.width + 20.0); + itemSize.height = MAX(100.0, itemSize.height + 30.0); - [_themedObjectsCollectionView setMinItemSize:itemSize]; - [_themedObjectsCollectionView setMaxItemSize:itemSize]; + [_themedObjectsCollectionView setMinItemSize:itemSize]; + [_themedObjectsCollectionView setMaxItemSize:itemSize]; - [_themedObjectsCollectionView setContent:[themeDescriptorClass themedShowcaseObjectTemplates]]; - [BKShowcaseCell setBackgroundColor:[themeDescriptorClass showcaseBackgroundColor]]; + [_themedObjectsCollectionView setContent:[themeDescriptorClass themedShowcaseObjectTemplates]]; + [BKShowcaseCell setBackgroundColor:[themeDescriptorClass showcaseBackgroundColor]]; + } } - (BOOL)hasLearnMoreURL