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.

192 lines
7.5 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef IUIPANELCLIENT_H
  6. #define IUIPANELCLIENT_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panoramatypes.h"
  11. #include "panoramasymbol.h"
  12. #include "input/mousecursors.h"
  13. #include "input/iuiinput.h"
  14. namespace panorama
  15. {
  16. class IUIPanelStyle;
  17. class IUIScrollBar;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Struct containing a panel property info parsed from a layout file
  20. //-----------------------------------------------------------------------------
  21. struct ParsedPanelProperty_t
  22. {
  23. CPanoramaSymbol m_symName;
  24. const char *m_pchValue;
  25. };
  26. //-----------------------------------------------------------------------------
  27. // Purpose: Client side of panel interface, this is what client code implementing controls
  28. // must provide to the core UI engine in terms of a callback interface
  29. //-----------------------------------------------------------------------------
  30. class IUIPanelClient
  31. {
  32. public:
  33. // Access the panorama side UI panel interface for the client panel
  34. virtual IUIPanel *UIPanel() const = 0;
  35. // Callback telling client/control code to delete the client panel object
  36. virtual void OnDeletePanel() = 0;
  37. // Get the panel type of a panel
  38. virtual CPanoramaSymbol GetPanelType() const = 0;
  39. // Paint the panels contents
  40. virtual void Paint() = 0;
  41. // override to change how this panel is measured
  42. virtual void OnContentSizeTraverse( float *pflContentWidth, float *pflContentHeight, float flMaxWidth, float flMaxHeight, bool bFinalDimensions ) = 0;
  43. // override to change how the panel lays out it's children (instead of default css positioning/flow-children support)
  44. virtual void OnLayoutTraverse( float flFinalWidth, float flFinalHeight ) = 0;
  45. // Direct key/input handling... better to use binds and events and to not directly
  46. // override these in your panel in nearly all cases.
  47. virtual bool OnKeyDown( const KeyData_t &code ) = 0;
  48. virtual bool OnKeyUp( const KeyData_t & code ) = 0;
  49. virtual bool OnKeyTyped( const KeyData_t &unichar ) = 0;
  50. virtual bool OnGamePadDown( const GamePadData_t &code ) = 0;
  51. virtual bool OnGamePadUp( const GamePadData_t &code ) = 0;
  52. virtual bool OnGamePadAnalog( const GamePadData_t &code ) = 0;
  53. virtual bool OnMouseButtonDown( const MouseData_t &code ) = 0;
  54. virtual bool OnMouseButtonUp( const MouseData_t &code ) = 0;
  55. virtual bool OnMouseButtonDoubleClick( const MouseData_t &code ) = 0;
  56. virtual bool OnMouseButtonTripleClick( const MouseData_t &code ) = 0;
  57. virtual bool OnMouseWheel( const MouseData_t &code ) = 0;
  58. virtual void OnMouseMove( float flMouseX, float flMouseY ) = 0;
  59. virtual bool OnClick( IUIPanel *pPanel, const MouseData_t &code ) = 0;
  60. // Override to make a panel allow new panel event symbols in XML
  61. virtual bool BIsClientPanelEvent( CPanoramaSymbol symProperty ) = 0;
  62. // Override to handle new properties from xml on your panel
  63. virtual bool BSetProperties( const CUtlVector< ParsedPanelProperty_t > &vecProperties ) = 0;
  64. // Override to handle new properties from xml on your panel
  65. virtual bool BSetProperty( CPanoramaSymbol symName, const char *pchValue ) = 0;
  66. // Should the panel event be applied only after all children are created as well?
  67. virtual bool BIsDelayedProperty( CPanoramaSymbol symProperty ) = 0;
  68. // Callback before children of this panel change
  69. virtual void OnBeforeChildrenChanged() = 0;
  70. // Callback for when a child of this panel is removed
  71. virtual void OnRemoveChild( IUIPanel *pChild ) = 0;
  72. // Callback after children of this panel change
  73. virtual void OnAfterChildrenChanged() = 0;
  74. // Callback on panel getting initialized from layout file
  75. virtual void OnInitializedFromLayout() = 0;
  76. // Callback when styles are changing for this panel
  77. virtual void OnStylesChanged() = 0;
  78. // Callback when styles are changing for an immediate child of this panel
  79. virtual void OnChildStylesChanged() = 0;
  80. // Callback when visibility of the panel is changing
  81. virtual void OnVisibilityChanged() = 0;
  82. // Callback which allows panels to override focus movement behavior, this is called before the base
  83. // framework behavior is executed and returning true will prevent the base behavior from occuring.
  84. virtual bool OnSetFocusToNextPanel( int nRepeats, panorama::EFocusMoveDirection moveType, bool bAllowWrap, float flTabIndexCurrent, float flXPosCurrent, float flYPosCurrent, float flXStart, float fYStart ) = 0;
  85. // Allows overriding the parent who will be considered by the localization system for dialog variables,
  86. // dropdowns do this to allow the dropdown to have dialog vars set that then impact the created popup menu for
  87. // the actual list... You should almost never need this... try to avoid!
  88. virtual IUIPanel *GetLocalizationParent() const = 0;
  89. // Allows panels that know they may draw outside their bounds to tell us to create a clip layer,
  90. // we don't always do this since it can be expensive
  91. virtual bool BRequiresContentClipLayer() = 0;
  92. // Callback you must first register for with UIEngine()->CallBeforeStyleAndLayout() if you need it
  93. virtual void OnCallBeforeStyleAndLayout() = 0;
  94. // bugbug jmccaskey - DELETE ME
  95. // Callback when a panel event gets set, DO NOT USE, DELETE THIS AS SOON AS WE CAN, ITS HARMFUL
  96. virtual void OnPanelEventSet( CPanoramaSymbol symEvent ) = 0;
  97. // Override to set appropriate mouse cursor when hovering over this panel
  98. virtual EMouseCursors GetMouseCursor() = 0;
  99. // Callback when UI scale factor changes, which may affect panel contents sizing/layout
  100. virtual void OnUIScaleFactorChanged( float flScaleFactor ) = 0;
  101. // Called to ask us to setup object template for Javascript, you can implement this in a child class and then call
  102. // the base method (so all the normal panel2d stuff gets exposed), plus call the various RegisterJS helpers yourself
  103. // to expose additional panel type specific data/methods.
  104. virtual void SetupJavascriptObjectTemplate() = 0;
  105. // Callback to client panel to create a scrollbar
  106. virtual IUIScrollBar *CreateNewVerticalScrollBar( float flInitialScrollPos ) = 0;
  107. // Callback to client panel to create a scrollbar
  108. virtual IUIScrollBar *CreateNewHorizontalScrollBar( float flInitialScrollPos ) = 0;
  109. // Callback to hide tooltip if it's visible
  110. virtual void HideTooltip() = 0;
  111. // Override getting default input focus
  112. virtual IUIPanel *OnGetDefaultInputFocus() = 0;
  113. virtual void GetPositionWithinAncestor( CPanel2D *pAncestor, float *pflX, float *pflY ) = 0;
  114. #ifdef DBGFLAG_VALIDATE
  115. virtual void ValidateClientPanel( CValidator &validator, const tchar *pchName ) = 0;
  116. #endif
  117. };
  118. class IUIScrollBar
  119. {
  120. public:
  121. virtual IUIPanel* UIPanel() = 0;
  122. virtual IUIPanelClient* ClientPtr() = 0;
  123. virtual void Normalize( bool bImmediateThumbUpdate = false ) = 0;
  124. virtual void SetRangeMinMax( float flRangeMin, float flRangeMax ) = 0;
  125. virtual float GetRangeSize() const = 0;
  126. virtual float GetRangeMin() const = 0;
  127. virtual float GetRangeMax() const = 0;
  128. // Set the window size
  129. virtual void SetScrollWindowSize( float flWindowSize ) = 0;
  130. // Get scroll window size
  131. virtual float GetScrollWindowSize() = 0;
  132. // Set the current window position
  133. virtual void SetScrollWindowPosition( float flWindowPos, bool bImmediateMove = false ) = 0;
  134. virtual float GetLastScrollTime() = 0;
  135. // Get scroll window position
  136. virtual float GetScrollWindowPosition() = 0;
  137. // Return true if the user is manually dragging the scrollbar with the mouse
  138. virtual bool BLastMoveImmediate() = 0;
  139. };
  140. }
  141. #endif // IUIPANELCLIENT_H