summaryrefslogtreecommitdiff
path: root/public/vgui_controls/ProgressBar.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /public/vgui_controls/ProgressBar.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'public/vgui_controls/ProgressBar.h')
-rw-r--r--public/vgui_controls/ProgressBar.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/public/vgui_controls/ProgressBar.h b/public/vgui_controls/ProgressBar.h
new file mode 100644
index 0000000..3dfac7f
--- /dev/null
+++ b/public/vgui_controls/ProgressBar.h
@@ -0,0 +1,112 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef PROGRESSBAR_H
+#define PROGRESSBAR_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include <vgui/VGUI.h>
+#include <vgui_controls/Panel.h>
+
+namespace vgui
+{
+
+//-----------------------------------------------------------------------------
+// Purpose: Status bar that visually displays discrete progress in the form
+// of a segmented strip
+//-----------------------------------------------------------------------------
+class ProgressBar : public Panel
+{
+ DECLARE_CLASS_SIMPLE( ProgressBar, Panel );
+
+public:
+ ProgressBar(Panel *parent, const char *panelName);
+ ~ProgressBar();
+
+ // 'progress' is in the range [0.0f, 1.0f]
+ MESSAGE_FUNC_FLOAT( SetProgress, "SetProgress", progress );
+ float GetProgress();
+ virtual void SetSegmentInfo( int gap, int width );
+
+ // utility function for calculating a time remaining string
+ static bool ConstructTimeRemainingString(OUT_Z_BYTECAP(outputBufferSizeInBytes) wchar_t *output, int outputBufferSizeInBytes, float startTime, float currentTime, float currentProgress, float lastProgressUpdateTime, bool addRemainingSuffix);
+
+ void SetBarInset( int pixels );
+ int GetBarInset( void );
+ void SetMargin( int pixels );
+ int GetMargin();
+
+ virtual void ApplySettings(KeyValues *inResourceData);
+ virtual void GetSettings(KeyValues *outResourceData);
+ virtual const char *GetDescription();
+
+ // returns the number of segment blocks drawn
+ int GetDrawnSegmentCount();
+
+ enum ProgressDir_e
+ {
+ PROGRESS_EAST,
+ PROGRESS_WEST,
+ PROGRESS_NORTH,
+ PROGRESS_SOUTH
+ };
+
+ int GetProgressDirection() const { return m_iProgressDirection; }
+ void SetProgressDirection( int val ) { m_iProgressDirection = val; }
+
+protected:
+ virtual void Paint();
+ void PaintSegment( int &x, int &y, int tall, int wide );
+ virtual void PaintBackground();
+ virtual void ApplySchemeSettings(IScheme *pScheme);
+ MESSAGE_FUNC_PARAMS( OnDialogVariablesChanged, "DialogVariables", dialogVariables );
+ /* CUSTOM MESSAGE HANDLING
+ "SetProgress"
+ input: "progress" - float value of the progress to set
+ */
+
+protected:
+ int m_iProgressDirection;
+ float _progress;
+
+private:
+ int _segmentCount;
+ int _segmentGap;
+ int _segmentWide;
+ int m_iBarInset;
+ int m_iBarMargin;
+ char *m_pszDialogVar;
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: Non-segmented progress bar
+//-----------------------------------------------------------------------------
+class ContinuousProgressBar : public ProgressBar
+{
+ DECLARE_CLASS_SIMPLE( ContinuousProgressBar, ProgressBar );
+
+public:
+ ContinuousProgressBar(Panel *parent, const char *panelName);
+ MESSAGE_FUNC_FLOAT( SetPrevProgress, "SetPrevProgress", prevProgress );
+
+ void SetGainColor( Color color ) { m_colorGain = color; }
+ void SetLossColor( Color color ) { m_colorLoss = color; }
+
+ virtual void Paint();
+
+protected:
+ float _prevProgress;
+ Color m_colorGain;
+ Color m_colorLoss;
+};
+
+} // namespace vgui
+
+#endif // PROGRESSBAR_H