From 9a4abe8bded76dc9f64653e9a6d4db80e6f80446 Mon Sep 17 00:00:00 2001 From: Omar Mohamed Ali Mudhir Date: Wed, 25 Jan 2017 19:06:49 +0000 Subject: [PATCH] added partial mouse events on osx --- data/layout.xml | 73 ++++++++++++++++++++++++++++--------------------- engine/app.cpp | 13 +++++++++ engine/app.hpp | 3 ++ engine/main.cpp | 15 ++++++++++ 4 files changed, 73 insertions(+), 31 deletions(-) diff --git a/data/layout.xml b/data/layout.xml index 58a0496..34bb991 100644 --- a/data/layout.xml +++ b/data/layout.xml @@ -1,34 +1,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/engine/app.cpp b/engine/app.cpp index 43ffb18..b1cdb7e 100644 --- a/engine/app.cpp +++ b/engine/app.cpp @@ -486,3 +486,16 @@ void App::resize(float w, float h) YGNodeStyleSetHeight(y_root, height); update_layout(); } + +void App::mouse_down(int button, float x, float y) +{ + printf("mouse click %f %f\n", x, y); +} +void App::mouse_move(float x, float y) +{ + +} +void App::mouse_up(int button, float x, float y) +{ + +} diff --git a/engine/app.hpp b/engine/app.hpp index 6a2a173..7379b5a 100644 --- a/engine/app.hpp +++ b/engine/app.hpp @@ -26,6 +26,9 @@ public: void create(); void update(float dt); void resize(float w, float h); + void mouse_down(int button, float x, float y); + void mouse_move(float x, float y); + void mouse_up(int button, float x, float y); void update_layout(); void load_layout(); }; diff --git a/engine/main.cpp b/engine/main.cpp index 169ba50..eb85af2 100644 --- a/engine/main.cpp +++ b/engine/main.cpp @@ -192,6 +192,21 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime [super renewGState]; } +- (void)mouseDown:(NSEvent *)theEvent +{ + auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + App::I.mouse_down(0, mouseLoc.x, mouseLoc.y); +} +- (void)mouseUp:(NSEvent *)theEvent +{ + auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + App::I.mouse_up(0, mouseLoc.x, mouseLoc.y); +} +- (void)mouseMoved:(NSEvent *)theEvent +{ + auto mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil]; + App::I.mouse_move(mouseLoc.x, mouseLoc.y); +} @end @interface Window : NSWindow