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.

242 lines
12 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef IUIPANELSTYLE_H
  6. #define IUIPANELSTYLE_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panoramatypes.h"
  11. #include "panorama/layout/uilength.h"
  12. #include "mathlib/beziercurve.h"
  13. #include "layout/stylesymbol.h"
  14. #include "layout/backgroundimage.h"
  15. #include "transformations.h"
  16. namespace panorama
  17. {
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Individual transition property data
  20. //-----------------------------------------------------------------------------
  21. struct TransitionProperty_t
  22. {
  23. panorama::CStyleSymbol m_symProperty;
  24. double m_flTransitionSeconds;
  25. double m_flTransitionDelaySeconds;
  26. EAnimationTimingFunction m_eTimingFunction;
  27. CCubicBezierCurve< Vector2D > m_CubicBezier;
  28. bool operator==(const TransitionProperty_t &rhs) const
  29. {
  30. return (m_symProperty == rhs.m_symProperty && m_flTransitionSeconds == rhs.m_flTransitionSeconds &&
  31. m_flTransitionDelaySeconds == rhs.m_flTransitionDelaySeconds && m_eTimingFunction == rhs.m_eTimingFunction
  32. && (m_eTimingFunction != k_EAnimationCustomBezier ||
  33. (m_CubicBezier.ControlPoint( 0 ) == rhs.m_CubicBezier.ControlPoint( 0 ) &&
  34. m_CubicBezier.ControlPoint( 1 ) == rhs.m_CubicBezier.ControlPoint( 1 ) &&
  35. m_CubicBezier.ControlPoint( 2 ) == rhs.m_CubicBezier.ControlPoint( 2 ) &&
  36. m_CubicBezier.ControlPoint( 3 ) == rhs.m_CubicBezier.ControlPoint( 3 )
  37. )
  38. ));
  39. }
  40. bool operator!=(const TransitionProperty_t &rhs) const { return !(*this == rhs); }
  41. };
  42. struct StyleEntry_t
  43. {
  44. CStyleSymbol m_StyleSymbol;
  45. CStyleProperty *m_pStyleProperty;
  46. };
  47. struct PropertyInTransition_t;
  48. class CActiveAnimation;
  49. //-----------------------------------------------------------------------------
  50. // Purpose: Basic panel interface exposing operations used inside of panorama, rather
  51. // than operations that are part of building/laying out controls in the panorama_client module
  52. //-----------------------------------------------------------------------------
  53. class IUIPanelStyle
  54. {
  55. public:
  56. // Clear the styles
  57. virtual void Clear() = 0;
  58. // Get the UI scale factor, this is a property of windows, but since we can have a panel
  59. // style with no explicit panel/window (text ranges) we have to set it into this class as well.
  60. virtual float GetUIScaleFactor() = 0;
  61. // Checks if the property has any style data at all, base, transition, or animation.
  62. // Useful to early out any work related to the stype when painting.
  63. virtual bool BHasAnyStyleDataForProperty( CStyleSymbol hSymbolProperty ) = 0;
  64. virtual void GetPosition( panorama::CUILength &x, panorama::CUILength &y, panorama::CUILength &z, bool bIncludeUIScaleFactor = true ) = 0;
  65. virtual void GetInterpolatedPosition( panorama::CUILength &x, panorama::CUILength &y, panorama::CUILength &z, bool bFinal, bool bIncludeUIScaleFactor = true ) = 0;
  66. virtual void SetPosition( panorama::CUILength x, panorama::CUILength y, panorama::CUILength z, bool bPreScaledByUIScaleFactor = false ) = 0;
  67. virtual void SetPositionWithoutTransition( panorama::CUILength x, panorama::CUILength y, panorama::CUILength z, bool bPreScaledByUIScaleFactor = false ) = 0;
  68. virtual void GetPerspectiveOrigin( panorama::CUILength &x, panorama::CUILength &y, bool &bInvert ) = 0;
  69. virtual void SetPerspectiveOrigin( panorama::CUILength &x, panorama::CUILength &y, bool &bInvert ) = 0;
  70. virtual void GetTransformOrigin( panorama::CUILength &x, panorama::CUILength &y, bool &bParentLayerRelative ) = 0;
  71. virtual void SetTransformOrigin( panorama::CUILength &x, panorama::CUILength &y, bool bParentLayerRelative ) = 0;
  72. virtual void GetPerspective( float &perspective ) = 0;
  73. virtual void SetPerspective( float perspective ) = 0;
  74. virtual void GetZIndex( float &zindex ) = 0;
  75. virtual void SetZIndex( float zIndex ) = 0;
  76. virtual void GetOverflow( panorama::EOverflowValue &eHorizontal, panorama::EOverflowValue &eVertical ) = 0;
  77. virtual void SetOverflow( const panorama::EOverflowValue eHorizontal, const panorama::EOverflowValue eVertical ) = 0;
  78. virtual void SetTransform3D( const CUtlVector<CTransform3D *> &vecTransforms ) = 0;
  79. virtual void SetTransform3DWithoutTransition( const CUtlVector<CTransform3D *> &vecTransforms ) = 0;
  80. virtual VMatrix GetTransform3DMatrix() = 0;
  81. virtual void GetOpacity( float &opacity ) = 0;
  82. virtual void SetOpacity( float opacity ) = 0;
  83. virtual void SetScale2DCentered( float flX, float flY ) = 0;
  84. virtual void SetRotate2DCentered( float flDegrees ) = 0;
  85. virtual void GetDesaturation( float &desaturation ) = 0;
  86. virtual void SetDesaturation( float desaturation ) = 0;
  87. virtual void GetGaussianBlur( float &passes, float &stddevhor, float &stddevver ) = 0;
  88. virtual void SetGaussianBlur( float passes, float stddevhor, float stddevver ) = 0;
  89. virtual void GetOpacityMaskImage( IImageSource *& pImage, float *pflOpacityMaskOpacity ) = 0;
  90. virtual void GetWashColor( Color &c ) = 0;
  91. virtual void SetWashColor( const Color &c ) = 0;
  92. virtual EMixBlendMode GetMixBlendMode() = 0;
  93. virtual ETextureSampleMode GetTexturesSampleMode() = 0;
  94. virtual void SetBackgroundColor( const char *pchColor ) = 0;
  95. virtual void SetSimpleBackgroundColor( const Color &c ) = 0;
  96. virtual bool GetSimpleBackgroundColor( Color &c ) = 0;
  97. virtual void SetForegroundColor( const char *pchColor ) = 0;
  98. virtual void SetSimpleForegroundColor( const Color &c ) = 0;
  99. virtual bool GetSimpleForegroundColor( Color &c ) = 0;
  100. virtual void SetFontStyle( const char *pchFontFamily, float flSize, EFontStyle style, EFontWeight weight ) = 0;
  101. virtual void GetFontStyle( const char **pchFontFamily, float &flSize, EFontStyle &style, EFontWeight &weight ) = 0;
  102. virtual void GetFontStyleNoDefaults( const char **pchFontFamily, float &flSize, EFontStyle &style, EFontWeight &weight ) = 0;
  103. virtual void GetForegroundFillBrushCollectionMsg( CMsgFillBrushCollection &msg, float flRenderWidth, float flRenderHeight ) = 0;
  104. virtual void GetLineHeight( float &flLineHeight ) = 0;
  105. virtual void GetTextAlign( ETextAlign &align ) = 0;
  106. virtual void GetTextDecoration( ETextDecoration &decoration ) = 0;
  107. virtual void GetTextTransform( ETextTransform &transform ) = 0;
  108. virtual void GetTextLetterSpacing( int &spacing ) = 0;
  109. virtual bool BHasPossibleBackgroundColor() = 0;
  110. virtual void GetWidth( panorama::CUILength &width ) = 0;
  111. virtual void SetWidth( panorama::CUILength width ) = 0;
  112. virtual void GetHeight( panorama::CUILength &height ) = 0;
  113. virtual void SetHeight( panorama::CUILength height ) = 0;
  114. virtual void GetMinWidth( panorama::CUILength &minWidth ) = 0;
  115. virtual void GetMinHeight( panorama::CUILength &minHeight ) = 0;
  116. virtual void GetMaxWidth( panorama::CUILength &maxWidth ) = 0;
  117. virtual void GetMaxHeight( panorama::CUILength &maxHeight ) = 0;
  118. virtual void GetInterpolatedWidth( panorama::CUILength &width, bool bFinal ) = 0;
  119. virtual void GetInterpolatedHeight( panorama::CUILength &height, bool bFinal ) = 0;
  120. virtual void GetInterpolatedMaxWidth( panorama::CUILength &width, bool bFinal ) = 0;
  121. virtual void GetInterpolatedMaxHeight( panorama::CUILength &height, bool bFinal ) = 0;
  122. virtual void GetVisibility( bool &bVisible ) = 0;
  123. virtual void SetVisibility( bool bVisible ) = 0;
  124. virtual void GetFlowChildren( panorama::EFlowDirection &eFlowDirection ) = 0;
  125. virtual void SetFlowChildren( panorama::EFlowDirection eFlowDirection ) = 0;
  126. virtual void GetInterpolatedBorderWidth( panorama::CUILength &left, panorama::CUILength &top, panorama::CUILength &right, panorama::CUILength &bottom, bool bFinal ) = 0;
  127. virtual void GetWhitespaceWrap( bool &bWrap ) = 0;
  128. virtual void GetTextOverflow( bool &bEllipsis ) = 0;
  129. // Content inset is padding+border-width
  130. virtual void GetContentInset( float flBoxWidth, float flBoxHeight, bool bFinalDimensions, float &left, float &top, float &right, float &bottom ) = 0;
  131. // You shouldn't need this outside layout code normally you want GetContentInset instead!
  132. virtual void GetPadding( panorama::CUILength &left, panorama::CUILength &top, panorama::CUILength &right, panorama::CUILength &bottom ) = 0;
  133. virtual void GetMargin( panorama::CUILength &left, panorama::CUILength &top, panorama::CUILength &right, panorama::CUILength &bottom ) = 0;
  134. virtual void GetMargin( float flBoxWidth, float flBoxHeight, float &left, float &top, float &right, float &bottom ) = 0;
  135. virtual void SetMargin( panorama::CUILength &left, panorama::CUILength &top, panorama::CUILength &right, panorama::CUILength &bottom ) = 0;
  136. virtual CUtlVector< CBackgroundImageLayer * > *GetBackgroundImages() = 0;
  137. virtual void SetBackgroundImages( const CUtlVector< CBackgroundImageLayer * > &vecLayers ) = 0;
  138. virtual void GetAlignment( EHorizontalAlignment &eHorizontalAlignment, EVerticalAlignment &eVerticalAlignment ) = 0;
  139. virtual void SetTooltipPositions( const EContextUIPosition( &eTooltipPositions )[ 4 ] ) = 0;
  140. virtual void GetTooltipPositions( EContextUIPosition( &eTooltipPositions )[ 4 ] ) = 0;
  141. virtual void SetTooltipBodyPosition( const panorama::CUILength &horizontalPosition, const panorama::CUILength &verticalPosition ) = 0;
  142. virtual void GetTooltipBodyPosition( panorama::CUILength &horizontalPosition, panorama::CUILength &verticalPosition ) = 0;
  143. virtual void SetTooltipArrowPosition( const panorama::CUILength &horizontalPosition, const panorama::CUILength &verticalPosition ) = 0;
  144. virtual void GetTooltipArrowPosition( panorama::CUILength &horizontalPosition, panorama::CUILength &verticalPosition ) = 0;
  145. virtual void SetContextMenuPositions( const EContextUIPosition( &eContextMenuPositions )[ 4 ] ) = 0;
  146. virtual void GetContextMenuPositions( EContextUIPosition( &eContextMenuPositions )[ 4 ] ) = 0;
  147. virtual void SetContextMenuBodyPosition( const panorama::CUILength &horizontalPosition, const panorama::CUILength &verticalPosition ) = 0;
  148. virtual void GetContextMenuBodyPosition( panorama::CUILength &horizontalPosition, panorama::CUILength &verticalPosition ) = 0;
  149. virtual void SetContextMenuArrowPosition( const panorama::CUILength &horizontalPosition, const panorama::CUILength &verticalPosition ) = 0;
  150. virtual void GetContextMenuArrowPosition( panorama::CUILength &horizontalPosition, panorama::CUILength &verticalPosition ) = 0;
  151. virtual void GetAnimationNames( CUtlVector< CPanoramaSymbol > *pvecAnimations ) = 0;
  152. virtual void ResetAnimations() = 0;
  153. // Get actual parent sizes, which we need to convert some % units to px
  154. virtual float GetParentActualRenderWidth() = 0;
  155. virtual float GetParentActualRenderHeight() = 0;
  156. // Checks if the property has any data for transition
  157. virtual bool BHasAnyTransition() = 0;
  158. // Checks if this panel has any active transitions or animations
  159. virtual bool BHasAnyTransitionOrAnimation( bool bExcludeStylesImpactingOnlyCompositing ) = 0;
  160. virtual bool BHasAnimatingBackground() = 0;
  161. // Checks if the panel is completely transparent, and has no current animation/transition of opacity.
  162. // If this is true it means we don't need to draw the panel.
  163. virtual bool BIsTransparentWithNoOpacityTransition() = 0;
  164. // Set a new UI scale factor from the one we constructed with
  165. virtual void SetUIScaleFactor( float flScaleFactor ) = 0;
  166. // Set transition properties
  167. virtual void SetTransitionProperties( const CUtlVector< TransitionProperty_t > &vecTransitionProperties ) = 0;
  168. // Get animation control curve points
  169. virtual void GetAnimationCurveControlPoints( EAnimationTimingFunction eTransitionEffect, Vector2D vecPoints[4] ) = 0;
  170. // Low level search for property info for debugger use
  171. virtual void FindPropertyInfo( CStyleSymbol hSymbol, CStyleProperty **ppProperty, PropertyInTransition_t **ppTransitionData, CUtlVector< CActiveAnimation * > *pvecAnimations ) = 0;
  172. virtual const CUtlVector<StyleEntry_t> &PropertiesSetFromElement() const = 0;
  173. virtual const CStyleProperty *GetPropertyNoInherit( CStyleSymbol symProperty ) = 0;
  174. // properties set on element style (set from code)
  175. virtual bool BPropertySetFromElement( CStyleSymbol symProperty ) const = 0;
  176. virtual void ClearPropertySetFromElement( CStyleSymbol symProperty ) = 0;
  177. #ifdef DBGFLAG_VALIDATE
  178. virtual void Validate( CValidator &validator, const tchar *pchName ) = 0;
  179. #endif
  180. };
  181. }
  182. #endif // IUIPANELSTYLE_H