Files
MuditaOS/module-gui/gui/widgets/ProgressBar.hpp
T
Adam 64db7d8327 EDG-3585 Small fixup for refresh & cleanup in buildDrawLists (#916)
* EGD-3585 Minor refresh fixup&  Normalised buildDrawList everywhere
2020-10-30 10:13:47 +01:00

68 lines
2.2 KiB
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <cstdint>
#include "Arc.hpp"
#include "Circle.hpp"
#include "Rect.hpp"
namespace gui
{
class Progress
{
public:
virtual ~Progress() noexcept = default;
virtual void setMaximum(unsigned int value) noexcept = 0;
virtual void setValue(unsigned int value) noexcept = 0;
virtual void setPercentageValue(unsigned int value) noexcept = 0;
};
class ProgressBar : public Rect, public Progress
{
public:
ProgressBar(Item *parent, std::uint32_t x, std::uint32_t y, std::uint32_t w, std::uint32_t h);
void setMaximum(unsigned int value) noexcept override;
void setValue(unsigned int value) noexcept override;
void setPercentageValue(unsigned int value) noexcept override;
void buildDrawListImplementation(std::list<Command> &commands) override;
bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
private:
void createWidgets();
unsigned int maxValue = 0U;
unsigned int currentValue = 0U;
gui::Rect *fillRect = nullptr;
};
class CircularProgressBar : public Circle, public Progress
{
public:
CircularProgressBar(Item *parent, const Circle::ShapeParams &shape);
void setMaximum(unsigned int value) noexcept override;
void setValue(unsigned int value) noexcept override;
void setPercentageValue(unsigned int value) noexcept override;
void buildDrawListImplementation(std::list<Command> &commands) override;
auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
private:
void createWidgets();
auto calculateProgressIndicatorCenter() const noexcept -> Point;
auto getPercentageValue() const noexcept -> float;
unsigned int maxValue = 0U;
unsigned int currentValue = 0U;
Arc *progressArc = nullptr;
Circle *progressIndicator = nullptr;
};
} // namespace gui