49 displayPercentage =
false;
50 displayedMessage = text;
79 if (displayPercentage)
81 if (currentValue >= 0 && currentValue <= 1.0)
82 text <<
roundToInt (currentValue * 100.0) <<
'%';
86 text = displayedMessage;
91 const auto v = currentValue;
104void ProgressBar::timerCallback()
110 lastCallbackTime = now;
114 || currentMessage != displayedMessage)
118 && currentValue >= 0 && currentValue < 1.0)
125 currentMessage = displayedMessage;
139 explicit ProgressBarAccessibilityHandler (
ProgressBar& progressBarToWrap)
141 AccessibilityRole::progressBar,
144 progressBar (progressBarToWrap)
148 String getHelp()
const override {
return progressBar.getTooltip(); }
154 explicit ValueInterface (
ProgressBar& progressBarToWrap)
155 : progressBar (progressBarToWrap)
159 bool isReadOnly()
const override {
return true; }
161 double getCurrentValue()
const override {
return progressBar.progress; }
162 AccessibleValueRange getRange()
const override {
return { { 0.0, 1.0 }, 0.001 }; }
177 return std::make_unique<ProgressBarAccessibilityHandler> (*
this);
A simple wrapper for building a collection of supported accessibility actions and corresponding callb...
Base class for accessible Components.
A value interface that represents a ranged numeric value.
bool isVisible() const noexcept
Tests whether the component is visible or not.
int getHeight() const noexcept
Returns the component's height in pixels.
AccessibilityHandler * getAccessibilityHandler()
Returns the accessibility handler for this component, or nullptr if this component is not accessible.
void setOpaque(bool shouldBeOpaque)
Indicates whether any parts of the component might be transparent.
void repaint()
Marks the whole component as needing to be redrawn.
int getWidth() const noexcept
Returns the component's width in pixels.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
A graphics context, used for drawing a component or image.
A progress bar component.
Style getResolvedStyle() const
Returns the progress bar's current style if it has one, or a default style determined by the look-and...
ProgressBar(double &progress)
Creates a ProgressBar.
void lookAndFeelChanged() override
Called to let the component react to a change in the look-and-feel setting.
void colourChanged() override
This method is called when a colour is changed by the setColour() method, or when the look-and-feel i...
Style
The types of ProgressBar styles available.
void setStyle(std::optional< Style > newStyle)
Sets the progress bar's current style.
void paint(Graphics &) override
Components can override this method to draw their content.
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Override this method to return a custom AccessibilityHandler for this component.
void setPercentageDisplay(bool shouldDisplayPercentage)
Turns the percentage display on or off.
void visibilityChanged() override
Called when this component's visibility changes.
void setTextToDisplay(const String &text)
Gives the progress bar a string to display inside it.
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).
void stopTimer() noexcept
Stops the timer.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
@ valueChanged
Indicates that the UI element's value has changed.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
Utility struct which holds one or more accessibility interfaces.
virtual void drawProgressBar(Graphics &, ProgressBar &, int width, int height, double progress, const String &textToShow)=0
Draws a progress bar.