NDEVR
API Documentation
QCustomProgressbar.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Widgets
28File: QCustomProgressbar
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/BaseValues.h>
35#include <NDEVR/TimeSpan.h>
36#include <NDEVR/RGBColor.h>
37#include <NDEVR/Buffer.h>
38#include <NDEVR/String.h>
39#include <QProgressBar>
40namespace NDEVR
41{
42 class TranslatedString;
43 class String;
56 class NDEVR_WIDGETS_API QCustomProgressBar : public QProgressBar
57 {
58 Q_OBJECT
59 public:
64 explicit QCustomProgressBar(QWidget* parent = nullptr);
65 virtual ~QCustomProgressBar() override;
66
72
80
90
96 virtual void setPercent(fltp08 percent);
101 [[nodiscard]] fltp08 percent() const;
102
107 [[nodiscard]] bool isIndeterminateState() const;
108
113 void setDrawBackground(bool draw_background);
114
120 virtual void setMessage(const TranslatedString& message);
121
127 void setFormat(const StringView& format);
128
135 virtual void setToIndeterminateState(bool is_indeterminate);
136
143 protected:
148 [[nodiscard]] QSize sizeHint() const override;
153 [[nodiscard]] QSize minimumSizeHint() const override;
158 [[nodiscard]] fltp08 indeterminatePercent() const;
164 [[nodiscard]] QString customText(fltp04 percent) const;
170 void paintEvent(QPaintEvent* event) override;
171 protected slots:
176 protected:
181 protected:
186 QString m_last_text;
188 };
189}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
QTimer * m_update_timer
Timer driving the indeterminate animation updates.
fltp08 percent() const
Returns the current progress percent.
virtual void setMessage(const TranslatedString &message)
Sets the translated message text displayed inside the progress bar when progress is indeterminate.
fltp08 indeterminatePercent() const
Returns the current indeterminate animation percent for rendering.
virtual void setPercent(fltp08 percent)
Sets the progress bar to a specific percent complete.
void setFormat(const StringView &format)
Sets the raw format string displayed inside the progress bar when progress is indeterminate.
TimeSpan m_indeterminate_period
Duration for one full indeterminate animation cycle.
virtual void setIndeterminateAnimationTimespan(const TimeSpan &span)
Sets the time span for one full cycle of the indeterminate animation.
void updateProgressColor()
Recalculates the current progress color based on the gradient stops and percent.
void paintEvent(QPaintEvent *event) override
Custom paint event handler that draws the progress bar with gradient and indeterminate animation supp...
QString m_last_text
The last rendered display text.
void addProgressColor(fltp08 percent, RGBColor color)
Adds a color stop at a given percent to form a gradient.
QString customText(fltp04 percent) const
Returns the formatted display text for a given percent value.
QSize minimumSizeHint() const override
Returns the minimum recommended size for the progress bar.
QCustomProgressBar(QWidget *parent=nullptr)
Constructs a progress bar widget.
void setProgressColors(const Buffer< RGBColor > &colors)
Sets multiple progress colors that will be evenly spaced across the progress range.
void updateFromTimer()
Slot called by the timer to update the indeterminate animation.
bool isIndeterminateState() const
Checks whether the progress bar is in an indeterminate (spinning) state.
String m_last_format
The last format string used for display text.
QSize sizeHint() const override
Returns the recommended size for the progress bar.
void setDrawBackground(bool draw_background)
Sets whether to draw the background behind the progress bar.
void setProgressColor(RGBColor color)
Sets a single solid color for the progress bar fill.
bool m_draw_background
Whether to draw the background behind the progress bar.
void clearProgressColors()
Removes all custom progress colors, reverting to the default appearance.
Buffer< std::pair< fltp08, RGBColor > > m_progress_colors
Gradient color stops as percent-color pairs.
virtual void setToIndeterminateState(bool is_indeterminate)
Toggles the indeterminate state, which shows an animation to indicate activity without a known comple...
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:57
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
double fltp08
Defines an alias representing an 8 byte floating-point number.