mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-21 13:35:04 -04:00
*DigitsContainer definicions moved to cpp file(for proper linkage) *DigitsContainer changed container to std::vector *Fixed a bug in ProgressTimerWithBarGraphAndCounter where timerText was treated as timeWidget *MeditationCountdownWindow timer is now custom size *Minus removed form MeditationRunningWindow timer
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "DigitsContainer.hpp"
|
|
|
|
#include <Utils.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
|
|
void setDigits(std::string text, const DigitsContainer &container, DimensionsParams params)
|
|
{
|
|
std::for_each(std::crbegin(container.digits),
|
|
std::crend(container.digits),
|
|
[text = std::move(text), ¶ms](Label *label) mutable {
|
|
if (text.empty()) {
|
|
label->setText("");
|
|
label->setSize(0, 0);
|
|
}
|
|
else {
|
|
label->setText(std::string{text.back()});
|
|
label->setSize(params.digitMaxWidth, params.mainBoxHeight);
|
|
text.pop_back();
|
|
}
|
|
});
|
|
}
|
|
|
|
DigitsContainer::DigitsContainer(uint32_t digitsCount) : digits(digitsCount, nullptr)
|
|
{}
|
|
|
|
void DigitsContainer::setMinutesBox(std::uint32_t minutes, DimensionsParams params)
|
|
{
|
|
constexpr auto rangeGuard = 1000;
|
|
minutes %= rangeGuard;
|
|
|
|
setDigits(std::to_string(minutes), *this, params);
|
|
}
|
|
|
|
void DigitsContainer::setSecondsBox(std::uint32_t seconds, DimensionsParams params)
|
|
{
|
|
constexpr auto rangeGuard = 100;
|
|
seconds %= rangeGuard;
|
|
|
|
std::string text = utils::addLeadingZeros(std::to_string(seconds), digits.size());
|
|
|
|
setDigits(std::move(text), *this, params);
|
|
}
|
|
|
|
} // namespace gui
|