ezEngine  Release 25.03
ezProgressRange Class Reference

ezProgressRange is the preferred method to inform the system of progress. More...

#include <Progress.h>

Public Member Functions

 ezProgressRange (ezStringView sDisplayText, ezUInt32 uiSteps, bool bAllowCancel, ezProgress *pProgressbar=nullptr)
 Creates a progress range scope. More...
 
 ezProgressRange (ezStringView sDisplayText, bool bAllowCancel, ezProgress *pProgressbar=nullptr)
 Creates a progress range scope without steps. Use SetCompletion to manually set the completion value.
 
 ~ezProgressRange ()
 The destructor closes the current range. All progress in this range is assumed to have completed, even if BeginNextStep() has not been called once for every subdivision step.
 
ezProgressGetProgressbar () const
 Returns the ezProgress instance that this range uses.
 
void SetStepWeighting (ezUInt32 uiStep, float fWeight)
 Allows to weigh each step differently. More...
 
bool BeginNextStep (ezStringView sStepDisplayText, ezUInt32 uiNumSteps=1)
 Should be called whenever a new sub-step is started to advance the progress. More...
 
bool SetCompletion (double fCompletionFactor)
 Manually set the completion value between 0..1.
 
bool WasCanceled () const
 Whether the user requested to cancel the operation.
 

Friends

class ezProgress
 

Detailed Description

ezProgressRange is the preferred method to inform the system of progress.

ezProgressRange is a scoped class, ie. upon creation it adds a range to the current progress and upon destruction the entire range is considered to be completed. Ranges can be nested. For instance when a top level range consists of three 'steps', then opening a nested range will sub-divide that first step. When the nested range is closed, the first top-level step is finished and BeginNextStep() should be called on the top-level range. Subsequently the second step is active and can again be further subdivided with another nested ezProgressRange.

Constructor & Destructor Documentation

◆ ezProgressRange()

ezProgressRange::ezProgressRange ( ezStringView  sDisplayText,
ezUInt32  uiSteps,
bool  bAllowCancel,
ezProgress pProgressbar = nullptr 
)

Creates a progress range scope.

If any other progress range is currently active, it will become the parent range and the currently active step will be subdivided.

Parameters
szDisplayTextis the main display text for this range.
uiStepsis the number of steps that this range will be subdivided into
bAllowCancelspecifies whether the user can cancel this operation
pProgressbarcan be specified, if available, otherwise the currently active ezProgress instance is used.

Member Function Documentation

◆ BeginNextStep()

bool ezProgressRange::BeginNextStep ( ezStringView  sStepDisplayText,
ezUInt32  uiNumSteps = 1 
)

Should be called whenever a new sub-step is started to advance the progress.

Parameters
szStepDisplayTextThe sub-text for the next step to be displayed.
uiNumStepsHow many steps have been completed.
Returns
Returns false if the user clicked cancel.

◆ SetStepWeighting()

void ezProgressRange::SetStepWeighting ( ezUInt32  uiStep,
float  fWeight 
)

Allows to weigh each step differently.

This makes it possible to divide an operation into two steps, but have one part take up 90% and the other 10%.

Parameters
uiStepThe index for the step to set the weight
fWeightThe weighting in [0; 1] range

The documentation for this class was generated from the following files: