mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-27 23:39:01 -06:00
Feature/touch web gui support (#798)
* Added touch support for web GUI * Code cleanup after master merge, no functionality changes * Fixed alignment of function arguments
This commit is contained in:
@@ -23,9 +23,12 @@
|
||||
****************************************************************************************/
|
||||
|
||||
#include <modules/touch/touchmodule.h>
|
||||
#include <modules/webbrowser/webbrowsermodule.h>
|
||||
#include <modules/webgui/webguimodule.h>
|
||||
|
||||
#include <openspace/engine/globals.h>
|
||||
#include <openspace/engine/globalscallbacks.h>
|
||||
#include <openspace/engine/moduleengine.h>
|
||||
#include <openspace/engine/windowdelegate.h>
|
||||
#include <openspace/interaction/navigationhandler.h>
|
||||
#include <openspace/interaction/orbitalnavigator.h>
|
||||
@@ -71,6 +74,9 @@ bool TouchModule::hasNewInput() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if we need to parse touchevent to the webgui
|
||||
hasNewWebInput(listOfContactPoints);
|
||||
|
||||
// Return true if we got new input
|
||||
if (listOfContactPoints.size() == lastProcessed.size() &&
|
||||
!listOfContactPoints.empty())
|
||||
@@ -104,7 +110,36 @@ bool TouchModule::hasNewInput() {
|
||||
}
|
||||
}
|
||||
|
||||
TouchModule::TouchModule() : OpenSpaceModule("Touch") {
|
||||
void TouchModule::hasNewWebInput(const std::vector<TuioCursor>& listOfContactPoints) {
|
||||
// If one point input and no data in webPosition callback send mouse click to webgui
|
||||
bool isWebPositionCallbackZero =
|
||||
(webPositionCallback.x == 0 && webPositionCallback.y == 0);
|
||||
bool isSingleContactPoint = (listOfContactPoints.size() == 1);
|
||||
if (isSingleContactPoint && isWebPositionCallbackZero) {
|
||||
glm::ivec2 res = global::windowDelegate.currentWindowSize();
|
||||
glm::dvec2 pos = glm::vec2(
|
||||
listOfContactPoints.at(0).getScreenX(res.x),
|
||||
listOfContactPoints.at(0).getScreenY(res.y)
|
||||
);
|
||||
|
||||
WebBrowserModule& module = *(global::moduleEngine.module<WebBrowserModule>());
|
||||
if (module.eventHandler().hasContentCallback(pos.x, pos.y)) {
|
||||
webPositionCallback = glm::vec2(pos.x, pos.y);
|
||||
module.eventHandler().touchPressCallback(pos.x, pos.y);
|
||||
}
|
||||
}
|
||||
// Send mouse release if not same point input
|
||||
else if (!isSingleContactPoint && !isWebPositionCallbackZero) {
|
||||
WebBrowserModule& module = *(global::moduleEngine.module<WebBrowserModule>());
|
||||
module.eventHandler().touchReleaseCallback(webPositionCallback.x,
|
||||
webPositionCallback.y);
|
||||
webPositionCallback = glm::vec2(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
TouchModule::TouchModule()
|
||||
: OpenSpaceModule("Touch")
|
||||
{
|
||||
addPropertySubOwner(touch);
|
||||
addPropertySubOwner(markers);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user