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.

114 lines
3.5 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef PANORAMA_SLIDESHOW_H
  6. #define PANORAMA_SLIDESHOW_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panorama/controls/panel2d.h"
  11. #include "panorama/controls/mousescroll.h"
  12. namespace panorama
  13. {
  14. DECLARE_PANEL_EVENT1( SlideShowPanelChanged, int );
  15. DECLARE_PANEL_EVENT0( SlideShowOnLayoutInitialized );
  16. //-----------------------------------------------------------------------------
  17. // Purpose: Panel that shows a slideshow of panels
  18. //-----------------------------------------------------------------------------
  19. class CSlideShow : public CPanel2D
  20. {
  21. DECLARE_PANEL2D( CSlideShow, CPanel2D );
  22. public:
  23. CSlideShow( CPanel2D *pParent, const char *pchID );
  24. virtual ~CSlideShow();
  25. void AddPanel( CPanel2D *pPanel, bool bDontSetFocusBySideEffect );
  26. void RemoveAndDeletePanel( CPanel2D *pPanel );
  27. void SetManageFocus( bool bManageFocus ) { m_bManageFocus = bManageFocus; }
  28. void SetFocusIndex( int iFocus, bool bSkipChildCountCheck = false );
  29. int GetFocusIndex() { return m_iFocusChild; }
  30. CPanel2D *GetFocusChild() { return GetChild(m_iFocusChild); }
  31. bool BFocusChildRightMost() { return (m_iFocusChild == (GetChildCount() - 1)); }
  32. virtual bool OnMoveRight( int nRepeats );
  33. virtual bool OnMoveLeft( int nRepeats );
  34. virtual bool OnTabForward( int nRepeats );
  35. virtual bool OnTabBackward( int nRepeats );
  36. virtual void Paint();
  37. virtual void OnLayoutTraverse( float flFinalWidth, float flFinalHeight );
  38. virtual bool OnSetFocusToNextPanel( int nRepeats, EFocusMoveDirection moveType, bool bAllowWrap, float flTabIndexCurrent, float flXPosCurrent, float flYPosCurrent, float flXStart, float fYStart ) OVERRIDE
  39. {
  40. switch( moveType )
  41. {
  42. case k_ENextInTabOrder:
  43. if ( m_bManageFocus && OnTabForward( nRepeats ) )
  44. return true;
  45. break;
  46. case k_ENextByXPosition:
  47. if ( m_bManageFocus && OnMoveRight( nRepeats ) )
  48. return true;
  49. break;
  50. case k_EPrevInTabOrder:
  51. if ( m_bManageFocus && OnTabBackward( nRepeats ) )
  52. return true;
  53. break;
  54. case k_EPrevByXPosition:
  55. if ( m_bManageFocus && OnMoveLeft( nRepeats ) )
  56. return true;
  57. break;
  58. case k_ENextByYPosition:
  59. if ( m_bManageFocus && OnMoveDown( nRepeats ) )
  60. return true;
  61. break;
  62. case k_EPrevByYPosition:
  63. if ( m_bManageFocus && OnMoveUp( nRepeats ) )
  64. return true;
  65. break;
  66. default:
  67. break;
  68. }
  69. return false;
  70. }
  71. virtual panorama::IUIPanel *OnGetDefaultInputFocus() OVERRIDE;
  72. #ifdef DBGFLAG_VALIDATE
  73. virtual void ValidateClientPanel( CValidator &validator, const tchar *pchName ) OVERRIDE;
  74. #endif
  75. protected:
  76. bool EventInputFocusSet( const panorama::CPanelPtr< panorama::IUIPanel > &ptrPanel );
  77. bool EventCarouselMouseScroll( const CPanelPtr< IUIPanel > &ptrPanel, int cRepeat );
  78. bool EventSlideShowOnLayoutInitialized( const CPanelPtr< IUIPanel > &ptrPanel );
  79. virtual void OnInitializedFromLayout();
  80. void SetPanelStyles( int iOldFocus, int iNewFocus );
  81. void LayoutMouseScrollRegions( float flFinalWidth, float flFinalHeight );
  82. private:
  83. virtual void AddDisabledFlagToChildren() OVERRIDE;
  84. virtual void RemoveDisabledFlagFromChildren() OVERRIDE;
  85. void SetIndividualPanelStyle( int iChild, int iOldFocus, int iNewFocus );
  86. void SetMouseScrollVisibility( int iFocus );
  87. int m_iFocusChild;
  88. bool m_bManageFocus;
  89. CMouseScrollRegion *m_pLeftMouseScrollRegion;
  90. CMouseScrollRegion *m_pRightMouseScrollRegion;
  91. };
  92. } // namespace panorama
  93. #endif // PANORAMA_SLIDESHOW_H