diff --git a/AppKit/CPButtonBar.j b/AppKit/CPButtonBar.j index 1f63473de..01aa1d833 100644 --- a/AppKit/CPButtonBar.j +++ b/AppKit/CPButtonBar.j @@ -14,7 +14,7 @@ + (id)plusButton { var button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)], - image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:self] pathForResource:@"plus_button.png"] size:CGSizeMake(11, 12)]; + image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPButtonBar class]] pathForResource:@"plus_button.png"] size:CGSizeMake(11, 12)]; [button setBordered:NO]; [button setImage:image]; @@ -26,7 +26,7 @@ + (id)minusButton { var button = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)], - image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:self] pathForResource:@"minus_button.png"] size:CGSizeMake(11, 4)]; + image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPButtonBar class]] pathForResource:@"minus_button.png"] size:CGSizeMake(11, 4)]; [button setBordered:NO]; [button setImage:image]; @@ -35,6 +35,21 @@ return button; } ++ (id)actionPopupButton +{ + var button = [[CPPopUpButton alloc] initWithFrame:CGRectMake(0, 0, 35, 25)], + image = [[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPButtonBar class]] pathForResource:@"action_button.png"] size:CGSizeMake(22, 14)]; + + [button addItemWithTitle:nil]; + [[button lastItem] setImage:image]; + [button setImagePosition:CPImageOnly]; + [button setValue:CGInsetMake(0, 0, 0, 0) forThemeAttribute:"content-inset"]; + + [button setPullsDown:YES]; + + return button; +} + + (CPString)themeClass { return @"button-bar"; @@ -174,13 +189,23 @@ [buttonsNotHidden removeObject:buttonsNotHidden[count]]; var currentButtonOffset = _resizeControlIsLeftAligned ? CGRectGetMaxX([self bounds]) + 1 : -1, - height = CGRectGetHeight([self bounds]) - 1; + bounds = [self bounds], + height = CGRectGetHeight(bounds) - 1, + frameWidth = CGRectGetWidth(bounds), + resizeRect = _hasResizeControl ? [self rectForEphemeralSubviewNamed:"resize-control-view"] : CGRectMakeZero(), + resizeWidth = CGRectGetWidth(resizeRect), + availableWidth = frameWidth - resizeWidth - 1; for (var i = 0, count = [buttonsNotHidden count]; i < count; i++) { var button = buttonsNotHidden[i], width = CGRectGetWidth([button frame]); + if (availableWidth > width) + availableWidth -=width; + else + break; + if (_resizeControlIsLeftAligned) { [button setFrame:CGRectMake(currentButtonOffset - width, 1, width, height)]; @@ -216,6 +241,12 @@ } } +- (void)setFrameSize:(CGSize)aSize +{ + [super setFrameSize:aSize]; + [self setNeedsLayout]; +} + @end var CPButtonBarHasResizeControlKey = @"CPButtonBarHasResizeControlKey", diff --git a/AppKit/Resources/action_button.png b/AppKit/Resources/action_button.png new file mode 100644 index 000000000..2af0dfc48 Binary files /dev/null and b/AppKit/Resources/action_button.png differ diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index c091aa8d8..adc445107 100644 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -721,7 +721,7 @@ + (CPButtonBar)themedButtonBar { - var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 140.0, 26.0)], + var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 147.0, 26.0)], color = [CPColor colorWithPatternImage:[_CPCibCustomResource imageResourceWithName:"buttonbar-bezel.png" size:CGSizeMake(1.0, 26.0)]]; [buttonBar setHasResizeControl:YES]; @@ -763,7 +763,11 @@ [buttonBar setValue:buttonBezelDisabledColor forThemeAttribute:@"button-bezel-color" inState:CPThemeStateDisabled]; [buttonBar setValue:[CPColor blackColor] forThemeAttribute:@"button-text-color"]; - [buttonBar setButtons:[[CPButtonBar plusButton], [CPButtonBar minusButton], [self themedPullDownMenu]]]; + var popup = [CPButtonBar actionPopupButton]; + [popup addItemWithTitle:"Item 1"]; + [popup addItemWithTitle:"Item 2"]; + + [buttonBar setButtons:[[CPButtonBar plusButton], [CPButtonBar minusButton], popup]]; return buttonBar; }