Various fixes for menus in Macintosh interface style (some apply to

Windows95 style as well).


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31800 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Wolfgang Lux 2010-12-30 19:56:03 +00:00
parent fb66e35ad6
commit 2583abd450
3 changed files with 55 additions and 41 deletions

View file

@ -1,3 +1,21 @@
2010-12-30 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSMenuView.m (-update):
Don't use a title bar for menus in Macintosh interface style.
* Source/NSMenuView.m (_executeItemAtIndex:removeSubmenu:):
End menu tracking in Macintosh and Windows95 interface styles when
the user clicks on a submenu item.
* Source/NSMenu.m (-displayTransient):
Place the top left edge of a menu at the mouse position when
displaying a context menu in Macintosh and Windows95 interface
styles to prevent a user from accidentally selecting the first
menu item.
* Source/NSMenu.m (-shiftOnScreen):
Don't move the main menu bar in Macintosh interface style.
2010-12-30 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSToolbar.m (-runCustomizationPalette:):
@ -57,7 +75,6 @@
Make sure the file name displayed in the panel has a valid
extension.
>>>>>>> .r31796
2010-12-27 16:51-EST Gregory John Casamento <greg.casamento@gmail.com>
* Source/GSThemeMenu.m: Changes for compiling with older compilers.

View file

@ -1863,13 +1863,26 @@ static BOOL menuBarVisible = YES;
else
{
NSRect frame = [_aWindow frame];
NSInterfaceStyle style;
location = [_aWindow mouseLocationOutsideOfEventStream];
location = [_aWindow convertBaseToScreen: location];
location.x -= frame.size.width/2;
if (location.x < 0)
location.x = 0;
location.y -= frame.size.height - 10;
location.y -= frame.size.height;
/* When using the standard NextStep/OpenStep interface style, the
center of the menu's title view is placed below the mouse cursor.
However, in Macintosh and Windows95 styles, menus have no visible
title. To prevent the user from accidentally selecting the first
item, the top left edge is placed below the mouse cursor for them. */
style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
if (style != NSWindows95InterfaceStyle &&
style != NSMacintoshInterfaceStyle)
{
location.x -= frame.size.width/2;
if (location.x < 0)
location.x = 0;
location.y += 10;
}
}
[_bWindow setFrameOrigin: location];
@ -2060,15 +2073,13 @@ static BOOL menuBarVisible = YES;
BOOL moveIt = NO;
NSPoint location = [theWindow mouseLocationOutsideOfEventStream];
NSPoint pointerLoc = [theWindow convertBaseToScreen: location];
NSInterfaceStyle style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
// Why forget about moving the main menu? If the main menu was partially
// shifted off screen while tracking one of its submenus, it should be
// possible to shift it back on screen again.
#if 0
// If we are the main menu forget about moving.
if ([self isEqual: [NSApp mainMenu]] && !_menu.transient)
// Don't move the main menu bar in Macintosh interface style, this is
// annoying (in particular, since the effective screen range is reduced
// by the height of the menu bar!)
if (style == NSMacintoshInterfaceStyle && [self isEqual: [NSApp mainMenu]])
return;
#endif
// 1 - determine the amount we need to shift in the y direction.
if (pointerLoc.y <= 1 && NSMinY (frameRect) < 0)
@ -2108,7 +2119,7 @@ static BOOL menuBarVisible = YES;
NSPoint masterLocation;
NSPoint destinationPoint;
if (_menu.horizontal)
if (style == NSMacintoshInterfaceStyle || _menu.horizontal)
{
masterLocation = frameRect.origin;
destinationPoint.x = masterLocation.x + vector.x;
@ -2123,6 +2134,7 @@ static BOOL menuBarVisible = YES;
// Look for the "master" menu, i.e. the one to move from.
for (candidateMenu = masterMenu = self;
(candidateMenu = masterMenu->_superMenu)
&& !candidateMenu->_menu.horizontal
&& (!masterMenu->_menu.is_tornoff
|| masterMenu->_menu.transient);
masterMenu = candidateMenu);

View file

@ -588,14 +588,15 @@ static NSMapTable *viewInfo = 0;
{
BOOL needTitleView;
BOOL rootIsAppMenu;
NSInterfaceStyle style;
NSDebugLLog (@"NSMenu", @"update called on menu view");
/*
* Ensure that a title view exists only if needed.
*/
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil) ==
NSWindows95InterfaceStyle)
style = NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil);
if (style == NSWindows95InterfaceStyle || style == NSMacintoshInterfaceStyle)
{
needTitleView = NO;
}
@ -1390,18 +1391,18 @@ static NSMapTable *viewInfo = 0;
&& [_attachedMenu attachedMenu] != nil && [_attachedMenu attachedMenu] ==
[[_items_link objectAtIndex: indexOfActionToExecute] submenu])
{
#if 1
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
== NSMacintoshInterfaceStyle)
NSInterfaceStyle style =
NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self);
if (style == NSMacintoshInterfaceStyle ||
style == NSWindows95InterfaceStyle)
{
/*
* FIXME ... always remove submenus in mac mode ... this is not
* quite the way the mac behaves, but it's closer than the normal
* behavior.
*/
subMenusNeedRemoving = YES;
// On Macintosh, clicking on or releasing the mouse over a
// submenu item always closes the menu (if it is open) and
// ends menu tracking. We do the same here, too.
[self detachSubmenu];
return YES;
}
#endif
if (subMenusNeedRemoving)
{
[self detachSubmenu];
@ -1409,22 +1410,6 @@ static NSMapTable *viewInfo = 0;
// Clicked on a submenu.
return NO;
}
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", self)
== NSMacintoshInterfaceStyle)
{
NSMenu *tmp = _attachedMenu;
do
{
if ([tmp isEqual: [NSApp mainMenu]] == NO)
{
[tmp close];
}
tmp = [tmp supermenu];
}
while (tmp != nil);
}
return YES;
}