mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 21:02:17 +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:
|
||||
mousePressEvent((QMouseEvent*)event);
|
||||
return true;
|
||||
case QEvent::MouseButtonDblClick:
|
||||
mouseDoublePressEvent((QMouseEvent*)event);
|
||||
return true;
|
||||
case QEvent::MouseButtonRelease:
|
||||
mouseReleaseEvent((QMouseEvent*)event);
|
||||
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) {
|
||||
|
||||
if (!_aboutToQuit) {
|
||||
|
|
|
@ -167,6 +167,7 @@ public:
|
|||
|
||||
void mouseMoveEvent(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 touchBeginEvent(QTouchEvent* event);
|
||||
|
|
|
@ -131,6 +131,7 @@ bool GLCanvas::event(QEvent* event) {
|
|||
case QEvent::MouseMove:
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::MouseButtonRelease:
|
||||
case QEvent::MouseButtonDblClick:
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyRelease:
|
||||
case QEvent::FocusIn:
|
||||
|
|
|
@ -20,21 +20,57 @@
|
|||
|
||||
|
||||
CameraToolBox::CameraToolBox() :
|
||||
_iconPulseTimeReference(usecTimestampNow())
|
||||
_iconPulseTimeReference(usecTimestampNow()),
|
||||
_doubleClickTimer(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CameraToolBox::~CameraToolBox() {
|
||||
if (_doubleClickTimer) {
|
||||
_doubleClickTimer->stop();
|
||||
delete _doubleClickTimer;
|
||||
}
|
||||
}
|
||||
|
||||
bool CameraToolBox::mousePressEvent(int x, int y) {
|
||||
if (_iconBounds.contains(x, y)) {
|
||||
FaceTracker* faceTracker = Application::getInstance()->getActiveFaceTracker();
|
||||
if (faceTracker) {
|
||||
faceTracker->toggleMute();
|
||||
if (!_doubleClickTimer) {
|
||||
// Toggle mute after waiting to check that it's not a double-click.
|
||||
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 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) {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
|
|
@ -12,18 +12,26 @@
|
|||
#ifndef hifi_CameraToolBox_h
|
||||
#define hifi_CameraToolBox_h
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <DependencyManager.h>
|
||||
#include <GeometryCache.h>
|
||||
|
||||
class CameraToolBox : public Dependency {
|
||||
class CameraToolBox : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public:
|
||||
void render(int x, int y, bool boxed);
|
||||
bool mousePressEvent(int x, int y);
|
||||
bool mouseDoublePressEvent(int x, int y);
|
||||
|
||||
protected:
|
||||
CameraToolBox();
|
||||
~CameraToolBox();
|
||||
|
||||
private slots:
|
||||
void toggleMute();
|
||||
|
||||
private:
|
||||
GLuint _enabledTextureId = 0;
|
||||
|
@ -31,6 +39,7 @@ private:
|
|||
int _boxQuadID = GeometryCache::UNKNOWN_ID;
|
||||
QRect _iconBounds;
|
||||
qint64 _iconPulseTimeReference = 0;
|
||||
QTimer* _doubleClickTimer;
|
||||
};
|
||||
|
||||
#endif // hifi_CameraToolBox_h
|
Loading…
Reference in a new issue