[DEV] better work on MacOS
This commit is contained in:
parent
546c90d972
commit
3e617536af
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 8d7bd46da421fe42eff61cd76543992e53acba48
|
Subproject commit a61639ef292b617a86a07fe30770d8533c17159b
|
@ -290,7 +290,7 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
|
|||||||
// set the curent interface :
|
// set the curent interface :
|
||||||
lockContext();
|
lockContext();
|
||||||
// parse the debug level:
|
// 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") {
|
if (m_commandLine.get(iii) == "-l0") {
|
||||||
debug::setGeneralLevel(etk::logLevelNone);
|
debug::setGeneralLevel(etk::logLevelNone);
|
||||||
} else if (m_commandLine.get(iii) == "-l1") {
|
} else if (m_commandLine.get(iii) == "-l1") {
|
||||||
@ -316,7 +316,9 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_commandLine.remove(iii);
|
m_commandLine.remove(iii);
|
||||||
|
--iii;
|
||||||
}
|
}
|
||||||
|
//etk::cout.setOutputFile(true);
|
||||||
|
|
||||||
EWOL_INFO("EWOL v:" << ewol::getVersion());
|
EWOL_INFO("EWOL v:" << ewol::getVersion());
|
||||||
EWOL_INFO("Build Date: " << date::getYear() << "/" << date::getMonth() << "/" << date::getDay() << " " << date::getHour() << "h" << date::getMinute());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
//EWOL_DEBUG("DRAW");
|
||||||
m_previousDisplayTime = currentTime;
|
m_previousDisplayTime = currentTime;
|
||||||
|
|
||||||
// process the events
|
// process the events
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#import <ewol/context/MacOs/Windows.h>
|
#import <ewol/context/MacOs/Windows.h>
|
||||||
#import <ewol/context/MacOs/AppDelegate.h>
|
#import <ewol/context/MacOs/AppDelegate.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int mm_main(int argc, const char *argv[]) {
|
int mm_main(int argc, const char *argv[]) {
|
||||||
[NSAutoreleasePool new];
|
[NSAutoreleasePool new];
|
||||||
|
|
||||||
@ -46,13 +48,13 @@ int mm_main(int argc, const char *argv[]) {
|
|||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// -- basic windows creation :
|
// -- basic windows creation :
|
||||||
// ---------------------------------------------------------------
|
// ----------------------- ----------------------------------------
|
||||||
// create a windows of size 800/600
|
// create a windows of size 800/600
|
||||||
#if 1
|
#if 1
|
||||||
id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
||||||
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
|
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
|
||||||
autorelease];
|
autorelease];
|
||||||
|
[window setAcceptsMouseMovedEvents:YES];
|
||||||
//id window = [ [MacOsAppDelegate alloc] autorelease];
|
//id window = [ [MacOsAppDelegate alloc] autorelease];
|
||||||
|
|
||||||
// set the windows at a specific position :
|
// set the windows at a specific position :
|
||||||
@ -71,6 +73,9 @@ int mm_main(int argc, const char *argv[]) {
|
|||||||
NSRect window_frame = [window frame];
|
NSRect window_frame = [window frame];
|
||||||
|
|
||||||
OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
|
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];
|
[window setContentView:view];
|
||||||
[view setAutoresizesSubviews:YES];
|
[view setAutoresizesSubviews:YES];
|
||||||
|
|
||||||
|
@ -6,11 +6,13 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#import <OpenGL/OpenGL.h>
|
||||||
|
#import <OpenGL/gl.h>
|
||||||
|
|
||||||
|
|
||||||
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
|
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
|
||||||
|
NSTimer* _refreshTimer;
|
||||||
}
|
}
|
||||||
- (void)prepareOpenGL;
|
- (void)prepareOpenGL;
|
||||||
- (void)drawRect:(NSRect) bounds;
|
- (void)drawRect:(NSRect) bounds;
|
||||||
@ -30,5 +32,3 @@
|
|||||||
- (void)keyDown:(NSEvent *)theEvent;
|
- (void)keyDown:(NSEvent *)theEvent;
|
||||||
- (void)flagsChanged:(NSEvent *)theEvent;
|
- (void)flagsChanged:(NSEvent *)theEvent;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/Dimension.h>
|
#include <ewol/Dimension.h>
|
||||||
|
|
||||||
|
|
||||||
@implementation OpenGLView
|
@implementation OpenGLView
|
||||||
|
|
||||||
static ewol::key::Special guiKeyBoardMode;
|
static ewol::key::Special guiKeyBoardMode;
|
||||||
@ -22,7 +23,6 @@ static ewol::key::Special guiKeyBoardMode;
|
|||||||
EWOL_ERROR("prepare");
|
EWOL_ERROR("prepare");
|
||||||
GLint swapInt = 1;
|
GLint swapInt = 1;
|
||||||
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
|
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
|
||||||
|
|
||||||
// set system dpi size :
|
// set system dpi size :
|
||||||
NSScreen *screen = [NSScreen mainScreen];
|
NSScreen *screen = [NSScreen mainScreen];
|
||||||
NSDictionary *description = [screen deviceDescription];
|
NSDictionary *description = [screen deviceDescription];
|
||||||
@ -32,14 +32,26 @@ static ewol::key::Special guiKeyBoardMode;
|
|||||||
ewol::Dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
|
ewol::Dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
|
||||||
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
|
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
|
||||||
ewol::Dimension::Millimeter);
|
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);
|
MacOs::draw(true);
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service the animation timer.
|
||||||
|
*/
|
||||||
|
- (void) animationTimerFired: (NSTimer *) timer {
|
||||||
|
[ self setNeedsDisplay: YES ];
|
||||||
|
//EWOL_INFO("view refresh ..." );
|
||||||
|
}
|
||||||
|
|
||||||
-(void)reshape {
|
-(void)reshape {
|
||||||
EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
|
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 {
|
-(void)mouseMoved:(NSEvent *)event {
|
||||||
NSPoint point = [event locationInWindow];
|
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);
|
MacOs::setMouseMotion(0, point.x, point.y);
|
||||||
}
|
}
|
||||||
-(void)mouseEntered:(NSEvent *)event {
|
-(void)mouseEntered:(NSEvent *)event {
|
||||||
@ -206,12 +218,15 @@ static ewol::key::Special guiKeyBoardMode;
|
|||||||
EWOL_INFO("sendEvent : " << (float)point.x << " " << (float)point.y);
|
EWOL_INFO("sendEvent : " << (float)point.x << " " << (float)point.y);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
// this generate all the event entry availlable ==> like a big keep focus ...
|
// this generate all the event entry availlable ==> like a big keep focus ...
|
||||||
- (BOOL)acceptsFirstResponder {
|
- (BOOL)acceptsFirstResponder {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
- (BOOL)becomeFirstResponder {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
*/
|
||||||
- (void)keyDown:(NSEvent *)theEvent {
|
- (void)keyDown:(NSEvent *)theEvent {
|
||||||
bool thisIsAReapeateKey = false;
|
bool thisIsAReapeateKey = false;
|
||||||
if ([theEvent isARepeat]) {
|
if ([theEvent isARepeat]) {
|
||||||
@ -242,7 +257,6 @@ static ewol::key::Special guiKeyBoardMode;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)flagsChanged:(NSEvent *)theEvent {
|
- (void)flagsChanged:(NSEvent *)theEvent {
|
||||||
|
|
||||||
if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) {
|
if (([theEvent modifierFlags] & NSAlphaShiftKeyMask) != 0) {
|
||||||
EWOL_DEBUG("NSAlphaShiftKeyMask");
|
EWOL_DEBUG("NSAlphaShiftKeyMask");
|
||||||
if (guiKeyBoardMode.getCapsLock() == false) {
|
if (guiKeyBoardMode.getCapsLock() == false) {
|
||||||
@ -339,15 +353,13 @@ static NSTimer *timer = nil;
|
|||||||
[timer invalidate];
|
[timer invalidate];
|
||||||
|
|
||||||
//game_deactivate(); // freeze, pause
|
//game_deactivate(); // freeze, pause
|
||||||
[self setNeedsDisplay:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidBecomeMain:(NSNotification *)notification {
|
- (void)windowDidBecomeMain:(NSNotification *)notification {
|
||||||
// NSLog(@"window did become main");
|
// NSLog(@"window did become main");
|
||||||
|
|
||||||
//game_activate();
|
//game_activate();
|
||||||
[self setNeedsDisplay:YES];
|
/*
|
||||||
|
|
||||||
timer = [NSTimer timerWithTimeInterval:FRAME_INTERVAL
|
timer = [NSTimer timerWithTimeInterval:FRAME_INTERVAL
|
||||||
target:self
|
target:self
|
||||||
selector:@selector(timerEvent:)
|
selector:@selector(timerEvent:)
|
||||||
@ -355,10 +367,13 @@ static NSTimer *timer = nil;
|
|||||||
repeats:YES];
|
repeats:YES];
|
||||||
|
|
||||||
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
|
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)timerEvent:(NSTimer *)t {
|
- (void)timerEvent:(NSTimer *)t {
|
||||||
//run_game();
|
//run_game();
|
||||||
[self setNeedsDisplay:YES];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface EwolMainWindows : NSWindow
|
@interface EwolMainWindows : NSWindow {
|
||||||
|
|
||||||
|
}
|
||||||
+ (id)alloc;
|
+ (id)alloc;
|
||||||
- (id)init;
|
- (id)init;
|
||||||
+ (void)dealloc;
|
+ (void)dealloc;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#import <ewol/context/MacOs/Windows.h>
|
#import <ewol/context/MacOs/Windows.h>
|
||||||
#import <ewol/context/MacOs/OpenglView.h>
|
#import <ewol/context/MacOs/OpenglView.h>
|
||||||
|
#include <ewol/context/MacOS/Context.h>
|
||||||
|
|
||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
|
|
||||||
@ -70,13 +71,39 @@
|
|||||||
//[_window release];
|
//[_window release];
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
|
|
||||||
|
/*
|
||||||
- (void)sendEvent:(NSEvent *)event {
|
- (void)sendEvent:(NSEvent *)event {
|
||||||
EWOL_WARNING(" 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
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user