/** Create and show an overlay nailed to the user's face */ bool ShowOverlay( EOverlayToDisplay eOverlay ) { if ( m_eCurrentOverlay == eOverlay && m_OverlayHandle != vr::k_ulOverlayHandleInvalid ) return true; // Hiding or changing, so destroy old overlay HideOverlay(); if ( eOverlay == k_eNone ) { m_eCurrentOverlay = eOverlay; return true; } // Compositor must be initialized to create overlays if ( !vr::VRCompositor() ) return false; vr::EVROverlayError eOverlayError = vr::VROverlay()->CreateOverlay( "leap_monitor", "Leap Monitor", &m_OverlayHandle ); if ( eOverlayError != vr::VROverlayError_None ) return false; vr::HmdMatrix34_t matInFrontOfHead; memset( &matInFrontOfHead, 0, sizeof( matInFrontOfHead ) ); float scale = 1.4f; matInFrontOfHead.m[0][0] = matInFrontOfHead.m[1][1] = matInFrontOfHead.m[2][2] = scale; matInFrontOfHead.m[2][3] = -2.0f; eOverlayError = vr::VROverlay()->SetOverlayTransformTrackedDeviceRelative( m_OverlayHandle, vr::k_unTrackedDeviceIndex_Hmd, &matInFrontOfHead ); if ( eOverlayError != vr::VROverlayError_None ) return false; std::string image; switch ( eOverlay ) { case k_ePointAtBaseForHemisphereTracking: image = m_strOverlayImagePath + "need_hemisphere_tracking.png"; break; case k_eHoldAtShouldersForCoordinateAlignment: image = m_strOverlayImagePath + "need_alignment_gesture.png"; break; default: HideOverlay(); return false; } eOverlayError = vr::VROverlay()->SetOverlayFromFile( m_OverlayHandle, image.c_str() ); if ( eOverlayError != vr::VROverlayError_None ) return false; eOverlayError = vr::VROverlay()->ShowOverlay( m_OverlayHandle ); if ( eOverlayError != vr::VROverlayError_None ) return false; m_eCurrentOverlay = eOverlay; return true; }
EEventStatus::Enum GEventLogWindow::OnMouseLeave(const GEventData & in_EventData, GBaseObject* in_pCaller) { if(!in_pCaller) HideOverlay(); return GUI::EEventStatus::Handled; }
GUI::EEventStatus::Enum GEventLogWindow::OnMouseDown(const GEventData & in_EventData, GBaseObject* in_pCaller) { if(in_EventData.Mouse.Actor.Bits.Left == in_EventData.Mouse.Down.Bits.Left) { if(!in_pCaller) { HideOverlay(); Drag(); } } return GUI::EEventStatus::Handled; }
void GEventLogWindow::DisplayOverlay() { if(!Visible()) { HideOverlay(); return; } //This code will handle the overlay appearing on news that are too long bool l_bMustDisplayOverlay = false; GVector2D<INT32> l_Pos = AbsoluteToRelative( g_Joshua.GUIManager()->MousePosition() ); INT32 x = l_Pos.x; INT32 y = l_Pos.y; //If the user is in the Event listbox zone if( (x >= m_pObjEventsLst->Left()) && (x <= (m_pObjEventsLst->Left() + m_pObjEventsLst->Width())) && (y >= m_pObjEventsLst->Top()) && (y <= (m_pObjEventsLst->Top() + m_pObjEventsLst->Height())) ) { y = y - m_pObjEventsLst->Top(); INT32 l_iOverRowID = (INT32)floor( (REAL32)y / (REAL32)m_pObjEventsLst->RowHeight() ); GUI::GListBox::GRow* l_pRow = m_pObjEventsLst->Get_Row_At(l_iOverRowID + m_pObjEventsLst->FirstRowShown()); if(l_pRow) { GUI::GLabel* l_pEvent = (GUI::GLabel*)l_pRow->Object()->Child(L"txtEvent"); if( (x >= l_pEvent->Left()) && (x <= (l_pEvent->Left() + l_pEvent->Width())) ) { //If the text do not fit the box, position and set text to the overlay if(l_pEvent->Width() < (INT32)l_pEvent->Text2D()->Width()) { g_ClientDDL.TextOverlay()->Update( l_pEvent->Text(), l_pEvent ); l_bMustDisplayOverlay = true; } } } } if(l_bMustDisplayOverlay) { g_ClientDDL.TextOverlay()->Show(); } else { g_ClientDDL.TextOverlay()->Hide(); } }
// Perform the action of overlay-Button 2 void MenuSystem::OnOverlayButton2() { onOverlayButton2(); HideOverlay(); }