diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/toolutils/toolwindowfactory.h | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'public/toolutils/toolwindowfactory.h')
| -rw-r--r-- | public/toolutils/toolwindowfactory.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/public/toolutils/toolwindowfactory.h b/public/toolutils/toolwindowfactory.h new file mode 100644 index 0000000..71b4c1c --- /dev/null +++ b/public/toolutils/toolwindowfactory.h @@ -0,0 +1,59 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//============================================================================= + +#ifndef TOOLWINDOWFACTORY_H +#define TOOLWINDOWFACTORY_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui_controls/ToolWindow.h" +#include "vgui/IInput.h" + +#define TOOLWINDOW_DEFAULT_WIDTH 640 +#define TOOLWINDOW_DEFAULT_HEIGHT 480 +#define TOOLWINDOW_MIN_WIDTH 120 +#define TOOLWINDOW_MIN_HEIGHT 80 + +template < class T > +class CToolWindowFactory : public vgui::IToolWindowFactory +{ +public: + virtual vgui::ToolWindow *InstanceToolWindow + ( + vgui::Panel *parent, + bool contextLabel, // Tool window shows context button for pages with context menus? + vgui::Panel *firstPage, + char const *title, + bool contextMenu // Page has context menu + ); +}; + +//----------------------------------------------------------------------------- +// Methods related to CToolWindowFactory +//----------------------------------------------------------------------------- +template < class T > +vgui::ToolWindow *CToolWindowFactory<T>::InstanceToolWindow( vgui::Panel *parent, bool contextLabel, vgui::Panel *firstPage, char const *title, bool contextMenu ) +{ + Assert( parent ); + if ( !parent ) + return NULL; + + int mx, my; + vgui::input()->GetCursorPos( mx, my ); + parent->ScreenToLocal( mx, my ); + + T *container = new T( parent, contextLabel, this, firstPage, title, contextMenu ); + Assert( container ); + if ( container ) + { + container->SetBounds( mx, my, TOOLWINDOW_DEFAULT_WIDTH, TOOLWINDOW_DEFAULT_HEIGHT ); + container->SetMinimumSize( TOOLWINDOW_MIN_WIDTH, TOOLWINDOW_MIN_HEIGHT ); + } + return container; +} + +#endif // TOOLWINDOWFACTORY_H |