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.

205 lines
7.0 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef IUIWINDOW_H
  6. #define IUIWINDOW_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panoramatypes.h"
  11. #include "iuirenderengine.h"
  12. #if defined( SOURCE2_PANORAMA )
  13. #include "rendersystem/irendercontext.h"
  14. #include "scenesystem/isceneview.h"
  15. #endif
  16. class CSharedMemStream;
  17. namespace panorama
  18. {
  19. class CLayoutFile;
  20. class IUIPanelStyle;
  21. class IUIOverlayWindow;
  22. class IUIWindowInput;
  23. //-----------------------------------------------------------------------------
  24. // Purpose: Basic window interface exposing operations used inside of panorama, rather
  25. // than operations that are part of building/laying out controls in the panorama_client module
  26. //-----------------------------------------------------------------------------
  27. class IUIWindow
  28. {
  29. public:
  30. #if defined( SOURCE2_PANORAMA )
  31. virtual void RenderWindow( ISceneView *pView, IRenderContext *pRenderContext, ISceneLayer *pLayer ) = 0;
  32. #endif
  33. // Delete the window object
  34. virtual void Delete() = 0;
  35. // Access input system for the window
  36. virtual IUIWindowInput *UIWindowInput() = 0;
  37. // Access the rendering interface you use to draw onto this window
  38. virtual IUIRenderEngine * UIRenderEngine() = 0;
  39. // Set scaling factor that applies to all x/y values in the UI for the window, used so we can
  40. // author content at say 1080p but pass 0.6666666f for this to render in 720p on cards with poor
  41. // fill rates or TVs without 1080p support.
  42. virtual void SetUIScaleFactor( float flScaleFactor ) = 0;
  43. virtual float GetUIScaleFactor() = 0;
  44. // Check if the mouse cursor is currently visible within the window
  45. virtual bool BCursorVisible() = 0;
  46. // Get the surface width for the window, this may be larger or smaller than the actual window if we are rendering lower res and scaling output for instance
  47. virtual uint32 GetSurfaceWidth() = 0;
  48. // Get the surface height for the window, this may be larger or smaller than the actual window if we are rendering lower res and scaling output for instance
  49. virtual uint32 GetSurfaceHeight() = 0;
  50. // Get the actual window width
  51. virtual uint32 GetWindowWidth() = 0;
  52. // Get the actual window height
  53. virtual uint32 GetWindowHeight() = 0;
  54. // Get the client area of the window, minus window borders, etc
  55. virtual void GetClientDimensions( float &width, float &height ) = 0;
  56. // Handle resize event, window has resized, backing surface needs to now resize to match
  57. virtual void OnWindowResize( uint32 width, uint32 height ) = 0;
  58. // Set window position on screen
  59. virtual void SetWindowPosition( float x, float y ) = 0;
  60. // Get window position on screen
  61. virtual void GetWindowPosition( float &x, float &y ) = 0;
  62. // bForceful in this call means try to bypass OS rules that may prevent focus (like our app wasn't last to receive input),
  63. // use this sparingly and only if we really know stealing focus from some other app is what the user definately desires!
  64. virtual void Activate( bool bForceful ) = 0;
  65. // Check if this window has focus currently
  66. virtual bool BHasFocus() = 0;
  67. // Get the number of visible top level panels in the window
  68. virtual uint32 GetNumVisibleTopLevelPanels() const = 0;
  69. // Access list of visible panels
  70. virtual const CUtlLinkedList< IUIPanel* > &GetTopLevelVisiblePanels() const = 0;
  71. // Check if mouse is over the window
  72. virtual bool IsMouseOver() = 0;
  73. // Helper for letting client code tell us about daisywheel usage
  74. virtual void RecordDaisyWheelUsage( float flEntryTimeInSeconds, int nWordsEntered, bool bViaKeyboard, bool bViaGamepad ) = 0;
  75. // Helper for tracking daisywheel usage
  76. virtual void GetDaisyWheelWPM( int &nWordsTyped, float &flMixedWPM, float &flKeyboardOnlyWPM, float &flGamepadOnlyWPM ) = 0;
  77. // Check if the window is inside it's own layout pass
  78. virtual bool BIsWindowInLayoutPass() = 0;
  79. // Set a context ptr that is attached to the window, just lets other code (panels) that
  80. // has access to the window access some shared state across the window.
  81. virtual void SetContextPtr( void *pv ) = 0;
  82. // Get context ptr value for this window,
  83. virtual void * GetContextPtr() const = 0;
  84. virtual bool BIsOverlay() = 0;
  85. virtual bool BIsSteamWMOverlay() = 0;
  86. // Get low level native window handle, used by streaming, should generally not be something you use
  87. virtual void* GetNativeWindowHandle() = 0;
  88. // Add a class to every top level panel in the window
  89. virtual void AddClass( const char *pchName ) = 0;
  90. // Add a class from every top level panel in the window
  91. virtual void RemoveClass( const char *pchName ) = 0;
  92. virtual void SetInhibitInput( bool bInhibitInput ) = 0;
  93. virtual void SetPreventForceWindowOnTop( bool bPreventForceTopLevel ) = 0;
  94. // Fade out the mouse cursor immediately in this window
  95. virtual void FadeOutCursorNow() = 0;
  96. // Check if the cursor is currently fading out
  97. virtual bool BCursorFadingOut() = 0;
  98. // Wakeup and show the mouse cursor immediately
  99. virtual void WakeupMouseCursor() = 0;
  100. // Set a min FPS for the window, this actually just prevents setting the max lower
  101. virtual void SetMinFPS( float flMinFPS ) = 0;
  102. // Stats tracking
  103. virtual void GetSessionFPSAverages( float &fpsPaint, float &fpsAnimation, float &fpsRender ) = 0;
  104. // Stats tracking
  105. virtual void GetNumPeriodsBelowMinFPS( int &nSlowPeriods ) = 0;
  106. // access data about how the gamepad was used
  107. virtual bool BWasGamepadConnectedThisSession() = 0;
  108. virtual bool BWasGamepadUsedThisSession() = 0;
  109. virtual bool BWasSteamControllerConnectedThisSession() = 0;
  110. virtual bool BWasSteamControllerUsedThisSession() = 0;
  111. // Access overlay window interface for this window, NULL on non Steam Overlay windows
  112. virtual IUIOverlayWindow *GetOverlayInterface() = 0;
  113. // Change visibility of this window
  114. virtual bool BIsVisible() = 0;
  115. virtual void SetVisible( bool bVisible ) = 0;
  116. // Change the focus behavior for controls in this window
  117. virtual EWindowFocusBehavior GetFocusBehavior() = 0;
  118. virtual void SetFocusBehavior( EWindowFocusBehavior eFocusBehavior ) = 0;
  119. virtual void OnDeviceLost() = 0;
  120. virtual void OnDeviceRestored() = 0;
  121. virtual bool BDeviceLost() = 0;
  122. // Clears the GPU resources associated with the window before the next render frame
  123. virtual void ClearGPUResourcesBeforeNextFrame() = 0;
  124. };
  125. //
  126. // Overlay window interface for Steam overlay specific windows
  127. //
  128. class IUIOverlayWindow
  129. {
  130. public:
  131. #if !defined( SOURCE2_PANORAMA )
  132. virtual void PushOverlayRenderCmdStream( CSharedMemStream *pRenderStream, unsigned long dwPID, float flOpacity, EOverlayWindowAlignment alignment ) = 0;
  133. virtual void SetFocus( bool bFocus ) = 0;
  134. virtual bool SetGameProcessInfo( AppId_t nAppId, bool bCanSharedSurfaces, int32 eTextureFormat ) = 0;
  135. virtual void SetInputEnabled( bool bEnabled ) = 0;
  136. virtual void SetGameWindowSize( uint32 nWidth, uint32 nHeight ) = 0;
  137. virtual void SetFixedSurfaceSize( uint32 unSurfaceWidth, uint32 unSurfaceHeight ) = 0;
  138. virtual void OnMouseMove( float x, float y ) = 0;
  139. virtual void OnMouseEnter() = 0;
  140. virtual void SetLetterboxColor( Color c ) = 0;
  141. #endif
  142. };
  143. }
  144. #endif // IUIWINDOW_H