M module-apps/application-alarm-clock/widgets/AlarmInternalListItem.hpp => module-apps/application-alarm-clock/widgets/AlarmInternalListItem.hpp +1 -8
@@ 7,12 7,5 @@
namespace gui
{
- class AlarmInternalListItem : public ListItem
- {
- public:
- std::function<void(std::shared_ptr<AlarmsRecord> event)> onSaveCallback = nullptr;
- std::function<void(std::shared_ptr<AlarmsRecord> event)> onLoadCallback = nullptr;
- std::function<bool()> onContentChangedCallback = nullptr;
- };
-
+ using AlarmInternalListItem = ListItemWithCallbacks<AlarmsRecord>;
} /* namespace gui */
M module-apps/application-alarm-clock/widgets/AlarmItem.cpp => module-apps/application-alarm-clock/widgets/AlarmItem.cpp +4 -6
@@ 43,13 43,11 @@ namespace gui
onOffImage->setMargins(gui::Margins(style::alarmClock::window::item::imageMargin, 0, 0, 0));
setAlarm();
- }
- bool AlarmItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void AlarmItem::setAlarm()
M module-apps/application-alarm-clock/widgets/AlarmItem.hpp => module-apps/application-alarm-clock/widgets/AlarmItem.hpp +0 -2
@@ 24,7 24,5 @@ namespace gui
public:
explicit AlarmItem(std::shared_ptr<AlarmsRecord> record);
-
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} // namespace gui
M module-apps/application-alarm-clock/widgets/AlarmOptionsItem.cpp => module-apps/application-alarm-clock/widgets/AlarmOptionsItem.cpp +4 -6
@@ 284,13 284,11 @@ namespace gui
}
optionLabel->setText(optionsNames[actualVectorIndex]);
};
- }
- bool AlarmOptionsItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
std::vector<audio::Tags> AlarmOptionsItem::getMusicFilesList()
M module-apps/application-alarm-clock/widgets/AlarmOptionsItem.hpp => module-apps/application-alarm-clock/widgets/AlarmOptionsItem.hpp +0 -2
@@ 47,8 47,6 @@ namespace gui
AlarmOptionItemName itemName,
std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
-
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-alarm-clock/widgets/AlarmTimeItem.cpp => module-apps/application-alarm-clock/widgets/AlarmTimeItem.cpp +5 -7
@@ 123,6 123,11 @@ namespace gui
onInputCallback(*hourInput);
onInputCallback(*minuteInput);
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void AlarmTimeItem::onInputCallback(gui::Text &textItem)
@@ 203,13 208,6 @@ namespace gui
}
}
- bool AlarmTimeItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
- }
-
bool AlarmTimeItem::isPm(const std::string &text) const
{
return !(text == utils::localize.get(utils::time::Locale::getAM()));
M module-apps/application-alarm-clock/widgets/AlarmTimeItem.hpp => module-apps/application-alarm-clock/widgets/AlarmTimeItem.hpp +0 -3
@@ 31,9 31,6 @@ namespace gui
AlarmTimeItem(bool mode24H,
std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-alarm-clock/widgets/CustomCheckBoxWithLabel.cpp => module-apps/application-alarm-clock/widgets/CustomCheckBoxWithLabel.cpp +5 -6
@@ 80,6 80,11 @@ namespace gui
return false;
};
onContentChangedCallback = [&]() { return checkBox->isChecked(); };
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void CustomCheckBoxWithLabel::setCheckBoxes()
@@ 91,10 96,4 @@ namespace gui
}
}
- bool CustomCheckBoxWithLabel::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
- }
} // namespace gui
M module-apps/application-alarm-clock/widgets/CustomCheckBoxWithLabel.hpp => module-apps/application-alarm-clock/widgets/CustomCheckBoxWithLabel.hpp +0 -2
@@ 26,8 26,6 @@ namespace gui
public:
CustomCheckBoxWithLabel(app::Application *app, const std::string &description, const WeekDaysRepeatData &data);
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
-
static const std::map<WeekDayIso, std::string> weekDays;
};
} // namespace gui
M module-apps/application-calendar/models/CustomRepeatModel.cpp => module-apps/application-calendar/models/CustomRepeatModel.cpp +1 -1
@@ 66,7 66,7 @@ std::vector<bool> CustomRepeatModel::getIsCheckedData()
{
std::vector<bool> isCheckedData;
for (auto item : internalData) {
- if (item->onContentChangeCallback && item->onContentChangeCallback()) {
+ if (item->onContentChangedCallback && item->onContentChangedCallback()) {
isCheckedData.push_back(true);
}
else {
M module-apps/application-calendar/widgets/AllEventsItem.cpp => module-apps/application-calendar/widgets/AllEventsItem.cpp +4 -6
@@ 34,13 34,11 @@ namespace gui
description->setEdges(gui::RectangleEdge::None);
description->setFont(style::window::font::bigbold);
description->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
- }
- bool AllEventsItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void AllEventsItem::setMarkerItem(UTF8 text)
M module-apps/application-calendar/widgets/AllEventsItem.hpp => module-apps/application-calendar/widgets/AllEventsItem.hpp +0 -3
@@ 24,9 24,6 @@ namespace gui
void setMarkerItem(UTF8 text);
[[nodiscard]] UTF8 getLabelMarker() const;
void setEvent(std::shared_ptr<EventsRecord> record);
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/CalendarListItem.hpp => module-apps/application-calendar/widgets/CalendarListItem.hpp +1 -8
@@ 7,12 7,5 @@
namespace gui
{
- class CalendarListItem : public ListItem
- {
- public:
- std::function<void(std::shared_ptr<EventsRecord> event)> onSaveCallback = nullptr;
- std::function<void(std::shared_ptr<EventsRecord> event)> onLoadCallback = nullptr;
- std::function<bool()> onContentChangeCallback = nullptr;
- };
-
+ using CalendarListItem = ListItemWithCallbacks<EventsRecord>;
} /* namespace gui */
M module-apps/application-calendar/widgets/CheckBoxWithLabelItem.cpp => module-apps/application-calendar/widgets/CheckBoxWithLabelItem.cpp +7 -9
@@ 57,7 57,7 @@ namespace gui
if (checkBoxData != nullptr) {
setCheckBoxes();
}
- onContentChangeCallback = [&]() { return checkBox->isChecked(); };
+ onContentChangedCallback = [&]() { return checkBox->isChecked(); };
}
void CheckBoxWithLabelItem::applyCallbacks()
@@ 76,11 76,16 @@ namespace gui
inputCallback = [&](gui::Item &item, const gui::InputEvent &event) {
if (checkBox->onInput(event)) {
checkBox->resizeItems();
- onContentChangeCallback = [&]() { return checkBox->isChecked(); };
+ onContentChangedCallback = [&]() { return checkBox->isChecked(); };
return true;
}
return false;
};
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void CheckBoxWithLabelItem::setCheckBoxes()
@@ 108,11 113,4 @@ namespace gui
}
}
- bool CheckBoxWithLabelItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
- }
-
} /* namespace gui */
M module-apps/application-calendar/widgets/CheckBoxWithLabelItem.hpp => module-apps/application-calendar/widgets/CheckBoxWithLabelItem.hpp +0 -3
@@ 30,9 30,6 @@ namespace gui
gui::Label *descriptionLabel = nullptr;
gui::CheckBox *checkBox = nullptr;
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/DayEventsItem.cpp => module-apps/application-calendar/widgets/DayEventsItem.cpp +5 -8
@@ 41,6 41,11 @@ namespace gui
description->setEdges(gui::RectangleEdge::None);
description->setFont(style::window::font::medium);
description->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void DayEventsItem::setEvent(std::shared_ptr<EventsRecord> rec)
@@ 55,12 60,4 @@ namespace gui
}
}
}
-
- bool DayEventsItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
- }
-
} /* namespace gui */
M module-apps/application-calendar/widgets/DayEventsItem.hpp => module-apps/application-calendar/widgets/DayEventsItem.hpp +0 -1
@@ 27,7 27,6 @@ namespace gui
// virtual methods from Item
void setEvent(std::shared_ptr<EventsRecord> record);
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/DayLabel.cpp => module-apps/application-calendar/widgets/DayLabel.cpp +5 -6
@@ 86,6 86,11 @@ namespace gui
this->setPenFocusWidth(style::window::default_border_focus_w);
this->setEdges(RectangleEdge::Top | RectangleEdge::Bottom);
}
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
uint32_t DayLabel::getDayNumber()
@@ 105,10 110,4 @@ namespace gui
}
}
- bool DayLabel::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- this->vBox->setPosition(0, 0);
- this->vBox->setSize(newDim.w, newDim.h);
- return true;
- }
} /* namespace gui */
M module-apps/application-calendar/widgets/DayLabel.hpp => module-apps/application-calendar/widgets/DayLabel.hpp +0 -1
@@ 25,7 25,6 @@ namespace gui
bool isDayEmpty);
~DayLabel() override = default;
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
uint32_t getDayNumber();
};
M module-apps/application-calendar/widgets/EventDateItem.cpp => module-apps/application-calendar/widgets/EventDateItem.cpp +4 -6
@@ 132,13 132,11 @@ namespace gui
setOnInputCallback(*dayInput);
setOnInputCallback(*monthInput);
setOnInputCallback(*yearInput);
- }
- bool EventDateItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
calendar::YearMonthDay EventDateItem::validateDate()
M module-apps/application-calendar/widgets/EventDateItem.hpp => module-apps/application-calendar/widgets/EventDateItem.hpp +0 -2
@@ 34,8 34,6 @@ namespace gui
EventDateItem();
const calendar::YearMonthDay getChosenDate();
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/EventDetailDescriptionItem.cpp => module-apps/application-calendar/widgets/EventDetailDescriptionItem.cpp +5 -7
@@ 64,14 64,12 @@ namespace gui
return true;
};
- descriptionHandler();
- }
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
- bool EventDetailDescriptionItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ descriptionHandler();
}
void EventDetailDescriptionItem::descriptionHandler()
M module-apps/application-calendar/widgets/EventDetailDescriptionItem.hpp => module-apps/application-calendar/widgets/EventDetailDescriptionItem.hpp +0 -2
@@ 23,8 23,6 @@ namespace gui
virtual ~EventDetailDescriptionItem() override = default;
void descriptionHandler();
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/EventTimeItem.cpp => module-apps/application-calendar/widgets/EventTimeItem.cpp +5 -7
@@ 73,6 73,11 @@ namespace gui
return true;
};
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
+
applyInputCallbacks();
prepareForTimeMode();
}
@@ 253,13 258,6 @@ namespace gui
}
}
- bool EventTimeItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
- }
-
void EventTimeItem::setConnectionToSecondItem(gui::EventTimeItem *item)
{
this->secondItem = item;
M module-apps/application-calendar/widgets/EventTimeItem.hpp => module-apps/application-calendar/widgets/EventTimeItem.hpp +0 -2
@@ 59,8 59,6 @@ namespace gui
void setConnectionToSecondItem(gui::EventTimeItem *item);
void setConnectionToDateItem(gui::EventDateItem *item);
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/RepeatAndReminderItem.cpp => module-apps/application-calendar/widgets/RepeatAndReminderItem.cpp +5 -7
@@ 89,14 89,12 @@ namespace gui
reminder->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
reminder->activeItem = false;
- descriptionHandler();
- }
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
- bool RepeatAndReminderItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
+ descriptionHandler();
}
void RepeatAndReminderItem::descriptionHandler()
M module-apps/application-calendar/widgets/RepeatAndReminderItem.hpp => module-apps/application-calendar/widgets/RepeatAndReminderItem.hpp +0 -1
@@ 30,7 30,6 @@ namespace gui
virtual ~RepeatAndReminderItem() = default;
void descriptionHandler();
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/SeveralOptionsItem.cpp => module-apps/application-calendar/widgets/SeveralOptionsItem.cpp +4 -7
@@ 218,13 218,10 @@ namespace gui
optionLabel->setText(optionsNames[actualVectorIndex]);
}
};
- }
- bool SeveralOptionsItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
-
} /* namespace gui */
M module-apps/application-calendar/widgets/SeveralOptionsItem.hpp => module-apps/application-calendar/widgets/SeveralOptionsItem.hpp +0 -3
@@ 49,9 49,6 @@ namespace gui
void prepareOptionsNames();
void applyCallbacks();
uint32_t repeatOptionValue = 0;
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calendar/widgets/TextWithLabelItem.cpp => module-apps/application-calendar/widgets/TextWithLabelItem.cpp +4 -7
@@ 63,13 63,10 @@ namespace gui
};
onLoadCallback = [&](std::shared_ptr<EventsRecord> event) { textInput->setText(event->title); };
- }
- bool TextWithLabelItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
-
} /* namespace gui */
M module-apps/application-calendar/widgets/TextWithLabelItem.hpp => module-apps/application-calendar/widgets/TextWithLabelItem.hpp +0 -3
@@ 21,9 21,6 @@ namespace gui
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr,
std::function<void()> selectSpecialCharacter = nullptr);
virtual ~TextWithLabelItem() override = default;
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-calllog/widgets/CalllogItem.cpp => module-apps/application-calllog/widgets/CalllogItem.cpp +4 -7
@@ 50,14 50,11 @@ namespace gui
timestamp->setEdges(gui::RectangleEdge::None);
timestamp->setFont(style::window::font::small);
timestamp->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Right, gui::Alignment::Vertical::Center});
- }
-
- bool CalllogItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void CalllogItem::setCall(std::shared_ptr<CalllogRecord> &call)
M module-apps/application-calllog/widgets/CalllogItem.hpp => module-apps/application-calllog/widgets/CalllogItem.hpp +0 -3
@@ 50,9 50,6 @@ namespace gui
{
return call != nullptr ? *call : CalllogRecord();
};
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-desktop/widgets/DesktopInputWidget.cpp => module-apps/application-desktop/widgets/DesktopInputWidget.cpp +4 -7
@@ 75,14 75,11 @@ namespace gui
replyImage->setAlignment(Alignment(gui::Alignment::Vertical::Center));
replyImage->setMargins(Margins(0, 0, 0, 0));
replyImage->activeItem = false;
- }
-
- auto DesktopInputWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- body->setPosition(0, 0);
- body->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ body->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
auto DesktopInputWidget::handleRequestResize([[maybe_unused]] const Item *child,
M module-apps/application-desktop/widgets/DesktopInputWidget.hpp => module-apps/application-desktop/widgets/DesktopInputWidget.hpp +0 -1
@@ 27,7 27,6 @@ namespace gui
DesktopInputWidget(app::Application *application, Item *parent, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
~DesktopInputWidget() override = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
auto handleRequestResize(const Item *, unsigned short request_w, unsigned short request_h) -> Size override;
};
M module-apps/application-messages/widgets/SMSInputWidget.cpp => module-apps/application-messages/widgets/SMSInputWidget.cpp +5 -8
@@ 97,6 97,11 @@ namespace gui
return true;
};
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ body->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void SMSInputWidget::handleDraftMessage()
@@ 151,14 156,6 @@ namespace gui
}
}
- auto SMSInputWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- body->setPosition(0, 0);
- body->setSize(newDim.w, newDim.h);
-
- return true;
- }
-
auto SMSInputWidget::handleRequestResize([[maybe_unused]] const Item *child,
unsigned short request_w,
unsigned short request_h) -> Size
M module-apps/application-messages/widgets/SMSInputWidget.hpp => module-apps/application-messages/widgets/SMSInputWidget.hpp +0 -1
@@ 33,7 33,6 @@ namespace gui
void updateDraftMessage(const UTF8 &inputText);
void displayDraftMessage() const;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
auto handleRequestResize(const Item *, unsigned short request_w, unsigned short request_h) -> Size override;
};
M module-apps/application-messages/widgets/SMSOutputWidget.cpp => module-apps/application-messages/widgets/SMSOutputWidget.cpp +9 -11
@@ 93,6 93,15 @@ namespace gui
}
return false;
};
+
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ body->setArea({0, 0, newDim.w, newDim.h});
+
+ // We need to calculate margin between sms and timeLabel and we can do it only after sizes are set.
+ positionTimeLabel();
+
+ return true;
+ };
}
void SMSOutputWidget::positionTimeLabel() const
@@ 136,17 145,6 @@ namespace gui
body->addWidget(errorIcon);
}
- auto SMSOutputWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- body->setPosition(0, 0);
- body->setSize(newDim.w, newDim.h);
-
- // We need to calculate margin between sms and timeLabel and we can do it only after sizes are set.
- positionTimeLabel();
-
- return true;
- }
-
auto SMSOutputWidget::handleRequestResize([[maybe_unused]] const Item *child,
unsigned short request_w,
unsigned short request_h) -> Size
M module-apps/application-messages/widgets/SMSOutputWidget.hpp => module-apps/application-messages/widgets/SMSOutputWidget.hpp +0 -1
@@ 31,7 31,6 @@ namespace gui
SMSOutputWidget(app::Application *application, const std::shared_ptr<SMSRecord> &record);
virtual ~SMSOutputWidget() = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
auto handleRequestResize(const Item *, unsigned short request_w, unsigned short request_h) -> Size override;
};
M module-apps/application-messages/widgets/SMSTemplateItem.cpp => module-apps/application-messages/widgets/SMSTemplateItem.cpp +4 -7
@@ 17,14 17,11 @@ namespace gui
text = new gui::Label(this, 0, 0, 0, 0);
style::window::decorateOption(text);
text->setEllipsis(gui::Ellipsis::Right);
- }
-
- bool SMSTemplateItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- text->setPosition(0, 0);
- text->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ text->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void SMSTemplateItem::setTemplate(std::shared_ptr<SMSTemplateRecord> templ)
M module-apps/application-messages/widgets/SMSTemplateItem.hpp => module-apps/application-messages/widgets/SMSTemplateItem.hpp +0 -3
@@ 25,9 25,6 @@ namespace gui
SMSTemplateItem();
virtual ~SMSTemplateItem() = default;
void setTemplate(std::shared_ptr<SMSTemplateRecord>);
-
- // virtual methods from Item
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
};
} /* namespace gui */
M module-apps/application-music-player/widgets/SongItem.cpp => module-apps/application-music-player/widgets/SongItem.cpp +4 -8
@@ 63,14 63,10 @@ namespace gui
authorText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
authorText->setEditMode(EditMode::Browse);
authorText->setText(authorName);
- }
-
- auto SongItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
-
} /* namespace gui */
M module-apps/application-music-player/widgets/SongItem.hpp => module-apps/application-music-player/widgets/SongItem.hpp +0 -1
@@ 19,7 19,6 @@ namespace gui
SongItem(std::string authorName, std::string songName, std::string duration);
~SongItem() override = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
VBox *vBox = nullptr;
HBox *firstHBox = nullptr;
HBox *secondHBox = nullptr;
M module-apps/application-phonebook/widgets/ContactListItem.hpp => module-apps/application-phonebook/widgets/ContactListItem.hpp +1 -8
@@ 7,12 7,5 @@
namespace gui
{
- class ContactListItem : public ListItem
- {
- public:
- std::function<void(std::shared_ptr<ContactRecord> contact)> onSaveCallback = nullptr;
- std::function<void(std::shared_ptr<ContactRecord> contact)> onLoadCallback = nullptr;
- std::function<bool()> onEmptyCallback = nullptr;
- };
-
+ using ContactListItem = ListItemWithCallbacks<ContactRecord>;
} /* namespace gui */
M module-apps/application-phonebook/widgets/InformationWidget.cpp => module-apps/application-phonebook/widgets/InformationWidget.cpp +5 -7
@@ 106,13 106,11 @@ namespace gui
return vBox->onInput(event);
};
- setEdges(RectangleEdge::None);
- }
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
- auto InformationWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ setEdges(RectangleEdge::None);
}
} /* namespace gui */
M module-apps/application-phonebook/widgets/InformationWidget.hpp => module-apps/application-phonebook/widgets/InformationWidget.hpp +0 -1
@@ 19,7 19,6 @@ namespace gui
public:
InformationWidget(app::Application *app);
~InformationWidget() override = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
VBox *vBox = nullptr;
Label *titleLabel = nullptr;
TextWithIconsWidget *primaryNumberHBox = nullptr;
M module-apps/application-phonebook/widgets/InputBoxWithLabelAndIconWidget.cpp => module-apps/application-phonebook/widgets/InputBoxWithLabelAndIconWidget.cpp +4 -8
@@ 66,15 66,11 @@ namespace gui
applyItemNameSpecificSettings();
setEdges(gui::RectangleEdge::None);
- }
-
- auto InputBoxWithLabelAndIconWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- -> bool
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
void InputBoxWithLabelAndIconWidget::applyItemNameSpecificSettings()
M module-apps/application-phonebook/widgets/InputBoxWithLabelAndIconWidget.hpp => module-apps/application-phonebook/widgets/InputBoxWithLabelAndIconWidget.hpp +0 -1
@@ 24,7 24,6 @@ namespace gui
std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
~InputBoxWithLabelAndIconWidget() override = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
gui::HBox *hBox = nullptr;
gui::Label *inputBoxLabel = nullptr;
gui::Label *descriptionLabel = nullptr;
M module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.cpp => module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.cpp +5 -7
@@ 80,15 80,13 @@ namespace gui
}
return result;
};
- setEdges(RectangleEdge::None);
- }
- auto InputLinesWithLabelIWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
- return true;
+ setEdges(RectangleEdge::None);
}
void InputLinesWithLabelIWidget::applyItemNameSpecificSettings()
M module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.hpp => module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.hpp +0 -1
@@ 26,7 26,6 @@ namespace gui
unsigned int lines = 1);
~InputLinesWithLabelIWidget() override = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
VBox *vBox = nullptr;
Label *titleLabel = nullptr;
TextFixedSize *inputText = nullptr;
M module-apps/application-phonebook/widgets/OutputLinesTextWithLabelWidget.cpp => module-apps/application-phonebook/widgets/OutputLinesTextWithLabelWidget.cpp +5 -9
@@ 46,19 46,15 @@ namespace gui
return true;
};
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
+
this->activeItem = false;
setEdges(RectangleEdge::All);
}
- auto OutputLinesTextWithLabelWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- -> bool
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
-
- return true;
- }
-
void OutputLinesTextWithLabelWidget::applyItemNameSpecificSettings()
{
switch (listItemName) {
M module-apps/application-phonebook/widgets/OutputLinesTextWithLabelWidget.hpp => module-apps/application-phonebook/widgets/OutputLinesTextWithLabelWidget.hpp +0 -1
@@ 20,7 20,6 @@ namespace gui
OutputLinesTextWithLabelWidget(phonebookInternals::ListItemName listItemName);
~OutputLinesTextWithLabelWidget() override = default;
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
VBox *vBox = nullptr;
Label *titleLabel = nullptr;
Text *multilineText = nullptr;
M module-apps/application-phonebook/widgets/PhonebookItem.cpp => module-apps/application-phonebook/widgets/PhonebookItem.cpp +4 -6
@@ 29,13 29,11 @@ namespace gui
contactName->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
contactName->setMinimumHeight(phonebookStyle::contactItem::h);
contactName->setMaximumWidth(phonebookStyle::contactItem::w);
- }
- bool PhonebookItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
// sets copy of alarm's
M module-apps/application-phonebook/widgets/PhonebookItem.hpp => module-apps/application-phonebook/widgets/PhonebookItem.hpp +0 -1
@@ 34,7 34,6 @@ namespace gui
void setMarkerItem(UTF8 text);
UTF8 getLabelMarker();
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
void setLabelMarkerDisplayMode(LabelMarkerDisplayMode mode);
};
M module-apps/application-settings-new/widgets/ApnInputWidget.cpp => module-apps/application-settings-new/widgets/ApnInputWidget.cpp +5 -7
@@ 79,15 79,13 @@ namespace gui
}
return result;
};
- setEdges(RectangleEdge::None);
- }
- auto ApnInputWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
- return true;
+ setEdges(RectangleEdge::None);
}
void ApnInputWidget::applyItemNameSpecificSettings()
M module-apps/application-settings-new/widgets/ApnInputWidget.hpp => module-apps/application-settings-new/widgets/ApnInputWidget.hpp +0 -1
@@ 31,7 31,6 @@ namespace gui
std::function<void()> checkTextContent = nullptr;
void applyItemNameSpecificSettings();
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
void nameHandler();
void apnHandler();
void usernameHandler();
M module-apps/application-settings-new/widgets/ApnListItem.hpp => module-apps/application-settings-new/widgets/ApnListItem.hpp +1 -8
@@ 7,12 7,5 @@
namespace gui
{
- class ApnListItem : public ListItem
- {
- public:
- std::function<void(std::shared_ptr<packet_data::APN::Config> apnRecord)> onSaveCallback = nullptr;
- std::function<void(std::shared_ptr<packet_data::APN::Config> apnRecord)> onLoadCallback = nullptr;
- std::function<bool()> onEmptyCallback = nullptr;
- };
-
+ using ApnListItem = ListItemWithCallbacks<packet_data::APN::Config>;
} /* namespace gui */
M module-apps/application-settings-new/widgets/QuoteWidget.cpp => module-apps/application-settings-new/widgets/QuoteWidget.cpp +5 -9
@@ 103,15 103,11 @@ namespace gui
return true;
};
- setEdges(gui::RectangleEdge::None);
- }
-
- auto QuoteWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- hBox->setPosition(0, 0);
- hBox->setSize(newDim.w, newDim.h);
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ hBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
- return true;
+ setEdges(gui::RectangleEdge::None);
}
-
} /* namespace gui */
M module-apps/application-settings-new/widgets/QuoteWidget.hpp => module-apps/application-settings-new/widgets/QuoteWidget.hpp +0 -2
@@ 20,8 20,6 @@ namespace gui
std::function<void(const UTF8 &text)> bottomBarTemporaryMode = nullptr,
std::function<void()> bottomBarRestoreFromTemporaryMode = nullptr);
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
-
[[nodiscard]] auto getQuoteData() const -> app::QuoteRecord
{
return quote;
M module-apps/application-settings/widgets/ColorTestListItem.cpp => module-apps/application-settings/widgets/ColorTestListItem.cpp +4 -6
@@ 31,13 31,11 @@ namespace gui
else {
colorLabel->setTextColor(ColorFullWhite);
}
- }
- bool ColorTestListItem::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
- {
- vBox->setPosition(0, 0);
- vBox->setSize(newDim.w, newDim.h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ vBox->setArea({0, 0, newDim.w, newDim.h});
+ return true;
+ };
}
bool ColorTestListItem::onInput(const InputEvent &inputEvent)
M module-apps/application-settings/widgets/ColorTestListItem.hpp => module-apps/application-settings/widgets/ColorTestListItem.hpp +0 -1
@@ 25,7 25,6 @@ namespace gui
explicit ColorTestListItem(app::Application *app, const Color color);
bool onInput(const InputEvent &inputEvent) override;
- bool onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) override;
[[nodiscard]] uint8_t getColorIntensity();
};
} /* namespace gui */
M module-apps/application-special-input/widgets/SpecialInputTableWidget.cpp => module-apps/application-special-input/widgets/SpecialInputTableWidget.cpp +5 -6
@@ 61,13 61,12 @@ namespace gui
}
return true;
};
- }
- auto SpecialInputTableWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
- {
- box->setPosition(0, 0);
- box->setSize(specialCharacterTableWidget::window_grid_w, specialCharacterTableWidget::window_grid_h);
- return true;
+ dimensionChangedCallback = [&](gui::Item &, const BoundingBox &newDim) -> bool {
+ box->setArea(
+ {0, 0, specialCharacterTableWidget::window_grid_w, specialCharacterTableWidget::window_grid_h});
+ return true;
+ };
}
void SpecialInputTableWidget::decorateActionActivated(Item *it, const std::string &str)
M module-apps/application-special-input/widgets/SpecialInputTableWidget.hpp => module-apps/application-special-input/widgets/SpecialInputTableWidget.hpp +0 -1
@@ 33,7 33,6 @@ namespace gui
public:
SpecialInputTableWidget(app::Application *app, std::list<Carrier> &&carier);
- auto onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool override;
};
} /* namespace gui */
M module-gui/gui/widgets/BoxLayout.cpp => module-gui/gui/widgets/BoxLayout.cpp +1 -0
@@ 551,6 551,7 @@ namespace gui
{
type = ItemType::HBOX;
}
+
HBox::HBox(Item *parent, const uint32_t &x, const uint32_t &y, const uint32_t &w, const uint32_t &h)
: BoxLayout(parent, x, y, w, h)
{
M module-gui/gui/widgets/ListItem.hpp => module-gui/gui/widgets/ListItem.hpp +8 -0
@@ 17,4 17,12 @@ namespace gui
ListItem();
};
+ template <class T> class ListItemWithCallbacks : public ListItem
+ {
+ public:
+ std::function<bool()> onEmptyCallback = nullptr;
+ std::function<bool()> onContentChangedCallback = nullptr;
+ std::function<void(std::shared_ptr<T> contact)> onSaveCallback = nullptr;
+ std::function<void(std::shared_ptr<T> contact)> onLoadCallback = nullptr;
+ };
} /* namespace gui */