diff --git a/ewol/context/Context.cpp b/ewol/context/Context.cpp index 6fa97098..0aabb04b 100644 --- a/ewol/context/Context.cpp +++ b/ewol/context/Context.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -329,7 +330,14 @@ ewol::Context::Context(ewol::context::Application* _application, int32_t _argc, m_displayFps=true; } else if ( m_commandLine.get(iii) == "-h" || m_commandLine.get(iii) == "--help") { - // TODO ... + EWOL_PRINT("ewol - help : "); + EWOL_PRINT(" " << etk::getApplicationName() << " [options]"); + EWOL_PRINT(" --ewol-fps: Display the current fps of the display"); + EWOL_PRINT(" -h/--help: Display this help"); + EWOL_PRINT(" example:"); + EWOL_PRINT(" " << etk::getApplicationName() << " --ewol-fps"); + // this is a global help system does not remove it + continue; } else { continue; } diff --git a/ewol/context/MacOs/Context.h b/ewol/context/MacOs/Context.h index e7a5c474..3a62c5c2 100644 --- a/ewol/context/MacOs/Context.h +++ b/ewol/context/MacOs/Context.h @@ -24,6 +24,7 @@ namespace MacOs { void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey); void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown, bool _isAReapeateKey); void stopRequested(); + void setRedrawCallback(const std::function& _func); }; #endif \ No newline at end of file diff --git a/ewol/context/MacOs/Context.mm b/ewol/context/MacOs/Context.mm index 02d4c188..0a09c284 100644 --- a/ewol/context/MacOs/Context.mm +++ b/ewol/context/MacOs/Context.mm @@ -211,6 +211,13 @@ void MacOs::stopRequested() { interface->MAC_Stop(); } +void MacOs::setRedrawCallback(const std::function& _func) { + if (interface == nullptr) { + return; + } + interface->getWidgetManager().setCallbackonRedrawNeeded(_func); +} + /** * @brief Main of the program * @param std IO diff --git a/ewol/context/MacOs/Interface.mm b/ewol/context/MacOs/Interface.mm index cade83e3..f8b6d0ba 100644 --- a/ewol/context/MacOs/Interface.mm +++ b/ewol/context/MacOs/Interface.mm @@ -5,7 +5,7 @@ * * @license APACHE v2.0 (see license file) */ - +#include "Context.h" #import #include "ewol/context/MacOs/Interface.h" @@ -16,6 +16,11 @@ id window = nil; +void callbackSomeThingToDo() { + //EWOL_CRITICAL("ksdjlkqjsdlfkjsqdlkfjslqkdjflqksjdf"); + [window UpdateScreenRequested]; +} + int mm_main(int _argc, const char* _argv[]) { [NSAutoreleasePool new]; @@ -74,23 +79,16 @@ 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 + NSTrackingArea *track = [[NSTrackingArea alloc] initWithRect:window_frame options: NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder | NSTrackingActiveInKeyWindow owner:window userInfo:nil]; - [view addTrackingArea:track]; + [view addTrackingArea:track]; [window setContentView:view]; [view setAutoresizesSubviews:YES]; - - // Override point for customization after application launch. - //[window addSubview:view]; - //[window addChildWindow:view]; - //[window makeKeyAndVisible]; - - //[window setDelegate:view]; - // return no error return 0; } int mm_run(void) { + //MacOs::setRedrawCallback(std::bind(callbackSomeThingToDo)); [NSApp run]; EWOL_DEBUG("END of application"); // return no error diff --git a/ewol/context/MacOs/OpenglView.h b/ewol/context/MacOs/OpenglView.h index 8a57b9cd..1154bf76 100644 --- a/ewol/context/MacOs/OpenglView.h +++ b/ewol/context/MacOs/OpenglView.h @@ -13,7 +13,9 @@ @interface OpenGLView : NSOpenGLView { NSTimer* _refreshTimer; + bool _redraw; } - (void)prepareOpenGL; - (void)drawRect:(NSRect) bounds; +- (void)UpdateScreenRequested; @end diff --git a/ewol/context/MacOs/OpenglView.mm b/ewol/context/MacOs/OpenglView.mm index cbf8469e..8fec1d55 100644 --- a/ewol/context/MacOs/OpenglView.mm +++ b/ewol/context/MacOs/OpenglView.mm @@ -30,13 +30,17 @@ 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 ] ; + _refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ; + _redraw = true; } +- (void)UpdateScreenRequested { + _redraw = true; +} -(void) drawRect: (NSRect) bounds { if ( ! _refreshTimer ) { - //_refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ; + _refreshTimer=[ [ NSTimer scheduledTimerWithTimeInterval:0.017 target:self selector:@selector(animationTimerFired:) userInfo:nil repeats:YES ] retain ] ; EWOL_WARNING("create timer ... "); } MacOs::draw(false); @@ -46,8 +50,11 @@ * Service the animation timer. */ - (void) animationTimerFired: (NSTimer *) timer { - [self setNeedsDisplay:YES]; - EWOL_WARNING("view refresh ..." ); + if (_redraw == true) { + //_redraw = false; + [self setNeedsDisplay:YES]; + //EWOL_WARNING("view refresh ..." ); + } } -(void)reshape { diff --git a/ewol/context/MacOs/Windows.h b/ewol/context/MacOs/Windows.h index aacf94ae..6ea8de69 100644 --- a/ewol/context/MacOs/Windows.h +++ b/ewol/context/MacOs/Windows.h @@ -7,9 +7,10 @@ */ #import +#import @interface EwolMainWindows : NSWindow { - + OpenGLView* _view; } + (id)alloc; - (id)init; @@ -32,6 +33,7 @@ - (void)keyDown:(NSEvent *)theEvent; - (void)flagsChanged:(NSEvent *)theEvent; - (void)closeRequestEwol; +- (void)UpdateScreenRequested; @end diff --git a/ewol/context/MacOs/Windows.mm b/ewol/context/MacOs/Windows.mm index c0605fe9..dd4e2183 100644 --- a/ewol/context/MacOs/Windows.mm +++ b/ewol/context/MacOs/Windows.mm @@ -8,7 +8,6 @@ #import -#import #include #include @@ -52,11 +51,11 @@ NSRect window_frame = [windowsID frame]; EWOL_DEBUG("ALLOCATE ..."); - OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)]; + _view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)]; EWOL_DEBUG("ALLOCATE ..."); - [windowsID setContentView:view]; + [windowsID setContentView:_view]; EWOL_DEBUG("ALLOCATE ..."); - [view setAutoresizesSubviews:YES]; + [_view setAutoresizesSubviews:YES]; EWOL_DEBUG("ALLOCATE ..."); // Override point for customization after application launch. @@ -79,7 +78,6 @@ + (void)performClose:(id)sender { EWOL_ERROR("perform close ..."); } - static ewol::key::Special guiKeyBoardMode; @@ -436,6 +434,9 @@ static ewol::key::Special guiKeyBoardMode; MacOs::stopRequested(); } +- (void)UpdateScreenRequested { + [_view UpdateScreenRequested]; +} @end diff --git a/ewol/widget/Manager.cpp b/ewol/widget/Manager.cpp index dbd45161..ead8e708 100644 --- a/ewol/widget/Manager.cpp +++ b/ewol/widget/Manager.cpp @@ -157,48 +157,18 @@ void ewol::widget::Manager::focusRemoveIfRemove(const std::shared_ptr= 0 ; iii--) { - auto tmpWidget = m_listOfPeriodicWidget[iii].lock(); - if (nullptr != tmpWidget) { - int64_t deltaTimeCallUser = tmpWidget->systemGetCallDeltaTime(); - if (deltaTimeCallUser <= 0) { - myTime.setDeltaCall(deltaTime); - EWOL_VERBOSE("[" << iii << "] periodic : " << myTime); - tmpWidget->systemSetLastCallTime(_localTime); - tmpWidget->periodicCall(myTime); - } else { - int64_t lastCallTime = tmpWidget->systemGetLastCallTime(); - if (lastCallTime == 0) { - lastCallTime = _localTime; - } - float deltaLocalTime = (float)(_localTime-lastCallTime)/1000000.0;; - if (deltaLocalTime >= lastCallTime) { - myTime.setDeltaCall(deltaLocalTime); - EWOL_VERBOSE("[" << iii << "] periodic : " << myTime); - tmpWidget->systemSetLastCallTime(_localTime); - tmpWidget->periodicCall(myTime); - } - } - } - } +void ewol::widget::Manager::setCallbackonRedrawNeeded(const std::function& _func) { + m_funcRedrawNeeded = _func; } -*/ - void ewol::widget::Manager::markDrawingIsNeeded() { + if (m_haveRedraw == true) { + return; + } m_haveRedraw = true; + if (m_funcRedrawNeeded != nullptr) { + m_funcRedrawNeeded(); + } } bool ewol::widget::Manager::isDrawingNeeded() { diff --git a/ewol/widget/Manager.h b/ewol/widget/Manager.h index f3bcea8b..c839c921 100644 --- a/ewol/widget/Manager.h +++ b/ewol/widget/Manager.h @@ -36,9 +36,12 @@ namespace ewol { void focusRelease(); // release focus from the current widget to the default std::shared_ptr focusGet(); void focusRemoveIfRemove(const std::shared_ptr& _newWidget); - + private: + std::function m_funcRedrawNeeded; + public: void markDrawingIsNeeded(); bool isDrawingNeeded(); + void setCallbackonRedrawNeeded(const std::function& _func); // element that generate the list of elements void addWidgetCreator(const std::string& _name, creator_tf _pointer);