mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:17:58 +02:00
Make double click face tracking toggle button reset tracking
This commit is contained in:
parent
bc05159504
commit
528f73897c
5 changed files with 73 additions and 5 deletions
|
@ -1016,6 +1016,9 @@ bool Application::event(QEvent* event) {
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
mousePressEvent((QMouseEvent*)event);
|
mousePressEvent((QMouseEvent*)event);
|
||||||
return true;
|
return true;
|
||||||
|
case QEvent::MouseButtonDblClick:
|
||||||
|
mouseDoublePressEvent((QMouseEvent*)event);
|
||||||
|
return true;
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
mouseReleaseEvent((QMouseEvent*)event);
|
mouseReleaseEvent((QMouseEvent*)event);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1529,6 +1532,24 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
// if one of our scripts have asked to capture this event, then stop processing it
|
||||||
|
if (_controllerScriptingInterface.isMouseCaptured()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeWindow() == _window) {
|
||||||
|
if (event->button() == Qt::LeftButton) {
|
||||||
|
if (mouseOnScreen()) {
|
||||||
|
if (DependencyManager::get<CameraToolBox>()->mouseDoublePressEvent(getMouseX(), getMouseY())) {
|
||||||
|
// stop propagation
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
|
||||||
|
|
||||||
if (!_aboutToQuit) {
|
if (!_aboutToQuit) {
|
||||||
|
|
|
@ -167,6 +167,7 @@ public:
|
||||||
|
|
||||||
void mouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
void mouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
||||||
void mousePressEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
void mousePressEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
||||||
|
void mouseDoublePressEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
||||||
void mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
void mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID = 0);
|
||||||
|
|
||||||
void touchBeginEvent(QTouchEvent* event);
|
void touchBeginEvent(QTouchEvent* event);
|
||||||
|
|
|
@ -131,6 +131,7 @@ bool GLCanvas::event(QEvent* event) {
|
||||||
case QEvent::MouseMove:
|
case QEvent::MouseMove:
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
|
case QEvent::MouseButtonDblClick:
|
||||||
case QEvent::KeyPress:
|
case QEvent::KeyPress:
|
||||||
case QEvent::KeyRelease:
|
case QEvent::KeyRelease:
|
||||||
case QEvent::FocusIn:
|
case QEvent::FocusIn:
|
||||||
|
|
|
@ -20,21 +20,57 @@
|
||||||
|
|
||||||
|
|
||||||
CameraToolBox::CameraToolBox() :
|
CameraToolBox::CameraToolBox() :
|
||||||
_iconPulseTimeReference(usecTimestampNow())
|
_iconPulseTimeReference(usecTimestampNow()),
|
||||||
|
_doubleClickTimer(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CameraToolBox::~CameraToolBox() {
|
||||||
|
if (_doubleClickTimer) {
|
||||||
|
_doubleClickTimer->stop();
|
||||||
|
delete _doubleClickTimer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CameraToolBox::mousePressEvent(int x, int y) {
|
bool CameraToolBox::mousePressEvent(int x, int y) {
|
||||||
if (_iconBounds.contains(x, y)) {
|
if (_iconBounds.contains(x, y)) {
|
||||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
if (!_doubleClickTimer) {
|
||||||
if (faceTracker) {
|
// Toggle mute after waiting to check that it's not a double-click.
|
||||||
faceTracker->toggleMute();
|
const int DOUBLE_CLICK_WAIT = 200; // ms
|
||||||
|
_doubleClickTimer = new QTimer(this);
|
||||||
|
connect(_doubleClickTimer, SIGNAL(timeout()), this, SLOT(toggleMute()));
|
||||||
|
_doubleClickTimer->setSingleShot(true);
|
||||||
|
_doubleClickTimer->setInterval(DOUBLE_CLICK_WAIT);
|
||||||
|
_doubleClickTimer->start();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CameraToolBox::mouseDoublePressEvent(int x, int y) {
|
||||||
|
if (_iconBounds.contains(x, y)) {
|
||||||
|
if (_doubleClickTimer) {
|
||||||
|
_doubleClickTimer->stop();
|
||||||
|
delete _doubleClickTimer;
|
||||||
|
_doubleClickTimer = NULL;
|
||||||
|
}
|
||||||
|
Application::getInstance()->resetSensors();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CameraToolBox::toggleMute() {
|
||||||
|
delete _doubleClickTimer;
|
||||||
|
_doubleClickTimer = NULL;
|
||||||
|
|
||||||
|
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||||
|
if (faceTracker) {
|
||||||
|
faceTracker->toggleMute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CameraToolBox::render(int x, int y, bool boxed) {
|
void CameraToolBox::render(int x, int y, bool boxed) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
|
|
|
@ -12,18 +12,26 @@
|
||||||
#ifndef hifi_CameraToolBox_h
|
#ifndef hifi_CameraToolBox_h
|
||||||
#define hifi_CameraToolBox_h
|
#define hifi_CameraToolBox_h
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
#include <GeometryCache.h>
|
#include <GeometryCache.h>
|
||||||
|
|
||||||
class CameraToolBox : public Dependency {
|
class CameraToolBox : public QObject, public Dependency {
|
||||||
|
Q_OBJECT
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void render(int x, int y, bool boxed);
|
void render(int x, int y, bool boxed);
|
||||||
bool mousePressEvent(int x, int y);
|
bool mousePressEvent(int x, int y);
|
||||||
|
bool mouseDoublePressEvent(int x, int y);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CameraToolBox();
|
CameraToolBox();
|
||||||
|
~CameraToolBox();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void toggleMute();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLuint _enabledTextureId = 0;
|
GLuint _enabledTextureId = 0;
|
||||||
|
@ -31,6 +39,7 @@ private:
|
||||||
int _boxQuadID = GeometryCache::UNKNOWN_ID;
|
int _boxQuadID = GeometryCache::UNKNOWN_ID;
|
||||||
QRect _iconBounds;
|
QRect _iconBounds;
|
||||||
qint64 _iconPulseTimeReference = 0;
|
qint64 _iconPulseTimeReference = 0;
|
||||||
|
QTimer* _doubleClickTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_CameraToolBox_h
|
#endif // hifi_CameraToolBox_h
|
Loading…
Reference in a new issue