[DEV] mac work again but not ended anymore

This commit is contained in:
Edouard DUPIN 2013-09-25 15:25:47 +02:00
parent 21f0a6856a
commit 5ca92a90cb
8 changed files with 172 additions and 215 deletions

2
external/etk vendored

@ -1 +1 @@
Subproject commit bb085be53d88d727686a5e23aa7c3e2cb2caf7f5
Subproject commit 1826eb6fd917c330ecabbfb7333a509044673964

View File

@ -7,8 +7,8 @@
*/
#import <ewol/renderer/os/gui.MacOs.AppDelegate.h>
#import <ewol/renderer/os/gui.MacOs.OpenglView.h>
#import <ewol/renderer/MacOs/AppDelegate.h>
#import <ewol/renderer/MacOs/OpenglView.h>
@implementation MacOsAppDelegate

View File

@ -10,15 +10,17 @@
#include <ewol/debug.h>
#include <ewol/ewol.h>
#include <ewol/key.h>
#include <ewol/config.h>
#include <ewol/commandLine.h>
#include <etk/UString.h>
#include <etk/unicode.h>
#include <etk/os/FSNode.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/renderer/ResourceManager.h>
#include <ewol/renderer/eSystem.h>
#include <ewol/resources/ResourceManager.h>
#include <ewol/renderer/eContext.h>
#include <ewol/renderer/MacOs/Interface.h>
#include <ewol/renderer/MacOs/Context.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@ -30,7 +32,7 @@
#include <mach/mach.h>
int64_t guiInterface::GetTime(void)
int64_t ewol::GetTime(void)
{
struct timespec now;
clock_serv_t cclock;
@ -45,144 +47,120 @@ int64_t guiInterface::GetTime(void)
}
#undef __class__
#define __class__ "guiInterface"
#define __class__ "MacOSInterface"
static ewol::SpecialKey guiKeyBoardMode;
/**
* @brief Set the new title of the windows
* @param title New desired title
* @return ---
*/
void guiInterface::SetTitle(etk::UString& title)
class MacOSInterface : public ewol::eContext
{
EWOL_INFO("X11: Set Title (START)");
EWOL_INFO("X11: Set Title (END)");
}
void guiInterface::SetIcon(etk::UString inputFile)
private:
ewol::SpecialKey m_guiKeyBoardMode;
public:
MacOSInterface(int32_t _argc, const char* _argv[]) :
ewol::eContext(_argc, _argv)
{
EWOL_TODO("plop");
mm_main(_argc, _argv);
}
void RemoveDecoration(void)
int32_t Run(void)
{
EWOL_TODO("X11:RemoveDecoration");
return mm_run();
}
public:
//interface MacOS :
void AddDecoration(void)
bool MAC_Draw(bool _displayEveryTime)
{
EWOL_TODO("X11:AddDecoration");
return OS_Draw(_displayEveryTime);
}
// -------------------------------------------------------------------------
// ClipBoard AREA :
// -------------------------------------------------------------------------
void guiInterface::ClipBoardGet(ewol::clipBoard::clipboardListe_te clipboardID)
void MAC_Resize(float _x, float _y)
{
OS_Resize(vec2(_x,_y));
}
void guiInterface::ClipBoardSet(ewol::clipBoard::clipboardListe_te clipboardID)
void MAC_SetMouseState(int32_t _id, bool _isDown, float _x, float _y)
{
OS_SetMouseState(_id, _isDown, vec2(_x, _y));
}
#undef __class__
#define __class__ "guiInterface"
void guiInterface::Stop(void)
void MAC_SetMouseMotion(int32_t _id, float _x, float _y)
{
EWOL_INFO("X11-API: Stop");
OS_SetMouseMotion(_id, vec2(_x, _y));
}
void guiInterface::KeyboardShow(void)
void MAC_SetKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey)
{
// nothing to do : No keyboard on computer ...
if (_unichar == '\r') {
_unichar = '\n';
}
EWOL_DEBUG("key: " << _unichar << " up=" << !_isDown);
OS_SetKeyboard(_keyboardMode, _unichar, !_isDown, _isAReapeateKey);
}
};
void guiInterface::KeyboardHide(void)
MacOSInterface* interface = NULL;
bool MacOs::Draw(bool _displayEveryTime)
{
// nothing to do : No keyboard on computer ...
if (interface == NULL) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void guiInterface::ChangeSize(ivec2 size)
void MacOs::Resize(float _x, float _y)
{
EWOL_INFO("X11-API: ChangeSize=" << size);
if (interface == NULL) {
return;
}
interface->MAC_Resize(_x, _y);
}
void guiInterface::ChangePos(ivec2 pos)
void MacOs::SetMouseState(int32_t _id, bool _isDown, float _x, float _y)
{
EWOL_INFO("X11-API: ChangePos=" << pos);
if (interface == NULL) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void guiInterface::GetAbsPos(ivec2& pos)
void MacOs::SetMouseMotion(int32_t _id, float _x, float _y)
{
EWOL_INFO("X11-API: GetAbsPos");
if (interface == NULL) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
// select the current cursor to display :
static ewol::cursorDisplay_te l_currentCursor = ewol::cursorArrow;
void guiInterface::SetCursor(ewol::cursorDisplay_te newCursor)
void MacOs::SetKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey)
{
if (newCursor != l_currentCursor) {
EWOL_DEBUG("X11-API: Set New Cursor : " << newCursor);
// set the new one :
l_currentCursor = newCursor;
if (interface == NULL) {
return;
}
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
}
void guiInterface::GrabPointerEvents(bool isGrabbed, vec2 forcedPosition)
{
}
#include <ewol/renderer/os/gui.MacOs.Interface.h>
/**
* @brief Main of the program
* @param std IO
* @return std IO
*/
int guiInterface::main(int argc, const char *argv[])
int ewol::Run(int _argc, const char *_argv[])
{
//start the basic thread :
eSystem::Init();
// Run ...
int ret = mm_main(argc, argv);
EWOL_INFO("Return main value=" << ret);
// close X11 :
guiInterface::Stop();
// uninit ALL :
eSystem::UnInit();
return 0;
etk::SetArgZero(_argv[0]);
interface = new MacOSInterface(_argc, _argv);
if (NULL == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2;
}
void guiInterface::ForceOrientation(ewol::orientation_te orientation)
{
// nothing to do ...
int32_t retValue = interface->Run();
delete(interface);
interface = NULL;
return retValue;
}
@ -190,3 +168,4 @@ void guiInterface::ForceOrientation(ewol::orientation_te orientation)

View File

@ -0,0 +1,31 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __MAC_OS_CONTEXT_H__
#define __MAC_OS_CONTEXT_H__
#include <ewol/key.h>
namespace MacOs
{
// return true if a flush is needed
bool Draw(bool _displayEveryTime);
/**
* @brief The OS inform that the current windows has change his size.
* @param[in] _size new size of the windows.
*/
void Resize(float _x, float _y);
void SetMouseState(int32_t _id, bool _isDown, float _x, float _y);
void SetMouseMotion(int32_t _id, float _x, float _y);
void SetKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
};
#endif

View File

@ -14,6 +14,7 @@ extern "C" {
#endif
int mm_main(int argc, const char *argv[]);
int mm_run(void);
#ifdef __cplusplus
}

View File

@ -6,26 +6,11 @@
* @license BSD v3 (see license file)
*/
/*
#import <Cocoa/Cocoa.h>
#import <ewol/renderer/os/gui.MacOs.Interface.h>
#include <ewol/renderer/os/gui.MacOs.AppDelegate.h>
#include "ewol/renderer/MacOs/Interface.h"
int mm_main(int argc, const char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}
*/
#import <Cocoa/Cocoa.h>
#include "ewol/renderer/os/gui.MacOs.Interface.h"
#import <ewol/renderer/os/gui.MacOs.OpenglView.h>
#import <ewol/renderer/os/gui.MacOs.AppDelegate.h>
#import <ewol/renderer/MacOs/OpenglView.h>
#import <ewol/renderer/MacOs/AppDelegate.h>
int mm_main(int argc, const char *argv[])
{
@ -92,58 +77,14 @@ int mm_main(int argc, const char *argv[])
//[window makeKeyAndVisible];
[window setDelegate:view];
// start application :
// return no error
return 0;
}
int mm_run(void)
{
[NSApp run];
// return no error
return 0;
}
/*
NSView* view0 = ...; // a view made with IB
NSView* view1 = ... ;// another view made with IB
NSWindow* window = [self window];
NSRect window_frame = [window frame];
NSView* cv = [[[NSView alloc] initWithFrame:window_frame] autorelease];
[window setContentView:cv];
[cv setAutoresizesSubviews:YES];
// add subview so it fits within the contentview frame
{
NSView* v = view0;
NSRect vframe = [v frame];
[v setHidden:YES];
[v setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
NSView* tmp_superview = [[[NSView alloc] initWithFrame:vframe] autorelease];
[tmp_superview addSubview:v];
[tmp_superview setAutoresizesSubviews:YES];
[tmp_superview setFrame:window_frame];
[v removeFromSuperview];
[cv addSubview:v];
}
// add subview so it fits within the contentview frame
{
NSView* v = view1;
NSRect vframe = [v frame];
[v setHidden:YES];
[v setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
NSView* tmp_superview = [[[NSView alloc] initWithFrame:vframe] autorelease];
[tmp_superview addSubview:v];
[tmp_superview setAutoresizesSubviews:YES];
[tmp_superview setFrame:window_frame];
[v removeFromSuperview];
[cv addSubview:v];
}
[view0 setHidden:NO];
*/

View File

@ -7,9 +7,9 @@
*/
#import <ewol/renderer/os/gui.MacOs.OpenglView.h>
#import <ewol/renderer/MacOs/OpenglView.h>
#include <OpenGL/gl.h>
#include <ewol/renderer/eSystem.h>
#include <ewol/renderer/MacOS/Context.h>
#include <ewol/debug.h>
#include <ewol/Dimension.h>
@ -39,7 +39,7 @@ static ewol::SpecialKey guiKeyBoardMode;
-(void) drawRect: (NSRect) bounds
{
eSystem::Draw(true);
MacOs::Draw(true);
glFlush();
}
@ -50,7 +50,7 @@ static ewol::SpecialKey guiKeyBoardMode;
// but they are floats
float width = [self frame].size.width;
float height = [self frame].size.height;
eSystem::Resize(width,height);
MacOs::Resize(width,height);
}
@ -58,22 +58,22 @@ static ewol::SpecialKey guiKeyBoardMode;
NSPoint point = [event locationInWindow];
//float x = [event locationInWindow].x; //point.x;
//EWOL_INFO("mouseDown : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseState(1, true, point.x, point.y);
MacOs::SetMouseState(1, true, point.x, point.y);
}
-(void)mouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("mouseDragged : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseMotion(1, point.x, point.y);
MacOs::SetMouseMotion(1, point.x, point.y);
}
-(void)mouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("mouseUp : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseState(1, false, point.x, point.y);
MacOs::SetMouseState(1, false, point.x, point.y);
}
-(void)mouseMoved:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("mouseMoved : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseMotion(0, point.x, point.y);
MacOs::SetMouseMotion(0, point.x, point.y);
}
-(void)mouseEntered:(NSEvent *)event {
NSPoint point = [event locationInWindow];
@ -86,17 +86,17 @@ static ewol::SpecialKey guiKeyBoardMode;
-(void)rightMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("rightMouseDown : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseState(3, true, point.x, point.y);
MacOs::SetMouseState(3, true, point.x, point.y);
}
-(void)rightMouseDragged:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("rightMouseDragged : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseMotion(3, point.x, point.y);
MacOs::SetMouseMotion(3, point.x, point.y);
}
-(void)rightMouseUp:(NSEvent *)event {
NSPoint point = [event locationInWindow];
//EWOL_INFO("rightMouseUp : " << (float)point.x << " " << (float)point.y);
eSystem::SetMouseState(3, false, point.x, point.y);
MacOs::SetMouseState(3, false, point.x, point.y);
}
-(void)otherMouseDown:(NSEvent *)event {
NSPoint point = [event locationInWindow];
@ -123,8 +123,8 @@ static ewol::SpecialKey guiKeyBoardMode;
return;
}
for (float iii=abs(deltaY) ; iii>=0.0f ; iii-=1.0f) {
eSystem::SetMouseState(idEvent, true , point.x, point.y);
eSystem::SetMouseState(idEvent, false, point.x, point.y);
MacOs::SetMouseState(idEvent, true , point.x, point.y);
MacOs::SetMouseState(idEvent, false, point.x, point.y);
}
}
/*
@ -146,16 +146,18 @@ static ewol::SpecialKey guiKeyBoardMode;
thisIsAReapeateKey = true;
}
NSString *str = [theEvent charactersIgnoringModifiers];
// TODO : set if for every char in the string !!!
unichar c = [str characterAtIndex:0];
/*
if (c < ' ' || c > '~') { // only ASCII please
c = 0;
return;
}
EWOL_DEBUG("KeyDown " << (char)c);
eSystem::SetKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
*/
//EWOL_DEBUG("KeyDown " << (char)c);
MacOs::SetKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
if (true==thisIsAReapeateKey) {
eSystem::SetKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
MacOs::SetKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
}
}
@ -164,17 +166,18 @@ static ewol::SpecialKey guiKeyBoardMode;
if ([theEvent isARepeat]) {
thisIsAReapeateKey = true;
}
EWOL_DEBUG("KeyUp ");
//EWOL_DEBUG("KeyUp ");
NSString *str = [theEvent charactersIgnoringModifiers];
unichar c = [str characterAtIndex:0];
/*
if (c < ' ' || c > '~') { // only ASCII please
c = 0;
return;
}
eSystem::SetKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
*/
MacOs::SetKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
if (true==thisIsAReapeateKey) {
eSystem::SetKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
MacOs::SetKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
}
}

View File

@ -13,6 +13,7 @@
#include <ewol/commandLine.h>
#include <etk/UString.h>
#include <etk/unicode.h>
#include <etk/os/FSNode.h>
#include <ewol/widget/WidgetManager.h>
#include <ewol/resources/ResourceManager.h>
@ -1285,6 +1286,7 @@ class X11Interface : public ewol::eContext
*/
int ewol::Run(int _argc, const char *_argv[])
{
etk::SetArgZero(_argv[0]);
X11Interface* interface = new X11Interface(_argc, _argv);
if (NULL == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");