M image/assets/lang/lang_en.json => image/assets/lang/lang_en.json +26 -0
@@ 91,6 91,32 @@
"app_calendar_reminder_2_days_before": "2 days before",
"app_calendar_reminder_1_week_before": "1 week before",
"app_calendar_custom_repeat_title": "Custom repeat",
+ "app_calendar_new_event_title": "New event",
+ "app_calendar_edit_event_title": "Edit event",
+ "app_calendar_edit": "EDIT",
+ "app_calendar_check": "CHECK",
+ "app_calendar_uncheck": "UNCHECK",
+ "app_calendar_new_edit_event_name": "Event name",
+ "app_calendar_new_edit_event_allday": "All day event",
+ "app_calendar_new_edit_event_start": "Start",
+ "app_calendar_new_edit_event_end": "End",
+ "app_calendar_repeat_never": "Never",
+ "app_calendar_repeat_daily": "Daily",
+ "app_calendar_repeat_weekly": "Weekly",
+ "app_calendar_repeat_two_weeks": "Two weeks",
+ "app_calendar_repeat_month": "Month",
+ "app_calendar_repeat_year": "Year",
+ "app_calendar_repeat_custom": "Custom",
+ "app_calendar_reminder_never": "Never",
+ "app_calendar_reminder_event_time": "At the time of the event",
+ "app_calendar_reminder_5_min_before": "5 mins before",
+ "app_calendar_reminder_15_min_before": "15 mins before",
+ "app_calendar_reminder_30_min_before": "30 mins before",
+ "app_calendar_reminder_1_hour_before": "1h before",
+ "app_calendar_reminder_2_hour_before": "2h before",
+ "app_calendar_reminder_1_day_before": "1 day before",
+ "app_calendar_reminder_2_days_before": "2 days before",
+ "app_calendar_reminder_1_week_before": "1 week before",
"app_options_invalid_option": " <Invalid Option> ",
"app_options_contact_details": "Contact details",
M module-apps/application-calendar/ApplicationCalendar.cpp => module-apps/application-calendar/ApplicationCalendar.cpp +2 -2
@@ 80,10 80,10 @@ namespace app
new gui::EventDetailWindow(this, style::window::calendar::name::details_window)));
windows.insert(std::pair<std::string, gui::AppWindow *>(
style::window::calendar::name::new_edit_event,
- new NewEditEventWindow(this, style::window::calendar::name::new_edit_event)));
+ new gui::NewEditEventWindow(this, style::window::calendar::name::new_edit_event)));
windows.insert(std::pair<std::string, gui::AppWindow *>(
style::window::calendar::name::custom_repeat_window,
- new CustomRepeatWindow(this, style::window::calendar::name::custom_repeat_window)));
+ new gui::CustomRepeatWindow(this, style::window::calendar::name::custom_repeat_window)));
}
void ApplicationCalendar::destroyUserInterface()
M module-apps/application-calendar/CMakeLists.txt => module-apps/application-calendar/CMakeLists.txt +1 -0
@@ 22,6 22,7 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/widgets/RepeatAndReminderItem.cpp"
"${CMAKE_CURRENT_LIST_DIR}/widgets/CheckBoxItem.cpp"
"${CMAKE_CURRENT_LIST_DIR}/widgets/EventTimeItem.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/widgets/SeveralOptionsItem.cpp"
PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/ApplicationCalendar.hpp"
"${CMAKE_CURRENT_LIST_DIR}/models/DayEventsModel.hpp"
M module-apps/application-calendar/models/CustomRepeatModel.cpp => module-apps/application-calendar/models/CustomRepeatModel.cpp +9 -37
@@ 11,69 11,41 @@ void CustomRepeatModel::requestRecords(const uint32_t offset, const uint32_t lim
unsigned int CustomRepeatModel::getMinimalItemHeight() const
{
- return 61; // style::window::calendar::item::customrepeat::height;
+ return style::window::calendar::item::checkBox::height;
}
gui::ListItem *CustomRepeatModel::getItem(gui::Order order)
{
auto app = application;
+ assert(app != nullptr);
// maybe this should be different
gui::CheckBoxItem *item = nullptr;
switch (count) {
case 7:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Monday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Monday));
break;
case 6:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Tuesday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Tuesday));
break;
case 5:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Wednesday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Wednesday));
break;
case 4:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Thursday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Thursday));
break;
case 3:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Friday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Friday));
break;
case 2:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Saturday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Saturday));
break;
case 1:
- item = new gui::CheckBoxItem(
- utils::localize.get(style::strings::common::Sunday),
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text); },
- [app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ item = new gui::CheckBoxItem(app, utils::localize.get(style::strings::common::Sunday));
break;
default:
return item;
break;
}
count--;
- // item->activatedCallback = [=](gui::Item &item) {
- // LOG_INFO("Check/Uncheck item");
- // return true;
- //};
- // item->focusChangedCallback = [=](gui::Item &) {
- // item->changeFont();
- // return true;
- //};
return item;
}
M module-apps/application-calendar/models/CustomRepeatModel.hpp => module-apps/application-calendar/models/CustomRepeatModel.hpp +3 -4
@@ 6,7 6,6 @@
class CustomRepeatModel : public gui::ListItemProvider
{
app::Application *application = nullptr;
- const int daysInWeek = 7;
int count = 7;
public:
@@ 14,10 13,10 @@ class CustomRepeatModel : public gui::ListItemProvider
void requestRecords(const uint32_t offset, const uint32_t limit) override;
// virtual methods for ListViewProvider
- unsigned int getMinimalItemHeight() const override;
+ [[nodiscard]] unsigned int getMinimalItemHeight() const override;
gui::ListItem *getItem(gui::Order order) override;
- int getItemCount() const override
+ [[nodiscard]] int getItemCount() const override
{
- return daysInWeek;
+ return style::window::calendar::week_days_number;
};
};
M module-apps/application-calendar/widgets/CalendarStyle.hpp => module-apps/application-calendar/widgets/CalendarStyle.hpp +46 -9
@@ 81,15 81,53 @@ namespace style
const inline int event_time_h = 30;
const inline int description_h = 40;
} // namespace eventDetail
- } // namespace item
- namespace options
- {
- const inline int item_height = 55;
- const inline int margin = 15;
- const inline int text_margin = 10;
- const inline int label_y = 112;
- } // namespace options
+ namespace eventTime
+ {
+ const inline int height = 120;
+ const inline int margin = 22;
+ const inline int description_label_w = 150;
+ const inline int description_label_h = 20;
+ const inline int colon_label_12h_x = 130;
+ const inline int colon_label_24h_x = 210;
+ const inline int colon_label_y = 85;
+ const inline int colon_label_w = 25;
+ const inline int colon_label_h = 20;
+ const inline int hour_input_x = 0;
+ const inline int minute_input_12h_x = 155;
+ const inline int minute_input_24h_x = 235;
+ const inline int mode12h_input_x = 310;
+ const inline int time_input_y = 20;
+ const inline int time_input_12h_w = 130;
+ const inline int time_input_24h_w = 207;
+ } // namespace eventTime
+
+ namespace checkBox
+ {
+ const inline int height = 62;
+ const inline int input_box_label_w = 55;
+ const inline int input_box_label_h = 50;
+ const inline int description_label_x = 75;
+ const inline int description_label_w = 280;
+ const inline int description_label_h = 40;
+ const inline int tick_image_x = 12;
+ const inline int tick_image_w = 30;
+ const inline int tick_image_h = 30;
+ } // namespace checkBox
+
+ namespace severalOptions
+ {
+ const inline int height = 62;
+ const inline int margin = 15;
+ const inline int description_label_w = 100;
+ const inline int description_label_h = 30;
+ const inline int option_label_y = 30;
+ const inline int option_label_h = 30;
+ const inline int arrow_y = 36;
+ const inline int arrow_w = 20;
+ const inline int arrow_h = 20;
+ } // namespace severalOptions
+ } // namespace item
namespace details
{
@@ 100,7 138,6 @@ namespace style
const inline int remind_heading_y = 290;
const inline int remind_y = 345;
} // namespace details
-
}; // namespace calendar
} // namespace window
} // namespace style
M module-apps/application-calendar/widgets/CheckBoxItem.cpp => module-apps/application-calendar/widgets/CheckBoxItem.cpp +31 -52
@@ 1,5 1,7 @@
-//#include "application-calendar/models/CustomRepeatModel.hpp"
#include "CheckBoxItem.hpp"
+#include "application-calendar/widgets/CalendarStyle.hpp"
+#include "application-calendar/windows/NewEditEventWindow.hpp"
+#include "windows/AppWindow.hpp"
#include <ListView.hpp>
#include <Style.hpp>
#include <time/time_conversion.hpp>
@@ 7,27 9,31 @@
namespace gui
{
- CheckBoxItem::CheckBoxItem(const std::string &description,
- std::function<void(const UTF8 &)> bottomBarTemporaryMode,
- std::function<void()> bottomBarRestoreFromTemporaryMode)
- : bottomBarTemporaryMode(std::move(bottomBarTemporaryMode)),
- bottomBarRestoreFromTemporaryMode(std::move(bottomBarRestoreFromTemporaryMode))
+ CheckBoxItem::CheckBoxItem(app::Application *application, const std::string &description)
{
- setMinimumSize(style::window::default_body_width, 62);
- setMaximumSize(style::window::default_body_width, 62);
+ app = application;
+ assert(app != nullptr);
+ setMinimumSize(style::window::default_body_width, style::window::calendar::item::checkBox::height);
+ setMaximumSize(style::window::default_body_width, style::window::calendar::item::checkBox::height);
- // setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
- hBox = new gui::HBox(this, 0, 0, 400, 0);
+ hBox = new gui::HBox(this, 0, 0, style::window::default_body_width, 0);
hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
hBox->setPenFocusWidth(style::window::default_border_focus_w);
- hBox->setPenWidth(1);
-
- inputBoxLabel = new gui::Label(hBox, 0, 0, 0, 0);
- inputBoxLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
- inputBoxLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
- inputBoxLabel->setFont(style::window::font::medium);
- inputBoxLabel->activeItem = false;
+ hBox->setPenWidth(style::window::default_border_rect_no_focus);
+
+ checkBox = new gui::CheckBox(
+ hBox,
+ 0,
+ 0,
+ 50,
+ 30,
+ [=](const UTF8 &text, gui::BottomBar::Side side, bool emptyOthers) {
+ app->getCurrentWindow()->bottomBarTemporaryMode(text, side, emptyOthers);
+ },
+ [=]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ checkBox->activeItem = false;
descriptionLabel = new gui::Label(hBox, 0, 0, 0, 0);
descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
@@ 35,29 41,18 @@ namespace gui
descriptionLabel->setFont(style::window::font::medium);
descriptionLabel->activeItem = false;
- tickImage = new gui::Image(hBox, 0, 0, 0, 0);
- tickImage->setVisible(false);
- tickImage->activeItem = false;
-
descriptionLabel->setText(description);
- tickImage->set("small_tick");
- /*this->focusChangedCallback = [&](gui::Item &item) {
+ focusChangedCallback = [&](Item &item) {
if (focus) {
- setFocusItem(inputBoxLabel);
- if (tickImage->visible) {
- bottomBarTemporaryMode(utils::localize.get("app_phonebook_uncheck"));
- }
- else {
- bottomBarTemporaryMode(utils::localize.get("app_phonebook_check"));
- }
+ setFocusItem(checkBox);
}
else {
+ // descriptionLabel->setFont(style::window::font::medium);
setFocusItem(nullptr);
- bottomBarRestoreFromTemporaryMode();
}
return true;
- };*/
+ };
}
bool CheckBoxItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
@@ 65,28 60,12 @@ namespace gui
hBox->setPosition(0, 0);
hBox->setSize(newDim.w, newDim.h);
LOG_DEBUG("SIZE: %i, %i", newDim.w, newDim.h);
- inputBoxLabel->setArea(BoundingBox(0, newDim.h - 50, 55, 50));
-
- descriptionLabel->setArea(BoundingBox(75, newDim.h - 40, 280, 40));
-
- tickImage->setArea(BoundingBox(12, newDim.h - 35, 30, 30));
- return true;
- }
+ descriptionLabel->setArea(BoundingBox(style::window::calendar::item::checkBox::description_label_x,
+ newDim.h - style::window::calendar::item::checkBox::description_label_h,
+ style::window::calendar::item::checkBox::description_label_w,
+ style::window::calendar::item::checkBox::description_label_h));
- void CheckBoxItem::changeFont()
- {}
-
- bool CheckBoxItem::onActivated(void *data)
- {
- /// TODO: Center check/uncheck, now it is on the left side.
- tickImage->setVisible(!tickImage->visible);
- if (tickImage->visible) {
- bottomBarTemporaryMode(utils::localize.get("app_phonebook_uncheck"));
- }
- else {
- bottomBarTemporaryMode(utils::localize.get("app_phonebook_check"));
- }
return true;
}
M module-apps/application-calendar/widgets/CheckBoxItem.hpp => module-apps/application-calendar/widgets/CheckBoxItem.hpp +10 -12
@@ 1,31 1,29 @@
#pragma once
+#include "Application.hpp"
#include <Label.hpp>
#include <Image.hpp>
#include <ListItem.hpp>
#include <BoxLayout.hpp>
+#include <BottomBar.hpp>
+#include <CheckBox.hpp>
namespace gui
{
class CheckBoxItem : public ListItem
{
gui::HBox *hBox = nullptr;
- gui::Label *inputBoxLabel = nullptr;
gui::Label *descriptionLabel = nullptr;
- gui::Image *tickImage = nullptr;
-
- std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr;
- std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr;
- // bool visibleState = false;
+ gui::CheckBox *checkBox = nullptr;
+ app::Application *app = nullptr;
public:
- CheckBoxItem(const std::string &description,
- std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
- std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
- virtual ~CheckBoxItem() = default;
+ CheckBoxItem(app::Application *application, const std::string &description);
+ virtual ~CheckBoxItem() override = default;
- void changeFont();
+ void checkOnLeftSettings();
+ void checkInCenterSettings();
+ bool isChecked();
// virtual methods from Item
- bool onActivated(void *data) override;
bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
M module-apps/application-calendar/widgets/EventTimeItem.cpp => module-apps/application-calendar/widgets/EventTimeItem.cpp +99 -37
@@ 2,30 2,28 @@
#include "EventTimeItem.hpp"
#include <ListView.hpp>
#include <Style.hpp>
-#include <time/time_conversion.hpp>
+#include <Utils.hpp>
namespace gui
{
- EventTimeItem::EventTimeItem(const std::string &description,
- std::function<void(const UTF8 &)> bottomBarTemporaryMode,
- std::function<void()> bottomBarRestoreFromTemporaryMode)
- : bottomBarTemporaryMode(std::move(bottomBarTemporaryMode)),
- bottomBarRestoreFromTemporaryMode(std::move(bottomBarRestoreFromTemporaryMode))
+ EventTimeItem::EventTimeItem(const std::string &description, bool mode24H) : mode24H{mode24H}
{
- setMinimumSize(style::window::default_body_width, 80);
- setMaximumSize(style::window::default_body_width, 80);
+ setMinimumSize(style::window::default_body_width, style::window::calendar::item::eventTime::height);
+ setMaximumSize(style::window::default_body_width, style::window::calendar::item::eventTime::height);
- // setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setMargins(gui::Margins(0, style::window::calendar::item::eventTime::margin, 0, 0));
- hBox = new gui::HBox(this, 0, 0, 450, 0);
+ hBox = new gui::HBox(this, 0, 0, style::window::default_body_width, 0);
hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
hBox->setPenFocusWidth(style::window::default_border_focus_w);
- hBox->setPenWidth(1);
+ hBox->setPenWidth(style::window::default_border_rect_no_focus);
+ hBox->activeItem = false;
colonLabel = new gui::Label(hBox, 0, 0, 0, 0);
colonLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
- colonLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
+ colonLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
colonLabel->setFont(style::window::font::medium);
colonLabel->setText(":");
colonLabel->activeItem = false;
@@ 33,37 31,74 @@ namespace gui
descriptionLabel = new gui::Label(hBox, 0, 0, 0, 0);
descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
- descriptionLabel->setFont(style::window::font::medium);
+ descriptionLabel->setFont(style::window::font::small);
descriptionLabel->activeItem = false;
hourInput = new gui::Text(hBox, 0, 0, 0, 0);
hourInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
- hourInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
- hourInput->setFont(style::window::font::medium);
+ hourInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
+ hourInput->setFont(style::window::font::largelight);
hourInput->setInputMode(new InputMode({InputMode::digit}));
hourInput->setPenFocusWidth(style::window::default_border_focus_w);
- hourInput->setPenWidth(1);
+ hourInput->setPenWidth(style::window::default_border_rect_no_focus);
hourInput->setEditMode(gui::EditMode::EDIT);
minuteInput = new gui::Text(hBox, 0, 0, 0, 0);
minuteInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
minuteInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
- minuteInput->setFont(style::window::font::medium);
+ minuteInput->setFont(style::window::font::largelight);
minuteInput->setInputMode(new InputMode({InputMode::digit}));
minuteInput->setPenFocusWidth(style::window::default_border_focus_w);
- minuteInput->setPenWidth(1);
+ minuteInput->setPenWidth(style::window::default_border_rect_no_focus);
minuteInput->setEditMode(gui::EditMode::EDIT);
- mode12hInput = new gui::Text(hBox, 0, 0, 0, 0);
- mode12hInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
- mode12hInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
- mode12hInput->setFont(style::window::font::medium);
- mode12hInput->setInputMode(new InputMode({InputMode::ABC}));
- mode12hInput->setPenFocusWidth(style::window::default_border_focus_w);
- mode12hInput->setPenWidth(1);
- mode12hInput->setEditMode(gui::EditMode::EDIT);
-
+ setNavigationItem(NavigationDirection::LEFT, hourInput);
descriptionLabel->setText(description);
+
+ focusChangedCallback = [&](Item &item) {
+ setFocusItem(focus ? hourInput : nullptr);
+ return true;
+ };
+
+ prepareForTimeMode();
+ setNavigation();
+ }
+
+ void EventTimeItem::prepareForTimeMode()
+ {
+ if (!mode24H) {
+ mode12hInput = new gui::Text(hBox, 0, 0, 0, 0);
+ mode12hInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ mode12hInput->setAlignment(
+ gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
+ mode12hInput->setFont(style::window::font::largelight);
+ mode12hInput->setInputMode(new InputMode({InputMode::ABC}));
+ mode12hInput->setPenFocusWidth(style::window::default_border_focus_w);
+ mode12hInput->setPenWidth(style::window::default_border_rect_no_focus);
+ mode12hInput->setEditMode(gui::EditMode::EDIT);
+ mode12hInput->activatedCallback = [=](gui::Item &item) {
+ LOG_INFO("12H mode clicked");
+ return true;
+ };
+ }
+ }
+
+ void EventTimeItem::setNavigation()
+ {
+ if (mode24H) {
+ hourInput->setNavigationItem(NavigationDirection::LEFT, minuteInput);
+ hourInput->setNavigationItem(NavigationDirection::RIGHT, minuteInput);
+ minuteInput->setNavigationItem(NavigationDirection::LEFT, hourInput);
+ minuteInput->setNavigationItem(NavigationDirection::RIGHT, hourInput);
+ }
+ else {
+ hourInput->setNavigationItem(NavigationDirection::LEFT, mode12hInput);
+ hourInput->setNavigationItem(NavigationDirection::RIGHT, minuteInput);
+ minuteInput->setNavigationItem(NavigationDirection::LEFT, hourInput);
+ minuteInput->setNavigationItem(NavigationDirection::RIGHT, mode12hInput);
+ mode12hInput->setNavigationItem(NavigationDirection::LEFT, minuteInput);
+ mode12hInput->setNavigationItem(NavigationDirection::RIGHT, hourInput);
+ }
}
bool EventTimeItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
@@ 71,18 106,45 @@ namespace gui
hBox->setPosition(0, 0);
hBox->setSize(newDim.w, newDim.h);
LOG_DEBUG("SIZE TIME ITEM: %i, %i", newDim.w, newDim.h);
+ // sth works wrong when text update..
+ descriptionLabel->setArea(BoundingBox(0,
+ 0,
+ style::window::calendar::item::eventTime::description_label_w,
+ style::window::calendar::item::eventTime::description_label_h));
- descriptionLabel->setArea(BoundingBox(15, 0, 150, 20));
- colonLabel->setArea(BoundingBox(50, 30, 10, 20));
- hourInput->setArea(BoundingBox(15, 20, 140, newDim.h - 20));
- minuteInput->setArea(BoundingBox(175, 20, 140, newDim.h - 20));
- mode12hInput->setArea(BoundingBox(335, 20, 140, newDim.h - 20));
-
- return true;
- }
+ if (!mode24H) {
+ colonLabel->setArea(BoundingBox(style::window::calendar::item::eventTime::colon_label_12h_x,
+ style::window::calendar::item::eventTime::colon_label_y,
+ style::window::calendar::item::eventTime::colon_label_w,
+ style::window::calendar::item::eventTime::colon_label_h));
+ hourInput->setArea(BoundingBox(style::window::calendar::item::eventTime::hour_input_x,
+ style::window::calendar::item::eventTime::time_input_y,
+ style::window::calendar::item::eventTime::time_input_12h_w,
+ newDim.h - style::window::calendar::item::eventTime::time_input_y));
+ minuteInput->setArea(BoundingBox(style::window::calendar::item::eventTime::minute_input_12h_x,
+ style::window::calendar::item::eventTime::time_input_y,
+ style::window::calendar::item::eventTime::time_input_12h_w,
+ newDim.h - style::window::calendar::item::eventTime::time_input_y));
+ mode12hInput->setArea(BoundingBox(style::window::calendar::item::eventTime::mode12h_input_x,
+ style::window::calendar::item::eventTime::time_input_y,
+ style::window::calendar::item::eventTime::time_input_12h_w,
+ newDim.h - style::window::calendar::item::eventTime::time_input_y));
+ }
+ else {
+ colonLabel->setArea(BoundingBox(style::window::calendar::item::eventTime::colon_label_24h_x,
+ style::window::calendar::item::eventTime::colon_label_y,
+ style::window::calendar::item::eventTime::colon_label_w,
+ style::window::calendar::item::eventTime::colon_label_h));
+ hourInput->setArea(BoundingBox(style::window::calendar::item::eventTime::hour_input_x,
+ style::window::calendar::item::eventTime::time_input_y,
+ style::window::calendar::item::eventTime::time_input_24h_w,
+ newDim.h - style::window::calendar::item::eventTime::time_input_y));
+ minuteInput->setArea(BoundingBox(style::window::calendar::item::eventTime::minute_input_24h_x,
+ style::window::calendar::item::eventTime::time_input_y,
+ style::window::calendar::item::eventTime::time_input_24h_w,
+ newDim.h - style::window::calendar::item::eventTime::time_input_y));
+ }
- bool EventTimeItem::onActivated(void *data)
- {
return true;
}
M module-apps/application-calendar/widgets/EventTimeItem.hpp => module-apps/application-calendar/widgets/EventTimeItem.hpp +5 -8
@@ 14,18 14,15 @@ namespace gui
gui::Text *hourInput = nullptr;
gui::Text *minuteInput = nullptr;
gui::Text *mode12hInput = nullptr;
-
- std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr;
- std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr;
+ bool mode24H = false;
public:
- EventTimeItem(const std::string &description,
- std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
- std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
- virtual ~EventTimeItem() = default;
+ EventTimeItem(const std::string &description, bool mode24H);
+ virtual ~EventTimeItem() override = default;
+ void prepareForTimeMode();
+ void setNavigation();
// virtual methods from Item
- bool onActivated(void *data) override;
bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
A module-apps/application-calendar/widgets/SeveralOptionsItem.cpp => module-apps/application-calendar/widgets/SeveralOptionsItem.cpp +153 -0
@@ 0,0 1,153 @@
+#include "SeveralOptionsItem.hpp"
+#include "application-calendar/widgets/CalendarStyle.hpp"
+#include <ListView.hpp>
+#include <Style.hpp>
+#include <Utils.hpp>
+
+namespace gui
+{
+
+ SeveralOptionsItem::SeveralOptionsItem(
+ app::Application *app,
+ const std::string &description,
+ std::function<void(const UTF8 &, BottomBar::Side, bool)> bottomBarTemporaryMode,
+ std::function<void()> bottomBarRestoreFromTemporaryMode)
+ : bottomBarTemporaryMode(std::move(bottomBarTemporaryMode)),
+ bottomBarRestoreFromTemporaryMode(std::move(bottomBarRestoreFromTemporaryMode))
+ {
+ application = app;
+ assert(app != nullptr);
+
+ setMinimumSize(style::window::default_body_width, style::window::calendar::item::severalOptions::height);
+ setMaximumSize(style::window::default_body_width, style::window::calendar::item::severalOptions::height);
+
+ setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ setPenWidth(style::window::default_border_rect_no_focus);
+ setMargins(gui::Margins(0, style::window::calendar::item::severalOptions::margin, 0, 0));
+
+ hBox = new gui::HBox(this, 0, 0, style::window::default_body_width, 0);
+ hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setPenFocusWidth(style::window::default_border_focus_w);
+ hBox->setPenWidth(style::window::default_border_rect_no_focus);
+ hBox->activeItem = false;
+
+ descriptionLabel = new gui::Label(hBox, 0, 0, 0, 0);
+ descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
+ descriptionLabel->setFont(style::window::font::small);
+ descriptionLabel->activeItem = false;
+ descriptionLabel->setText(description);
+
+ optionLabel = new gui::Label(hBox, 0, 0, 0, 0);
+ optionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ optionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
+ optionLabel->setFont(style::window::font::small);
+ optionLabel->activeItem = false;
+
+ leftArrow = new gui::Image(hBox, 0, 0, 0, 0);
+ leftArrow->activeItem = false;
+ leftArrow->set("arrow_left");
+
+ rightArrow = new gui::Image(hBox, 0, 0, 0, 0);
+ rightArrow->activeItem = false;
+ rightArrow->set("arrow_right");
+
+ prepareOptionsNames();
+ setNavigation();
+ }
+
+ void SeveralOptionsItem::prepareOptionsNames()
+ {
+ optionsNames.clear();
+ if (descriptionLabel->getText() == utils::localize.get("app_calendar_event_detail_reminder")) {
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_never"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_event_time"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_5_min_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_15_min_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_30_min_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_1_hour_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_2_hour_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_1_day_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_2_days_before"));
+ optionsNames.push_back(utils::localize.get("app_calendar_reminder_1_week_before"));
+ }
+ else if (descriptionLabel->getText() == utils::localize.get("app_calendar_event_detail_repeat")) {
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_never"));
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_daily"));
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_weekly"));
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_two_weeks"));
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_month"));
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_year"));
+ optionsNames.push_back(utils::localize.get("app_calendar_repeat_custom"));
+ }
+ optionLabel->setText(optionsNames[0]);
+ }
+
+ void SeveralOptionsItem::setNavigation()
+ {
+ inputCallback = [&](gui::Item &item, const gui::InputEvent &event) {
+ if (event.state != gui::InputEvent::State::keyReleasedShort) {
+ return false;
+ }
+ if (event.keyCode == gui::KeyCode::KEY_LEFT) {
+ actualVectorIndex--;
+ if (actualVectorIndex >= optionsNames.size()) {
+ actualVectorIndex = optionsNames.size() - 1;
+ bottomBarTemporaryMode(utils::localize.get("app_calendar_edit"), BottomBar::Side::LEFT, false);
+ }
+ else {
+ bottomBarRestoreFromTemporaryMode();
+ }
+ optionLabel->setText(optionsNames[actualVectorIndex]);
+ return true;
+ }
+ if (event.keyCode == gui::KeyCode::KEY_RIGHT) {
+ actualVectorIndex++;
+ if (actualVectorIndex >= optionsNames.size()) {
+ actualVectorIndex = 0;
+ }
+ optionLabel->setText(optionsNames[actualVectorIndex]);
+ if (actualVectorIndex == optionsNames.size() - 1) {
+ bottomBarTemporaryMode(utils::localize.get("app_calendar_edit"), BottomBar::Side::LEFT, false);
+ }
+ else {
+ bottomBarRestoreFromTemporaryMode();
+ }
+ return true;
+ }
+ if (event.keyCode == gui::KeyCode::KEY_LF && actualVectorIndex == optionsNames.size() - 1 &&
+ descriptionLabel->getText() == utils::localize.get("app_calendar_event_detail_repeat")) {
+ application->switchWindow(style::window::calendar::name::custom_repeat_window);
+ return true;
+ }
+ return false;
+ };
+ }
+
+ bool SeveralOptionsItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
+ {
+ hBox->setPosition(0, 0);
+ hBox->setSize(newDim.w, newDim.h);
+ LOG_DEBUG("SIZE SEVERALOPTIONS ITEM: %i, %i", newDim.w, newDim.h);
+
+ descriptionLabel->setArea(BoundingBox(0,
+ 0,
+ style::window::calendar::item::severalOptions::description_label_w,
+ style::window::calendar::item::severalOptions::description_label_h));
+ optionLabel->setArea(BoundingBox(style::window::calendar::item::severalOptions::arrow_w,
+ style::window::calendar::item::severalOptions::option_label_y,
+ newDim.w - 2 * style::window::calendar::item::severalOptions::arrow_w,
+ style::window::calendar::item::severalOptions::option_label_h));
+ leftArrow->setArea(BoundingBox(0,
+ style::window::calendar::item::severalOptions::arrow_y,
+ style::window::calendar::item::severalOptions::arrow_w,
+ style::window::calendar::item::severalOptions::arrow_h));
+ rightArrow->setArea(BoundingBox(newDim.w - style::window::calendar::item::severalOptions::arrow_w,
+ style::window::calendar::item::severalOptions::arrow_y,
+ style::window::calendar::item::severalOptions::arrow_w,
+ style::window::calendar::item::severalOptions::arrow_h));
+
+ return true;
+ }
+
+} /* namespace gui */
A module-apps/application-calendar/widgets/SeveralOptionsItem.hpp => module-apps/application-calendar/widgets/SeveralOptionsItem.hpp +39 -0
@@ 0,0 1,39 @@
+#pragma once
+#include "Application.hpp"
+#include <Label.hpp>
+#include <Image.hpp>
+#include <ListItem.hpp>
+#include <BoxLayout.hpp>
+#include <BottomBar.hpp>
+
+namespace gui
+{
+ class SeveralOptionsItem : public ListItem
+ {
+ app::Application *application = nullptr;
+ gui::HBox *hBox = nullptr;
+ gui::Label *optionLabel = nullptr;
+ gui::Label *descriptionLabel = nullptr;
+ gui::Image *leftArrow = nullptr;
+ gui::Image *rightArrow = nullptr;
+ std::vector<std::string> optionsNames;
+ unsigned int actualVectorIndex = 0;
+
+ std::function<void(const UTF8 &text, BottomBar::Side side, bool emptyOthers)> bottomBarTemporaryMode = nullptr;
+ std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr;
+
+ public:
+ SeveralOptionsItem(app::Application *app,
+ const std::string &description,
+ std::function<void(const UTF8 &text, BottomBar::Side side, bool emptyOthers)>
+ bottomBarTemporaryMode = nullptr,
+ std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
+ virtual ~SeveralOptionsItem() override = default;
+
+ void prepareOptionsNames();
+ void setNavigation();
+ // virtual methods from Item
+ bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
+ };
+
+} /* namespace gui */
M module-apps/application-calendar/windows/CalendarEventsOptionsWindow.cpp => module-apps/application-calendar/windows/CalendarEventsOptionsWindow.cpp +5 -1
@@ 20,7 20,11 @@ namespace gui
std::list<gui::Option> options;
options.emplace_back(gui::Option{utils::localize.get("app_calendar_options_edit"), [=](gui::Item &item) {
LOG_INFO("Switch to edit window");
- application->switchWindow(style::window::calendar::name::new_edit_event);
+ std::unique_ptr<gui::SwitchData> data = std::make_unique<SwitchData>();
+ data->setDescription("Edit");
+ application->switchWindow(style::window::calendar::name::new_edit_event,
+ gui::ShowMode::GUI_SHOW_INIT,
+ std::move(data));
return true;
}});
options.emplace_back(gui::Option{utils::localize.get("app_calendar_options_delete"),
M module-apps/application-calendar/windows/CustomRepeatWindow.cpp => module-apps/application-calendar/windows/CustomRepeatWindow.cpp +2 -2
@@ 5,7 5,7 @@
#include <gui/widgets/TopBar.hpp>
#include <Utils.hpp>
-namespace app
+namespace gui
{
CustomRepeatWindow::CustomRepeatWindow(app::Application *app, std::string name)
@@ 41,4 41,4 @@ namespace app
setFocusItem(list);
}
-} /* namespace app */
+} /* namespace gui */
M module-apps/application-calendar/windows/CustomRepeatWindow.hpp => module-apps/application-calendar/windows/CustomRepeatWindow.hpp +3 -4
@@ 6,7 6,7 @@
#include <gui/widgets/Item.hpp>
#include <ListView.hpp>
-namespace app
+namespace gui
{
class CustomRepeatWindow : public gui::AppWindow
{
@@ 14,11 14,10 @@ namespace app
std::shared_ptr<CustomRepeatModel> customRepeatModel = nullptr;
public:
- CustomRepeatWindow(Application *app, std::string name);
+ CustomRepeatWindow(app::Application *app, std::string name);
- // bool onInput(const gui::InputEvent &inputEvent) override;
void rebuild() override;
void buildInterface() override;
};
-} /* namespace app */
+} /* namespace gui */
M module-apps/application-calendar/windows/NewEditEventWindow.cpp => module-apps/application-calendar/windows/NewEditEventWindow.cpp +56 -34
@@ 1,15 1,10 @@
#include "NewEditEventWindow.hpp"
#include "application-calendar/widgets/CheckBoxItem.hpp"
#include "application-calendar/widgets/EventTimeItem.hpp"
-#include <gui/widgets/Window.hpp>
-#include <gui/widgets/Span.hpp>
+#include "application-calendar/widgets/SeveralOptionsItem.hpp"
#include <gui/widgets/BoxLayout.hpp>
-#include <gui/widgets/BottomBar.hpp>
-#include <gui/widgets/TopBar.hpp>
-#include <time/time_conversion.hpp>
-
-namespace app
+namespace gui
{
NewEditEventWindow::NewEditEventWindow(app::Application *app, std::string name)
@@ 27,51 22,65 @@ namespace app
{
AppWindow::buildInterface();
- auto ttime = utils::time::Time();
topBar->setActive(gui::TopBar::Elements::TIME, true);
bottomBar->setActive(gui::BottomBar::Side::RIGHT, true);
bottomBar->setActive(gui::BottomBar::Side::CENTER, true);
bottomBar->setText(gui::BottomBar::Side::RIGHT, utils::localize.get(style::strings::common::back));
bottomBar->setText(gui::BottomBar::Side::CENTER, utils::localize.get(style::strings::common::save));
- setTitle("New/Edit event");
-
- // Event name box
- eventNameVBox = new gui::VBox(this, 15, 120, 400, 230); // 70
- eventNameVBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ body = new gui::VBox(this, 15, 120, style::window::default_body_width, 430);
+ body->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
- eventNameLabel = new gui::Label(eventNameVBox, 0, 0, 400, 20);
+ eventNameLabel = new gui::Label(body, 0, 0, style::window::default_body_width, 20);
eventNameLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
eventNameLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
eventNameLabel->setFont(style::window::font::small);
- eventNameLabel->setText("Event name");
+ eventNameLabel->setText(utils::localize.get("app_calendar_new_edit_event_name"));
eventNameLabel->activeItem = false;
- // new gui::Span(eventNameVBox, gui::Axis::Y, 30); // spread title & eventNameInput
-
- eventNameInput = new gui::Text(eventNameVBox, 0, 0, 400, 50);
+ eventNameInput = new gui::Text(body, 0, 0, style::window::default_body_width, 50);
eventNameInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
eventNameInput->setAlignment(
gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
eventNameInput->setFont(style::window::font::medium);
- eventNameInput->setInputMode(new InputMode(
- {InputMode::ABC, InputMode::abc, InputMode::digit},
- [=](const UTF8 &text) { bottomBarTemporaryMode(text); },
- [=]() { bottomBarRestoreFromTemporaryMode(); },
- [=]() { selectSpecialCharacter(); }));
+ eventNameInput->setInputMode(new InputMode({InputMode::ABC, InputMode::abc, InputMode::digit}));
eventNameInput->setPenFocusWidth(style::window::default_border_focus_w);
- eventNameInput->setPenWidth(1);
+ eventNameInput->setPenWidth(style::window::default_border_rect_no_focus);
eventNameInput->setEditMode(gui::EditMode::EDIT);
// All day event box
- checkBox = new gui::CheckBoxItem("All day event");
- eventNameVBox->addWidget(checkBox);
+ checkBox = new gui::CheckBoxItem(application, utils::localize.get("app_calendar_new_edit_event_allday"));
+ body->addWidget(checkBox);
// time
- startTime = new gui::EventTimeItem("Start");
- eventNameVBox->addWidget(startTime);
- // setFocusItem(eventNameInput);
- setFocusItem(eventNameVBox);
+ startTime = new gui::EventTimeItem(utils::localize.get("app_calendar_new_edit_event_start"), true);
+ body->addWidget(startTime);
+
+ // repeat
+ reminderOptions = new gui::SeveralOptionsItem(
+ application,
+ utils::localize.get("app_calendar_event_detail_repeat"),
+ [=](const UTF8 &text, gui::BottomBar::Side side, bool emptyOthers) {
+ application->getCurrentWindow()->bottomBarTemporaryMode(text, side, emptyOthers);
+ },
+ [=]() { application->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); });
+ body->addWidget(reminderOptions);
+
+ setFocusItem(body);
+ }
+
+ void NewEditEventWindow::onBeforeShow(gui::ShowMode mode, gui::SwitchData *data)
+ {
+ switch (eventAction) {
+ case EventAction::None:
+ break;
+ case EventAction::Add:
+ setTitle(utils::localize.get("app_calendar_new_event_title"));
+ break;
+ case EventAction::Edit:
+ setTitle(utils::localize.get("app_calendar_edit_event_title"));
+ break;
+ }
}
bool NewEditEventWindow::onInput(const gui::InputEvent &inputEvent)
@@ 85,12 94,25 @@ namespace app
}
if (inputEvent.keyCode == gui::KeyCode::KEY_ENTER) {
- // LOG_DEBUG("TODO: Save event");
- LOG_DEBUG("TEMPORARY: Switch to custom repeat window");
- application->switchWindow(style::window::calendar::name::custom_repeat_window);
+ LOG_DEBUG("TODO: Save event");
return true;
}
return false;
}
-} /* namespace app */
+
+ bool NewEditEventWindow::handleSwitchData(gui::SwitchData *data)
+ {
+ if (data == nullptr) {
+ return false;
+ }
+
+ if (data->getDescription() == "Edit") {
+ eventAction = EventAction::Edit;
+ }
+ else if (data->getDescription() == "New") {
+ eventAction = EventAction::Add;
+ }
+ return false;
+ }
+} /* namespace gui */
M module-apps/application-calendar/windows/NewEditEventWindow.hpp => module-apps/application-calendar/windows/NewEditEventWindow.hpp +58 -4
@@ 7,23 7,77 @@
#include <gui/widgets/Label.hpp>
#include <gui/widgets/Text.hpp>
#include <gui/widgets/ListItem.hpp>
+#include <Utils.hpp>
-namespace app
+namespace gui
{
+ struct customRepeat
+ {
+ bool daysChecked[style::window::calendar::week_days_number] = {false};
+ bool isNothingChosen()
+ {
+ for (int i = 0; i < style::window::calendar::week_days_number; ++i) {
+ if (daysChecked[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ int dayNameToNumber(std::string &name)
+ {
+ if (name == utils::localize.get("common_monday")) {
+ return 0;
+ }
+ else if (name == utils::localize.get("common_tuesday")) {
+ return 1;
+ }
+ else if (name == utils::localize.get("common_wednesday")) {
+ return 2;
+ }
+ else if (name == utils::localize.get("common_thursday")) {
+ return 3;
+ }
+ else if (name == utils::localize.get("common_friday")) {
+ return 4;
+ }
+ else if (name == utils::localize.get("common_saturday")) {
+ return 5;
+ }
+ else if (name == utils::localize.get("common_sunday")) {
+ return 6;
+ }
+ else {
+ return -1;
+ }
+ }
+ };
+
class NewEditEventWindow : public gui::AppWindow
{
- gui::VBox *eventNameVBox = nullptr;
+ private:
+ enum class EventAction
+ {
+ None,
+ Add,
+ Edit
+ };
+ gui::VBox *body = nullptr;
gui::Label *eventNameLabel = nullptr;
gui::Text *eventNameInput = nullptr;
gui::ListItem *checkBox = nullptr;
gui::ListItem *startTime = nullptr;
+ gui::ListItem *reminderOptions = nullptr;
+ EventAction eventAction = EventAction::None;
public:
- NewEditEventWindow(Application *app, std::string name);
+ NewEditEventWindow(app::Application *app, std::string name);
+ // customRepeat *choosenDays = new customRepeat();
+ bool handleSwitchData(gui::SwitchData *data) override;
+ void onBeforeShow(gui::ShowMode mode, gui::SwitchData *data) override;
bool onInput(const gui::InputEvent &inputEvent) override;
void rebuild() override;
void buildInterface() override;
};
-} /* namespace app */
+} /* namespace gui */
M module-apps/application-phonebook/models/NewContactModel.cpp => module-apps/application-phonebook/models/NewContactModel.cpp +13 -4
@@ 6,6 6,7 @@
#include <ListView.hpp>
#include <time/ScopedTime.hpp>
+#include <BottomBar.hpp>
NewContactModel::NewContactModel(app::Application *app) : application(app)
{}
@@ 69,24 70,32 @@ void NewContactModel::createData()
internalData.push_back(new gui::InputBoxWithLabelAndIconWidget(
phonebookInternals::ListItemName::AddToFavourites,
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text, false); },
+ [app](const UTF8 &text) {
+ app->getCurrentWindow()->bottomBarTemporaryMode(text, gui::BottomBar::Side::LEFT, false);
+ },
[app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); }));
internalData.push_back(new gui::InputBoxWithLabelAndIconWidget(
phonebookInternals::ListItemName::AddToICE,
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text, false); },
+ [app](const UTF8 &text) {
+ app->getCurrentWindow()->bottomBarTemporaryMode(text, gui::BottomBar::Side::LEFT, false);
+ },
[app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); }));
internalData.push_back(new gui::InputLinesWithLabelIWidget(
phonebookInternals::ListItemName::Address,
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text, false); },
+ [app](const UTF8 &text) {
+ app->getCurrentWindow()->bottomBarTemporaryMode(text, gui::BottomBar::Side::LEFT, false);
+ },
[app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); },
[app]() { app->getCurrentWindow()->selectSpecialCharacter(); },
2));
internalData.push_back(new gui::InputLinesWithLabelIWidget(
phonebookInternals::ListItemName::Note,
- [app](const UTF8 &text) { app->getCurrentWindow()->bottomBarTemporaryMode(text, false); },
+ [app](const UTF8 &text) {
+ app->getCurrentWindow()->bottomBarTemporaryMode(text, gui::BottomBar::Side::LEFT, false);
+ },
[app]() { app->getCurrentWindow()->bottomBarRestoreFromTemporaryMode(); },
[app]() { app->getCurrentWindow()->selectSpecialCharacter(); }));
M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +32 -9
@@ 154,7 154,7 @@ namespace gui
return false;
}
- void AppWindow::bottomBarTemporaryMode(const UTF8 &text, bool emptyOthers)
+ void AppWindow::bottomBarTemporaryMode(const UTF8 &text, BottomBar::Side side, bool emptyOthers)
{
if (bottomBar == nullptr) {
return;
@@ 162,15 162,38 @@ namespace gui
bottomBar->store();
- if (emptyOthers) {
- bottomBar->setText(BottomBar::Side::LEFT, text);
- bottomBar->setText(BottomBar::Side::CENTER, "");
- bottomBar->setText(BottomBar::Side::RIGHT, "");
- }
- else {
- bottomBar->setText(BottomBar::Side::LEFT, text);
+ switch (side) {
+ case BottomBar::Side::LEFT:
+ if (emptyOthers) {
+ bottomBar->setText(BottomBar::Side::LEFT, text);
+ bottomBar->setText(BottomBar::Side::CENTER, "");
+ bottomBar->setText(BottomBar::Side::RIGHT, "");
+ }
+ else {
+ bottomBar->setText(BottomBar::Side::LEFT, text);
+ }
+ break;
+ case BottomBar::Side::CENTER:
+ if (emptyOthers) {
+ bottomBar->setText(BottomBar::Side::LEFT, "");
+ bottomBar->setText(BottomBar::Side::CENTER, text);
+ bottomBar->setText(BottomBar::Side::RIGHT, "");
+ }
+ else {
+ bottomBar->setText(BottomBar::Side::CENTER, text);
+ }
+ break;
+ case BottomBar::Side::RIGHT:
+ if (emptyOthers) {
+ bottomBar->setText(BottomBar::Side::LEFT, "");
+ bottomBar->setText(BottomBar::Side::CENTER, "");
+ bottomBar->setText(BottomBar::Side::RIGHT, text);
+ }
+ else {
+ bottomBar->setText(BottomBar::Side::RIGHT, text);
+ }
+ break;
}
-
application->refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
}
M module-apps/windows/AppWindow.hpp => module-apps/windows/AppWindow.hpp +3 -1
@@ 77,7 77,9 @@ namespace gui
/// Setting bottom bar temporary text
/// @param text - bottomBar text
/// @param overwriteOthers - set or not other bottomBar texts to "" (default true)
- void bottomBarTemporaryMode(const UTF8 &text, bool emptyOthers = true);
+ void bottomBarTemporaryMode(const UTF8 &text,
+ BottomBar::Side side = BottomBar::Side::LEFT,
+ bool emptyOthers = true);
void bottomBarRestoreFromTemporaryMode();
bool selectSpecialCharacter();
/// get BoundingBox size of Window "body" area
M module-gui/gui/widgets/CMakeLists.txt => module-gui/gui/widgets/CMakeLists.txt +1 -0
@@ 3,6 3,7 @@ target_sources( ${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Alignment.cpp"
"${CMAKE_CURRENT_LIST_DIR}/BottomBar.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/CheckBox.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Icon.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Image.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ImageBox.cpp"
A module-gui/gui/widgets/CheckBox.cpp => module-gui/gui/widgets/CheckBox.cpp +61 -0
@@ 0,0 1,61 @@
+#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 */
A module-gui/gui/widgets/CheckBox.hpp => module-gui/gui/widgets/CheckBox.hpp +28 -0
@@ 0,0 1,28 @@
+#pragma once
+#include "ImageBox.hpp"
+#include "Label.hpp"
+#include "Image.hpp"
+#include "BoxLayout.hpp"
+#include "BottomBar.hpp"
+
+namespace gui
+{
+ class CheckBox : public ImageBox
+ {
+ Image *image = nullptr;
+ std::function<void(const UTF8 &text, BottomBar::Side side, bool emptyOthers)> bottomBarTemporaryMode = nullptr;
+ std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr;
+
+ public:
+ CheckBox(Item *parent,
+ const uint32_t &x,
+ const uint32_t &y,
+ const uint32_t &w,
+ const uint32_t &h,
+ std::function<void(const UTF8 &text, BottomBar::Side side, bool emptyOthers)> bottomBarTemporaryMode =
+ nullptr,
+ std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
+ virtual ~CheckBox() override = default;
+ };
+
+} /* namespace gui */