mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-30 07:49:31 -05: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:
@@ -84,6 +84,12 @@ public:
|
||||
void draw();
|
||||
void close(bool force = false);
|
||||
|
||||
void sendTouchPressEvent(const CefMouseEvent & event,
|
||||
CefBrowserHost::MouseButtonType button, const int clickCount);
|
||||
|
||||
void sendResleasePressEvent(const CefMouseEvent & event,
|
||||
CefBrowserHost::MouseButtonType button, const int clickCount);
|
||||
|
||||
bool sendKeyEvent(const CefKeyEvent& event);
|
||||
bool sendMouseClickEvent(const CefMouseEvent& event,
|
||||
CefBrowserHost::MouseButtonType button, bool mouseUp,
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
void setBrowser(const CefRefPtr<CefBrowser>& browser);
|
||||
void setBrowserInstance(BrowserInstance* browserInstance);
|
||||
void detachBrowser();
|
||||
void touchPressCallback(const double x, const double y);
|
||||
void touchReleaseCallback(const double x, const double y);
|
||||
bool hasContentCallback(const double, const double);
|
||||
|
||||
private:
|
||||
bool mouseButtonCallback(MouseButton button, MouseAction action, KeyModifier mods);
|
||||
|
||||
@@ -131,6 +131,18 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event,
|
||||
return hasContent(event.x, event.y);
|
||||
}
|
||||
|
||||
void BrowserInstance::sendTouchPressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
|
||||
const int clickCount)
|
||||
{
|
||||
_browser->GetHost()->SendMouseClickEvent(event, button, false, clickCount);
|
||||
}
|
||||
|
||||
void BrowserInstance::sendResleasePressEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button,
|
||||
const int clickCount)
|
||||
{
|
||||
_browser->GetHost()->SendMouseClickEvent(event, button, true, clickCount);
|
||||
}
|
||||
|
||||
bool BrowserInstance::sendMouseMoveEvent(const CefMouseEvent& event) {
|
||||
constexpr const bool DidNotLeaveWindow = false;
|
||||
|
||||
|
||||
@@ -143,6 +143,30 @@ void EventHandler::initialize() {
|
||||
);
|
||||
}
|
||||
|
||||
void EventHandler::touchPressCallback(const double x, const double y) {
|
||||
if (_browserInstance) {
|
||||
_mousePosition.x = static_cast<float>(x);
|
||||
_mousePosition.y = static_cast<float>(y);
|
||||
|
||||
int clickCount = BrowserInstance::SingleClick;
|
||||
_browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, false, clickCount);
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandler::touchReleaseCallback(const double x, const double y) {
|
||||
if (_browserInstance) {
|
||||
_mousePosition.x = static_cast<float>(x);
|
||||
_mousePosition.y = static_cast<float>(y);
|
||||
|
||||
int clickCount = BrowserInstance::SingleClick;
|
||||
_browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, true, clickCount);
|
||||
}
|
||||
}
|
||||
|
||||
bool EventHandler::hasContentCallback(const double x, const double y) {
|
||||
return _browserInstance->hasContent(static_cast<int>(x), static_cast<int>(y));
|
||||
}
|
||||
|
||||
bool EventHandler::mouseButtonCallback(MouseButton button,
|
||||
MouseAction action,
|
||||
KeyModifier mods)
|
||||
|
||||
@@ -140,6 +140,10 @@ void WebBrowserModule::attachEventHandler(BrowserInstance* browserInstance) {
|
||||
}
|
||||
}
|
||||
|
||||
EventHandler WebBrowserModule::eventHandler() {
|
||||
return _eventHandler;
|
||||
}
|
||||
|
||||
void WebBrowserModule::detachEventHandler() {
|
||||
if (_enabled) {
|
||||
_eventHandler.setBrowserInstance(nullptr);
|
||||
|
||||
@@ -42,6 +42,7 @@ public:
|
||||
void addBrowser(BrowserInstance*);
|
||||
void removeBrowser(BrowserInstance*);
|
||||
|
||||
EventHandler eventHandler();
|
||||
void attachEventHandler(BrowserInstance* browserInstance);
|
||||
void detachEventHandler();
|
||||
bool isEnabled() const;
|
||||
|
||||
Reference in New Issue
Block a user