forked from bartvdbraak/blender
Cocoa :
- Small changes to make ghost_cocoa compatible with 10.4 + gcc4.0 (the initial goal was to be 10.5+ compatible, but 10.4 is finally also possible) - Main window title is now in Apple document window title style (proxy icon + filename) - fix for top menu "Blender" sub-menu not anchored correctly in 10.5
This commit is contained in:
parent
e6e8ba98df
commit
3b2d752933
@ -635,6 +635,7 @@ GHOST_TSuccess GHOST_SystemCocoa::init()
|
||||
|
||||
[mainMenubar addItem:menuItem];
|
||||
[menuItem release];
|
||||
[NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu]; //Needed for 10.5
|
||||
[appMenu release];
|
||||
|
||||
//Create the window menu
|
||||
@ -815,7 +816,7 @@ GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
|
||||
|
||||
GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys(GHOST_ModifierKeys& keys) const
|
||||
{
|
||||
NSUInteger modifiers = [[NSApp currentEvent] modifierFlags];
|
||||
unsigned int modifiers = [[NSApp currentEvent] modifierFlags];
|
||||
//Direct query to modifierFlags can be used in 10.6
|
||||
|
||||
keys.set(GHOST_kModifierKeyCommand, (modifiers & NSCommandKeyMask) ? true : false);
|
||||
@ -1175,7 +1176,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
|
||||
{
|
||||
NSEvent *event = (NSEvent *)eventPtr;
|
||||
GHOST_IWindow* window = m_windowManager->getActiveWindow();
|
||||
NSUInteger modifiers;
|
||||
unsigned int modifiers;
|
||||
NSString *characters;
|
||||
GHOST_TKey keyCode;
|
||||
unsigned char ascii;
|
||||
|
@ -40,13 +40,13 @@
|
||||
|
||||
|
||||
// Pixel Format Attributes for the windowed NSOpenGLContext
|
||||
static const NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[] =
|
||||
static NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[] =
|
||||
{
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFAAllowOfflineRenderers, // NOTE: Needed to connect to secondary GPUs
|
||||
NSOpenGLPFADepthSize, 32,
|
||||
0
|
||||
//NSOpenGLPFAAllowOfflineRenderers, // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway
|
||||
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) 32,
|
||||
(NSOpenGLPixelFormatAttribute) 0
|
||||
};
|
||||
|
||||
#pragma mark Cocoa window delegate object
|
||||
@ -187,7 +187,7 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
|
||||
return;
|
||||
}
|
||||
|
||||
[m_window setTitle:[NSString stringWithUTF8String:title]];
|
||||
setTitle(title);
|
||||
|
||||
|
||||
//Creates the OpenGL View inside the window
|
||||
@ -271,7 +271,38 @@ void GHOST_WindowCocoa::setTitle(const STR_String& title)
|
||||
|
||||
NSString *windowTitle = [[NSString alloc] initWithUTF8String:title];
|
||||
|
||||
//Set associated file if applicable
|
||||
if ([windowTitle hasPrefix:@"Blender"])
|
||||
{
|
||||
NSRange fileStrRange;
|
||||
NSString *associatedFileName;
|
||||
int len;
|
||||
|
||||
fileStrRange.location = [windowTitle rangeOfString:@"["].location+1;
|
||||
len = [windowTitle rangeOfString:@"]"].location - fileStrRange.location;
|
||||
|
||||
if (len >0)
|
||||
{
|
||||
fileStrRange.length = len;
|
||||
associatedFileName = [windowTitle substringWithRange:fileStrRange];
|
||||
@try {
|
||||
[m_window setRepresentedFilename:associatedFileName];
|
||||
}
|
||||
@catch (NSException * e) {
|
||||
printf("\nInvalid file path given in window title");
|
||||
}
|
||||
[m_window setTitle:[associatedFileName lastPathComponent]];
|
||||
}
|
||||
else {
|
||||
[m_window setTitle:windowTitle];
|
||||
[m_window setRepresentedFilename:@""];
|
||||
}
|
||||
|
||||
} else {
|
||||
[m_window setTitle:windowTitle];
|
||||
[m_window setRepresentedFilename:@""];
|
||||
}
|
||||
|
||||
|
||||
[windowTitle release];
|
||||
[pool drain];
|
||||
@ -501,7 +532,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
|
||||
defer:YES];
|
||||
//Copy current window parameters
|
||||
[tmpWindow setTitle:[m_window title]];
|
||||
[tmpWindow setRepresentedURL:[m_window representedURL]];
|
||||
[tmpWindow setRepresentedFilename:[m_window representedFilename]];
|
||||
[tmpWindow setReleasedWhenClosed:NO];
|
||||
[tmpWindow setAcceptsMouseMovedEvents:YES];
|
||||
[tmpWindow setDelegate:[m_window delegate]];
|
||||
@ -557,7 +588,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
|
||||
defer:YES];
|
||||
//Copy current window parameters
|
||||
[tmpWindow setTitle:[m_window title]];
|
||||
[tmpWindow setRepresentedURL:[m_window representedURL]];
|
||||
[tmpWindow setRepresentedFilename:[m_window representedFilename]];
|
||||
[tmpWindow setReleasedWhenClosed:NO];
|
||||
[tmpWindow setAcceptsMouseMovedEvents:YES];
|
||||
[tmpWindow setDelegate:[m_window delegate]];
|
||||
|
Loading…
Reference in New Issue
Block a user