From 2f7bb54fcab3177ee6cee210aae6ccec2ea37bfd Mon Sep 17 00:00:00 2001 From: nick block Date: Fri, 1 Feb 2019 17:04:35 +0000 Subject: [PATCH 1/3] remove clipboard code for android --- src/CinderImGui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/CinderImGui.cpp b/src/CinderImGui.cpp index 12a83f8..45877ce 100644 --- a/src/CinderImGui.cpp +++ b/src/CinderImGui.cpp @@ -1053,7 +1053,8 @@ void initialize( const Options &options ) } renderer->initFontTexture(); -#ifndef CINDER_LINUX +#ifndef CINDER_LINUX +#ifndef CINDER_ANDROID // clipboard callbacks io.SetClipboardTextFn = []( void* user_data, const char* text ) { // clipboard text is already zero-terminated @@ -1066,6 +1067,7 @@ void initialize( const Options &options ) strCopy.push_back('\0'); return (const char *) &strCopy[0]; }; +#endif #endif // connect window's signals From 925e09789d29d0e937769995507258bd11fc3e7d Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 2 Feb 2019 11:42:15 +0000 Subject: [PATCH 2/3] implemented response to touch events, treating only first touch as same as mouse --- src/CinderImGui.cpp | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/CinderImGui.cpp b/src/CinderImGui.cpp index 45877ce..4806e19 100644 --- a/src/CinderImGui.cpp +++ b/src/CinderImGui.cpp @@ -856,7 +856,38 @@ namespace { event.setHandled( io.WantCaptureMouse ); } - + + void touchesBegan( ci::app::TouchEvent& event ) + { + if(event.getTouches().size() > 0) + { + ImGuiIO& io = ImGui::GetIO(); + io.MousePos = toPixels( event.getTouches()[0].getPos() ); + io.MouseDown[0] = true; + + event.setHandled( io.WantCaptureMouse ); + } + } + void touchesMoved( ci::app::TouchEvent& event ) + { + if(event.getTouches().size() > 0) + { + ImGuiIO& io = ImGui::GetIO(); + io.MousePos = toPixels( event.getTouches()[0].getPos() ); + + event.setHandled( io.WantCaptureMouse ); + } + } + void touchesEnded( ci::app::TouchEvent& event ) + { + if(event.getTouches().size() > 0) + { + ImGuiIO& io = ImGui::GetIO(); + io.MousePos = toPixels( event.getTouches()[0].getPos() ); + io.MouseDown[0] = false; + event.setHandled( io.WantCaptureMouse ); + } + } vector sAccelKeys; @@ -1108,6 +1139,9 @@ void connectWindow( ci::app::WindowRef window ) sWindowConnections += window->getSignalKeyDown().connect( keyDown ); sWindowConnections += window->getSignalKeyUp().connect( keyUp ); sWindowConnections += window->getSignalResize().connect( resize ); + sWindowConnections += window->getSignalTouchesBegan().connect( touchesBegan ); + sWindowConnections += window->getSignalTouchesMoved().connect( touchesMoved ); + sWindowConnections += window->getSignalTouchesEnded().connect( touchesEnded ); } void disconnectWindow( ci::app::WindowRef window ) { From 7a9ee6fe57cfebcffbdc44a5fe5b9d4f2fe8a51a Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 2 Feb 2019 14:09:17 +0000 Subject: [PATCH 3/3] better ifdefs --- src/CinderImGui.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/CinderImGui.cpp b/src/CinderImGui.cpp index 4806e19..4620172 100644 --- a/src/CinderImGui.cpp +++ b/src/CinderImGui.cpp @@ -1084,8 +1084,7 @@ void initialize( const Options &options ) } renderer->initFontTexture(); -#ifndef CINDER_LINUX -#ifndef CINDER_ANDROID +#if !defined(CINDER_LINUX) && !defined(CINDER_ANDROID) // clipboard callbacks io.SetClipboardTextFn = []( void* user_data, const char* text ) { // clipboard text is already zero-terminated @@ -1098,7 +1097,6 @@ void initialize( const Options &options ) strCopy.push_back('\0'); return (const char *) &strCopy[0]; }; -#endif #endif // connect window's signals