VGUI Grid

From Valve Developer Community
Jump to: navigation, search

Stub

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

VGUI Grid is a vgui2 control. In Episodic mods, it is defined in src\cl_dll\vgui_grid.cpp. Grid is used to group multiple control panels into a single grid.

Example Usage

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

//(Episodic only)
#include "vgui_grid.h"
using namespace vgui;


Grids can be created via the c++ keyword new with a simple call to CGrid:

CGrid* pGrid = new CGrid();


Once created, we now need to configure it:

pGrid->SetDimensions(5,5); //columns, rows
pGrid->SetSpacing(10,10); //xSpacing, ySpacing
pGrid->SetPos(100,100);
pGrid->SetVisible(true);


Now we can add control elements to it, for this example we'll use an ImagePanel.

ImagePanel* img = new ImagePanel(this, "img");
img->SetImage(scheme()->GetImage("vgui/eye", false));
img->SetVisible(true);

pGrid->SetEntry(0,0,img);