From 6ee80f618262d72dc49bc32c06970a1510908601 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 9 Jan 2013 18:23:09 -0800 Subject: [PATCH 1/3] Added support for theme --- AppKit/CPToolbar.j | 99 +++++++++++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index eff884890..5b7dc7a57 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -135,18 +135,18 @@ var CPToolbarsByIdentifier = nil, [toolbarsSharingIdentifier addObject:toolbar]; } -/* - Temporary theme attributes until we've figured out which CPView these theme attributes should - belong to. - @ignore -*/ -+ (id)_themeAttributes -{ - // "regular-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeRegular. - // "small-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeSmall. - return [CPDictionary dictionaryWithObjects:[_CGInsetMake(4.0, 4.0, 4.0, TOOLBAR_ITEM_MARGIN), 59.0, 46.0] - forKeys:[@"content-inset", @"regular-size-height", @"small-size-height"]]; -} +// /* +// Temporary theme attributes until we've figured out which CPView these theme attributes should +// belong to. +// @ignore +// */ +// + (id)_themeAttributes +// { +// // "regular-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeRegular. +// // "small-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeSmall. +// return [CPDictionary dictionaryWithObjects:[_CGInsetMake(4.0, 4.0, 4.0, TOOLBAR_ITEM_MARGIN), 59.0, 46.0] +// forKeys:[@"content-inset", @"regular-size-height", @"small-size-height"]]; +// } - (id)init { @@ -281,19 +281,19 @@ var CPToolbarsByIdentifier = nil, - (CGRect)_toolbarViewFrame { - var height = _desiredHeight || (_sizeMode != CPToolbarSizeModeSmall ? [self _valueForThemeAttribute:@"regular-size-height"] : [self _valueForThemeAttribute:@"small-size-height"]); + var height = _desiredHeight || (_sizeMode != CPToolbarSizeModeSmall ? [_toolbarView valueForThemeAttribute:@"regular-size-height"] : [_toolbarView valueForThemeAttribute:@"small-size-height"]); return CPRectMake(0.0, 0.0, 1200.0, height); } -/* - Temporary theme attributes until we've figured out which CPView these theme attributes should - belong to. - @ignore -*/ -- (id)_valueForThemeAttribute:(CPString)attributeName -{ - return [[[self class] _themeAttributes] valueForKey:attributeName]; -} +// /* +// Temporary theme attributes until we've figured out which CPView these theme attributes should +// belong to. +// @ignore +// */ +// - (id)_valueForThemeAttribute:(CPString)attributeName +// { +// return [[[self class] _themeAttributes] valueForKey:attributeName]; +// } /* @ignore */ - (CPView)_toolbarView @@ -592,8 +592,8 @@ var _CPToolbarViewBackgroundColor = nil, _CPToolbarViewExtraItemsImage = nil, _CPToolbarViewExtraItemsAlternateImage = nil; -var TOOLBAR_ITEM_MARGIN = 10.0, - TOOLBAR_EXTRA_ITEMS_WIDTH = 20.0; +// var TOOLBAR_ITEM_MARGIN = 10.0, +// TOOLBAR_EXTRA_ITEMS_WIDTH = 20.0; var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) { @@ -623,16 +623,28 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) BOOL _FIXME_isHUD; } -+ (void)initialize +// + (void)initialize +// { +// if (self !== [_CPToolbarView class]) +// return; +// +// var bundle = [CPBundle bundleForClass:self]; +// +// _CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size:CPSizeMake(10.0, 15.0)]; +// +// _CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:_CGSizeMake(10.0, 15.0)]; +// } + + ++ (CPString)defaultThemeClass { - if (self !== [_CPToolbarView class]) - return; + return @"toolbar-view"; +} - var bundle = [CPBundle bundleForClass:self]; - - _CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size:CPSizeMake(10.0, 15.0)]; - - _CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:_CGSizeMake(10.0, 15.0)]; ++ (id)themeAttributes +{ + return [CPDictionary dictionaryWithObjects:[10.0, 20.0,[CPNull null], [CPNull null], _CGInsetMake(4.0, 4.0, 4.0, 10), 59.0, 46.0] + forKeys:[@"item-margin", @"extra-item-width", @"extra-item-extra-image", @"extra-item-extra-alternate-image", @"content-inset", @"regular-size-height", @"small-size-height"]]; } - (id)initWithFrame:(CGRect)aFrame @@ -653,7 +665,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [[_additionalItemsButton menu] setShowsStateColumn:NO]; [[_additionalItemsButton menu] setAutoenablesItems:NO]; - [_additionalItemsButton setAlternateImage:_CPToolbarViewExtraItemsAlternateImage]; + //[_additionalItemsButton setAlternateImage:_CPToolbarViewExtraItemsAlternateImage]; } return self; @@ -709,7 +721,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) // minimum width for hiding items. if (itemsWidth < minWidth) { - itemsWidth -= TOOLBAR_EXTRA_ITEMS_WIDTH; + itemsWidth -= [self valueForThemeAttribute:@"extra-item-width"]; _visibleItems = [_visibleItems copy]; @@ -725,7 +737,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) var item = itemsSortedByVisibilityPriority[--count], view = [self viewForItem:item]; - minWidth -= [view minSize].width + TOOLBAR_ITEM_MARGIN; + minWidth -= [view minSize].width + [self valueForThemeAttribute:@"item-margin"]; [_visibleItems removeObjectIdenticalTo:item]; [invisibleItemsSortedByPriority addObject:item]; @@ -751,7 +763,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) // We'll figure out the proper height for the toolbar depending on its items. // If nothing has a minimum size we'll use the standard toolbar size for the // sizeMode, indicated by a 0 _desiredHeight. - var contentInset = [_toolbar _valueForThemeAttribute:@"content-inset"], + var contentInset = [self valueForThemeAttribute:@"content-inset"], newDesiredHeight = height ? height + contentInset.top + contentInset.bottom : 0; if (newDesiredHeight != _toolbar._desiredHeight) @@ -828,7 +840,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) var index = 0, count = _visibleItems.length, x = contentInset.left, - contentInset = [_toolbar _valueForThemeAttribute:@"content-inset"], + contentInset = [self valueForThemeAttribute:@"content-inset"], y = contentInset.top; for (; index < count; ++index) @@ -838,7 +850,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [view setFrame:_CGRectMake(x, y, viewWidth, height)]; - x += viewWidth + TOOLBAR_ITEM_MARGIN; + x += viewWidth + [self valueForThemeAttribute:@"item-margin"]; } var needsAdditionalItemsButton = NO; @@ -877,7 +889,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [_additionalItemsButton removeAllItems]; [_additionalItemsButton addItemWithTitle:@"Additional Items"]; - [[_additionalItemsButton itemArray][0] setImage:_CPToolbarViewExtraItemsImage]; + [[_additionalItemsButton itemArray][0] setImage:[self valueForThemeAttribute:@"extra-item-extra-image"]]; var index = 0, count = [_invisibleItems count], @@ -943,7 +955,7 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) count = items.length; - _minWidth = TOOLBAR_ITEM_MARGIN; + _minWidth = [self valueForThemeAttribute:@"item-margin"]; _viewsForToolbarItems = { }; for (; index < count; ++index) @@ -958,12 +970,17 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [self addSubview:view]; - _minWidth += [view minSize].width + TOOLBAR_ITEM_MARGIN; + _minWidth += [view minSize].width + [self valueForThemeAttribute:@"item-margin"]; } [self tile]; } +- (void)layoutSubviews +{ + [_additionalItemsButton setAlternateImage:[self valueForThemeAttribute:@"extra-item-extra-alternate-image"]]; +} + @end /* @ignore */ From fdd5aa0a5ad874bf7a9784f714937feff2280cf5 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 9 Jan 2013 18:24:06 -0800 Subject: [PATCH 2/3] Removed unused comments --- AppKit/CPToolbar.j | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/AppKit/CPToolbar.j b/AppKit/CPToolbar.j index 5b7dc7a57..9c3e2e8c9 100644 --- a/AppKit/CPToolbar.j +++ b/AppKit/CPToolbar.j @@ -135,19 +135,6 @@ var CPToolbarsByIdentifier = nil, [toolbarsSharingIdentifier addObject:toolbar]; } -// /* -// Temporary theme attributes until we've figured out which CPView these theme attributes should -// belong to. -// @ignore -// */ -// + (id)_themeAttributes -// { -// // "regular-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeRegular. -// // "small-size-height" is used if no item has a non-zero min size and sizeMode == CPToolbarSizeModeSmall. -// return [CPDictionary dictionaryWithObjects:[_CGInsetMake(4.0, 4.0, 4.0, TOOLBAR_ITEM_MARGIN), 59.0, 46.0] -// forKeys:[@"content-inset", @"regular-size-height", @"small-size-height"]]; -// } - - (id)init { return [self initWithIdentifier:@""]; @@ -285,16 +272,6 @@ var CPToolbarsByIdentifier = nil, return CPRectMake(0.0, 0.0, 1200.0, height); } -// /* -// Temporary theme attributes until we've figured out which CPView these theme attributes should -// belong to. -// @ignore -// */ -// - (id)_valueForThemeAttribute:(CPString)attributeName -// { -// return [[[self class] _themeAttributes] valueForKey:attributeName]; -// } - /* @ignore */ - (CPView)_toolbarView { @@ -592,9 +569,6 @@ var _CPToolbarViewBackgroundColor = nil, _CPToolbarViewExtraItemsImage = nil, _CPToolbarViewExtraItemsAlternateImage = nil; -// var TOOLBAR_ITEM_MARGIN = 10.0, -// TOOLBAR_EXTRA_ITEMS_WIDTH = 20.0; - var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) { return { index:anIndex, view:aView, label:aLabel, minWidth:aMinWidth }; @@ -623,19 +597,6 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) BOOL _FIXME_isHUD; } -// + (void)initialize -// { -// if (self !== [_CPToolbarView class]) -// return; -// -// var bundle = [CPBundle bundleForClass:self]; -// -// _CPToolbarViewExtraItemsImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsImage.png"] size:CPSizeMake(10.0, 15.0)]; -// -// _CPToolbarViewExtraItemsAlternateImage = [[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:"_CPToolbarView/_CPToolbarViewExtraItemsAlternateImage.png"] size:_CGSizeMake(10.0, 15.0)]; -// } - - + (CPString)defaultThemeClass { return @"toolbar-view"; @@ -664,8 +625,6 @@ var _CPToolbarItemInfoMake = function(anIndex, aView, aLabel, aMinWidth) [_additionalItemsButton setImagePosition:CPImageOnly]; [[_additionalItemsButton menu] setShowsStateColumn:NO]; [[_additionalItemsButton menu] setAutoenablesItems:NO]; - - //[_additionalItemsButton setAlternateImage:_CPToolbarViewExtraItemsAlternateImage]; } return self; From 7ba759b08a6c480fa0b4b033359d06df8b150143 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Wed, 9 Jan 2013 18:24:32 -0800 Subject: [PATCH 3/3] Updated Aristo2 for toolBar --- ...olbar-view-extra-items-alternate-image.png | Bin 0 -> 258 bytes .../toolbar-view-extra-items-image.png | Bin 0 -> 261 bytes AppKit/Themes/Aristo2/ThemeDescriptors.j | 22 ++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 AppKit/Themes/Aristo2/Resources/toolbar-view-extra-items-alternate-image.png create mode 100644 AppKit/Themes/Aristo2/Resources/toolbar-view-extra-items-image.png diff --git a/AppKit/Themes/Aristo2/Resources/toolbar-view-extra-items-alternate-image.png b/AppKit/Themes/Aristo2/Resources/toolbar-view-extra-items-alternate-image.png new file mode 100644 index 0000000000000000000000000000000000000000..e3787b91fe3fdd4a0b0bc76b342269d4ee4108fe GIT binary patch literal 258 zcmV+d0sa1oP)o@ghivcLtsjz#A%lb8ym1-P;bHi+W#Qog0qn!PBK6tr{0+Vr9h$D|7F`!^}wo}dZU1*)%>sdRXjaW z5^7C2Sg86_K}8HF+@0w_p~`!?QQ^!eKB_pEVT0!P