When sizing a menu view correctly take into account that the first

item of a pull down menu is not visible.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30837 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-06-23 21:38:29 +00:00
parent ceb0f17569
commit 1c4797d2a0
2 changed files with 29 additions and 3 deletions

View file

@ -1,3 +1,12 @@
2010-06-23 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSMenuView.m (-sizeToFit): Correctly take into account
that the first item of a pull down menu is not visible.
* Source/NSMenuView.m (-setHorizontal:): Ensure that the layout is
recomputed after changing the view from vertical to horizontal and
vice versa.
2010-06-22 Doug Simons <doug.simons@testplant.com>
* Source/NSButton.m:

View file

@ -306,6 +306,7 @@ static NSMapTable *viewInfo = 0;
scRect.size.height = [NSMenuView menuBarHeight];
[self setFrameSize: scRect.size];
[self setNeedsSizing: YES];
}
else if (flag == NO && _horizontal == YES)
{
@ -317,6 +318,7 @@ static NSMapTable *viewInfo = 0;
NSZoneFree(NSDefaultMallocZone(), a);
NSMapRemove(viewInfo, self);
}
[self setNeedsSizing: YES];
}
_horizontal = flag;
@ -649,6 +651,9 @@ static NSMapTable *viewInfo = 0;
- (void) sizeToFit
{
BOOL isPullDown =
[_attachedMenu _ownedByPopUp] && [[_attachedMenu _owningPopUp] pullsDown];
if (_horizontal == YES)
{
unsigned i;
@ -665,7 +670,17 @@ static NSMapTable *viewInfo = 0;
*/
_cellSize.height = [NSMenuView menuBarHeight];
for (i = 0; i < howMany; i++)
if (howMany && isPullDown)
{
GSCellRect elem;
elem.rect = NSMakeRect (currentX,
0,
(2 * _horizontalEdgePad),
_cellSize.height);
GSIArrayAddItem(cellRects, (GSIArrayItem)elem);
currentX += 2 * _horizontalEdgePad;
}
for (i = isPullDown ? 1 : 0; i < howMany; i++)
{
GSCellRect elem;
NSMenuItemCell *aCell = [self menuItemCellForItemAtIndex: i];
@ -722,8 +737,8 @@ static NSMapTable *viewInfo = 0;
{
menuBarHeight += _leftBorderOffset;
}
for (i = 0; i < howMany; i++)
for (i = isPullDown ? 1 : 0; i < howMany; i++)
{
float aStateImageWidth;
float aTitleWidth;
@ -787,6 +802,8 @@ static NSMapTable *viewInfo = 0;
if (anImageWidth)
popupImageWidth = anImageWidth;
}
if (isPullDown && howMany)
howMany -= 1;
// Cache the needed widths.
_stateImageWidth = neededStateImageWidth;