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.

84 lines
2.9 KiB

  1. //=========== Copyright Valve Corporation, All rights reserved. ===============//
  2. //
  3. // Purpose:
  4. //=============================================================================//
  5. #ifndef LIST_SEGMENT_VIEW_H
  6. #define LIST_SEGMENT_VIEW_H
  7. #ifdef _WIN32
  8. #pragma once
  9. #endif
  10. #include "panel2d.h"
  11. DECLARE_PANEL_EVENT0( ListSegmentViewRetreat );
  12. DECLARE_PANEL_EVENT0( ListSegmentViewAdvance );
  13. DECLARE_PANORAMA_EVENT0( ListSegmentViewChanged );
  14. namespace panorama
  15. {
  16. /*
  17. A class that handles displaying X sequential elements from its children. Similar to a carousel, but more
  18. minimal -- you handle advancing/retreating yourself. Supports up to 10 visible elements.
  19. Things you need to do:
  20. - Specify "items-displayed:" in the xml, which is how many elements are shown at once.
  21. - Specify "step-size:" in the xml, which is how many steps it'll move when advancing or retreating. Cannot be bigger than items-displayed.
  22. - Define these classes, which will be added to the child elements (X is always 1 through 10):
  23. .ListSegmentDisplayedX, one for each of the elements you intend to display.
  24. .ListSegmentHiddenBeforeX, one for each hidden element that's off the "top/left" of the display. These guys are prior to the displayed window.
  25. .ListSegmentHiddenAfterX, one for each hidden element that's off the "bottom/right" of the display. These guys are after the displayed window.
  26. .ListSegmentSnap, which eliminates any transitions you're using in your element class, so that elements just go directly to their displayed/hidden states immediately.
  27. Then you just need to add children (in order) to it, and call AdvancePosition and RetreatPosition to move through them.
  28. */
  29. //-----------------------------------------------------------------------------
  30. // Purpose: List Segment View
  31. //-----------------------------------------------------------------------------
  32. class CListSegmentView : public CPanel2D
  33. {
  34. DECLARE_PANEL2D( CListSegmentView, CPanel2D );
  35. public:
  36. CListSegmentView( CPanel2D *parent, const char * pchPanelID );
  37. virtual ~CListSegmentView();
  38. virtual bool BSetProperty( CPanoramaSymbol symName, const char *pchValue ) OVERRIDE;
  39. virtual void GetDebugPropertyInfo( CUtlVector< DebugPropertyOutput_t *> *pvecProperties ) OVERRIDE;
  40. virtual void OnStylesChanged() OVERRIDE { UpdateChildrenStyles( false ); BaseClass::OnStylesChanged(); }
  41. virtual void OnAfterChildrenChanged() OVERRIDE { UpdateChildrenStyles( false ); BaseClass::OnAfterChildrenChanged(); }
  42. virtual bool BRequiresContentClipLayer() OVERRIDE { return true; }
  43. bool RetreatPosition( const CPanelPtr< IUIPanel > &panelPtr );
  44. bool AdvancePosition( const CPanelPtr< IUIPanel > &panelPtr );
  45. int GetCurrentPage( void );
  46. int GetNumPages( void );
  47. bool IsAtStart( void );
  48. bool IsAtEnd( void );
  49. void ResetPosition( void );
  50. private:
  51. void UpdateChildrenStyles( bool bSnap );
  52. int m_nItemsDisplayed;
  53. int m_nStepSize;
  54. int m_nCurrentChildIndex;
  55. };
  56. } // namespace panorama
  57. #endif // LIST_SEGMENT_VIEW_H