VGUI ImagePanel: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (clean up, added deadend tag)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Dead end|date=January 2024}}
An ImagePanel is a vgui2 element defined in the vgui_controls library, in the file ImagePanel.cpp. ImagePanels are available in all source games. An ImagePanel is a simple panel that displays an image.
An ImagePanel is a vgui2 element defined in the vgui_controls library, in the file ImagePanel.cpp. ImagePanels are available in all source games. An ImagePanel is a simple panel that displays an image.


Line 8: Line 10:


  using namespace vgui;
  using namespace vgui;


ImagePanels can be created via the c++ keyword new with a simple call to ImagePanel:
ImagePanels can be created via the c++ keyword new with a simple call to ImagePanel:


  ImagePanel* imagePanel = new ImagePanel(this, "myPanel");
  ImagePanel* imagePanel = new ImagePanel(this, "myPanel");


Once we have our ImagePanel created, we can now tell it which image to display:
Once we have our ImagePanel created, we can now tell it which image to display:
Line 19: Line 19:
  imagePanel->SetImage(scheme()->GetImage("myimage", false));
  imagePanel->SetImage(scheme()->GetImage("myimage", false));
   
   
Its important to note that scheme()->GetImage begins from "materials/vgui" and no extensions should be provided. So, scheme()->GetImage("vgui/eye", false) would really point to "materials/vgui/vgui/eye.vmt".
Its important to note that scheme::GetImage begins from "materials/vgui" and no extensions should be provided. So, scheme()->GetImage("vgui/eye", false) would really point to "materials/vgui/vgui/eye.vmt".
 


And we're done!
And we're done!


[[Category:VGUI_Controls|I]]
[[Category:VGUI Controls|I]]

Latest revision as of 10:18, 21 January 2024

Dead End - Icon.png
This article has no Wikipedia icon links to other VDC articles. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024

An ImagePanel is a vgui2 element defined in the vgui_controls library, in the file ImagePanel.cpp. ImagePanels are available in all source games. An ImagePanel is a simple panel that displays an image.

Example Usage

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

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

ImagePanels can be created via the c++ keyword new with a simple call to ImagePanel:

ImagePanel* imagePanel = new ImagePanel(this, "myPanel");

Once we have our ImagePanel created, we can now tell it which image to display:

imagePanel->SetImage(scheme()->GetImage("myimage", false));

Its important to note that scheme::GetImage begins from "materials/vgui" and no extensions should be provided. So, scheme()->GetImage("vgui/eye", false) would really point to "materials/vgui/vgui/eye.vmt".

And we're done!