M module-apps/application-alarm-clock/widgets/AlarmItem.cpp => module-apps/application-alarm-clock/widgets/AlarmItem.cpp +2 -2
@@ 37,7 37,7 @@ namespace gui
periodLabel->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top});
periodLabel->setFont(style::window::font::small);
- onOffImage = new gui::ButtonOnOff(hBox, ButtonState::On);
+ onOffImage = new gui::ButtonTriState(hBox, ButtonTriState::State::On);
onOffImage->setMargins(gui::Margins(0, 0, style::widgets::rightMargin, 0));
setAlarm();
@@ 54,7 54,7 @@ namespace gui
getPresenter()->getAlarm()->alarmTime.minuteOfHour,
utils::time::TimestampType::Time);
timeLabel->setText(time);
- onOffImage->switchState(getPresenter()->getAlarm()->enabled ? ButtonState::On : ButtonState::Off);
+ onOffImage->switchState(getPresenter()->getAlarm()->enabled ? ButtonTriState::State::On : ButtonTriState::State::Off);
if (getPresenter()->hasRecurrence()) {
periodLabel->setText(getPresenter()->getDescription());
M module-apps/application-alarm-clock/widgets/AlarmItem.hpp => module-apps/application-alarm-clock/widgets/AlarmItem.hpp +2 -2
@@ 5,7 5,7 @@
#include "Application.hpp"
#include <module-db/Interface/AlarmEventRecord.hpp>
-#include <widgets/ButtonOnOff.hpp>
+#include <widgets/ButtonTriState.hpp>
#include <ListItem.hpp>
#include <BoxLayout.hpp>
#include <Label.hpp>
@@ 17,7 17,7 @@ namespace gui
{
gui::HBox *hBox = nullptr;
gui::VBox *vBox = nullptr;
- gui::ButtonOnOff *onOffImage = nullptr;
+ gui::ButtonTriState *onOffImage = nullptr;
gui::Label *timeLabel = nullptr;
gui::Label *periodLabel = nullptr;
void setAlarm();
M module-apps/apps-common/CMakeLists.txt => module-apps/apps-common/CMakeLists.txt +1 -1
@@ 42,7 42,7 @@ target_sources(apps-common
widgets/ActiveIconFactory.cpp
widgets/BarGraph.cpp
widgets/BrightnessBox.cpp
- widgets/ButtonOnOff.cpp
+ widgets/ButtonTriState.cpp
widgets/BellBaseLayout.cpp
widgets/BellSideListItem.cpp
widgets/ClockDateWidget.cpp
M module-apps/apps-common/notifications/NotificationListItem.cpp => module-apps/apps-common/notifications/NotificationListItem.cpp +2 -2
@@ 141,10 141,10 @@ NotificationWithEventCounter::NotificationWithEventCounter(notifications::Notifi
text->setMaximumSize(text->getSize(Axis::X), Axis::X);
}
-NotificationWithOnOffButton::NotificationWithOnOffButton(notifications::NotificationType type, gui::ButtonState state)
+NotificationWithOnOffButton::NotificationWithOnOffButton(notifications::NotificationType type, gui::ButtonTriState::State state)
: NotificationListItem(type)
{
- auto button = new ButtonOnOff(nullptr, state);
+ auto button = new ButtonTriState(nullptr, state);
button->setMargins(Margins(0, 0, 20, 0));
box->addWidget(button);
}
M module-apps/apps-common/notifications/NotificationListItem.hpp => module-apps/apps-common/notifications/NotificationListItem.hpp +2 -2
@@ 6,7 6,7 @@
#include <ListItem.hpp>
#include <BoxLayout.hpp>
#include <Text.hpp>
-#include <widgets/ButtonOnOff.hpp>
+#include <widgets/ButtonTriState.hpp>
#include "NotificationData.hpp"
@@ 46,7 46,7 @@ namespace gui
{
public:
- NotificationWithOnOffButton(notifications::NotificationType type, gui::ButtonState state);
+ NotificationWithOnOffButton(notifications::NotificationType type, gui::ButtonTriState::State state);
};
} // namespace gui
M module-apps/apps-common/notifications/NotificationsListPresenter.cpp => module-apps/apps-common/notifications/NotificationsListPresenter.cpp +1 -1
@@ 95,7 95,7 @@ auto NotificationsListPresenter::create(const notifications::NotSeenCallNotifica
auto NotificationsListPresenter::create(const notifications::TetheringNotification *notification)
-> NotificationListItem *
{
- auto item = new NotificationWithOnOffButton(notifications::NotificationType::Tethering, gui::ButtonState::On);
+ auto item = new NotificationWithOnOffButton(notifications::NotificationType::Tethering, gui::ButtonTriState::State::On);
item->setName(utils::translate("Tethering"), false);
item->deleteByList = false;
return item;
M module-apps/apps-common/options/type/OptionSetting.cpp => module-apps/apps-common/options/type/OptionSetting.cpp +4 -4
@@ 3,7 3,7 @@
#include <TextFixedSize.hpp>
#include "OptionSetting.hpp"
-#include "widgets/ButtonOnOff.hpp"
+#include "widgets/ButtonTriState.hpp"
#include <Image.hpp>
namespace gui::option
@@ 35,7 35,7 @@ namespace gui::option
optionText->setRichText(text);
std::string imageName;
- ButtonOnOff *button = nullptr;
+ ButtonTriState *button = nullptr;
switch (rightItem) {
case SettingRightItem::ArrowBlack:
@@ 45,10 45,10 @@ namespace gui::option
imageName = "arrow_right_empty_32px_W_G";
break;
case SettingRightItem::On:
- button = new ButtonOnOff(optionBodyHBox, ButtonState::On);
+ button = new ButtonTriState(optionBodyHBox, ButtonTriState::State::On);
break;
case SettingRightItem::Off:
- button = new ButtonOnOff(optionBodyHBox, ButtonState::Off);
+ button = new ButtonTriState(optionBodyHBox, ButtonTriState::State::Off);
break;
case SettingRightItem::Bt:
imageName = "bluetooth_32px_W_M";
R module-apps/apps-common/widgets/ButtonOnOff.cpp => module-apps/apps-common/widgets/ButtonTriState.cpp +7 -12
@@ 1,16 1,16 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-#include "ButtonOnOff.hpp"
+#include "ButtonTriState.hpp"
#include <Style.hpp>
#include <i18n/i18n.hpp>
namespace gui
{
- ButtonOnOff::ButtonOnOff(Item *parent, const ButtonState buttonState) : Label{parent}
+ ButtonTriState::ButtonTriState(Item *parent, State state) : Label{parent}
{
- setMinimumSize(style::buttonOnOff::w, style::buttonOnOff::h);
+ setMinimumSize(style::buttonTriState::w, style::buttonTriState::h);
setEdges(RectangleEdge::None);
setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
@@ 27,13 27,13 @@ namespace gui
return true;
};
- switchState(buttonState);
+ switchState(state);
}
- void ButtonOnOff::switchState(const ButtonState newButtonState)
+ void ButtonTriState::switchState(State requestedState)
{
- currentState = newButtonState;
- if (currentState == ButtonState::On) {
+ currentState = requestedState;
+ if (currentState == State::On) {
fill->setFillColor(ColorFullBlack);
setColor(ColorFullWhite);
setText(utils::translate("app_settings_toggle_on"));
@@ 44,9 44,4 @@ namespace gui
setText(utils::translate("app_settings_toggle_off"));
}
}
- void ButtonOnOff::toggleState()
- {
- switchState(static_cast<ButtonState>(!static_cast<bool>(currentState)));
- }
-
} /* namespace gui */
R module-apps/apps-common/widgets/ButtonOnOff.hpp => module-apps/apps-common/widgets/ButtonTriState.hpp +15 -16
@@ 7,31 7,30 @@
namespace style
{
- namespace buttonOnOff
+ namespace buttonTriState
{
constexpr uint32_t w = 56;
constexpr uint32_t h = 32;
- } // namespace buttonOnOff
-} // namespace style
+ }
+}
namespace gui
{
- enum class ButtonState : bool
- {
- Off,
- On
- };
-
- class ButtonOnOff : public Label
+ class ButtonTriState : public Label
{
public:
- ButtonOnOff(Item *parent, const ButtonState buttonState);
- void switchState(const ButtonState);
- void toggleState();
+ enum class State
+ {
+ Transiting,
+ Off,
+ On
+ };
+
+ ButtonTriState(Item *parent, State state);
+ void switchState(State requestedState);
private:
Rect *fill = nullptr;
- ButtonState currentState;
+ State currentState;
};
-
-} /* namespace gui */
+}