mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-03 11:28:48 -05:00
62 lines
2.3 KiB
C++
62 lines
2.3 KiB
C++
#include "CheckBox.hpp"
|
|
#include "Style.hpp"
|
|
#include "Utils.hpp"
|
|
|
|
namespace gui
|
|
{
|
|
|
|
CheckBox::CheckBox(Item *parent,
|
|
const uint32_t &x,
|
|
const uint32_t &y,
|
|
const uint32_t &w,
|
|
const uint32_t &h,
|
|
std::function<void(const UTF8 &, BottomBar::Side, bool)> bottomBarTemporaryMode,
|
|
std::function<void()> bottomBarRestoreFromTemporaryMode)
|
|
: ImageBox(parent, x, y, w, h, image = new Image("small_tick")),
|
|
bottomBarTemporaryMode(std::move(bottomBarTemporaryMode)),
|
|
bottomBarRestoreFromTemporaryMode(std::move(bottomBarRestoreFromTemporaryMode))
|
|
{
|
|
setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
|
|
|
|
focusChangedCallback = [&](Item &item) {
|
|
if (focus) {
|
|
LOG_DEBUG("FOCUS");
|
|
setFocusItem(image);
|
|
if (image->visible) {
|
|
// bottomBarTemporaryMode(utils::localize.get("app_calendar_uncheck"), BottomBar::Side::LEFT,
|
|
// false);
|
|
}
|
|
else {
|
|
// bottomBarTemporaryMode(utils::localize.get("app_calendar_check"), BottomBar::Side::LEFT, false);
|
|
}
|
|
}
|
|
else {
|
|
LOG_DEBUG("NOT FOCUS");
|
|
setFocusItem(nullptr);
|
|
// bottomBarRestoreFromTemporaryMode();
|
|
}
|
|
return true;
|
|
};
|
|
|
|
inputCallback = [&](gui::Item &item, const gui::InputEvent &event) {
|
|
LOG_DEBUG("INPUT CALLBACK");
|
|
if (event.state != gui::InputEvent::State::keyReleasedShort) {
|
|
return false;
|
|
}
|
|
if (event.keyCode == gui::KeyCode::KEY_ENTER) {
|
|
LOG_DEBUG("KEY ENTER");
|
|
image->setVisible(!image->visible);
|
|
if (image->visible) {
|
|
bottomBarTemporaryMode(utils::localize.get("app_calendar_uncheck"), BottomBar::Side::CENTER, false);
|
|
}
|
|
else {
|
|
bottomBarTemporaryMode(utils::localize.get("app_calendar_check"), BottomBar::Side::CENTER, false);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
}
|
|
|
|
} /* namespace gui */
|