Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
4.9 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef UITOPLEVELWINDOWOVERLAY_H
  6. #define UITOPLEVELWINDOWOVERLAY_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. // bad reach
  11. #include "../../../panorama/input/controller.h"
  12. class CSharedMemStream;
  13. namespace IPC
  14. {
  15. class IEvent;
  16. class ISharedMem;
  17. }
  18. namespace panorama
  19. {
  20. class CTopLevelWindowOverlay;
  21. class COverlayInterface;
  22. class CTopLevelWindowOverlay : public CTopLevelWindow
  23. {
  24. typedef CTopLevelWindow BaseClass;
  25. public:
  26. CTopLevelWindowOverlay( CUIEngine *pUIEngineParent );
  27. virtual ~CTopLevelWindowOverlay();
  28. // Access overlay window interface for this window, NULL on non Steam Overlay windows
  29. virtual IUIOverlayWindow *GetOverlayInterface();
  30. // Initialize backing surface for window
  31. virtual bool BInitializeSurface( const char *pchWindowTitle, int nWidth, int nHeight, IUIEngine::ERenderTarget eRenderTarget, bool bFixedSurfaceSize, bool bEnforceWindowAspectRatio, bool bUseCustomMouseCursor, const char *pchTargetMonitor );
  32. // Run any per window frame func logic
  33. virtual void RunPlatformFrame();
  34. // Resize the window to specified dimensions
  35. virtual void OnWindowResize( uint32 nWidth, uint32 nHeight );
  36. // Window position management
  37. virtual void SetWindowPosition( float x, float y );
  38. virtual void GetWindowPosition( float &x, float &y );
  39. virtual void GetWindowBounds( float &left, float &top, float &right, float &bottom );
  40. virtual void GetClientDimensions( float &width, float &height );
  41. virtual void Activate( bool bForceful );
  42. virtual bool BHasFocus() { return m_bFocus; }
  43. virtual bool BIsFullscreen() { return m_bFullScreen; }
  44. virtual void* GetNativeWindowHandle() { return 0; }
  45. virtual bool BAllowInput( InputMessage_t &msg );
  46. virtual bool BIsVisible() { return m_bVisible; }
  47. virtual void SetVisible( bool bVisible ) { AssertMsg( false, "SetVisible not implemented on CTopLevelWindowOverlay" ); }
  48. void SetInputEnabled( bool bEnabled ) { m_bInputEnabled = bEnabled; }
  49. // Clear color for the window, normally black, transparent for overlay
  50. virtual Color GetClearColor() { return Color( 0, 0, 0, 0 ); }
  51. // Necessary for generating mouse enter & leave events on windows
  52. bool IsMouseOver() { return m_bMouseOverWindow; }
  53. void OnMouseEnter();
  54. void OnMouseLeave() { m_bMouseOverWindow = false; }
  55. void SetMouseCursor( EMouseCursors eCursor );
  56. bool SetGameProcessInfo( AppId_t nAppId, bool bCanSharedSurfaces, int32 eTextureFormat );
  57. void ProcessInputEvents();
  58. bool BVisiblityChanged() const { return m_bVisibleThisFrame != m_bVisibleLastFrame; }
  59. void PushOverlayRenderCmdStream( CSharedMemStream *pRenderStream, unsigned long dwPID, float flOpacity, EOverlayWindowAlignment alignment );
  60. void SetGameWindowSize( uint32 nWidth, uint32 nHeight );
  61. void SetFixedSurfaceSize( uint32 unSurfaceWidth, uint32 unSurfaceHeight );
  62. void OnMouseMove( float x, float y );
  63. void SetFocus( bool bFocus );
  64. void SetLetterboxColor( Color c );
  65. #ifdef DBGFLAG_VALIDATE
  66. virtual void Validate( CValidator &validator, const tchar *pchName );
  67. #endif
  68. protected:
  69. virtual void Shutdown();
  70. private:
  71. COverlayInterface *m_pOverlayInterface;
  72. IUI3DSurface *m_p3DSurface;
  73. bool m_bMouseOverWindow;
  74. AppId_t m_nAppId;
  75. bool m_bInputEnabled;
  76. bool m_bFocus;
  77. bool m_bCanShareSurfaces;
  78. bool m_bVisibleThisFrame;
  79. bool m_bVisibleLastFrame;
  80. uint32 m_unGameWidth;
  81. uint32 m_unGameHeight;
  82. bool m_bFullScreen;
  83. bool m_bVisible;
  84. };
  85. class COverlayInterface : public IUIOverlayWindow
  86. {
  87. public:
  88. COverlayInterface( CTopLevelWindowOverlay *pWindow )
  89. {
  90. m_pWindow = pWindow;
  91. }
  92. virtual void PushOverlayRenderCmdStream( CSharedMemStream *pRenderStream, unsigned long dwPID, float flOpacity, EOverlayWindowAlignment alignment ) OVERRIDE
  93. {
  94. return m_pWindow->PushOverlayRenderCmdStream( pRenderStream, dwPID, flOpacity, alignment );
  95. }
  96. virtual void SetFocus( bool bFocus ) OVERRIDE
  97. {
  98. return m_pWindow->SetFocus( bFocus );
  99. }
  100. virtual bool SetGameProcessInfo( AppId_t nAppId, bool bCanSharedSurfaces, int32 eTextureFormat ) OVERRIDE
  101. {
  102. return m_pWindow->SetGameProcessInfo( nAppId, bCanSharedSurfaces, eTextureFormat );
  103. }
  104. virtual void SetInputEnabled( bool bEnabled ) OVERRIDE
  105. {
  106. return m_pWindow->SetInputEnabled( bEnabled );
  107. }
  108. virtual void SetGameWindowSize( uint32 nWidth, uint32 nHeight ) OVERRIDE
  109. {
  110. return m_pWindow->SetGameWindowSize( nWidth, nHeight );
  111. }
  112. virtual void SetFixedSurfaceSize( uint32 unSurfaceWidth, uint32 unSurfaceHeight ) OVERRIDE
  113. {
  114. return m_pWindow->SetFixedSurfaceSize( unSurfaceWidth, unSurfaceHeight );
  115. }
  116. virtual void OnMouseMove( float x, float y ) OVERRIDE
  117. {
  118. return m_pWindow->OnMouseMove( x, y );
  119. }
  120. virtual void OnMouseEnter() OVERRIDE
  121. {
  122. return m_pWindow->OnMouseEnter();
  123. }
  124. virtual void SetLetterboxColor( Color c ) OVERRIDE
  125. {
  126. return m_pWindow->SetLetterboxColor( c );
  127. }
  128. private:
  129. CTopLevelWindowOverlay *m_pWindow;
  130. };
  131. } // namespace panorama
  132. #endif // UITOPLEVELWINDOWOVERLAY_H