Difference between revisions of "VGUI SectionedListPanel"

From Valve Developer Community
Jump to: navigation, search
Line 7: Line 7:
 
</div>
 
</div>
  
A SectionedListPanel is a vgui2 element defined in the vgui_controls library, in the file SectionedListPanel.cpp. SectionedListPanels are available in all source games. SectionedListPanels, as the name suggests, are useful for listing sectioned groups of information. Furthermore, the list items are sortable. The standard scoreboard was created using a SectionedListPanel, and thus represents a good example of the SectionedListPanel's capabilities. The member m_Items is a CutlLinkedList structure that contains _unsorted_ items, ResortList() traverses through m_Items and sorts m_Items provided you define a sorting function (which is passed to an object of class SectionedListPanel via AddSection, and subsequently stored in m_pFuncSort. Look at CClientScoreBoardDialog::StaticPlayerSortFunc for an example sorting function), the resulting, sorted list is then stored in m_ItemSorted.  
+
A SectionedListPanel is a vgui2 element defined in the vgui_controls library, in the file SectionedListPanel.cpp. SectionedListPanels are available in all source games. SectionedListPanels, as the name suggests, are useful for listing sectioned groups of information. Furthermore, the list items are sortable. The standard scoreboard was created using a SectionedListPanel, and thus represents a good example of the SectionedListPanel's capabilities.  
 +
 
 +
The member m_Items is a CutlLinkedList structure that contains ''unsorted'' items, SectionedListPanel::ResortList() traverses through m_Items and sorts m_Items provided you define a sorting function passed via AddSection(), and subsequently stored in m_pFuncSort. Look at CClientScoreBoardDialog::StaticPlayerSortFunc for an example sorting function. The resulting, sorted list is then stored in m_ItemSorted.  
  
 
[[Image:SectionedListPanel.jpg|thumb|This screenshot represents valve's default scoreboard which was built using a SectionedListPanel.]]
 
[[Image:SectionedListPanel.jpg|thumb|This screenshot represents valve's default scoreboard which was built using a SectionedListPanel.]]

Revision as of 04:52, 13 April 2011

This article is a stub. You can help by adding to it.

A SectionedListPanel is a vgui2 element defined in the vgui_controls library, in the file SectionedListPanel.cpp. SectionedListPanels are available in all source games. SectionedListPanels, as the name suggests, are useful for listing sectioned groups of information. Furthermore, the list items are sortable. The standard scoreboard was created using a SectionedListPanel, and thus represents a good example of the SectionedListPanel's capabilities.

The member m_Items is a CutlLinkedList structure that contains unsorted items, SectionedListPanel::ResortList() traverses through m_Items and sorts m_Items provided you define a sorting function passed via AddSection(), and subsequently stored in m_pFuncSort. Look at CClientScoreBoardDialog::StaticPlayerSortFunc for an example sorting function. The resulting, sorted list is then stored in m_ItemSorted.

This screenshot represents valve's default scoreboard which was built using a SectionedListPanel.

Example Usage

Before creating anything, we first need to include the SectionedListPanel header file and use the vgui namespace.

#include <vgui_controls/SectionedListPanel.h>
using namespace vgui;

SectionedListPanels can be created via the c++ keyword new with a simple call to SectionedListPanel.

SectionedListPanel* myPanel = new SectionedListPanel(this, "myPanel");

Additional Information

Additional information and examples can be found by simply looking at the scoreboard code, found in ClientScoreBoardDialog.cpp in the game_controls folder.