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
This commit is contained in:
Alexandre Wilhelm
2013-04-30 14:11:45 -07:00
parent 6048814635
commit 7b59ec93df
11 changed files with 46 additions and 7 deletions
+37 -7
View File
@@ -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);
Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 993 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 996 B

+9
View File
@@ -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]],