From 7b59ec93df0a0a181096a408e9e47f3a5658ca77 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Tue, 30 Apr 2013 14:11:45 -0700 Subject: [PATCH] Fixed: Windows with toolbars do not display correctly as sheets Previously it wasn't possible to display a toolbar in a sheet window. Now, a toobar is displayed well in a window. This PR allows every sheet window to have a toolbar, with the PR #1918 just the CPTitleWindow/HUD sheet could have a toolbar as in cocoa. Fixes #1863 --- AppKit/CPWindow/_CPStandardWindowView.j | 44 +++++++++++++++--- ...tandard-head-sheet-solid-bottom-center.png | Bin 0 -> 82 bytes ...-standard-head-sheet-solid-bottom-left.png | Bin 0 -> 76 bytes ...standard-head-sheet-solid-bottom-right.png | Bin 0 -> 76 bytes ...tandard-head-sheet-solid-center-center.png | Bin 0 -> 82 bytes ...-standard-head-sheet-solid-center-left.png | Bin 0 -> 76 bytes ...standard-head-sheet-solid-center-right.png | Bin 0 -> 76 bytes ...w-standard-head-sheet-solid-top-center.png | Bin 0 -> 993 bytes ...dow-standard-head-sheet-solid-top-left.png | Bin 0 -> 996 bytes ...ow-standard-head-sheet-solid-top-right.png | Bin 0 -> 996 bytes AppKit/Themes/Aristo2/ThemeDescriptors.j | 9 ++++ 11 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-center.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-left.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-bottom-right.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-center.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-left.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-center-right.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-center.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-left.png create mode 100644 AppKit/Themes/Aristo2/Resources/window-standard-head-sheet-solid-top-right.png diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index b2c68ef6a..c9d981880 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; @@ -69,7 +71,11 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; bounds = [self bounds]; [_gradientView setFrame:CGRectMake(0.0, 0.0, CGRectGetWidth(bounds), gradientHeight)]; - [_gradientView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]]; + + if (_isSheet) + [_gradientView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"bezel-head-sheet-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]]; + else + [_gradientView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"bezel-head-color" inState:[_parentView themeState] forClass:_CPStandardWindowView]]; [_solidView setFrame:CGRectMake(0.0, gradientHeight, CGRectGetWidth(bounds), CGRectGetHeight(bounds) - gradientHeight)]; [_solidView setBackgroundColor:[[CPTheme defaultTheme] valueForAttributeWithName:@"solid-color" forClass:_CPStandardWindowView]]; @@ -97,6 +103,7 @@ var _CPStandardWindowViewDividerViewHeight = 1.0; CPButton _minimizeButton; BOOL _isDocumentEdited; + BOOL _isSheet; } + (CPString)defaultThemeClass @@ -110,6 +117,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 +232,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 +327,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 +362,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/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 0000000000000000000000000000000000000000..1a86f0428a70fb06dfa8465a81e6f5b265307857 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?jt}kA^u=u+^2gv2}ba4#f ckWEeivY8kd&z~@T3S=>Oy85}Sb4q9e0H(1L{r~^~ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..93aad32e69f977282b03c0a9ce3bc51e9fcb2991 GIT binary patch literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1j!3HG7{-t~dQo^1tjv*Yf$q5Mw0o5NL9j#B{ ZVQ7fwXWsh4{WVaU!PC{xWt~$(697>i6FvX{ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..201e8fd643e1b0f0899990198e46e157008021bb GIT binary patch literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1j!3HG7{-t~dQo^1tjv*Yf$rT?T9j#9}bKt-N ZHin(~{LJP3;d_A644$rjF6*2UngDkL6hr_3 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1a86f0428a70fb06dfa8465a81e6f5b265307857 GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?jt}kA^u=u+^2gv2}ba4#f ckWEeivY8kd&z~@T3S=>Oy85}Sb4q9e0H(1L{r~^~ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..93aad32e69f977282b03c0a9ce3bc51e9fcb2991 GIT binary patch literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1j!3HG7{-t~dQo^1tjv*Yf$q5Mw0o5NL9j#B{ ZVQ7fwXWsh4{WVaU!PC{xWt~$(697>i6FvX{ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..201e8fd643e1b0f0899990198e46e157008021bb GIT binary patch literal 76 zcmeAS@N?(olHy`uVBq!ia0vp^tU%1j!3HG7{-t~dQo^1tjv*Yf$rT?T9j#9}bKt-N ZHin(~{LJP3;d_A644$rjF6*2UngDkL6hr_3 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..408bbde4938cd7b226d40fd0975b71a165430069 GIT binary patch literal 993 zcmbVL&u-H&7!R5R)1-+L2M`igb^ruTY^P0{Xkp5dhE*b?>MGG2brW}uw#32lXg0xx z+g@fbz<~=Kcm+eFHx>tMCKiNK#Y@5!7-^xb#5tte~rbTk&@=#>+*Oe3|9R%L}m zE6VmxRgn0I3NWRIY3{1OK7Ua`nz-tlP6VUEr}K30jMIa&{ZV{&6x)fq^8##FjwHya zAfU>Q^U|qYb;;|0^q`7h0oCrVK1C}olX zT9Wn;$}9-anLuN97N?f{8GpUZ&j||rGXkrdrZ*2=smOK?AGgWmypDXjG!t*ng7=}@CP}%^EMzKgmP&U$H zw`Ooz5$16wVxFRkF&Oiiuw?Lb6+)8v{xxx0tP=$(Q_CPziGtN6sp48{7h=HvxN)O) zFA#V8aHr{c#-T$!+H`eWUSp&G$(jnzs8xIX)h@LNda&AFH$NP%$A_gbGdT>$ t^oo6l!Mfjb?P2+C9G#x_!{?jQ#+G#FleG8dF}|wiuGc+wKOUaG{|(ZSET8}Y literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a772da25293e4c7538fe5b485a8712a23c5b12d1 GIT binary patch literal 996 zcmbVLO>fgM7|xiO(4<{BAb~ho*=0yHvE9~fqGcmX8diyns;fjVNOKdfjkd(W@o2Uq zH~tK8=YTk}pTM8sz#ZXq%>ZfIfhdXX*YESZ-|q(p&o|Z|t!tXL(ckxnYQ3wzm3wRI z|KL~rQ!Ni=Z!8b_v7A%EG&klG2Kp(TvLU1K`I~QSThmr&$!ILc;R`$BsX;3pqfB#! z*0k;2GN;iAlVHN8N#^K3K7Y|c5Zk$%c?jqZYYgLah^$9HnL)~ zX7E`Ni6oZ^&p^dUC;Uu0y7KfYgftJsYvQa}CQ7BuENN~c1Da`C#kJ5b