[DEV] better work on MacOS

This commit is contained in:
Edouard DUPIN 2014-01-06 21:38:49 +01:00
parent 546c90d972
commit 3e617536af
7 changed files with 74 additions and 23 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit 8d7bd46da421fe42eff61cd76543992e53acba48
Subproject commit a61639ef292b617a86a07fe30770d8533c17159b

View File

@ -290,7 +290,7 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
// set the curent interface :
lockContext();
// parse the debug level:
for(int32_t iii=m_commandLine.size()-1 ; iii >= 0 ; --iii) {
for(int32_t iii = 0; iii < m_commandLine.size() ; ++iii) {
if (m_commandLine.get(iii) == "-l0") {
debug::setGeneralLevel(etk::logLevelNone);
} else if (m_commandLine.get(iii) == "-l1") {
@ -316,7 +316,9 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
continue;
}
m_commandLine.remove(iii);
--iii;
}
//etk::cout.setOutputFile(true);
EWOL_INFO("EWOL v:" << ewol::getVersion());
EWOL_INFO("Build Date: " << date::getYear() << "/" << date::getMonth() << "/" << date::getDay() << " " << date::getHour() << "h" << date::getMinute());
@ -529,7 +531,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
return false;
}
#endif
//EWOL_DEBUG("DRAW");
m_previousDisplayTime = currentTime;
// process the events

View File

@ -13,6 +13,8 @@
#import <ewol/context/MacOs/Windows.h>
#import <ewol/context/MacOs/AppDelegate.h>
int mm_main(int argc, const char *argv[]) {
[NSAutoreleasePool new];
@ -46,13 +48,13 @@ int mm_main(int argc, const char *argv[]) {
// ---------------------------------------------------------------
// -- basic windows creation :
// ---------------------------------------------------------------
// ----------------------- ----------------------------------------
// create a windows of size 800/600
#if 1
id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
autorelease];
[window setAcceptsMouseMovedEvents:YES];
//id window = [ [MacOsAppDelegate alloc] autorelease];
// set the windows at a specific position :
@ -71,6 +73,9 @@ int mm_main(int argc, const char *argv[]) {
NSRect window_frame = [window frame];
OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
NSTrackingArea *track = [[NSTrackingArea alloc] initWithRect:window_frame options: NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder | NSTrackingActiveInKeyWindow
owner:window userInfo:nil];
[view addTrackingArea:track];
[window setContentView:view];
[view setAutoresizesSubviews:YES];

View File

@ -6,11 +6,13 @@
* @license BSD v3 (see license file)
*/
#import <Cocoa/Cocoa.h>
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
NSTimer* _refreshTimer;
}
- (void)prepareOpenGL;
- (void)drawRect:(NSRect) bounds;
@ -30,5 +32,3 @@
- (void)keyDown:(NSEvent *)theEvent;
- (void)flagsChanged:(NSEvent *)theEvent;
@end

View File

@ -13,6 +13,7 @@
#include <ewol/debug.h>
#include <ewol/Dimension.h>
@implementation OpenGLView
static ewol::key::Special guiKeyBoardMode;
@ -22,7 +23,6 @@ static ewol::key::Special guiKeyBoardMode;
EWOL_ERROR("prepare");
GLint swapInt = 1;
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
// set system dpi size :
NSScreen *screen = [NSScreen mainScreen];
NSDictionary *description = [screen deviceDescription];
@ -32,14 +32,26 @@ static ewol::key::Special guiKeyBoardMode;
ewol::Dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
ewol::Dimension::Millimeter);
_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ;
}
-(void) drawRect: (NSRect) bounds
{
-(void) drawRect: (NSRect) bounds {
if ( ! _refreshTimer ) {
_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ;
}
MacOs::draw(true);
glFlush();
}
/**
* Service the animation timer.
*/
- (void) animationTimerFired: (NSTimer *) timer {
[ self setNeedsDisplay: YES ];
//EWOL_INFO("view refresh ..." );
}
-(void)reshape {
EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
@ -68,7 +80,7 @@ static ewol::key::Special guiKeyBoardMode;
}
-(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y);
EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(0, point.x, point.y);
}
-(void)mouseEntered:(NSEvent *)event {
@ -206,12 +218,15 @@ static ewol::key::Special guiKeyBoardMode;
EWOL_INFO("sendEvent : " << (float)point.x << " " << (float)point.y);
}
*/
/*
// this generate all the event entry availlable ==> like a big keep focus ...
- (BOOL)acceptsFirstResponder {
return YES;
}
- (BOOL)becomeFirstResponder {
return YES;
}
*/
- (void)keyDown:(NSEvent *)theEvent {
bool thisIsAReapeateKey = false;
if ([theEvent isARepeat]) {
@ -242,7 +257,6 @@ static ewol::key::Special guiKeyBoardMode;
}
- (void)flagsChanged:(NSEvent *)theEvent {
if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) {
EWOL_DEBUG("NSAlphaShiftKeyMask");
if (guiKeyBoardMode.getCapsLock() == false) {
@ -339,15 +353,13 @@ static NSTimer *timer = nil;
[timer invalidate];
//game_deactivate(); // freeze, pause
[self setNeedsDisplay:YES];
}
- (void)windowDidBecomeMain:(NSNotification *)notification {
// NSLog(@"window did become main");
//game_activate();
[self setNeedsDisplay:YES];
/*
timer = [NSTimer timerWithTimeInterval:FRAME_INTERVAL
target:self
selector:@selector(timerEvent:)
@ -355,10 +367,13 @@ static NSTimer *timer = nil;
repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
*/
}
- (void)timerEvent:(NSTimer *)t {
//run_game();
[self setNeedsDisplay:YES];
}
@end

View File

@ -8,7 +8,9 @@
#import <Cocoa/Cocoa.h>
@interface EwolMainWindows : NSWindow
@interface EwolMainWindows : NSWindow {
}
+ (id)alloc;
- (id)init;
+ (void)dealloc;

View File

@ -9,6 +9,7 @@
#import <ewol/context/MacOs/Windows.h>
#import <ewol/context/MacOs/OpenglView.h>
#include <ewol/context/MacOS/Context.h>
#include <ewol/debug.h>
@ -70,13 +71,39 @@
//[_window release];
[super dealloc];
}
/*
/*
- (void)sendEvent:(NSEvent *)event {
EWOL_WARNING(" EVENT ... ");
}
*/
// this generate all the event entry availlable ==> like a big keep focus ...
- (BOOL)acceptsFirstResponder {
return YES;
}
- (BOOL)becomeFirstResponder {
return YES;
}
-(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y);
MacOs::setMouseMotion(0, point.x, point.y);
}
-(void)mouseEntered:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseEntered : " << (float)point.x << " " << (float)point.y);
}
-(void)mouseExited:(NSEvent *)event {
NSPoint point = [event locationInWindow];
EWOL_INFO("mouseExited : " << (float)point.x << " " << (float)point.y);
}
@end