diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index b2c68ef6a..b7aedf1ce 100644 --- a/AppKit/CPWindow/_CPStandardWindowView.j +++ b/AppKit/CPWindow/_CPStandardWindowView.j @@ -29,6 +29,8 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; @implementation _CPTexturedWindowHeadView : CPView { + BOOL _isSheet @accessors(setter=setSheet:); + _CPWindowView _parentView; CPView _gradientView; CPView _solidView; @@ -66,10 +68,11 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; [super layoutSubviews]; var gradientHeight = [[CPTheme defaultTheme] valueForAttributeWithName:@"gradient-height" forClass:_CPStandardWindowView], - bounds = [self bounds]; + bounds = [self bounds], + bezelHeadColor = [[CPTheme defaultTheme] valueForAttributeWithName:_isSheet ? @"bezel-head-sheet-color" : @"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]; [_gradientView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), gradientHeight)]; - [_gradientView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]]; + [_gradientView setBackgroundColor:bezelHeadColor]; [_solidView setFrame:CGRectMake(0.0, gradientHeight, CGRectGetWidth(bounds), CGRectGetHeight(bounds) - gradientHeight)]; [_solidView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"solid-color" forClass:_CPStandardWindowView]]; @@ -97,6 +100,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; CPButton _minimizeButton; BOOL _isDocumentEdited; + BOOL _isSheet; } + (CPString)defaultThemeClass @@ -110,6 +114,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; @"gradient-height": [CPNull null], @"solid-color": [CPNull null], @"bezel-head-color": [CPNull null], + @"bezel-head-sheet-color": [CPNull null], @"divider-color": [CPColor blackColor], @"body-color": [CPColor whiteColor], @"title-bar-height": 32, @@ -224,7 +229,14 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; width = CGRectGetWidth(bounds), headHeight = [self toolbarMaxY]; + if (_isSheet && _toolbarView && [self showsToolbar]) + { + headHeight = [_toolbarView frameSize].height; + [_toolbarView setFrameOrigin:CGPointMake(0.0, 0.0)]; + } + [_headView setFrameSize:CGSizeMake(width, headHeight)]; + [_dividerView setFrame:CGRectMake(0.0, headHeight, width, _CPStandardWindowViewDividerViewHeight)]; var dividerMinY = 0, @@ -312,12 +324,26 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; { [super _enableSheet:enable inWindow:parentWindow]; - [_headView setHidden:enable]; - [_dividerView setHidden:enable]; + _isSheet = enable; + [_headView setSheet:enable]; + + if (_toolbarView && [self showsToolbar]) + { + [_headView setHidden:NO]; + [_dividerView setHidden:NO]; + } + else + { + [_headView setHidden:enable]; + [_dividerView setHidden:enable]; + } + [_closeButton setHidden:enable]; [_minimizeButton setHidden:enable]; [_titleField setHidden:enable]; + [[self window] setMovable:!enable]; + if (enable) { [_bodyView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"body-color" forClass:_CPDocModalWindowView]]; @@ -333,12 +359,13 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; var theWindow = [self window], frame = [theWindow frame], dividerHeight = [_dividerView frame].size.height, - dy; + dy = [self toolbarMaxY] + dividerHeight; + + if (_toolbarView && [self showsToolbar]) + dy = [[CPTheme defaultTheme] valueForAttributeWithName:@"gradient-height" forClass:_CPStandardWindowView]; if (enable) - dy = -[_headView frame].size.height; - else - dy = [self toolbarMaxY] + dividerHeight; + dy = -dy; var newHeight = CGRectGetHeight(frame) + dy, newWidth = CGRectGetWidth(frame); diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index ed9f0cc15..d7c47c1eb 100755 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -2687,6 +2687,7 @@ var themedButtonValues = nil, [ [@"gradient-height", 31.0], [@"bezel-head-color", bezelHeadColor], + [@"bezel-head-sheet-color", solidColor], [@"solid-color", solidColor], [@"title-font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]], diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-center.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-center.png new file mode 100644 index 000000000..1a86f0428 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-center.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-left.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-left.png new file mode 100644 index 000000000..93aad32e6 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-left.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-right.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-right.png new file mode 100644 index 000000000..201e8fd64 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-right.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-center.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-center.png new file mode 100644 index 000000000..1a86f0428 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-center.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-left.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-left.png new file mode 100644 index 000000000..93aad32e6 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-left.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-right.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-right.png new file mode 100644 index 000000000..201e8fd64 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-right.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-center.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-center.png new file mode 100644 index 000000000..408bbde49 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-center.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-left.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-left.png new file mode 100644 index 000000000..87ccfb2a6 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-left.png differ diff --git a/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-right.png b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-right.png new file mode 100644 index 000000000..a772da252 Binary files /dev/null and b/AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-right.png differ diff --git a/AppKit/Themes/Aristo2/ThemeDescriptors.j b/AppKit/Themes/Aristo2/ThemeDescriptors.j index 6b663393a..384c61f57 100644 --- a/AppKit/Themes/Aristo2/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo2/ThemeDescriptors.j @@ -2070,6 +2070,14 @@ var themedButtonValues = nil, height: 1.0 }), + bezelSheetHeadColor = PatternColor( + "window-standard-head-sheet-solid{position}.png", + { + positions: "full", + width: 5.0, + height: 1.0 + }), + bezelColor = PatternColor( "window-standard{position}.png", { @@ -2104,6 +2112,7 @@ var themedButtonValues = nil, [@"bezel-head-color", bezelHeadColor["inactive"], CPThemeStateNormal], [@"bezel-head-color", bezelHeadColor["@"], CPThemeStateKeyWindow], [@"bezel-head-color", bezelHeadColor["@"], CPThemeStateMainWindow], + [@"bezel-head-sheet-color", bezelSheetHeadColor], [@"solid-color", solidColor], [@"title-font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]], diff --git a/Tests/Manual/AttachedSheet/AppController.j b/Tests/Manual/AttachedSheet/AppController.j index 4b48a33cb..b91f6c2b2 100644 --- a/Tests/Manual/AttachedSheet/AppController.j +++ b/Tests/Manual/AttachedSheet/AppController.j @@ -12,6 +12,7 @@ { CPWindow wind; CPWindow sheet; + CPWindow secondSheet; CPTextField textField; } @@ -21,10 +22,19 @@ [wind setMinSize:CGSizeMake(300, 200)]; [wind setTitle:@"Untitled"]; - sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(0, 0, 300, 100) styleMask:CPDocModalWindowMask | CPResizableWindowMask]; + sheet = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 300, 100) styleMask:CPTitledWindowMask | CPResizableWindowMask]; [sheet setMinSize:CGSizeMake(300, 100)]; [sheet setMaxSize:CGSizeMake(600, 300)]; + secondSheet = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 300, 50) styleMask:CPTitledWindowMask | CPResizableWindowMask]; + [secondSheet setMinSize:CGSizeMake(300, 100)]; + [secondSheet setMaxSize:CGSizeMake(600, 300)]; + + toolbar = [CPToolbar new]; + [toolbar setDisplayMode:CPToolbarDisplayModeIconAndLabel] + [toolbar setDelegate:self]; + [secondSheet setToolbar:toolbar]; + var sheetContent = [sheet contentView]; textField = [[CPTextField alloc] initWithFrame:CGRectMake(10, 30, 280, 30)]; @@ -51,19 +61,50 @@ [sheetContent addSubview:okButton]; [sheetContent addSubview:cancelButton]; + var secondSheetContent = [secondSheet contentView]; + + var okButton2 = [[CPButton alloc] initWithFrame:CGRectMake(180, 25, 50, buttonHeight)]; + [okButton2 setTitle:"OK"]; + [okButton2 setTarget:self]; + [okButton2 setTag:1]; + [okButton2 setAction:@selector(closeSecondSheet:)]; + [okButton2 setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; + + var cancelButton2 = [[CPButton alloc] initWithFrame:CGRectMake(70, 25, 100, buttonHeight)]; + [cancelButton2 setTitle:"Cancel"]; + [cancelButton2 setTarget:self]; + [cancelButton2 setTag:0]; + [cancelButton2 setAction:@selector(closeSecondSheet:)]; + [cancelButton2 setAutoresizingMask:CPViewMinXMargin | CPViewMinYMargin]; + + [secondSheetContent addSubview:okButton2]; + [secondSheetContent addSubview:cancelButton2]; + var displayButton = [[CPButton alloc] initWithFrame:CGRectMake(200, 150, 100, buttonHeight)]; [displayButton setTitle:"Display Sheet"]; [displayButton setTarget:self]; [displayButton setAction:@selector(displaySheet:)]; [[wind contentView] addSubview:displayButton]; + var displayButton = [[CPButton alloc] initWithFrame:CGRectMake(160, 180, 180, buttonHeight)]; + [displayButton setTitle:"Display Sheet with toolbar"]; + [displayButton setTarget:self]; + [displayButton setAction:@selector(displaySheetWithToolBar:)]; + [[wind contentView] addSubview:displayButton]; + [wind orderFront:self] } +- (void)displaySheetWithToolBar:(id)sender +{ + [CPApp beginSheet:secondSheet modalForWindow:wind modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil]; +} + - (void)displaySheet:(id)sender { [textField setStringValue:""]; [sheet makeFirstResponder:textField]; + [sheet setToolbar:nil]; [CPApp beginSheet:sheet modalForWindow:wind modalDelegate:self didEndSelector:@selector(didEndSheet:returnCode:contextInfo:) contextInfo:nil]; } @@ -73,14 +114,46 @@ [CPApp endSheet:sheet returnCode:[sender tag]]; } +- (void)closeSecondSheet:(id)sender +{ + [CPApp endSheet:secondSheet returnCode:0]; +} + - (void)didEndSheet:(CPWindow)aSheet returnCode:(int)returnCode contextInfo:(id)contextInfo { var str = [textField stringValue]; - [sheet orderOut:self]; + [aSheet orderOut:self]; if (returnCode == CPOKButton && [str length] > 0) [wind setTitle:str]; } +- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)toolbar +{ + return ["item1", "item2"]; +} + +- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)toolbar +{ + return ["item1", "item2"]; +} + +- (CPToolbarItem)toolbar:(CPToolbar)toolbar itemForItemIdentifier:(CPString)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag +{ + var toolbarItem = [[CPToolbarItem alloc] initWithItemIdentifier:itemIdentifier]; + if (itemIdentifier == "item1") + { + [toolbarItem setLabel:@"Color"]; + [toolbarItem setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"CPImageNameColorPanel.png"] size:CGSizeMake(26, 29)]]; + return toolbarItem; + } + else if (itemIdentifier == "item2") + { + [toolbarItem setLabel:@"Small New"]; + [toolbarItem setImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"New.png"] size:CGSizeMake(16, 16)]]; + return toolbarItem; + } +} + @end diff --git a/Tests/Manual/AttachedSheet/Resources/CPImageNameColorPanel.png b/Tests/Manual/AttachedSheet/Resources/CPImageNameColorPanel.png new file mode 100644 index 000000000..a18918665 Binary files /dev/null and b/Tests/Manual/AttachedSheet/Resources/CPImageNameColorPanel.png differ diff --git a/Tests/Manual/AttachedSheet/Resources/New.png b/Tests/Manual/AttachedSheet/Resources/New.png new file mode 100644 index 000000000..2ca371152 Binary files /dev/null and b/Tests/Manual/AttachedSheet/Resources/New.png differ