From 1543d214f0201e2a0d8aaf6549d2065e1742c618 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 25 Oct 2016 22:29:01 +0200 Subject: [PATCH] [DEBUG] correct build on MacOs and IOs --- gale/context/IOs/AppDelegate.mm | 2 +- gale/context/IOs/Context.cpp | 2 +- gale/context/MacOs/Context.mm | 2 +- gale/context/MacOs/Interface.mm | 18 ++++++-- gale/context/MacOs/Windows.hpp | 2 +- gale/context/MacOs/Windows.mm | 74 ++++++++++++++++++++++++--------- 6 files changed, 73 insertions(+), 27 deletions(-) diff --git a/gale/context/IOs/AppDelegate.mm b/gale/context/IOs/AppDelegate.mm index 2638776..a745f7b 100644 --- a/gale/context/IOs/AppDelegate.mm +++ b/gale/context/IOs/AppDelegate.mm @@ -5,7 +5,7 @@ */ #import -#include "gale/context/IOs/Interface.hpp" +#include "gale/context/IOs/Interface.h" #import #import diff --git a/gale/context/IOs/Context.cpp b/gale/context/IOs/Context.cpp index c14c417..0f23367 100644 --- a/gale/context/IOs/Context.cpp +++ b/gale/context/IOs/Context.cpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include class MacOSInterface : public gale::Context { private: diff --git a/gale/context/MacOs/Context.mm b/gale/context/MacOs/Context.mm index 36711a4..66b7713 100644 --- a/gale/context/MacOs/Context.mm +++ b/gale/context/MacOs/Context.mm @@ -27,7 +27,7 @@ #include #include #include -#include +#include #import diff --git a/gale/context/MacOs/Interface.mm b/gale/context/MacOs/Interface.mm index 2a61b02..95d360b 100644 --- a/gale/context/MacOs/Interface.mm +++ b/gale/context/MacOs/Interface.mm @@ -55,16 +55,26 @@ int mm_main(int _argc, const char* _argv[]) { // -- basic windows creation : // --------------------------------------------------------------- // create a windows of size 800/600 - window = [ [ [GaleMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) - styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO] - autorelease]; + #ifdef __MAC_10_12 + window = [ [ [GaleMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) + styleMask:(NSWindowStyleMaskTitled|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskClosable) backing:NSBackingStoreBuffered defer:NO] + autorelease]; + #else + window = [ [ [GaleMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) + styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO] + autorelease]; + #endif [window setAcceptsMouseMovedEvents:YES]; //id window = [ [MacOsAppDelegate alloc] autorelease]; // set the windows at a specific position : [window cascadeTopLeftFromPoint:NSMakePoint(50,50)]; // set the windows resizable - [window setStyleMask:[window styleMask] | NSResizableWindowMask]; + #ifdef __MAC_10_12 + [window setStyleMask:[window styleMask] | NSWindowStyleMaskResizable]; + #else + [window setStyleMask:[window styleMask] | NSResizableWindowMask]; + #endif // oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask]; // set the title [window setTitle:appName]; diff --git a/gale/context/MacOs/Windows.hpp b/gale/context/MacOs/Windows.hpp index f319167..28eb4db 100644 --- a/gale/context/MacOs/Windows.hpp +++ b/gale/context/MacOs/Windows.hpp @@ -5,7 +5,7 @@ */ #import -#import +#import @interface GaleMainWindows : NSWindow { OpenGLView* _view; diff --git a/gale/context/MacOs/Windows.mm b/gale/context/MacOs/Windows.mm index 3b5b18d..8ef8b6c 100644 --- a/gale/context/MacOs/Windows.mm +++ b/gale/context/MacOs/Windows.mm @@ -30,7 +30,11 @@ [windowsID cascadeTopLeftFromPoint:NSMakePoint(50,50)]; GALE_DEBUG("ALLOCATE ..."); // set the windows resizable - [windowsID setStyleMask:[windowsID styleMask] | NSResizableWindowMask]; + #ifdef __MAC_10_12 + [windowsID setStyleMask:[windowsID styleMask] | NSWindowStyleMaskResizable]; + #else + [windowsID setStyleMask:[windowsID styleMask] | NSResizableWindowMask]; + #endif GALE_DEBUG("ALLOCATE ..."); // oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask]; // set the title @@ -175,8 +179,12 @@ static gale::key::Special guiKeyBoardMode; } - (void)flagsChanged:(NSEvent *)theEvent { - if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) { - GALE_VERBOSE("NSAlphaShiftKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagCapsLock) != 0) { + #else + if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagCapsLock"); if (guiKeyBoardMode.getCapsLock() == false) { guiKeyBoardMode.setCapsLock(true); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::capLock, true, false); @@ -188,8 +196,12 @@ static gale::key::Special guiKeyBoardMode; } } - if (([theEvent modifierFlags] & NSShiftKeyMask) != 0) { - GALE_VERBOSE("NSShiftKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagShift) != 0) { + #else + if (([theEvent modifierFlags] & NSShiftKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagShift"); if (guiKeyBoardMode.getShift() == false) { guiKeyBoardMode.setShift(true); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::shiftLeft, true, false); @@ -201,23 +213,31 @@ static gale::key::Special guiKeyBoardMode; } } - if (([theEvent modifierFlags] & NSControlKeyMask) != 0) { - //GALE_VERBOSE("NSControlKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagControl) != 0) { + #else + if (([theEvent modifierFlags] & NSControlKeyMask) != 0) { + #endif + //GALE_VERBOSE("NSEventModifierFlagControl"); if (guiKeyBoardMode.getCtrl() == false) { - GALE_VERBOSE("NSControlKeyMask DOWN"); + GALE_VERBOSE("NSEventModifierFlagControl DOWN"); guiKeyBoardMode.setCtrl(true); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::ctrlLeft, true, false); } } else { if (guiKeyBoardMode.getCtrl() == true) { - GALE_VERBOSE("NSControlKeyMask UP"); + GALE_VERBOSE("NSEventModifierFlagControl UP"); guiKeyBoardMode.setCtrl(false); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::ctrlLeft, false, false); } } - if (([theEvent modifierFlags] & NSAlternateKeyMask) != 0) { - GALE_VERBOSE("NSAlternateKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagOption) != 0) { + #else + if (([theEvent modifierFlags] & NSAlternateKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagOption"); if (guiKeyBoardMode.getAlt() == false) { guiKeyBoardMode.setAlt(true); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::alt, true, false); @@ -229,8 +249,12 @@ static gale::key::Special guiKeyBoardMode; } } - if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) { - GALE_VERBOSE("NSCommandKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagCommand) != 0) { + #else + if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagCommand"); if (guiKeyBoardMode.getMeta() == false) { guiKeyBoardMode.setMeta(true); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::metaLeft, true, false); @@ -242,8 +266,12 @@ static gale::key::Special guiKeyBoardMode; } } - if (([theEvent modifierFlags] & NSNumericPadKeyMask) != 0) { - GALE_VERBOSE("NSNumericPadKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagNumericPad) != 0) { + #else + if (([theEvent modifierFlags] & NSNumericPadKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagNumericPad"); if (guiKeyBoardMode.getNumLock() == false) { guiKeyBoardMode.setNumLock(true); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::numLock, true, false); @@ -254,11 +282,19 @@ static gale::key::Special guiKeyBoardMode; MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::numLock, false, false); } } - if (([theEvent modifierFlags] & NSHelpKeyMask) != 0) { - GALE_VERBOSE("NSHelpKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagHelp) != 0) { + #else + if (([theEvent modifierFlags] & NSHelpKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagHelp"); } - if (([theEvent modifierFlags] & NSFunctionKeyMask) != 0) { - GALE_VERBOSE("NSFunctionKeyMask"); + #ifdef __MAC_10_12 + if (([theEvent modifierFlags] & NSEventModifierFlagFunction) != 0) { + #else + if (([theEvent modifierFlags] & NSFunctionKeyMask) != 0) { + #endif + GALE_VERBOSE("NSEventModifierFlagFunction"); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::contextMenu, true, false); MacOs::setKeyboardMove(guiKeyBoardMode, gale::key::keyboard::contextMenu, false, false); }