mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-24 05:47:58 -05:00
Due to vfs deprecation there is need to remove all vfs calls from code. This PR covers module gui. There are some modifications in other modules included which are necessary because of build system issues.
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#include "ButtonOnOff.hpp"
|
|
|
|
#include <Style.hpp>
|
|
#include <i18n/i18n.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
ButtonOnOff::ButtonOnOff(Item *parent, const ButtonState buttonState) : Label{parent}
|
|
{
|
|
setMinimumSize(style::buttonOnOff::w, style::buttonOnOff::h);
|
|
|
|
setEdges(RectangleEdge::All);
|
|
setCorners(RectangleRoundedCorner::All);
|
|
setRadius(4);
|
|
setPenWidth(2);
|
|
setFilled(true);
|
|
setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
|
|
setFont(style::window::font::small);
|
|
switchState(buttonState);
|
|
}
|
|
|
|
void ButtonOnOff::switchState(const ButtonState newButtonState)
|
|
{
|
|
currentState = newButtonState;
|
|
if (currentState == ButtonState::On) {
|
|
setFillColor(ColorFullBlack);
|
|
setText(utils::translateI18("app_settings_toggle_on"));
|
|
setTextColor(ColorFullWhite);
|
|
}
|
|
else if (currentState == ButtonState::Off) {
|
|
setFillColor(ColorFullWhite);
|
|
setText(utils::translateI18("app_settings_toggle_off"));
|
|
setTextColor(ColorFullBlack);
|
|
}
|
|
}
|
|
void ButtonOnOff::toggleState()
|
|
{
|
|
switchState(static_cast<ButtonState>(!static_cast<bool>(currentState)));
|
|
}
|
|
|
|
} /* namespace gui */
|