add an HFMetaEvent class as super class for meta events

This commit is contained in:
Stephen Birarda 2014-10-27 12:56:48 -07:00
parent 6626787ae5
commit 0ddf665b86
6 changed files with 62 additions and 14 deletions

View file

@ -45,7 +45,7 @@ configure_file(InterfaceVersion.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceVe
# grab the implementation and header files from src dirs # grab the implementation and header files from src dirs
file(GLOB INTERFACE_SRCS src/*.cpp src/*.h) file(GLOB INTERFACE_SRCS src/*.cpp src/*.h)
foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels particles entities gpu) foreach(SUBDIR avatar devices events renderer ui starfield location scripting voxels particles entities gpu)
file(GLOB_RECURSE SUBDIR_SRCS src/${SUBDIR}/*.cpp src/${SUBDIR}/*.h) file(GLOB_RECURSE SUBDIR_SRCS src/${SUBDIR}/*.cpp src/${SUBDIR}/*.h)
set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}")
endforeach(SUBDIR) endforeach(SUBDIR)

View file

@ -67,7 +67,6 @@
#include <UUID.h> #include <UUID.h>
#include "Application.h" #include "Application.h"
#include "HFActionEvent.h"
#include "InterfaceVersion.h" #include "InterfaceVersion.h"
#include "Menu.h" #include "Menu.h"
#include "ModelUploader.h" #include "ModelUploader.h"
@ -78,6 +77,8 @@
#include "devices/OculusManager.h" #include "devices/OculusManager.h"
#include "devices/TV3DManager.h" #include "devices/TV3DManager.h"
#include "events/HFActionEvent.h"
#include "renderer/ProgramObject.h" #include "renderer/ProgramObject.h"
#include "scripting/AccountScriptingInterface.h" #include "scripting/AccountScriptingInterface.h"
@ -139,6 +140,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_glWidget(new GLCanvas()), _glWidget(new GLCanvas()),
_nodeThread(new QThread(this)), _nodeThread(new QThread(this)),
_datagramProcessor(), _datagramProcessor(),
_undoStack(),
_undoStackScriptingInterface(&_undoStack),
_frameCount(0), _frameCount(0),
_fps(60.0f), _fps(60.0f),
_justStarted(true), _justStarted(true),
@ -175,8 +178,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
_nodeBoundsDisplay(this), _nodeBoundsDisplay(this),
_previousScriptLocation(), _previousScriptLocation(),
_applicationOverlay(), _applicationOverlay(),
_undoStack(),
_undoStackScriptingInterface(&_undoStack),
_runningScriptsWidget(NULL), _runningScriptsWidget(NULL),
_runningScriptsWidgetWasVisible(false), _runningScriptsWidgetWasVisible(false),
_trayIcon(new QSystemTrayIcon(_window)), _trayIcon(new QSystemTrayIcon(_window)),
@ -835,7 +836,7 @@ bool Application::event(QEvent* event) {
return false; return false;
} }
return QApplication::event(event); return QApplication::event(event);
} }
@ -1245,7 +1246,7 @@ void Application::mousePressEvent(QMouseEvent* event, unsigned int deviceID) {
// nobody handled this - make it an action event on the _window object // nobody handled this - make it an action event on the _window object
HFActionEvent actionEvent(HFActionEvent::startType(), event->localPos()); HFActionEvent actionEvent(HFActionEvent::startType(), event->localPos());
sendEvent(_window, &actionEvent); sendEvent(this, &actionEvent);
} else if (event->button() == Qt::RightButton) { } else if (event->button() == Qt::RightButton) {
// right click items here // right click items here
@ -1276,7 +1277,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
// fire an action end event // fire an action end event
HFActionEvent actionEvent(HFActionEvent::endType(), event->localPos()); HFActionEvent actionEvent(HFActionEvent::endType(), event->localPos());
sendEvent(_window, &actionEvent); sendEvent(this, &actionEvent);
} }
} }
} }

View file

@ -1,6 +1,6 @@
// //
// HFActionEvent.cpp // HFActionEvent.cpp
// interface/src // interface/src/events
// //
// Created by Stephen Birarda on 2014-10-27. // Created by Stephen Birarda on 2014-10-27.
// Copyright 2014 High Fidelity, Inc. // Copyright 2014 High Fidelity, Inc.
@ -12,19 +12,19 @@
#include "HFActionEvent.h" #include "HFActionEvent.h"
HFActionEvent::HFActionEvent(QEvent::Type type, const QPointF& localPosition) : HFActionEvent::HFActionEvent(QEvent::Type type, const QPointF& localPosition) :
QEvent(type), HFMetaEvent(type),
_localPosition(localPosition) _localPosition(localPosition)
{ {
} }
QEvent::Type HFActionEvent::startType() { QEvent::Type HFActionEvent::startType() {
static QEvent::Type startType = static_cast<QEvent::Type>(QEvent::registerEventType()); static QEvent::Type startType = HFMetaEvent::newEventType();
return startType; return startType;
} }
QEvent::Type HFActionEvent::endType() { QEvent::Type HFActionEvent::endType() {
static QEvent::Type endType = static_cast<QEvent::Type>(QEvent::registerEventType()); static QEvent::Type endType = HFMetaEvent::newEventType();
return endType; return endType;
} }

View file

@ -1,6 +1,6 @@
// //
// HFActionEvent.h // HFActionEvent.h
// interface/src // interface/src/events
// //
// Created by Stephen Birarda on 2014-10-27. // Created by Stephen Birarda on 2014-10-27.
// Copyright 2014 High Fidelity, Inc. // Copyright 2014 High Fidelity, Inc.
@ -12,9 +12,9 @@
#ifndef hifi_HFActionEvent_h #ifndef hifi_HFActionEvent_h
#define hifi_HFActionEvent_h #define hifi_HFActionEvent_h
#include <qevent.h> #include "HFMetaEvent.h"
class HFActionEvent : public QEvent { class HFActionEvent : public HFMetaEvent {
public: public:
HFActionEvent(QEvent::Type type, const QPointF& localPosition); HFActionEvent(QEvent::Type type, const QPointF& localPosition);

View file

@ -0,0 +1,20 @@
//
// HFMetaEvent.cpp
// interface/src/events
//
// Created by Stephen Birarda on 2014-10-27.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "HFMetaEvent.h"
QSet<QEvent::Type> HFMetaEvent::_types = QSet<QEvent::Type>();
QEvent::Type HFMetaEvent::newEventType() {
QEvent::Type newType = static_cast<QEvent::Type>(QEvent::registerEventType());
_types.insert(newType);
return newType;
}

View file

@ -0,0 +1,27 @@
//
// HFMetaEvent.h
// interface/src/events
//
// Created by Stephen Birarda on 2014-10-27.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_HFMetaEvent_h
#define hifi_HFMetaEvent_h
#include <qevent.h>
class HFMetaEvent : public QEvent {
public:
HFMetaEvent(QEvent::Type type) : QEvent(type) {};
static const QSet<QEvent::Type>& types() { return HFMetaEvent::_types; }
protected:
static QEvent::Type newEventType();
static QSet<QEvent::Type> _types;
};
#endif // hifi_HFMetaEvent_h