History

Merge pull request #11584 from SamGondelman/pointerEvents

First step of cleaning up PointerEvents

Bradley Austin Davis committed 9 years ago

Commit becd99a2 parents 6051a39 863a20413 files · +284 −358Browse files

Showing the changes to interface/src/Application.cpp (1 of 13 files). Show all

Unified · Split

interface/src/Application.cpp+5−87
@@ -692,7 +692,6 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 691 unmodified lines
692 DependencyManager::set<CloseEventSender>();692 DependencyManager::set<CloseEventSender>();
693 DependencyManager::set<ResourceManager>();693 DependencyManager::set<ResourceManager>();
694 DependencyManager::set<SelectionScriptingInterface>();694 DependencyManager::set<SelectionScriptingInterface>();
695 DependencyManager::set<ContextOverlayInterface>();
696 DependencyManager::set<Ledger>();695 DependencyManager::set<Ledger>();
697 DependencyManager::set<Wallet>();696 DependencyManager::set<Wallet>();
698 DependencyManager::set<WalletScriptingInterface>();697 DependencyManager::set<WalletScriptingInterface>();
@@ -1188,7 +1187,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 489 unmodified lines
1188 // allow you to move an entity around in your hand1187 // allow you to move an entity around in your hand
1189 _entityEditSender.setPacketsPerSecond(3000); // super high!!1188 _entityEditSender.setPacketsPerSecond(3000); // super high!!
1190 1189
1190 // Overlays need to exist before we set the ContextOverlayInterface dependency
1191 _overlays.init(); // do this before scripts load1191 _overlays.init(); // do this before scripts load
1192 DependencyManager::set<ContextOverlayInterface>();
1193
1192 // Make sure we don't time out during slow operations at startup1194 // Make sure we don't time out during slow operations at startup
1193 updateHeartbeat();1195 updateHeartbeat();
1194 1196
@@ -1478,53 +1480,19 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 283 unmodified lines
1478 }1480 }
1479 });1481 });
1480 1482
1481 // If the user clicks somewhere where there is NO entity at all, we will release focus
1482 connect(getEntities().data(), &EntityTreeRenderer::mousePressOffEntity, [=]() {
1483 setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);
1484 });
1485
1486 // Keyboard focus handling for Web overlays.1483 // Keyboard focus handling for Web overlays.
1487 auto overlays = &(qApp->getOverlays());1484 auto overlays = &(qApp->getOverlays());
1488
1489 connect(overlays, &Overlays::mousePressOnOverlay, [=](const OverlayID& overlayID, const PointerEvent& event) {
1490 auto thisOverlay = std::dynamic_pointer_cast<Web3DOverlay>(overlays->getOverlay(overlayID));
1491 // Only Web overlays can have keyboard focus.
1492 if (thisOverlay) {
1493 setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);
1494 setKeyboardFocusOverlay(overlayID);
1495 }
1496 });
1497
1498 connect(overlays, &Overlays::overlayDeleted, [=](const OverlayID& overlayID) {1485 connect(overlays, &Overlays::overlayDeleted, [=](const OverlayID& overlayID) {
1499 if (overlayID == _keyboardFocusedOverlay.get()) {1486 if (overlayID == _keyboardFocusedOverlay.get()) {
1500 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);1487 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1501 }1488 }
1502 });1489 });
1503 1490
1504 connect(overlays, &Overlays::mousePressOffOverlay, [=]() {
1505 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1506 });
1507
1508 connect(this, &Application::aboutToQuit, [=]() {1491 connect(this, &Application::aboutToQuit, [=]() {
1509 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);1492 setKeyboardFocusOverlay(UNKNOWN_OVERLAY_ID);
1510 setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);1493 setKeyboardFocusEntity(UNKNOWN_ENTITY_ID);
1511 });1494 });
1512 1495
1513 connect(overlays,
1514 SIGNAL(mousePressOnOverlay(const OverlayID&, const PointerEvent&)),
1515 DependencyManager::get<ContextOverlayInterface>().data(),
1516 SLOT(contextOverlays_mousePressOnOverlay(const OverlayID&, const PointerEvent&)));
1517
1518 connect(overlays,
1519 SIGNAL(hoverEnterOverlay(const OverlayID&, const PointerEvent&)),
1520 DependencyManager::get<ContextOverlayInterface>().data(),
1521 SLOT(contextOverlays_hoverEnterOverlay(const OverlayID&, const PointerEvent&)));
1522
1523 connect(overlays,
1524 SIGNAL(hoverLeaveOverlay(const OverlayID&, const PointerEvent&)),
1525 DependencyManager::get<ContextOverlayInterface>().data(),
1526 SLOT(contextOverlays_hoverLeaveOverlay(const OverlayID&, const PointerEvent&)));
1527
1528 // Add periodic checks to send user activity data1496 // Add periodic checks to send user activity data
1529 static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;1497 static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;
1530 static int NEARBY_AVATAR_RADIUS_METERS = 10;1498 static int NEARBY_AVATAR_RADIUS_METERS = 10;
@@ -4561,14 +4529,9 @@ QUuid Application::getKeyboardFocusEntity() const { · 3030 unmodified lines
4561 return _keyboardFocusedEntity.get();4529 return _keyboardFocusedEntity.get();
4562}4530}
4563 4531
4564void Application::setKeyboardFocusEntity(QUuid id) {
4565 EntityItemID entityItemID(id);
4566 setKeyboardFocusEntity(entityItemID);
4567}
4568
4569static const float FOCUS_HIGHLIGHT_EXPANSION_FACTOR = 1.05f;4532static const float FOCUS_HIGHLIGHT_EXPANSION_FACTOR = 1.05f;
4570 4533
4571void Application::setKeyboardFocusEntity(EntityItemID entityItemID) {4534void Application::setKeyboardFocusEntity(const EntityItemID& entityItemID) {
4572 if (_keyboardFocusedEntity.get() != entityItemID) {4535 if (_keyboardFocusedEntity.get() != entityItemID) {
4573 _keyboardFocusedEntity.set(entityItemID);4536 _keyboardFocusedEntity.set(entityItemID);
4574 4537
@@ -4605,7 +4568,7 @@ OverlayID Application::getKeyboardFocusOverlay() { · 30 unmodified lines
4605 return _keyboardFocusedOverlay.get();4568 return _keyboardFocusedOverlay.get();
4606}4569}
4607 4570
4608void Application::setKeyboardFocusOverlay(OverlayID overlayID) {4571void Application::setKeyboardFocusOverlay(const OverlayID& overlayID) {
4609 if (overlayID != _keyboardFocusedOverlay.get()) {4572 if (overlayID != _keyboardFocusedOverlay.get()) {
4610 _keyboardFocusedOverlay.set(overlayID);4573 _keyboardFocusedOverlay.set(overlayID);
4611 4574
@@ -7443,51 +7406,6 @@ bool Application::isForeground() const { · 2831 unmodified lines
7443 return _isForeground && !_window->isMinimized();7406 return _isForeground && !_window->isMinimized();
7444}7407}
7445 7408
7446void Application::sendMousePressOnEntity(QUuid id, PointerEvent event) {
7447 EntityItemID entityItemID(id);
7448 emit getEntities()->mousePressOnEntity(entityItemID, event);
7449}
7450
7451void Application::sendMouseMoveOnEntity(QUuid id, PointerEvent event) {
7452 EntityItemID entityItemID(id);
7453 emit getEntities()->mouseMoveOnEntity(entityItemID, event);
7454}
7455
7456void Application::sendMouseReleaseOnEntity(QUuid id, PointerEvent event) {
7457 EntityItemID entityItemID(id);
7458 emit getEntities()->mouseReleaseOnEntity(entityItemID, event);
7459}
7460
7461void Application::sendClickDownOnEntity(QUuid id, PointerEvent event) {
7462 EntityItemID entityItemID(id);
7463 emit getEntities()->clickDownOnEntity(entityItemID, event);
7464}
7465
7466void Application::sendHoldingClickOnEntity(QUuid id, PointerEvent event) {
7467 EntityItemID entityItemID(id);
7468 emit getEntities()->holdingClickOnEntity(entityItemID, event);
7469}
7470
7471void Application::sendClickReleaseOnEntity(QUuid id, PointerEvent event) {
7472 EntityItemID entityItemID(id);
7473 emit getEntities()->clickReleaseOnEntity(entityItemID, event);
7474}
7475
7476void Application::sendHoverEnterEntity(QUuid id, PointerEvent event) {
7477 EntityItemID entityItemID(id);
7478 emit getEntities()->hoverEnterEntity(entityItemID, event);
7479}
7480
7481void Application::sendHoverOverEntity(QUuid id, PointerEvent event) {
7482 EntityItemID entityItemID(id);
7483 emit getEntities()->hoverOverEntity(entityItemID, event);
7484}
7485
7486void Application::sendHoverLeaveEntity(QUuid id, PointerEvent event) {
7487 EntityItemID entityItemID(id);
7488 emit getEntities()->hoverLeaveEntity(entityItemID, event);
7489}
7490
7491// FIXME? perhaps two, one for the main thread and one for the offscreen UI rendering thread?7409// FIXME? perhaps two, one for the main thread and one for the offscreen UI rendering thread?
7492static const int UI_RESERVED_THREADS = 1;7410static const int UI_RESERVED_THREADS = 1;
7493// Windows won't let you have all the cores7411// Windows won't let you have all the cores