mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-03 19:44:22 +00:00
AppKit: Size empty toolbar views to theme height in -[CPToolbar _toolbarView]
-[CPToolbar _toolbarView] created the view using -_toolbarViewFrame, which read the theme's height from _toolbarView before the view existed, so the height was nil. A toolbar with items received its height later during tiling, whereas an itemless toolbar kept a view with no height and took no vertical space in its window. Create the view with the toolbar's width and no height, assign its toolbar and item views, and then set its frame with -_toolbarViewFrame.
This commit is contained in:
1 parent
f549eb39ee
commit
ab7aff5e72
2 files changed
+31
-1
No files matched your search
+16
-1
@@ -591,11 +591,26 @@ var CPToolbarConfigurationDisplayModeKey = @"TB Display Mode",
|
||||
{
|
||||
if (!_toolbarView)
|
||||
{
|
||||
_toolbarView = [[_CPToolbarView alloc] initWithFrame:[self _toolbarViewFrame]];
|
||||
/*
|
||||
The frame takes the theme's height from the toolbar view, so the view is made first
|
||||
and sized last. A new frame tiles the view, and tiling reads the toolbar and the
|
||||
views of its items, so the frame is set after both exist. The view starts with the
|
||||
toolbar's width and no height: -reloadToolbarItems tiles it, and at a smaller width
|
||||
tiling hides items by their visibility priority, which the toolbar has not sorted
|
||||
yet. The view was made with -_toolbarViewFrame, which read the height from the view
|
||||
before it existed. The height was nil, so a toolbar without items, whose items set
|
||||
no height, had a view of no height and took no room in its window.
|
||||
*/
|
||||
var initialFrame = [self _toolbarViewFrame];
|
||||
|
||||
initialFrame.size.height = 0.0;
|
||||
|
||||
_toolbarView = [[_CPToolbarView alloc] initWithFrame:initialFrame];
|
||||
|
||||
[_toolbarView setToolbar:self];
|
||||
[_toolbarView setAutoresizingMask:CPViewWidthSizable];
|
||||
[_toolbarView reloadToolbarItems];
|
||||
[_toolbarView setFrame:[self _toolbarViewFrame]];
|
||||
}
|
||||
|
||||
return _toolbarView;
|
||||
|
||||
@@ -308,6 +308,21 @@ var ToolbarTestIdentifiersOf = function(aToolbar)
|
||||
[self assert:[delegate cachedItem] same:[toolbar items][0] message:@"a reload must not copy an item that the toolbar shows"];
|
||||
}
|
||||
|
||||
/*
|
||||
A toolbar without items takes the theme's height for its size mode. Its view had no height,
|
||||
because the height was read from the view before the view existed.
|
||||
*/
|
||||
- (void)testTheViewOfAToolbarWithoutItemsHasTheThemesHeight
|
||||
{
|
||||
var toolbar = [[CPToolbar alloc] initWithIdentifier:@"CPToolbarTestEmpty"],
|
||||
toolbarView = [toolbar _toolbarView],
|
||||
height = CGRectGetHeight([toolbarView frame]),
|
||||
themeHeight = [toolbarView valueForThemeAttribute:@"regular-size-height"];
|
||||
|
||||
[self assertTrue:themeHeight > 0 message:@"the theme gives a regular height"];
|
||||
[self assert:themeHeight equals:height message:@"the toolbar view's height"];
|
||||
}
|
||||
|
||||
- (void)testAnItemViewThatAReloadDiscardsNoLongerFollowsItsItem
|
||||
{
|
||||
var delegate = [_ToolbarTestDelegate new],
|
||||
|
||||
Reference in new issue
Block a user