M changelog.md => changelog.md +1 -0
@@ 27,6 27,7 @@
### Changed
* `[messages]` Split SMS thread for a specific contact into separate ones if multiple phone numbers are available.
+* `[gui][renderer]` Shape rendering refactored.
### Fixed
M module-apps/application-antenna/windows/ScanModesWindow.cpp => module-apps/application-antenna/windows/ScanModesWindow.cpp +2 -2
@@ 57,7 57,7 @@ namespace gui
modesBox = new gui::VBox(this, style::window::default_left_margin, (uint32_t)title->offset_h(), w, h);
modesBox->setPenWidth(0);
modesBox->setPenFocusWidth(0);
- modesBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ modesBox->setEdges(gui::RectangleEdge::None);
for (auto el : modeButtonParams) {
gui::Label *modeLabel = addMode(nullptr, el.second);
@@ 134,7 134,7 @@ namespace gui
antenna::scan_mode_window::commonDefaultPos,
antenna::scan_mode_window::buttonW,
antenna::scan_mode_window::commonSpacerH);
- label->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(gui::RectangleEdge::None);
label->setFilled(false);
label->activeItem = false;
label->visible = false;
M module-apps/application-calendar/widgets/AllEventsItem.cpp => module-apps/application-calendar/widgets/AllEventsItem.cpp +4 -4
@@ 15,13 15,13 @@ namespace gui
setMargins(gui::Margins(0, style::margins::big, 0, 0));
hBox = new gui::HBox(this, 0, 0, 0, 0);
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
startTime = new gui::Label(hBox, 0, 0, 0, 0);
startTime->setMinimumSize(style::window::calendar::item::allEvents::start_time_min_w,
style::window::label::big_h);
startTime->setMaximumSize(style::window::default_body_width, style::window::label::big_h);
- startTime->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ startTime->setEdges(gui::RectangleEdge::None);
startTime->setFont(style::window::font::small);
startTime->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
startTime->setMargins(gui::Margins(style::margins::small, 0, 0, 0));
@@ 29,7 29,7 @@ namespace gui
description = new gui::Label(hBox, 0, 0, 0, 0);
description->setMinimumSize(style::window::calendar::item::allEvents::description_w,
style::window::label::big_h);
- description->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ description->setEdges(gui::RectangleEdge::None);
description->setFont(style::window::font::bigbold);
description->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
}
@@ 48,7 48,7 @@ namespace gui
description->setMinimumSize(0, 0);
startTime->setLineMode(true);
activeItem = false;
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
}
UTF8 AllEventsItem::getLabelMarker() const
M module-apps/application-calendar/widgets/CheckBoxWithLabelItem.cpp => module-apps/application-calendar/widgets/CheckBoxWithLabelItem.cpp +3 -3
@@ 19,10 19,10 @@ namespace gui
setMinimumSize(style::window::default_body_width, style::window::calendar::item::checkBox::height);
setMargins(gui::Margins(style::margins::small, style::window::calendar::item::checkBox::margin_top, 0, 0));
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
hBox = new gui::HBox(this, 0, 0, 0, 0);
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
if (checkIsOnLeftBarSide) {
checkBox = new gui::CheckBox(
@@ 58,7 58,7 @@ namespace gui
descriptionLabel->setMinimumSize(style::window::calendar::item::checkBox::description_label_w,
style::window::calendar::item::checkBox::height);
descriptionLabel->setMargins(gui::Margins(style::margins::very_big, 0, 0, 0));
- descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ descriptionLabel->setEdges(gui::RectangleEdge::None);
descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
descriptionLabel->setFont(style::window::font::medium);
descriptionLabel->activeItem = false;
M module-apps/application-calendar/widgets/DayEventsItem.cpp => module-apps/application-calendar/widgets/DayEventsItem.cpp +4 -4
@@ 14,17 14,17 @@ namespace gui
setMargins(gui::Margins(0, style::margins::small, 0, 0));
vBox = new gui::VBox(this, 0, 0, 0, 0);
- vBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(gui::RectangleEdge::None);
hBox = new gui::HBox(vBox, 0, 0, 0, 0);
hBox->setMinimumSize(style::window::default_body_width, style::window::calendar::item::dayEvents::box_height);
hBox->setMargins(gui::Margins(0, style::margins::small + style::margins::big, 0, 0));
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
title = new gui::Label(hBox, 0, 0, 0, 0);
title->setMinimumSize(style::window::calendar::item::dayEvents::title_w,
style::window::calendar::item::dayEvents::box_height);
title->setMargins(gui::Margins(style::margins::small, 0, style::margins::small + style::margins::big, 0));
- title->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ title->setEdges(gui::RectangleEdge::None);
title->setFont(style::window::font::bigbold);
title->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
@@ 35,7 35,7 @@ namespace gui
description->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::dayEvents::box_height);
description->setMargins(gui::Margins(style::margins::small, style::margins::big, 0, style::margins::very_big));
- description->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ description->setEdges(gui::RectangleEdge::None);
description->setFont(style::window::font::medium);
description->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
}
M module-apps/application-calendar/widgets/DayLabel.cpp => module-apps/application-calendar/widgets/DayLabel.cpp +4 -4
@@ 16,14 16,14 @@ namespace gui
bool isDayEmpty)
: Rect(parent, 0, 0, width, height)
{
- this->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ this->setEdges(RectangleEdge::None);
this->vBox = new gui::VBox(this, 0, 0, 0, 0);
- this->vBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ this->vBox->setEdges(gui::RectangleEdge::None);
this->dayNumber = new gui::Label(this->vBox, 0, 0, 0, 0);
this->dayNumber->setMinimumSize(width, height - 22);
- this->dayNumber->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ this->dayNumber->setEdges(RectangleEdge::None);
this->dayNumber->setAlignment(
gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
this->dayNumber->setMargins(gui::Margins(0, 11, 0, 0));
@@ 78,7 78,7 @@ namespace gui
};
this->setPenWidth(style::window::default_border_no_focus_w);
this->setPenFocusWidth(style::window::default_border_focus_w);
- this->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_TOP | RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ this->setEdges(RectangleEdge::Top | RectangleEdge::Bottom);
}
}
M module-apps/application-calendar/widgets/EventDetailDescriptionItem.cpp => module-apps/application-calendar/widgets/EventDetailDescriptionItem.cpp +5 -5
@@ 10,17 10,17 @@ namespace gui
EventDetailDescriptionItem::EventDetailDescriptionItem()
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
setMinimumSize(style::window::default_body_width, style::window::calendar::item::eventDetail::height_min);
setMaximumSize(style::window::default_body_width, style::window::calendar::item::eventDetail::height_max);
setMargins(gui::Margins(style::margins::small, style::window::calendar::item::eventDetail::margin_top, 0, 0));
vBox = new VBox(this, 0, 0, 0, 0);
- vBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(RectangleEdge::None);
title = new gui::Label(vBox, 0, 0, 0, 0);
title->setMinimumSize(style::window::default_body_width, style::window::calendar::item::eventDetail::title_h);
- title->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ title->setEdges(RectangleEdge::None);
title->setFont(style::window::font::small);
title->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
title->setLineMode(true);
@@ 29,7 29,7 @@ namespace gui
eventTime = new gui::Label(vBox, 0, 0, 0, 0);
eventTime->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::eventDetail::label_h);
- eventTime->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ eventTime->setEdges(RectangleEdge::None);
eventTime->setMargins(
gui::Margins(0, style::window::calendar::item::eventDetail::event_time_margin, 0, style::margins::small));
eventTime->setFont(style::window::font::bigbold);
@@ 39,7 39,7 @@ namespace gui
description = new gui::Text(vBox, 0, 0, 0, 0);
description->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::eventDetail::label_h);
- description->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ description->setEdges(RectangleEdge::None);
description->setMaximumSize(style::window::default_body_width,
2 * style::window::calendar::item::eventDetail::label_h);
description->setFont(style::window::font::big);
M module-apps/application-calendar/widgets/EventTimeItem.cpp => module-apps/application-calendar/widgets/EventTimeItem.cpp +8 -8
@@ 17,17 17,17 @@ namespace gui
{
setMinimumSize(style::window::default_body_width, style::window::calendar::item::eventTime::height);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
setMargins(gui::Margins(style::margins::small, style::window::calendar::item::eventTime::margin, 0, 0));
vBox = new gui::VBox(this, 0, 0, 0, 0);
- vBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(gui::RectangleEdge::None);
vBox->activeItem = false;
descriptionLabel = new gui::Label(vBox, 0, 0, 0, 0);
descriptionLabel->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::eventTime::separator);
- descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ descriptionLabel->setEdges(gui::RectangleEdge::None);
descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
descriptionLabel->setFont(style::window::font::small);
descriptionLabel->activeItem = false;
@@ 36,11 36,11 @@ namespace gui
hBox->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::eventTime::height -
style::window::calendar::item::eventTime::separator);
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
hBox->activeItem = false;
hourInput = new gui::Text(hBox, 0, 0, 0, 0);
- hourInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ hourInput->setEdges(gui::RectangleEdge::Bottom);
hourInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
hourInput->setFont(style::window::font::largelight);
hourInput->setInputMode(new InputMode({InputMode::digit}));
@@ 52,14 52,14 @@ namespace gui
colonLabel->setMinimumSize(style::window::calendar::item::eventTime::separator,
style::window::calendar::item::eventTime::height -
style::window::calendar::item::eventTime::separator);
- colonLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ colonLabel->setEdges(gui::RectangleEdge::None);
colonLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
colonLabel->setFont(style::window::font::medium);
colonLabel->setText(":");
colonLabel->activeItem = false;
minuteInput = new gui::Text(hBox, 0, 0, 0, 0);
- minuteInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ minuteInput->setEdges(gui::RectangleEdge::Bottom);
minuteInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
minuteInput->setFont(style::window::font::largelight);
minuteInput->setInputMode(new InputMode({InputMode::digit}));
@@ 216,7 216,7 @@ namespace gui
{
if (!mode24H) {
mode12hInput = new gui::Label(hBox, 0, 0, 0, 0);
- mode12hInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ mode12hInput->setEdges(gui::RectangleEdge::Bottom);
mode12hInput->setAlignment(
gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
mode12hInput->setFont(style::window::font::largelight);
M module-apps/application-calendar/widgets/RepeatAndReminderItem.cpp => module-apps/application-calendar/widgets/RepeatAndReminderItem.cpp +8 -8
@@ 10,28 10,28 @@ namespace gui
RepeatAndReminderItem::RepeatAndReminderItem(app::ApplicationCalendar *application) : app(application)
{
activeItem = false;
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
setMinimumSize(style::window::default_body_width, style::window::calendar::item::repeatAndReminder::height);
hBox = new HBox(this, 0, 0, 0, 0);
- hBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(RectangleEdge::None);
repeatVBox = new VBox(hBox, 0, 0, 0, 0);
repeatVBox->setMinimumSize(style::window::default_body_width / 2,
style::window::calendar::item::repeatAndReminder::height);
- repeatVBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ repeatVBox->setEdges(RectangleEdge::None);
reminderVBox = new VBox(hBox, 0, 0, 0, 0);
reminderVBox->setMinimumSize(style::window::default_body_width / 2,
style::window::calendar::item::repeatAndReminder::height);
- reminderVBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ reminderVBox->setEdges(RectangleEdge::None);
repeatTitle = new gui::Label(repeatVBox, 0, 0, 0, 0);
repeatTitle->setMinimumSize(style::window::calendar::item::repeatAndReminder::description_w,
style::window::calendar::item::repeatAndReminder::title_label_h);
repeatTitle->setMargins(
gui::Margins(0, 0, 0, style::window::calendar::item::repeatAndReminder::title_label_margin));
- repeatTitle->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ repeatTitle->setEdges(RectangleEdge::None);
repeatTitle->setFont(style::window::font::small);
repeatTitle->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
repeatTitle->setLineMode(true);
@@ 40,7 40,7 @@ namespace gui
repeat = new gui::Label(repeatVBox, 0, 0, 0, 0);
repeat->setMinimumSize(style::window::calendar::item::repeatAndReminder::description_w,
style::window::calendar::item::repeatAndReminder::description_h);
- repeat->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ repeat->setEdges(RectangleEdge::None);
repeat->setFont(style::window::font::medium);
repeat->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
repeat->activeItem = false;
@@ 50,7 50,7 @@ namespace gui
style::window::calendar::item::repeatAndReminder::title_label_h);
reminderTitle->setMargins(
gui::Margins(0, 0, 0, style::window::calendar::item::repeatAndReminder::title_label_margin));
- reminderTitle->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ reminderTitle->setEdges(RectangleEdge::None);
reminderTitle->setFont(style::window::font::small);
reminderTitle->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
reminderTitle->setLineMode(true);
@@ 59,7 59,7 @@ namespace gui
reminder = new gui::Label(reminderVBox, 0, 0, 0, 0);
reminder->setMinimumSize(style::window::default_body_width / 2,
style::window::calendar::item::repeatAndReminder::description_h);
- reminder->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ reminder->setEdges(RectangleEdge::None);
reminder->setFont(style::window::font::medium);
reminder->setAlignment(gui::Alignment{gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center});
reminder->activeItem = false;
M module-apps/application-calendar/widgets/SeveralOptionsItem.cpp => module-apps/application-calendar/widgets/SeveralOptionsItem.cpp +5 -5
@@ 23,18 23,18 @@ namespace gui
setMinimumSize(style::window::default_body_width, style::window::calendar::item::severalOptions::height);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ setEdges(RectangleEdge::Bottom);
setPenWidth(style::window::default_border_rect_no_focus);
setMargins(gui::Margins(style::margins::small, style::margins::huge / 2, 0, style::margins::huge / 2));
vBox = new gui::VBox(this, 0, 0, 0, 0);
- vBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(gui::RectangleEdge::None);
vBox->activeItem = false;
descriptionLabel = new gui::Label(vBox, 0, 0, 0, 0);
descriptionLabel->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::severalOptions::label_h);
- descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ descriptionLabel->setEdges(gui::RectangleEdge::None);
descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
descriptionLabel->setFont(style::window::font::small);
descriptionLabel->activeItem = false;
@@ 44,7 44,7 @@ namespace gui
hBox->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::severalOptions::height -
style::window::calendar::item::severalOptions::label_h);
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
hBox->activeItem = false;
leftArrow = new gui::Image(hBox, 0, 0, 0, 0);
@@ 59,7 59,7 @@ namespace gui
2 * style::window::calendar::item::severalOptions::arrow_w_h,
style::window::calendar::item::severalOptions::height -
style::window::calendar::item::severalOptions::label_h);
- optionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ optionLabel->setEdges(gui::RectangleEdge::None);
optionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
optionLabel->setFont(style::window::font::medium);
optionLabel->activeItem = false;
M module-apps/application-calendar/widgets/TextWithLabelItem.cpp => module-apps/application-calendar/widgets/TextWithLabelItem.cpp +4 -4
@@ 12,11 12,11 @@ namespace gui
{
setMinimumSize(style::window::default_body_width, style::window::calendar::item::textWithLabel::height);
setMargins(gui::Margins(style::margins::small, 0, 0, 0));
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
bottomBarRestoreFromTemporaryMode();
vBox = new gui::VBox(this, 0, 0, 0, 0);
- vBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(gui::RectangleEdge::None);
vBox->setPenFocusWidth(style::window::default_border_focus_w);
vBox->setPenWidth(style::window::default_border_rect_no_focus);
@@ 24,7 24,7 @@ namespace gui
descriptionLabel->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::textWithLabel::description_h);
descriptionLabel->setMargins(gui::Margins(0, style::margins::small, 0, 0));
- descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ descriptionLabel->setEdges(gui::RectangleEdge::None);
descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
descriptionLabel->setFont(style::window::font::small);
descriptionLabel->activeItem = false;
@@ 33,7 33,7 @@ namespace gui
textInput = new gui::Text(vBox, 0, 0, 0, 0);
textInput->setMinimumSize(style::window::default_body_width,
style::window::calendar::item::textWithLabel::text_input_h);
- textInput->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ textInput->setEdges(gui::RectangleEdge::Bottom);
textInput->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
textInput->setFont(style::window::font::medium);
textInput->setInputMode(new InputMode(
M module-apps/application-call/widgets/Icon.hpp => module-apps/application-call/widgets/Icon.hpp +3 -3
@@ 42,17 42,17 @@ namespace gui
Icon(Item *parent, const uint32_t &x, const uint32_t &y, const uint32_t &w_margin, T state, const IconMap &data)
: Rect(parent, x, y, icon::w + 2 * w_margin, icon::h), data(data)
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
setPenFocusWidth(style::window::default_border_no_focus_w);
setPenWidth(style::window::default_border_no_focus_w);
boundingRect = new Rect(this, w_margin, 0, icon::w, icon::h);
- boundingRect->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ boundingRect->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
boundingRect->setPenFocusWidth(style::window::default_border_focus_w);
boundingRect->setPenWidth(style::window::default_border_no_focus_w);
img = new gui::Image(boundingRect, icon::img::x, icon::img::y, 0, 0);
label = new gui::Label(this, icon::label::x, icon::label::y, icon::label::w + 2 * w_margin, icon::label::h);
- label->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(RectangleEdge::None);
label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
label->setFont(style::window::font::verysmall);
M module-apps/application-call/windows/EnterNumberWindow.cpp => module-apps/application-call/windows/EnterNumberWindow.cpp +1 -1
@@ 59,7 59,7 @@ namespace gui
numberLabel = new gui::Label(this, numberLabel::x, numberLabel::y, numberLabel::w, numberLabel::h);
numberLabel->setPenWidth(numberLabel::borderW);
numberLabel->setFont(style::window::font::largelight);
- numberLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ numberLabel->setEdges(RectangleEdge::Bottom);
numberLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
numberLabel->setEllipsis(Ellipsis::Left);
M module-apps/application-calllog/widgets/CalllogItem.cpp => module-apps/application-calllog/widgets/CalllogItem.cpp +1 -1
@@ 26,7 26,7 @@ namespace gui
setMaximumSize(clItemStyle::w, clItemStyle::h);
setRadius(0);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
setPenFocusWidth(style::window::default_border_focus_w);
setPenWidth(style::window::default_border_no_focus_w);
M module-apps/application-calllog/windows/CallLogDetailsWindow.cpp => module-apps/application-calllog/windows/CallLogDetailsWindow.cpp +1 -1
@@ 104,7 104,7 @@ namespace gui
for (uint32_t i = 0; i < 2; ++i) {
rects[i] = new gui::Rect(this, 0, 0, information::imgs::w, information::imgs::h);
rects[i]->setFilled(false);
- rects[i]->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ rects[i]->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
rects[i]->setPenFocusWidth(style::window::default_border_focus_w);
rects[i]->setPenWidth(style::window::default_border_no_focus_w);
}
M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +1 -1
@@ 309,7 309,7 @@ namespace gui
// 3. Set hbox layout properties
el->setPenWidth(style::window::default_border_no_focus_w);
el->setPenFocusWidth(style::window::default_border_focus_w);
- el->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ el->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
el->inputCallback = [showCallback, clearCallback](Item &, const InputEvent &event) -> bool {
if (event.state != InputEvent::State::keyReleasedShort) {
return false;
M => +1 -1
@@ 54,7 54,7 @@ namespace gui
this->activatedCallback = activatedCallback;
this->setPenWidth(style::window::default_border_no_focus_w);
this->setPenFocusWidth(style::window::default_border_focus_w);
this->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_TOP | RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
this->setEdges(RectangleEdge::Top | RectangleEdge::Bottom);
addWidget(it);
};
M module-apps/application-desktop/windows/PinLockBaseWindow.cpp => module-apps/application-desktop/windows/PinLockBaseWindow.cpp +1 -1
@@ 34,7 34,7 @@ namespace gui
titleLabel->setBorderColor(gui::ColorFullBlack);
titleLabel->setFont(style::header::font::title);
titleLabel->setText(utils::localize.get("app_desktop_pin_info1"));
- titleLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ titleLabel->setEdges(RectangleEdge::None);
titleLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
}
void PinLockBaseWindow::buildInfoText(unsigned int h)
M module-apps/application-desktop/windows/PowerOffWindow.cpp => module-apps/application-desktop/windows/PowerOffWindow.cpp +3 -3
@@ 55,7 55,7 @@ namespace gui
titleLabel->setBorderColor(gui::ColorFullBlack);
titleLabel->setFont(style::header::font::title);
titleLabel->setText(utils::localize.get("app_desktop_poweroff_title"));
- titleLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ titleLabel->setEdges(RectangleEdge::None);
titleLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
// label with question for powering down
@@ 76,7 76,7 @@ namespace gui
label->setPenFocusWidth(2);
label->setRadius(5);
label->setFont(style::window::font::medium);
- label->setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ label->setEdges(RectangleEdge::All);
label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
selectionLabels.push_back(label);
pinLabelX += 193;
@@ 95,7 95,7 @@ namespace gui
eventMgrLabel->setRadius(5);
eventMgrLabel->setFont(style::window::font::bigbold);
eventMgrLabel->setText("TURN PWR MGR OFF");
- eventMgrLabel->setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ eventMgrLabel->setEdges(RectangleEdge::All);
eventMgrLabel->setAlignment(
gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
M module-apps/application-desktop/windows/PukLockBox.cpp => module-apps/application-desktop/windows/PukLockBox.cpp +2 -2
@@ 32,11 32,11 @@ namespace gui
const uint32_t pinLabelWidth = style::window_width - 2 * lock_style::pin_label_x;
LockWindow->pinLabel = new gui::Label(
LockWindow, lock_style::pin_label_x, lock_style::pin_label_y, pinLabelWidth, lock_style::label_size);
- LockWindow->pinLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ LockWindow->pinLabel->setEdges(RectangleEdge::Bottom);
LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size);
for (auto label : LockWindow->pinLabels) {
- label->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(RectangleEdge::None);
}
}
void PukLockBox::setVisibleStateEnterPin()
M module-apps/application-desktop/windows/Reboot.cpp => module-apps/application-desktop/windows/Reboot.cpp +1 -1
@@ 34,7 34,7 @@ namespace gui
text->setFilled(false);
text->setBorderColor(gui::ColorFullBlack);
text->setFont(style::header::font::title);
- text->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ text->setEdges(RectangleEdge::None);
text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Bottom));
}
M module-apps/application-desktop/windows/ScreenLockBox.cpp => module-apps/application-desktop/windows/ScreenLockBox.cpp +2 -2
@@ 31,11 31,11 @@ namespace gui
const uint32_t pinLabelWidth = style::window_width - 2 * lock_style::pin_label_x_screen;
LockWindow->pinLabel = new gui::Label(
LockWindow, lock_style::pin_label_x_screen, lock_style::pin_label_y, pinLabelWidth, lock_style::label_size);
- LockWindow->pinLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ LockWindow->pinLabel->setEdges(RectangleEdge::None);
LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size_screen);
for (auto label : LockWindow->pinLabels) {
- label->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ label->setEdges(RectangleEdge::Bottom);
}
}
void ScreenLockBox::setVisibleStateEnterPin()
M module-apps/application-desktop/windows/SimLockBox.cpp => module-apps/application-desktop/windows/SimLockBox.cpp +2 -2
@@ 33,11 33,11 @@ namespace gui
const uint32_t pinLabelWidth = style::window_width - 2 * lock_style::pin_label_x;
LockWindow->pinLabel = new gui::Label(
LockWindow, lock_style::pin_label_x, lock_style::pin_label_y, pinLabelWidth, lock_style::label_size);
- LockWindow->pinLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ LockWindow->pinLabel->setEdges(RectangleEdge::Bottom);
LockWindow->buildPinLabels(LockWindow->pinLabel, pinSize, lock_style::label_size);
for (auto label : LockWindow->pinLabels) {
- label->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(RectangleEdge::None);
}
}
void SimLockBox::setVisibleStateEnterPin()
M module-apps/application-meditation/widgets/MeditationTimer.cpp => module-apps/application-meditation/widgets/MeditationTimer.cpp +2 -2
@@ 22,7 22,7 @@ namespace gui
Item *_parent)
: HBox(_parent, x, y, width, height), application{app}
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
build();
}
@@ 40,7 40,7 @@ namespace gui
progressBar = new CircularProgressBar(this, params);
timer = new Text(progressBar, 0, 0, getWidth(), getHeight());
- timer->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ timer->setEdges(RectangleEdge::None);
timer->setFont(style::window::font::supersizemelight);
timer->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
timer->setEditMode(EditMode::BROWSE);
M module-apps/application-messages/widgets/BaseThreadItem.cpp => module-apps/application-messages/widgets/BaseThreadItem.cpp +1 -1
@@ 16,7 16,7 @@ namespace gui
setMaximumSize(window::default_body_width, style::messages::threadItem::sms_thread_item_h);
setRadius(0);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
setPenFocusWidth(window::default_border_focus_w);
setPenWidth(window::default_border_no_focus_w);
M module-apps/application-messages/widgets/SMSInputWidget.cpp => module-apps/application-messages/widgets/SMSInputWidget.cpp +3 -3
@@ 18,10 18,10 @@ namespace gui
{
setMinimumSize(style::window::default_body_width, style::messages::smsInput::min_h);
setMargins(Margins(0, style::messages::smsInput::new_sms_vertical_spacer, 0, 0));
- setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(gui::RectangleEdge::None);
body = new HBox(this, 0, 0, 0, 0);
- body->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ body->setEdges(RectangleEdge::Bottom);
body->setMaximumSize(style::window::default_body_width, style::messages::smsInput::max_input_h);
deleteByList = false;
@@ 34,7 34,7 @@ namespace gui
inputText->setPadding(Padding(0, 0, 0, style::messages::smsInput::bottom_padding));
inputText->setPenFocusWidth(style::window::default_border_focus_w);
inputText->setPenWidth(style::window::default_border_focus_w);
- inputText->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ inputText->setEdges(gui::RectangleEdge::None);
replyImage = new Image(body, 0, 0, "messages_reply");
replyImage->setAlignment(Alignment(gui::Alignment::Vertical::Bottom));
M module-apps/application-messages/widgets/SMSOutputWidget.cpp => module-apps/application-messages/widgets/SMSOutputWidget.cpp +6 -6
@@ 15,10 15,10 @@ namespace gui
{
setMinimumSize(style::window::default_body_width, style::messages::smsOutput::default_h);
setMargins(Margins(0, style::messages::smsOutput::sms_vertical_spacer, 0, 0));
- setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(gui::RectangleEdge::None);
body = new HBox(this, 0, 0, 0, 0);
- body->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ body->setEdges(RectangleEdge::None);
body->setMaximumSize(style::window::default_body_width, style::window::default_body_height);
smsBubble = new TextBubble(nullptr, 0, 0, 0, 0);
@@ 37,20 37,20 @@ namespace gui
// Handle in the same way as case below. (pending sending display as already sent)
[[fallthrough]];
case SMSType::OUTBOX:
- smsBubble->setYaps(RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT);
+ smsBubble->setYaps(RectangleYap::TopRight);
body->setReverseOrder(true);
body->addWidget(smsBubble);
timeLabelBuild(record->date);
break;
case SMSType::INBOX:
smsBubble->setPadding(style::messages::smsOutput::sms_left_bubble_padding);
- smsBubble->setYaps(RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT);
+ smsBubble->setYaps(RectangleYap::TopLeft);
body->setReverseOrder(false);
body->addWidget(smsBubble);
timeLabelBuild(record->date);
break;
case SMSType::FAILED:
- smsBubble->setYaps(RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT);
+ smsBubble->setYaps(RectangleYap::TopRight);
body->setReverseOrder(true);
errorIconBuild();
body->addWidget(smsBubble);
@@ 118,7 118,7 @@ namespace gui
timeLabel->setText(utils::time::Time(timestamp));
timeLabel->setVisible(false);
timeLabel->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
- timeLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ timeLabel->setEdges(RectangleEdge::None);
}
void SMSOutputWidget::errorIconBuild()
M module-apps/application-messages/windows/NewMessage.cpp => module-apps/application-messages/windows/NewMessage.cpp +6 -6
@@ 169,13 169,13 @@ namespace gui
auto recipientLabel = new Label(body, 0, 0, body->getWidth(), msgStyle::recipientLabel::h);
recipientLabel->setText(utils::localize.get("sms_add_rec_num"));
recipientLabel->activeItem = false;
- recipientLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ recipientLabel->setEdges(gui::RectangleEdge::None);
recipientLabel->setFont(style::window::font::small);
recipientLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
auto reciepientHbox = new gui::HBox(body, 0, 0, body->getWidth(), msgStyle::text::h);
reciepientHbox->setAlignment(gui::Alignment::Vertical::Center);
- reciepientHbox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ reciepientHbox->setEdges(gui::RectangleEdge::Bottom);
reciepientHbox->setPenFocusWidth(style::window::default_border_focus_w);
reciepientHbox->setPenWidth(style::window::default_border_rect_no_focus);
@@ 186,7 186,7 @@ namespace gui
msgStyle::text::h,
"",
ExpandMode::EXPAND_NONE);
- recipient->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ recipient->setEdges(gui::RectangleEdge::None);
recipient->setInputMode(new InputMode({InputMode::phone}));
recipient->setFont(style::window::font::mediumbold);
recipient->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
@@ 208,13 208,13 @@ namespace gui
auto labelMessage = new Label(body, 0, 0, body->getWidth(), msgStyle::messageLabel::h);
labelMessage->setText(utils::localize.get("app_messages_message"));
labelMessage->activeItem = false;
- labelMessage->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ labelMessage->setEdges(gui::RectangleEdge::None);
labelMessage->setFont(style::window::font::small);
labelMessage->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
message = new gui::Text(nullptr, 0, 0, body->getWidth(), msgStyle::text::h, "", ExpandMode::EXPAND_UP);
message->setMaximumSize(body->getWidth(), body->getHeight());
- message->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ message->setEdges(gui::RectangleEdge::Bottom);
message->setInputMode(new InputMode(
{InputMode::ABC, InputMode::abc, InputMode::digit},
[=](const UTF8 &text) { bottomBarTemporaryMode(text); },
@@ 247,7 247,7 @@ namespace gui
body->addWidget(new Span(Axis::Y, body->getHeight()));
message->setText(""); // to set actual size of Text
- body->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ body->setEdges(gui::RectangleEdge::None);
body->setVisible(true);
body->setNavigation();
setFocusItem(body);
M module-apps/application-music-player/widgets/SongItem.cpp => module-apps/application-music-player/widgets/SongItem.cpp +6 -6
@@ 11,24 11,24 @@ namespace gui
setMargins(Margins(0, style::margins::small, 0, style::margins::small));
vBox = new VBox(this, 0, 0, 0, 0);
- vBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(RectangleEdge::None);
firstHBox = new HBox(vBox, 0, 0, 0, 0);
firstHBox->setMinimumSize(songItem::w, songItem::bold_text_h);
firstHBox->setMargins(Margins(0, songItem::topMargin, 0, 0));
firstHBox->setReverseOrder(true);
- firstHBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ firstHBox->setEdges(RectangleEdge::None);
secondHBox = new HBox(vBox, 0, 0, 0, 0);
secondHBox->setMinimumSize(songItem::w, songItem::text_h);
secondHBox->setMargins(Margins(0, songItem::topMargin, 0, 0));
secondHBox->setReverseOrder(true);
- secondHBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ secondHBox->setEdges(RectangleEdge::None);
durationText = new TextFixedSize(firstHBox, 0, 0, 0, 0);
durationText->setMinimumSize(songItem::duration_w, songItem::text_h);
durationText->setMargins(Margins(0, 0, songItem::rightMargin, 0));
- durationText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ durationText->setEdges(RectangleEdge::None);
durationText->setUnderline(false);
durationText->setFont(style::window::font::verysmall);
durationText->setAlignment(Alignment(gui::Alignment::Horizontal::Right, gui::Alignment::Vertical::Center));
@@ 39,7 39,7 @@ namespace gui
songText->setMinimumHeight(songItem::bold_text_h);
songText->setMaximumWidth(songItem::w);
songText->setMargins(Margins(songItem::leftMargin, 0, 0, 0));
- songText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ songText->setEdges(RectangleEdge::None);
songText->setUnderline(false);
songText->setFont(style::window::font::verysmallbold);
songText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
@@ 54,7 54,7 @@ namespace gui
authorText->setMinimumHeight(songItem::text_h);
authorText->setMaximumWidth(songItem::w);
authorText->setMargins(Margins(songItem::leftMargin, 0, 0, 0));
- authorText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ authorText->setEdges(RectangleEdge::None);
authorText->setUnderline(false);
authorText->setFont(style::window::font::verysmall);
authorText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
M module-apps/application-music-player/windows/MusicPlayerEmptyWindow.cpp => module-apps/application-music-player/windows/MusicPlayerEmptyWindow.cpp +1 -1
@@ 38,7 38,7 @@ namespace gui
text->setText(utils::localize.get("app_music_player_music_empty_window_notification"));
text->setTextType(TextType::MULTI_LINE);
text->setEditMode(EditMode::BROWSE);
- text->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ text->setEdges(RectangleEdge::None);
text->setFont(style::window::font::medium);
text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
M module-apps/application-phonebook/widgets/ContactFlagIconWidget.cpp => module-apps/application-phonebook/widgets/ContactFlagIconWidget.cpp +5 -5
@@ 34,7 34,7 @@ namespace gui
{
icon = new Image(
this, 0, 0, style::widget::ContactFlag::iconsSize, style::widget::ContactFlag::iconsSize, iconName);
- icon->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ icon->setEdges(RectangleEdge::None);
}
void ContactFlagIconWidget::buildItemWithText()
@@ 44,24 44,24 @@ namespace gui
numericLabel->setFont(style::window::font::bigbold);
numericLabel->setText(std::to_string(number));
numericLabel->setAlignment(Alignment(Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
- numericLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ numericLabel->setEdges(RectangleEdge::None);
}
void ContactFlagIconWidget::buildItem()
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
label = new Label(this, 0, 0, style::widget::ContactFlag::itemWidth, style::widget::ContactFlag::labelHeight);
label->setFilled(false);
label->setFont(style::window::font::verysmall);
label->setText(itemText);
label->setEllipsis(gui::Ellipsis::None);
- label->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(RectangleEdge::None);
label->setAlignment(Alignment(Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
mainBox = new VBox(this, 0, 0, style::widget::ContactFlag::itemWidth, style::widget::ContactFlag::itemHeight);
mainBox->setAlignment(Alignment(Alignment::Horizontal::Center, Alignment::Vertical::Center));
- mainBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ mainBox->setEdges(RectangleEdge::None);
if (numericIcon) {
mainBox->addWidget(numericLabel);
}
M module-apps/application-phonebook/widgets/ContactFlagsWidget.cpp => module-apps/application-phonebook/widgets/ContactFlagsWidget.cpp +2 -2
@@ 18,7 18,7 @@ namespace gui
{
favourites = speedDial = ice = true;
blocked = false;
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ setEdges(RectangleEdge::Bottom);
initGUIIcons();
buildWidget();
repositionIcons();
@@ 72,7 72,7 @@ namespace gui
{
mainBox = new HBox(this, 0, 0, style::window_width, style::widget::ContactFlag::itemHeight);
mainBox->setAlignment(Alignment(Alignment::Horizontal::Center));
- mainBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ mainBox->setEdges(RectangleEdge::None);
mainBox->addWidget(favouritesIcon);
mainBox->addWidget(iceIcon);
mainBox->addWidget(speedDialIcon);
M module-apps/application-phonebook/widgets/InformationWidget.cpp => module-apps/application-phonebook/widgets/InformationWidget.cpp +4 -4
@@ 16,12 16,12 @@ namespace gui
phonebookStyle::informationWidget::title_label_h + style::margins::huge);
vBox = new VBox(this, 0, 0, 0, 0);
- vBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(RectangleEdge::None);
titleLabel = new Label(vBox, 0, 0, 0, 0, utils::localize.get("app_phonebook_contact_information"));
titleLabel->setMinimumSize(phonebookStyle::informationWidget::w,
phonebookStyle::informationWidget::title_label_h);
- titleLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ titleLabel->setEdges(RectangleEdge::None);
titleLabel->setMargins(Margins(0, 0, 0, style::margins::very_big));
titleLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
titleLabel->setFont(style::window::font::verysmall);
@@ 62,7 62,7 @@ namespace gui
emailText->setMargins(Margins(0, style::margins::very_big, 0, 0));
emailText->setFont(style::window::font::medium);
emailText->setEditMode(EditMode::BROWSE);
- emailText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ emailText->setEdges(RectangleEdge::None);
emailText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
emailText->setText(contact->mail);
emailText->activeItem = false;
@@ 98,7 98,7 @@ namespace gui
return vBox->onInput(event);
};
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
}
auto InformationWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
M module-apps/application-phonebook/widgets/InputBoxWithLabelAndIconWidget.cpp => module-apps/application-phonebook/widgets/InputBoxWithLabelAndIconWidget.cpp +4 -4
@@ 22,7 22,7 @@ namespace gui
setMargins(gui::Margins(0, style::margins::big, 0, 0));
hBox = new gui::HBox(this, 0, 0, phonebookStyle::inputBoxWithLabelAndIconIWidget::w, 0);
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
hBox->setPenFocusWidth(style::window::default_border_focus_w);
hBox->setPenWidth(style::window::default_border_rect_no_focus);
@@ 31,7 31,7 @@ namespace gui
phonebookStyle::inputBoxWithLabelAndIconIWidget::input_box_h);
inputBoxLabel->setMargins(
gui::Margins(0, 0, phonebookStyle::inputBoxWithLabelAndIconIWidget::input_box_right_margin, 0));
- inputBoxLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ inputBoxLabel->setEdges(gui::RectangleEdge::Bottom);
inputBoxLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
inputBoxLabel->setFont(style::window::font::medium);
inputBoxLabel->activeItem = false;
@@ 51,7 51,7 @@ namespace gui
phonebookStyle::inputBoxWithLabelAndIconIWidget::description_label_h);
descriptionLabel->setMargins(
gui::Margins(0, 0, phonebookStyle::inputBoxWithLabelAndIconIWidget::description_label_right_margin, 0));
- descriptionLabel->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ descriptionLabel->setEdges(gui::RectangleEdge::None);
descriptionLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
descriptionLabel->setFont(style::window::font::medium);
descriptionLabel->activeItem = false;
@@ 62,7 62,7 @@ namespace gui
applyItemNameSpecificSettings();
- setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(gui::RectangleEdge::None);
}
auto InputBoxWithLabelAndIconWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
M module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.cpp => module-apps/application-phonebook/widgets/InputLinesWithLabelIWidget.cpp +4 -4
@@ 24,12 24,12 @@ namespace gui
setMargins(gui::Margins(0, style::margins::huge, 0, 0));
vBox = new VBox(this, 0, 0, 0, 0);
- vBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(RectangleEdge::None);
titleLabel = new Label(vBox);
titleLabel->setMinimumSize(phonebookStyle::inputLinesWithLabelWidget::w,
phonebookStyle::inputLinesWithLabelWidget::title_label_h);
- titleLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ titleLabel->setEdges(RectangleEdge::None);
titleLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
titleLabel->setFont(style::window::font::verysmall);
titleLabel->activeItem = false;
@@ 40,7 40,7 @@ namespace gui
inputText->setMargins(Margins(0, phonebookStyle::inputLinesWithLabelWidget::span_size, 0, 0));
inputText->setUnderlinePadding(phonebookStyle::inputLinesWithLabelWidget::underline_padding);
- inputText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ inputText->setEdges(RectangleEdge::None);
inputText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Top));
inputText->setFont(style::window::font::medium);
inputText->setInputMode(new InputMode(
@@ 77,7 77,7 @@ namespace gui
}
return result;
};
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
}
auto InputLinesWithLabelIWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim) -> bool
M module-apps/application-phonebook/widgets/NumberWithIconsWidget.cpp => module-apps/application-phonebook/widgets/NumberWithIconsWidget.cpp +6 -6
@@ 15,7 15,7 @@ namespace gui
{
setReverseOrder(true);
setMinimumSize(phonebookStyle::informationWidget::w, phonebookStyle::numbersWithIconsWidget::h);
- setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(gui::RectangleEdge::None);
setAlignment(Alignment(gui::Alignment::Horizontal::Right, gui::Alignment::Vertical::Center));
smsImage = new ImageBox(this,
@@ 55,7 55,7 @@ namespace gui
numberText->setMaximumSize(phonebookStyle::informationWidget::w,
phonebookStyle::numbersWithIconsWidget::number_text_h);
numberText->setFont(font);
- numberText->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ numberText->setEdges(gui::RectangleEdge::None);
numberText->setEditMode(EditMode::BROWSE);
numberText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
numberText->setText(number.getFormatted());
@@ 68,24 68,24 @@ namespace gui
phoneImage->focusChangedCallback = [&, app](Item &item) {
if (phoneImage->focus) {
- phoneImage->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ phoneImage->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
app->getCurrentWindow()->bottomBarTemporaryMode(
utils::localize.get(style::strings::common::call), BottomBar::Side::CENTER, false);
}
else {
- phoneImage->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ phoneImage->setEdges(RectangleEdge::None);
}
return true;
};
smsImage->focusChangedCallback = [&, app](Item &item) {
if (smsImage->focus) {
- smsImage->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ smsImage->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
app->getCurrentWindow()->bottomBarTemporaryMode(
utils::localize.get(style::strings::common::send), BottomBar::Side::CENTER, false);
}
else {
- smsImage->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ smsImage->setEdges(RectangleEdge::None);
}
return true;
};
M module-apps/application-phonebook/widgets/OutputLinesTextWithLabelWidget.cpp => module-apps/application-phonebook/widgets/OutputLinesTextWithLabelWidget.cpp +4 -4
@@ 16,12 16,12 @@ namespace gui
setMargins(gui::Margins(0, style::margins::huge, 0, 0));
vBox = new VBox(this, 0, 0, 0, 0);
- vBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ vBox->setEdges(RectangleEdge::None);
titleLabel = new Label(vBox);
titleLabel->setMinimumSize(phonebookStyle::outputLinesTextWithLabelWidget::w,
phonebookStyle::outputLinesTextWithLabelWidget::title_label_h);
- titleLabel->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ titleLabel->setEdges(RectangleEdge::None);
titleLabel->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center));
titleLabel->setFont(style::window::font::verysmall);
titleLabel->setLineMode(true);
@@ 31,7 31,7 @@ namespace gui
multilineText->setMaximumSize(phonebookStyle::outputLinesTextWithLabelWidget::w,
phonebookStyle::outputLinesTextWithLabelWidget::input_text_h * 10);
multilineText->setMargins(Margins(0, phonebookStyle::outputLinesTextWithLabelWidget::span_size, 0, 0));
- multilineText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ multilineText->setEdges(RectangleEdge::None);
multilineText->setAlignment(Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom));
multilineText->setFont(style::window::font::medium);
multilineText->setEditMode(EditMode::BROWSE);
@@ 44,7 44,7 @@ namespace gui
};
this->activeItem = false;
- setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ setEdges(RectangleEdge::All);
}
auto OutputLinesTextWithLabelWidget::onDimensionChanged(const BoundingBox &oldDim, const BoundingBox &newDim)
M module-apps/application-phonebook/widgets/PhonebookItem.cpp => module-apps/application-phonebook/widgets/PhonebookItem.cpp +3 -3
@@ 11,10 11,10 @@ namespace gui
setMargins(Margins(0, style::margins::big, 0, 0));
setMinimumSize(phonebookStyle::contactItem::w, phonebookStyle::contactItem::h);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
hBox = new gui::HBox(this, 0, 0, 0, 0);
- hBox->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ hBox->setEdges(gui::RectangleEdge::None);
hBox->setPenFocusWidth(style::window::default_border_focus_w);
hBox->setPenWidth(style::window::default_border_rect_no_focus);
@@ 50,7 50,7 @@ namespace gui
contactName->setText(text);
contactName->setLineMode(true);
activeItem = false;
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
}
UTF8 PhonebookItem::getLabelMarker()
M module-apps/application-phonebook/windows/PhonebookContactDetails.cpp => module-apps/application-phonebook/windows/PhonebookContactDetails.cpp +2 -2
@@ 74,13 74,13 @@ namespace gui
contactFlagsWidget->setBlocked(contact->isOnBlocked());
contactFlagsWidget->setFavourites(contact->isOnFavourites());
if (contactFlagsWidget->visible) {
- title->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ title->setEdges(RectangleEdge::None);
bodyList->setY(phonebookStyle::contactDetailsWindow::contactDetailsList::y);
bodyList->setSize(phonebookStyle::contactDetailsWindow::contactDetailsList::w,
phonebookStyle::contactDetailsWindow::contactDetailsList::h);
}
else {
- title->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ title->setEdges(RectangleEdge::Bottom);
bodyList->setY(phonebookStyle::contactDetailsWindow::contactDetailsListNoFlags::y);
bodyList->setSize(phonebookStyle::contactDetailsWindow::contactDetailsListNoFlags::w,
phonebookStyle::contactDetailsWindow::contactDetailsListNoFlags::h);
M module-apps/application-settings/windows/CellularPassthroughWindow.cpp => module-apps/application-settings/windows/CellularPassthroughWindow.cpp +2 -2
@@ 172,8 172,8 @@ namespace gui
separatorLower->setBorderColor(gui::ColorFullBlack);
separatorUpper->setPenWidth(1);
separatorLower->setPenWidth(1);
- separatorUpper->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
- separatorLower->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ separatorUpper->setEdges(RectangleEdge::Bottom);
+ separatorLower->setEdges(RectangleEdge::Top);
separatorLayout->addWidget(separatorUpper);
separatorLayout->addWidget(separatorLower);
M module-apps/application-settings/windows/DateTimeWindow.cpp => module-apps/application-settings/windows/DateTimeWindow.cpp +5 -5
@@ 110,7 110,7 @@ namespace gui
dateBody->addWidget(toAdd->second);
}
- dateBody->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ dateBody->setEdges(gui::RectangleEdge::None);
// create time items
@@ 153,7 153,7 @@ namespace gui
timeItems.insert(std::pair<DateTimeItems, Item *>(DateTimeItems::Hour, item));
timeBody->addWidget(item);
- timeBody->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ timeBody->setEdges(gui::RectangleEdge::None);
setFocusItem(timeBody);
timeBody->setNavigationItem(NavigationDirection::UP, dateBody);
@@ 183,7 183,7 @@ namespace gui
{
auto label = new gui::Label(
nullptr, 0, 0, style::settings::date::date_time_spacer_width, style::settings::date::date_time_item_height);
- label->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(gui::RectangleEdge::None);
label->setText(text);
label->setFont(style::window::font::largelight);
label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
@@ 206,7 206,7 @@ namespace gui
label->setPenWidth(1);
label->setFont(style::window::font::largelight);
label->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
- label->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ label->setEdges(gui::RectangleEdge::Bottom);
label->activatedCallback = [=](gui::Item &) {
this->setRTC();
return true;
@@ 219,7 219,7 @@ namespace gui
style::settings::date::date_time_item_width,
style::settings::date::date_time_item_title_height);
title->setText(itemTitle);
- title->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ title->setEdges(gui::RectangleEdge::None);
title->setFont(style::window::font::verysmall);
return label;
}
M module-apps/application-settings/windows/Info.cpp => module-apps/application-settings/windows/Info.cpp +3 -3
@@ 71,12 71,12 @@ namespace gui
void Info::addAlignedLabelWithValue(BoxLayout *layout, const std::string &labelText, const std::string &valueText)
{
auto lineBox = new gui::VBox(layout, 0, 0, style::window_width, style::window::label::small_h * 2);
- lineBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ lineBox->setEdges(RectangleEdge::Bottom);
auto label = new gui::Label(lineBox, 0, 0, 0, 0);
label->setMinimumHeight(style::window::label::small_h);
label->setMaximumWidth(style::window_width);
- label->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ label->setEdges(RectangleEdge::None);
label->setMargins(gui::Margins(style::window::default_left_margin, 0, 0, 0));
label->setText(labelText);
label->setFont(style::window::font::smallbold);
@@ 84,7 84,7 @@ namespace gui
auto value = new gui::Label(lineBox, 0, 0, 0, 0);
value->setMinimumHeight(style::window::label::small_h);
value->setMaximumWidth(style::window_width);
- value->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ value->setEdges(RectangleEdge::None);
value->setMargins(gui::Margins(0, 0, style::window::default_right_margin, 0));
value->setAlignment(gui::Alignment::Horizontal::Right);
value->setText(valueText);
M module-apps/application-settings/windows/SettingsChange.cpp => module-apps/application-settings/windows/SettingsChange.cpp +2 -2
@@ 45,7 45,7 @@ namespace gui::option
auto font_bold = FontManager::getInstance().getFont(style::window::font::mediumbold);
auto settings = app->getSettings();
- rect->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ rect->setEdges(RectangleEdge::None);
rect->setReverseOrder(true);
auto text = new TextFixedSize(nullptr, style::option::text_left_padding, 0, 0, 0);
@@ 70,7 70,7 @@ namespace gui::option
pin_text->setPenWidth(0);
pin_text->setInputMode(new InputMode(
{InputMode::digit}, [=](const UTF8 &text) {}, [=]() {}, [=]() {}));
- pin_text->setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ pin_text->setEdges(RectangleEdge::All);
auto lapp = app;
pin_text->activatedCallback = [pin_text, lapp](gui::Item &item) {
M module-apps/application-settings/windows/USSDWindow.cpp => module-apps/application-settings/windows/USSDWindow.cpp +1 -1
@@ 106,7 106,7 @@ namespace gui
text->setFont(style::window::font::verysmall);
text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
- text->setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ text->setEdges(RectangleEdge::All);
return text;
}
M module-apps/application-special-input/widgets/SpecialInputTableWidget.cpp => module-apps/application-special-input/widgets/SpecialInputTableWidget.cpp +2 -2
@@ 17,7 17,7 @@ namespace gui
: application(app)
{
setMinimumSize(specialCharacterTableWidget::window_grid_w, specialCharacterTableWidget::window_grid_h);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
box = new GridLayout(0,
0,
@@ 87,7 87,7 @@ namespace gui
{
auto rect = new Rect(
nullptr, 0, 0, specialCharacterTableWidget::char_label_w, specialCharacterTableWidget::char_label_h);
- rect->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_TOP | gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ rect->setEdges(gui::RectangleEdge::Top | gui::RectangleEdge::Bottom);
rect->setPenWidth(0);
new gui::Image(rect,
specialCharacterTableWidget::char_newline_x,
M module-apps/widgets/SearchBox.cpp => module-apps/widgets/SearchBox.cpp +4 -4
@@ 52,7 52,7 @@ namespace gui
horizontalBox::inputField::h);
inputField->setTextType(TextType::SINGLE_LINE);
inputField->setEditMode(EditMode::EDIT);
- inputField->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ inputField->setEdges(RectangleEdge::None);
inputField->setInputMode(new InputMode({InputMode::ABC, InputMode::abc}));
inputField->setFont(style::window::font::mediumbold);
@@ 66,10 66,10 @@ namespace gui
icon));
horizontalBox->setPenWidth(horizontalBox::penWidth);
- horizontalBox->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ horizontalBox->setEdges(RectangleEdge::Bottom);
- const RectangleEdgeFlags edges = RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES;
- const Alignment alignment = Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom);
+ const RectangleEdge edges = RectangleEdge::None;
+ const Alignment alignment = Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Bottom);
auto l = new Label(parent, searchHeader::x, searchHeader::y, searchHeader::w, searchHeader::h);
l->setFont(style::window::font::small);
M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +1 -1
@@ 48,7 48,7 @@ namespace gui
title->setFont(font::title);
title->clear();
title->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
- title->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ title->setEdges(RectangleEdge::Bottom);
title->setEllipsis(Ellipsis::Right);
title->visible = false;
M module-apps/windows/Dialog.cpp => module-apps/windows/Dialog.cpp +4 -4
@@ 58,7 58,7 @@ Dialog::Dialog(app::Application *app, const std::string &name) : gui::AppWindow(
text->setRichText("lol");
text->setTextType(TextType::MULTI_LINE);
text->setEditMode(EditMode::BROWSE);
- text->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ text->setEdges(RectangleEdge::None);
text->setFont(style::window::font::medium);
text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
}
@@ 106,7 106,7 @@ DialogYesNo::DialogYesNo(app::Application *app, const std::string &name) : Dialo
no->setPenFocusWidth(3);
no->setFilled(false);
no->setBorderColor(ColorFullBlack);
- no->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ no->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
no->setFont(style::window::font::big);
no->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
no->activatedCallback = [=](Item &) -> bool {
@@ 124,7 124,7 @@ DialogYesNo::DialogYesNo(app::Application *app, const std::string &name) : Dialo
yes->setPenFocusWidth(3);
yes->setFilled(false);
yes->setBorderColor(ColorFullBlack);
- yes->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ yes->setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
yes->setFont(style::window::font::big);
yes->setAlignment(Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
yes->activatedCallback = [=](Item &) -> bool { return false; };
@@ 155,7 155,7 @@ DialogYesNoIconTxt::DialogYesNoIconTxt(app::Application *app, const std::string
iconText->setText("");
iconText->setTextType(TextType::SINGLE_LINE);
iconText->setEditMode(EditMode::BROWSE);
- iconText->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ iconText->setEdges(RectangleEdge::None);
iconText->setFont(style::window::font::largelight);
iconText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::None));
setFocusItem(no);
M module-gui/gui/Common.hpp => module-gui/gui/Common.hpp +26 -30
@@ 96,46 96,42 @@ namespace gui
return lhs;
}
- enum class RectangleEdgeFlags
+ enum class RectangleEdge
{
- GUI_RECT_EDGE_NO_EDGES = 0x00,
- GUI_RECT_EDGE_TOP = 0x01,
- GUI_RECT_EDGE_BOTTOM = 0x02,
- GUI_RECT_EDGE_LEFT = 0x04,
- GUI_RECT_EDGE_RIGHT = 0x08,
- GUI_RECT_ALL_EDGES = 0x0F
+ None = 0x00,
+ Top = 0x01,
+ Bottom = 0x02,
+ Left = 0x04,
+ Right = 0x08,
+ All = 0x0F
};
- // bool operator&( const RectangleEdgeFlags& lhs, const RectangleEdgeFlags& rhs );
- // RectangleEdgeFlags operator|( const RectangleEdgeFlags& lhs, const RectangleEdgeFlags& rhs );
- // RectangleEdgeFlags operator|=( const RectangleEdgeFlags& lhs, const RectangleEdgeFlags& rhs );
-
- enum class RectangleCornerFlags
+ enum class RectangleRoundedCorner
{
- GUI_RECT_CORNER_NO_CORNERS = 0x00,
- GUI_RECT_CORNER_TOP_LEFT = 0x10,
- GUI_RECT_CORNER_TOP_RIGHT = 0x20,
- GUI_RECT_CORNER_BOTTOM_LEFT = 0x40,
- GUI_RECT_CORNER_BOTTOM_RIGHT = 0x80,
- GUI_RECT_ALL_CORNERS = 0xF0,
+ None = 0x00,
+ TopLeft = 0x10,
+ TopRight = 0x20,
+ BottomLeft = 0x40,
+ BottomRight = 0x80,
+ All = 0xF0,
};
- enum class RectangleFlatFlags
+ enum class RectangleFlatEdge
{
- GUI_RECT_FLAT_NO_FLAT = 0x00,
- GUI_RECT_FLAT_TOP_LEFT = 0x01,
- GUI_RECT_FLAT_TOP_RIGHT = 0x02,
- GUI_RECT_FLAT_BOTTOM_LEFT = 0x04,
- GUI_RECT_FLAT_BOTTOM_RIGHT = 0x08
+ None = 0x00,
+ TopLeft = 0x01,
+ TopRight = 0x02,
+ BottomLeft = 0x04,
+ BottomRight = 0x08
};
- enum class RectangleYapFlags
+ enum class RectangleYap
{
- GUI_RECT_YAP_NO_YAPS = 0x00,
- GUI_RECT_YAP_TOP_LEFT = 0x10,
- GUI_RECT_YAP_TOP_RIGHT = 0x20,
- GUI_RECT_YAP_BOTTOM_LEFT = 0x40,
- GUI_RECT_YAP_BOTTOM_RIGHT = 0x80,
+ None = 0x00,
+ TopLeft = 0x10,
+ TopRight = 0x20,
+ BottomLeft = 0x40,
+ BottomRight = 0x80,
};
typedef uint32_t (*timeSecondsFunctionPtr)();
M module-gui/gui/GuiCommon.cpp => module-gui/gui/GuiCommon.cpp +7 -6
@@ 13,18 13,19 @@ namespace gui
static timeSecondsFunctionPtr timeSecondsFunction = nullptr;
- bool operator&(const gui::RectangleEdgeFlags &lhs, const gui::RectangleEdgeFlags &rhs)
+ bool operator&(const gui::RectangleEdge &lhs, const gui::RectangleEdge &rhs)
{
- return static_cast<uint32_t>(lhs) & static_cast<uint32_t>(rhs);
+ using T = std::underlying_type_t<RectangleEdge>;
+ return static_cast<bool>(static_cast<T>(lhs) & static_cast<T>(rhs));
}
- RectangleEdgeFlags operator|(const RectangleEdgeFlags &lhs, const RectangleEdgeFlags &rhs)
+ RectangleEdge operator|(const RectangleEdge &lhs, const RectangleEdge &rhs)
{
- using T = std::underlying_type_t<RectangleEdgeFlags>;
- return static_cast<RectangleEdgeFlags>(static_cast<T>(lhs) | static_cast<T>(rhs));
+ using T = std::underlying_type_t<RectangleEdge>;
+ return static_cast<RectangleEdge>(static_cast<T>(lhs) | static_cast<T>(rhs));
}
- RectangleEdgeFlags operator|=(RectangleEdgeFlags &lhs, const RectangleEdgeFlags &rhs)
+ RectangleEdge operator|=(RectangleEdge &lhs, const RectangleEdge &rhs)
{
lhs = lhs | rhs;
return lhs;
M module-gui/gui/core/CMakeLists.txt => module-gui/gui/core/CMakeLists.txt +10 -0
@@ 11,6 11,11 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/BoundingBox.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Context.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Renderer.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/PixelRenderer.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/LineRenderer.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/ArcRenderer.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/CircleRenderer.cpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/RectangleRenderer.cpp"
"${CMAKE_CURRENT_LIST_DIR}/PixMap.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ImageManager.cpp"
"${CMAKE_CURRENT_LIST_DIR}/ImageMap.cpp"
@@ 24,6 29,11 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/BoundingBox.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Context.hpp"
"${CMAKE_CURRENT_LIST_DIR}/Renderer.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/PixelRenderer.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/LineRenderer.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/ArcRenderer.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/CircleRenderer.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/renderers/RectangleRenderer.hpp"
"${CMAKE_CURRENT_LIST_DIR}/PixMap.hpp"
"${CMAKE_CURRENT_LIST_DIR}/ImageManager.hpp"
"${CMAKE_CURRENT_LIST_DIR}/ImageMap.hpp"
M module-gui/gui/core/DrawCommand.hpp => module-gui/gui/core/DrawCommand.hpp +6 -7
@@ 115,13 115,13 @@ namespace gui
uint16_t h;
uint16_t radius;
// flags that defines whether paint given border
- RectangleEdgeFlags edges;
+ RectangleEdge edges;
// flags that defines which edge should be flat. This will disable roundness on both sides of the edge.
- RectangleFlatFlags flatEdges;
+ RectangleFlatEdge flatEdges;
// flags that defines whether paint given corner (only for rounded corners)
- RectangleCornerFlags corners;
+ RectangleRoundedCorner corners;
// flags indicating yaps for speech bubbles, it takes precendece over other properties
- RectangleYapFlags yaps;
+ RectangleYap yaps;
// defines which of the edges and corners are painted
unsigned short yapSize = 0;
bool filled;
@@ 129,9 129,8 @@ namespace gui
Color fillColor;
Color borderColor;
CommandRectangle()
- : x{0}, y{0}, w{0}, h{0}, radius{0}, edges{RectangleEdgeFlags::GUI_RECT_ALL_EDGES},
- flatEdges{RectangleFlatFlags::GUI_RECT_FLAT_NO_FLAT}, corners{RectangleCornerFlags::GUI_RECT_ALL_CORNERS},
- yaps{RectangleYapFlags::GUI_RECT_YAP_NO_YAPS}, yapSize{0}, filled{false}, penWidth{1},
+ : x{0}, y{0}, w{0}, h{0}, radius{0}, edges{RectangleEdge::All}, flatEdges{RectangleFlatEdge::None},
+ corners{RectangleRoundedCorner::All}, yaps{RectangleYap::None}, yapSize{0}, filled{false}, penWidth{1},
fillColor(ColorFullBlack), borderColor(ColorFullBlack)
{
id = DrawCommandID::GUI_DRAW_RECT;
M module-gui/gui/core/Renderer.cpp => module-gui/gui/core/Renderer.cpp +42 -857
@@ 11,6 11,11 @@ extern "C"
#include "Context.hpp"
#include "ImageManager.hpp"
#include "../Common.hpp"
+// renderers
+#include "renderers/LineRenderer.hpp"
+#include "renderers/ArcRenderer.hpp"
+#include "renderers/CircleRenderer.hpp"
+#include "renderers/RectangleRenderer.hpp"
// utils
#include "log/log.hpp"
@@ 34,905 39,85 @@ extern "C"
namespace gui
{
- void Renderer::drawPixel(Context *ctx, Point point, Color color)
- {
- const auto contextWidth = ctx->getW();
- const auto position = point.y * contextWidth + point.x;
- memset(ctx->getData() + position, color.intensity, 1);
- }
-
void Renderer::drawLine(Context *ctx, CommandLine *cmd)
{
+ using renderer::LineRenderer;
const Point p1{cmd->x1, cmd->y1};
const Point p2{cmd->x2, cmd->y2};
const auto color = cmd->color;
- drawLine(ctx, p1, p2, color);
- }
-
- void Renderer::drawLine(Context *ctx, Point start, Point end, Color color)
- {
- if (color.alpha == Color::FullTransparent) {
- return;
- }
-
- const int distanceX = std::abs(end.x - start.x);
- const int distanceY = std::abs(end.y - start.y);
- const auto step = distanceX >= distanceY ? distanceX : distanceY;
-
- auto dx = static_cast<float>(distanceX) / step;
- dx = end.x < start.x ? -dx : dx;
- auto dy = static_cast<float>(distanceY) / step;
- dy = end.y < start.y ? -dy : dy;
-
- float x = start.x;
- float y = start.y;
- for (int i = 0; i < step; ++i) {
- drawPixel(ctx, Point(x, y), color);
- x += dx;
- y += dy;
- }
- }
-
- // any checks are not performed as this should be done by function handling draw command
- void Renderer::drawHorizontalLine(
- Context *ctx, int16_t x, int16_t y, uint16_t width, uint16_t penWidth, Color color, LineExpansionDirection dir)
- {
- // if color is fully transparent - return
- if (color.alpha == Color::FullTransparent) {
- return;
- }
- // If expansion is neither down or up - return.
- if (dir != LineExpansionDirection::LINE_EXPAND_DOWN && dir != LineExpansionDirection::LINE_EXPAND_UP) {
- return;
- }
-
- for (int i = 0; i < penWidth; ++i) {
- const auto offset = (dir == LineExpansionDirection::LINE_EXPAND_DOWN) ? i : -i - 1;
- drawLine(ctx, Point{x, y + offset}, Point{x + width, y + offset}, color);
- }
- }
-
- // any checks are not performed as this should be done by function handling draw command
- void Renderer::drawVerticalLine(
- Context *ctx, int16_t x, int16_t y, uint16_t height, uint16_t penWidth, Color color, LineExpansionDirection dir)
- {
- // if color is fully transparent - return.
- if (color.alpha == Color::FullTransparent) {
- return;
- }
- // If expansion is neither left or right - return.
- if (dir != LineExpansionDirection::LINE_EXPAND_LEFT && dir != LineExpansionDirection::LINE_EXPAND_RIGHT) {
- return;
- }
-
- for (int i = 0; i < penWidth; ++i) {
- const auto offset = (dir == LineExpansionDirection::LINE_EXPAND_RIGHT) ? i : -i - 1;
- drawLine(ctx, Point{x + offset, y}, Point{x + offset, y + height}, color);
- }
- }
-
- void Renderer::draw45degLine(Context *ctx,
- int16_t x,
- int16_t y,
- uint16_t side,
- uint16_t penWidth,
- Color color,
- LineExpansionDirection dir,
- bool toRight,
- Line45degEnd lineEnds)
- {
- // if color is fully transparent - return
- if (color.alpha == 0x0F) {
- return;
- }
-
- uint16_t penWidthAcross = 0;
- switch (penWidth) {
- case 1:
- penWidthAcross = 1;
- break;
- case 2:
- penWidthAcross = 3;
- break;
- case 3:
- penWidthAcross = 5;
- break;
- default:
- penWidthAcross = penWidth * 141 / 100;
- break;
- }
-
- // approach: as in drawVertical rather than drawHorizontal. draw small horizontal lines offset to preceding one
- uint32_t drawOffset = y * ctx->getW() + x;
- if (dir & LineExpansionDirection::LINE_EXPAND_RIGHT) {
- // no action needed unless there is need to draw gradient
- }
- else if (dir & LineExpansionDirection::LINE_EXPAND_LEFT) {
- drawOffset -= penWidthAcross;
- }
-
- int32_t rowStride = ctx->getW();
- if (dir & LineExpansionDirection::LINE_EXPAND_DOWN) {}
- else if (dir & LineExpansionDirection::LINE_EXPAND_UP) {
- drawOffset -= rowStride * penWidth;
- }
- // memsets are vertical. they fill a column
-
- // produces top tip
- if (lineEnds & Line45degEnd::TOP_TIP) {
- drawOffset -= rowStride * penWidthAcross;
- for (uint32_t skew = 0; skew < penWidthAcross; skew++) {
- if (toRight) {
- memset(ctx->getData() + drawOffset, color.intensity, skew);
- }
- else {
- memset(ctx->getData() + drawOffset + (penWidthAcross - skew), color.intensity, (skew));
- }
- drawOffset += rowStride;
- }
- }
- // produces \\\ with flat top and bottom
- for (uint32_t skew = 0; skew < side; skew++) {
- memset(ctx->getData() + drawOffset, color.intensity, penWidthAcross);
- drawOffset += rowStride;
- drawOffset += (toRight ? 1 : -1); // add skew
- }
- // produces bottom tip
- if (lineEnds & Line45degEnd::BOTTOM_TIP) {
- for (uint32_t skew = 0; skew < penWidthAcross; skew++) {
- if (toRight) {
- memset(ctx->getData() + (drawOffset + skew), color.intensity, (penWidthAcross - skew) - 1);
- }
- else {
- memset(ctx->getData() + drawOffset + 1, color.intensity, (penWidthAcross - skew) - 1);
- }
- drawOffset += rowStride;
- }
- }
+ LineRenderer::draw(ctx, p1, p2, color);
}
void Renderer::drawRectangle(Context *ctx, CommandRectangle *cmd)
{
+ using renderer::RectangleRenderer;
- // check if there is anything to draw
+ // First, check if there is anything to draw
if (cmd->w == 0 || cmd->h == 0) {
return;
}
-
- if (((cmd->fillColor.alpha == 0x0F) && (cmd->borderColor.alpha == 0x0F)) ||
- ((cmd->filled == false) && (cmd->borderColor.alpha == 0x0F))) {
+ if (cmd->fillColor.alpha == Color::FullTransparent && cmd->borderColor.alpha == Color::FullTransparent) {
+ return;
+ }
+ if (!cmd->filled && cmd->borderColor.alpha == Color::FullTransparent) {
return;
}
- // get copy of original context using x,y of draw coordinates and original size of the widget
- Context *drawCtx;
- bool copyContext = false;
- int16_t wgtX = 0, wgtY = 0;
- uint16_t wgtW = cmd->areaW, wgtH = cmd->areaH;
- int16_t wgtR = cmd->radius;
- if (cmd->yaps & (RectangleYapFlags::GUI_RECT_YAP_BOTTOM_LEFT | RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT)) {
- wgtX += cmd->yapSize;
- wgtW -= cmd->yapSize;
+ Context *drawingContext = ctx;
+ Point position;
+ if (cmd->yaps & (RectangleYap::BottomLeft | RectangleYap::TopLeft)) {
+ position.x += cmd->yapSize;
}
- if (cmd->yaps & (RectangleYapFlags::GUI_RECT_YAP_BOTTOM_RIGHT | RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT)) {
- wgtW -= cmd->yapSize;
+ Length width = cmd->areaW;
+ Length height = cmd->areaH;
+ if (cmd->yaps != RectangleYap::None) {
+ width -= cmd->yapSize;
}
- // check if there is a need or making copy of context to use is as background
- if ((cmd->areaW == cmd->w) && (cmd->areaH == cmd->h)) {
- drawCtx = ctx;
- wgtX += cmd->x;
- wgtY += cmd->y;
+ if (cmd->areaW == cmd->w && cmd->areaH == cmd->h) {
+ position.x += cmd->x;
+ position.y += cmd->y;
}
else {
- copyContext = true;
- int16_t x = cmd->x;
- int16_t y = cmd->y;
- if (cmd->areaX < 0)
- x += cmd->areaX;
- if (cmd->areaY < 0)
- y += cmd->areaY;
- drawCtx = ctx->get(x, y, cmd->areaW, cmd->areaH);
+ const auto x = cmd->areaX < 0 ? cmd->x + cmd->areaX : cmd->x;
+ const auto y = cmd->areaY < 0 ? cmd->y + cmd->areaY : cmd->y;
+ drawingContext = ctx->get(x, y, cmd->areaW, cmd->areaH);
}
- // if rounding of corners is 0
- if (wgtR == 0) {
- // fill field inside the rectangle if fill flag is set
- if (cmd->filled) {
- uint32_t offset = wgtY * drawCtx->getW() + wgtX;
- for (int32_t y = 0; y < cmd->areaH; y++) {
- memset(drawCtx->getData() + offset, cmd->fillColor.intensity, wgtW);
- offset += drawCtx->getW();
- }
- }
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_TOP)
- drawHorizontalLine(drawCtx,
- wgtX,
- wgtY,
- wgtW,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM)
- drawHorizontalLine(drawCtx,
- wgtX,
- wgtY + wgtH,
- wgtW,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_UP);
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_LEFT)
- drawVerticalLine(drawCtx,
- wgtX,
- wgtY,
- wgtH,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_RIGHT);
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_RIGHT)
- drawVerticalLine(drawCtx,
- wgtX + wgtW,
- wgtY,
- wgtH,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_LEFT);
+ Length radius = cmd->radius;
+ if (radius == 0) {
+ RectangleRenderer::drawFlat(
+ drawingContext, position, width, height, RectangleRenderer::DrawableStyle::from(*cmd));
}
else {
-
- // calculate centers of circle for all corners
- int16_t xcTopRight = wgtX + wgtW - wgtR;
- int16_t xcTopLeft = wgtX + wgtR;
- int16_t xcBottomRight = xcTopRight;
- int16_t xcBottomLeft = xcTopLeft;
-
- int16_t ycTopRight = wgtY + wgtR;
- int16_t ycTopLeft = ycTopRight;
- int16_t ycBottomRight = wgtY + cmd->h - wgtR;
- int16_t ycBottomLeft = ycBottomRight;
-
- int x = wgtR, y = 0;
-
- // Calculate coordinates of the points on the circle's quarter.
- std::unique_ptr<int16_t[]> Px, Py;
- try {
- Px = std::unique_ptr<int16_t[]>(new int16_t[2 * wgtR * sizeof(int16_t)]);
- Py = std::unique_ptr<int16_t[]>(new int16_t[2 * wgtR * sizeof(int16_t)]);
- }
- catch (const std::bad_alloc &) {
- LOG_ERROR("Allocation error");
- return;
- }
-
- memset(Px.get(), 0, 2 * wgtR * sizeof(int16_t));
- memset(Py.get(), 0, 2 * wgtR * sizeof(int16_t));
- int32_t index = 0;
- // index where middle point of quarter of arc is located. This means that Y starts to grow faster than X
- int32_t middleIndex = 0;
- // number of points in the quater arc
- int32_t pointCount = 0;
- Px[index] = x;
- Py[index] = y;
- ++index;
- pointCount++;
-
- int P = 1 - wgtR;
-
- while (y < wgtR) // just a failsafe
- {
- y++;
-
- // Mid-point is inside or on the perimeter
- if (P <= 0)
- P = P + 2 * y + 1;
-
- // Mid-point is outside the perimeter
- else {
- x--;
- P = P + 2 * y - 2 * x + 1;
- }
-
- Px[index] = x;
- Py[index] = y;
-
- // All the perimeter points have already been printed
- if (x <= y) {
-
- int16_t pointsLeft = 0;
- int indexOut = index;
- if (x == y) {
- // we have a central point. it can be drawn with either type of line
- middleIndex = index;
- pointsLeft = index;
- pointsLeft++;
- }
- else if (x < y) {
- pointsLeft = index;
- // we don't have a central point. halves are alike
- index--;
- middleIndex = index;
- }
- int xValue = 0; // Px[index];
-
- while (pointsLeft > 0) {
- Px[indexOut] = Py[index];
- Py[indexOut] = Px[index] - 2 * xValue;
- index--;
- indexOut++;
- pointCount++;
- pointsLeft--;
- }
- break;
- }
- ++index;
- pointCount++;
- }
-
- // fill the rectangle if fill flag is set using fillColor. Painting is divieded into 3 parts
- // First part takes into consideration if top corners exists, are they rounded or are they sharp.
- // Second draws simple lines between between left and right edges.
- // Third part takes into consideration if bottom corners exists, are they rounded or are they sharp.
-
- if (cmd->filled) {
- // corners
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_TOP_RIGHT) {
- // if corner then evaluate: sharp corner (aka flat), sms (aka yap), else: round.
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_RIGHT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 1; index < middleIndex; ++index) {
- // then draw the outline
- // fill the quarter first
- drawHorizontalLine(drawCtx,
- xcTopRight,
- ycTopRight - Py[index],
- Px[index],
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_DOWN);
- ;
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount - 1; ++index) {
- drawVerticalLine(drawCtx,
- xcTopRight + Px[index],
- ycTopRight - Py[index] + cmd->penWidth,
- Py[index] - cmd->penWidth,
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_LEFT);
- }
- }
- }
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_BOTTOM_RIGHT) {
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_RIGHT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_RIGHT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 1; index < middleIndex; ++index) {
- // fill the quarter first
- drawHorizontalLine(drawCtx,
- xcBottomRight,
- ycBottomRight + Py[index],
- Px[index] - cmd->penWidth,
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_UP);
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount - 1; ++index) {
- drawVerticalLine(drawCtx,
- xcBottomRight + Px[index],
- ycBottomRight /*+ 1*/,
- Py[index],
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_LEFT);
- }
- }
- }
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_TOP_LEFT) {
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_LEFT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 1; index < middleIndex; ++index) {
- // fill the quarter first
- drawHorizontalLine(drawCtx,
- xcTopLeft - Px[index] + cmd->penWidth,
- ycTopLeft - Py[index],
- Px[index] - cmd->penWidth,
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount - 1; ++index) {
- drawVerticalLine(drawCtx,
- xcTopLeft - Px[index] /*+ 1*/,
- ycTopLeft - Py[index] + cmd->penWidth,
- Py[index] - cmd->penWidth,
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_RIGHT);
- }
- }
- }
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_BOTTOM_LEFT) {
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_LEFT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_LEFT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 1; index < middleIndex; ++index) {
- // fill the quarter first
- drawHorizontalLine(drawCtx,
- xcBottomLeft - Px[index] + cmd->penWidth,
- ycBottomLeft + Py[index],
- Px[index] - cmd->penWidth,
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_UP);
- }
-
- ;
- // Y is growing faster
- for (index = middleIndex; index < pointCount - 1; ++index) {
- drawVerticalLine(drawCtx,
- xcBottomLeft - Px[index],
- ycBottomLeft,
- Py[index] - cmd->penWidth,
- 1,
- cmd->fillColor,
- gui::LineExpansionDirection::LINE_EXPAND_RIGHT);
- }
- }
- }
-
- // edges
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_TOP) {
- drawHorizontalLine(drawCtx,
- wgtX + wgtR,
- wgtY,
- wgtW - 2 * wgtR,
- wgtR,
- cmd->fillColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM) {
- drawHorizontalLine(drawCtx,
- wgtX + wgtR,
- wgtY + wgtH - wgtR,
- wgtW - 2 * wgtR,
- wgtR,
- cmd->fillColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_LEFT) {
- drawHorizontalLine(drawCtx,
- wgtX,
- wgtY + wgtR,
- wgtR,
- wgtH - 2 * wgtR,
- cmd->fillColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_RIGHT) {
- drawHorizontalLine(drawCtx,
- wgtX + wgtW - wgtR,
- wgtY + wgtR,
- wgtR,
- wgtH - 2 * wgtR,
- cmd->fillColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- }
-
- // center
- drawHorizontalLine(drawCtx,
- wgtX + wgtR,
- wgtY + wgtR,
- wgtW - 2 * wgtR,
- wgtH - 2 * wgtR,
- cmd->fillColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- }
-
- // Here rounded border is painted
-
- // upper right corner
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_TOP_RIGHT) {
- // if corner then evaluate: sharp corner (aka flat), sms (aka yap), else: round.
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_RIGHT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 0; index < middleIndex; ++index) {
- // then draw the outline
- drawHorizontalLine(drawCtx,
- xcTopRight + Px[index] - cmd->penWidth,
- ycTopRight - Py[index],
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount; ++index) {
- drawVerticalLine(drawCtx,
- xcTopRight + Px[index],
- ycTopRight - Py[index],
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_LEFT);
-
- ;
- }
- }
- }
-
- // bottom right corner
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_BOTTOM_RIGHT) {
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_RIGHT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_RIGHT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 0; index < middleIndex; ++index) {
- drawHorizontalLine(drawCtx,
- xcBottomRight + Px[index] - cmd->penWidth,
- ycBottomRight + Py[index],
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_UP);
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount; ++index) {
- drawVerticalLine(drawCtx,
- xcBottomRight + Px[index],
- ycBottomRight + Py[index] - cmd->penWidth /*+ 1*/,
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_LEFT);
- }
- }
- }
-
- // upper left corner
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_TOP_LEFT) {
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_LEFT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 0; index < middleIndex; ++index) {
- drawHorizontalLine(drawCtx,
- xcTopLeft - Px[index],
- ycTopLeft - Py[index],
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount; ++index) {
- drawVerticalLine(drawCtx,
- xcTopLeft - Px[index] /*+ 1*/,
- ycTopLeft - Py[index],
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_RIGHT);
- }
- }
- }
-
- // lower left corner
- if (cmd->corners & RectangleCornerFlags::GUI_RECT_CORNER_BOTTOM_LEFT) {
- if (cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_LEFT) {}
- else if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_LEFT) {
- }
- else {
- // draw arc from 0 index up to mid point using horizontal line
- index = 0;
- // X is growing faster
- for (index = 0; index < middleIndex; ++index) {
-
- drawHorizontalLine(drawCtx,
- xcBottomLeft - Px[index],
- ycBottomLeft + Py[index],
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_UP);
- }
- // Y is growing faster
- for (index = middleIndex; index < pointCount; ++index) {
-
- drawVerticalLine(drawCtx,
- xcBottomLeft - Px[index],
- ycBottomLeft + Py[index] - cmd->penWidth,
- cmd->penWidth,
- 1,
- cmd->borderColor,
- gui::LineExpansionDirection::LINE_EXPAND_RIGHT);
- }
- }
- }
-
- // render edges between corners
- int16_t xs, ys, le;
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_TOP) {
- le = wgtW;
- // left "corner" first
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT) {
- xs = -cmd->yapSize;
- xs += cmd->penWidth;
- }
- else {
- xs = wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_LEFT));
- }
- // right "corner" now
- le -= xs;
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT) {
- le += (cmd->yapSize - cmd->penWidth);
- }
- else {
- le -= wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_RIGHT));
- }
- ys = 0;
- drawHorizontalLine(drawCtx,
- wgtX + xs,
- wgtY + ys,
- le,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_DOWN);
- }
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM) {
- le = wgtW;
- // left "corner" first
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_LEFT) {
- xs = -cmd->yapSize;
- xs += cmd->penWidth;
- }
- else {
- xs = wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_LEFT));
- }
- // right "corner" now
- le -= xs;
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_RIGHT) {
- le += (cmd->yapSize - cmd->penWidth);
- }
- else {
- le -= wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_RIGHT));
- }
- ys = wgtH; // beware. doesn't -1 break rounded corners ?
- drawHorizontalLine(drawCtx,
- wgtX + xs,
- wgtY + ys,
- le,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_UP);
- }
-
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_LEFT) {
- // top "corner" first
- xs = 0;
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT) {
- ys = cmd->yapSize;
- draw45degLine(drawCtx,
- wgtX + xs - cmd->yapSize,
- wgtY + ys - cmd->yapSize,
- cmd->yapSize,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_RIGHT,
- true,
- Line45degEnd::BOTTOM_TIP);
- }
- else {
- ys = wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_LEFT));
- }
- // bottom "corner" now
- le = wgtH - ys;
-
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_LEFT) {
- le -= cmd->yapSize;
- draw45degLine(drawCtx,
- wgtX + xs,
- wgtY + ys + le,
- cmd->yapSize,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_RIGHT,
- false,
- Line45degEnd::TOP_TIP);
- }
- else {
- le -= wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_LEFT));
- }
- drawVerticalLine(drawCtx,
- wgtX + xs,
- wgtY + ys,
- le,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_RIGHT);
- }
- if (cmd->edges & RectangleEdgeFlags::GUI_RECT_EDGE_RIGHT) {
- // top "corner" first
- xs = wgtW;
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT) {
- ys = cmd->yapSize;
- draw45degLine(drawCtx,
- wgtX + xs + cmd->yapSize,
- wgtY + ys - cmd->yapSize,
- cmd->yapSize,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_LEFT,
- false,
- Line45degEnd::BOTTOM_TIP);
- }
- else {
- ys = wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_TOP_RIGHT));
- }
- // bottom "corner" now
- le = wgtH - ys;
-
- if (cmd->yaps & RectangleYapFlags::GUI_RECT_YAP_BOTTOM_RIGHT) {
- le -= cmd->yapSize;
- draw45degLine(drawCtx,
- wgtX + xs,
- wgtY + ys + le,
- cmd->yapSize,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_LEFT,
- true,
- Line45degEnd::TOP_TIP);
- }
- else {
- le -= wgtR * (!(cmd->flatEdges & RectangleFlatFlags::GUI_RECT_FLAT_BOTTOM_RIGHT));
- }
- drawVerticalLine(drawCtx,
- wgtX + xs,
- wgtY + ys,
- le,
- cmd->penWidth,
- cmd->borderColor,
- LineExpansionDirection::LINE_EXPAND_LEFT);
- }
+ RectangleRenderer::draw(
+ drawingContext, position, width, height, RectangleRenderer::DrawableStyle::from(*cmd));
}
- // if drawing was performed in temporary context
- // reinsert drawCtx into last context
- if (copyContext) {
- ctx->insertArea(cmd->x, cmd->y, cmd->areaX, cmd->areaY, cmd->w, cmd->h, drawCtx);
- delete drawCtx;
+ if (drawingContext != ctx) {
+ ctx->insertArea(cmd->x, cmd->y, cmd->areaX, cmd->areaY, cmd->w, cmd->h, drawingContext);
+ delete drawingContext;
}
}
void Renderer::drawArc(Context *ctx, CommandArc *cmd)
{
+ using renderer::ArcRenderer;
const auto center{cmd->center};
const auto radius{cmd->radius};
const auto startAngle{cmd->start};
const auto sweepAngle{cmd->sweep};
- const auto color{cmd->borderColor};
- const auto width{cmd->width};
- drawArc(ctx, center, radius, startAngle, sweepAngle, color, width);
- }
-
- void Renderer::drawArc(Context *ctx,
- Point center,
- Length radius,
- trigonometry::Degrees begin,
- trigonometry::Degrees sweep,
- Color color,
- int width)
- {
- if (width == 1) {
- drawArc(ctx, center, radius, begin, sweep, color);
- return;
- }
-
- const auto start = trigonometry::toRadians(begin);
- const auto end = trigonometry::toRadians(begin + sweep);
- constexpr double step{0.001};
-
- double cosine = .0;
- double sine = .0;
- for (double radians = start; radians <= end; radians += step) {
- cosine = std::cos(radians);
- sine = std::sin(radians);
- for (int i = 0; i < width; ++i) {
- const auto r = radius - i;
- const auto x = trigonometry::AdjacentSide::fromCosine(cosine, r);
- const auto y = trigonometry::OppositeSide::fromSine(sine, r);
- drawPixel(ctx, Point(center.x + x, center.y + y), color);
- }
- }
- }
-
- void Renderer::drawArc(Context *ctx,
- Point center,
- Length radius,
- trigonometry::Degrees begin,
- trigonometry::Degrees sweep,
- Color color)
- {
- const auto start = trigonometry::toRadians(begin);
- const auto end = trigonometry::toRadians(begin + sweep);
- constexpr double step{0.001};
-
- long int x{0};
- long int y{0};
- for (double radians = start; radians <= end; radians += step) {
- x = trigonometry::AdjacentSide::fromAngle(radians, radius);
- y = trigonometry::OppositeSide::fromAngle(radians, radius);
- drawPixel(ctx, Point(center.x + x, center.y + y), color);
- }
+ const auto style = ArcRenderer::DrawableStyle::from(*cmd);
+ ArcRenderer::draw(ctx, center, radius, startAngle, sweepAngle, style);
}
void Renderer::drawCircle(Context *ctx, CommandCircle *cmd)
{
+ using renderer::CircleRenderer;
const auto center{cmd->center};
const auto radius{cmd->radius};
- const auto color{cmd->borderColor};
- const auto width{cmd->width};
- if (cmd->filled) {
- const auto fillColor{cmd->fillColor};
- drawFilledCircle(ctx, center, radius, color, width, fillColor);
- return;
- }
-
- drawCircle(ctx, center, radius, color, width);
- }
-
- void Renderer::drawFilledCircle(
- Context *ctx, Point center, Length radius, Color borderColor, int borderWidth, Color fillColor)
- {
- // First, fill the desired area.
- const auto r = static_cast<int>(radius);
- const auto rr = r * r;
- for (auto x = -r; x < r; ++x) {
- const auto height = static_cast<int>(std::sqrt(rr - (x * x)));
- for (auto y = -height; y < height; ++y) {
- drawPixel(ctx, Point(center.x + x, center.y + y), fillColor);
- }
- }
-
- // Next, draw a border on top.
- drawCircle(ctx, center, radius, borderColor, borderWidth);
- }
-
- void Renderer::drawCircle(Context *ctx, Point center, Length radius, Color color, int width)
- {
- drawArc(ctx, center, radius, 0, trigonometry::FullAngle, color, width);
+ const auto style = CircleRenderer::DrawableStyle::from(*cmd);
+ CircleRenderer::draw(ctx, center, radius, style);
}
void Renderer::drawChar(Context *context, const int16_t x, const int16_t y, FontGlyph *glyph, const Color color)
M module-gui/gui/core/Renderer.hpp => module-gui/gui/core/Renderer.hpp +0 -71
@@ 12,22 12,6 @@ namespace gui
class RawFont;
class FontGlyph;
- enum class LineExpansionDirection
- {
- LINE_EXPAND_UP = 1,
- LINE_EXPAND_DOWN = 1 << 1,
- LINE_EXPAND_LEFT = 1 << 2,
- LINE_EXPAND_RIGHT = 1 << 3
- };
-
- enum class Line45degEnd
- {
- TOP_FLAT = 1,
- TOP_TIP = 1 << 1,
- BOTTOM_FLAT = 1 << 2,
- BOTTOM_TIP = 1 << 3
- };
-
class Renderer
{
/**
@@ 45,69 29,14 @@ namespace gui
*
*/
protected:
- void drawPixel(Context *ctx, Point point, Color color);
-
void drawLine(Context *ctx, CommandLine *cmd);
- void drawLine(Context *ctx, Point start, Point end, Color color);
-
- void drawHorizontalLine(Context *ctx,
- int16_t x,
- int16_t y,
- uint16_t width,
- uint16_t penWidth,
- Color color,
- LineExpansionDirection dir);
-
- void drawVerticalLine(Context *ctx,
- int16_t x,
- int16_t y,
- uint16_t height,
- uint16_t penWidth,
- Color color,
- LineExpansionDirection dir);
-
- /**
- * @brief Function for drawing a line skewed at 45 deg with given width in specified direction. by default the
- * line is drawn from top to bottom in V-dim and from left to right in H-dim.
- * @param[in] toRight changes H-dim draw direction, so it is drawn to the right of vertical axis.
- */
- void draw45degLine(Context *ctx,
- int16_t x,
- int16_t y,
- uint16_t side,
- uint16_t penWidth,
- Color color,
- LineExpansionDirection dir,
- bool toRight,
- Line45degEnd lineEnds = Line45degEnd::TOP_FLAT | Line45degEnd::BOTTOM_FLAT);
-
void drawRectangle(Context *ctx, CommandRectangle *cmd);
void drawArc(Context *ctx, CommandArc *cmd);
- void drawArc(Context *ctx,
- Point center,
- Length radius,
- trigonometry::Degrees begin,
- trigonometry::Degrees sweep,
- Color color);
-
- void drawArc(Context *ctx,
- Point center,
- Length radius,
- trigonometry::Degrees begin,
- trigonometry::Degrees sweep,
- Color color,
- int width);
-
void drawCircle(Context *ctx, CommandCircle *cmd);
- void drawCircle(Context *ctx, Point center, Length radius, Color color, int width);
-
- void drawFilledCircle(
- Context *ctx, Point center, Length radius, Color borderColor, int borderWidth, Color fillColor);
-
void drawText(Context *ctx, CommandText *cmd);
void drawChar(Context *context, const int16_t x, const int16_t y, FontGlyph *glyph, const Color color);
A module-gui/gui/core/renderers/ArcRenderer.cpp => module-gui/gui/core/renderers/ArcRenderer.cpp +74 -0
@@ 0,0 1,74 @@
+#include "ArcRenderer.hpp"
+#include "PixelRenderer.hpp"
+
+namespace gui::renderer
+{
+ auto ArcRenderer::DrawableStyle::from(const CommandArc &command) -> DrawableStyle
+ {
+ return DrawableStyle{command.width, command.borderColor};
+ }
+
+ void ArcRenderer::draw(Context *ctx,
+ Point center,
+ Length radius,
+ trigonometry::Degrees begin,
+ trigonometry::Degrees sweep,
+ const DrawableStyle &style)
+ {
+ if (style.penWidth == 1) {
+ draw(ctx, center, radius, begin, sweep, style.color);
+ }
+ else {
+ draw(ctx, center, radius, begin, sweep, style.color, style.penWidth);
+ }
+ }
+
+ void ArcRenderer::draw(Context *ctx,
+ Point center,
+ Length radius,
+ trigonometry::Degrees begin,
+ trigonometry::Degrees sweep,
+ Color color,
+ Length width)
+ {
+ if (width == 1) {
+ draw(ctx, center, radius, begin, sweep, color);
+ return;
+ }
+
+ const auto start = trigonometry::toRadians(begin);
+ const auto end = trigonometry::toRadians(begin + sweep);
+ constexpr double step{0.001};
+
+ double cosine, sine;
+ for (double radians = start; radians <= end; radians += step) {
+ cosine = std::cos(radians);
+ sine = std::sin(radians);
+ for (Length i = 0; i < width; ++i) {
+ const auto r = radius - i;
+ const auto x = trigonometry::AdjacentSide::fromCosine(cosine, r);
+ const auto y = trigonometry::OppositeSide::fromSine(sine, r);
+ PixelRenderer::draw(ctx, Point(center.x + x, center.y + y), color);
+ }
+ }
+ }
+
+ void ArcRenderer::draw(Context *ctx,
+ Point center,
+ Length radius,
+ trigonometry::Degrees begin,
+ trigonometry::Degrees sweep,
+ Color color)
+ {
+ const auto start = trigonometry::toRadians(begin);
+ const auto end = trigonometry::toRadians(begin + sweep);
+ constexpr double step{0.001};
+
+ long int x, y;
+ for (double radians = start; radians <= end; radians += step) {
+ x = trigonometry::AdjacentSide::fromAngle(radians, radius);
+ y = trigonometry::OppositeSide::fromAngle(radians, radius);
+ PixelRenderer::draw(ctx, Point(center.x + x, center.y + y), color);
+ }
+ }
+} // namespace gui::renderer
A module-gui/gui/core/renderers/ArcRenderer.hpp => module-gui/gui/core/renderers/ArcRenderer.hpp +51 -0
@@ 0,0 1,51 @@
+#pragma once
+
+#include "Color.hpp"
+#include "Common.hpp"
+
+#include "DrawCommand.hpp"
+
+#include <module-utils/math/Math.hpp>
+
+namespace gui
+{
+ class Context;
+} // namespace gui
+
+namespace gui::renderer
+{
+ class ArcRenderer
+ {
+ public:
+ struct DrawableStyle
+ {
+ Length penWidth{1};
+ Color color{ColorFullBlack};
+
+ static auto from(const CommandArc &command) -> DrawableStyle;
+ };
+
+ static void draw(Context *ctx,
+ Point center,
+ Length radius,
+ trigonometry::Degrees begin,
+ trigonometry::Degrees sweep,
+ const DrawableStyle &style);
+
+ private:
+ static void draw(Context *ctx,
+ Point center,
+ Length radius,
+ trigonometry::Degrees begin,
+ trigonometry::Degrees sweep,
+ Color color);
+
+ static void draw(Context *ctx,
+ Point center,
+ Length radius,
+ trigonometry::Degrees begin,
+ trigonometry::Degrees sweep,
+ Color color,
+ Length width);
+ };
+} // namespace gui::renderer
A module-gui/gui/core/renderers/CircleRenderer.cpp => module-gui/gui/core/renderers/CircleRenderer.cpp +45 -0
@@ 0,0 1,45 @@
+#include "CircleRenderer.hpp"
+
+#include "ArcRenderer.hpp"
+#include "PixelRenderer.hpp"
+
+namespace gui::renderer
+{
+ auto CircleRenderer::DrawableStyle::from(const CommandCircle &command) -> DrawableStyle
+ {
+ return DrawableStyle{command.width, command.borderColor, command.filled ? command.fillColor : ColorNoColor};
+ }
+
+ void CircleRenderer::draw(Context *ctx, Point center, Length radius, const DrawableStyle &style)
+ {
+ if (style.fillColor == ColorNoColor) {
+ draw(ctx, center, radius, style.borderColor, style.penWidth);
+ }
+ else {
+ draw(ctx, center, radius, style.borderColor, style.penWidth, style.fillColor);
+ }
+ }
+
+ void CircleRenderer::draw(
+ Context *ctx, Point center, Length radius, Color borderColor, Length borderWidth, Color fillColor)
+ {
+ // First, fill the desired area.
+ const auto r = static_cast<int>(radius);
+ const auto rr = r * r;
+ for (auto x = -r; x < r; ++x) {
+ const auto height = static_cast<int>(std::sqrt(rr - (x * x)));
+ for (auto y = -height; y < height; ++y) {
+ PixelRenderer::draw(ctx, Point(center.x + x, center.y + y), fillColor);
+ }
+ }
+
+ // Next, draw a border on top.
+ draw(ctx, center, radius, borderColor, borderWidth);
+ }
+
+ void CircleRenderer::draw(Context *ctx, Point center, Length radius, Color color, Length width)
+ {
+ ArcRenderer::draw(ctx, center, radius, 0, trigonometry::FullAngle, ArcRenderer::DrawableStyle{width, color});
+ }
+
+} // namespace gui::renderer
A module-gui/gui/core/renderers/CircleRenderer.hpp => module-gui/gui/core/renderers/CircleRenderer.hpp +35 -0
@@ 0,0 1,35 @@
+#pragma once
+
+#include "Color.hpp"
+#include "Common.hpp"
+
+#include "DrawCommand.hpp"
+
+namespace gui
+{
+ class Context;
+} // namespace gui
+
+namespace gui::renderer
+{
+ class CircleRenderer
+ {
+ public:
+ struct DrawableStyle
+ {
+ Length penWidth{1};
+ Color borderColor{ColorFullBlack};
+ Color fillColor{ColorNoColor};
+
+ static auto from(const CommandCircle &command) -> DrawableStyle;
+ };
+
+ static void draw(Context *ctx, Point center, Length radius, const DrawableStyle &style);
+
+ private:
+ static void draw(Context *ctx, Point center, Length radius, Color color, Length width);
+
+ static void draw(
+ Context *ctx, Point center, Length radius, Color borderColor, Length borderWidth, Color fillColor);
+ };
+} // namespace gui::renderer
A module-gui/gui/core/renderers/LineRenderer.cpp => module-gui/gui/core/renderers/LineRenderer.cpp +119 -0
@@ 0,0 1,119 @@
+#include "LineRenderer.hpp"
+#include "PixelRenderer.hpp"
+
+#include "Context.hpp"
+
+#include <cmath>
+
+namespace gui::renderer
+{
+ namespace
+ {
+ constexpr auto toSymmetricPenWidth(std::uint16_t penWidth) noexcept -> std::uint16_t
+ {
+ switch (penWidth) {
+ case 1:
+ return 1;
+ case 2:
+ return 3;
+ case 3:
+ return 5;
+ default:
+ return penWidth * M_SQRT2;
+ }
+ }
+ } // namespace
+
+ auto LineRenderer::DrawableStyle::from(const CommandLine &command) -> DrawableStyle
+ {
+ DrawableStyle details;
+ details.penWidth = command.penWidth;
+ details.color = command.color;
+ return details;
+ }
+
+ void LineRenderer::draw(Context *ctx, Point start, Point end, Color color)
+ {
+ if (color.alpha == Color::FullTransparent) {
+ return;
+ }
+
+ const int distanceX = std::abs(end.x - start.x);
+ const int distanceY = std::abs(end.y - start.y);
+ const auto step = distanceX >= distanceY ? distanceX : distanceY;
+
+ auto dx = static_cast<float>(distanceX) / step;
+ dx = end.x < start.x ? -dx : dx;
+ auto dy = static_cast<float>(distanceY) / step;
+ dy = end.y < start.y ? -dy : dy;
+
+ float x = start.x;
+ float y = start.y;
+ for (int i = 0; i < step; ++i) {
+ PixelRenderer::draw(ctx, Point(x, y), color);
+ x += dx;
+ y += dy;
+ }
+ }
+
+ void LineRenderer::drawHorizontal(Context *ctx, Point start, Length width, const DrawableStyle &style)
+ {
+ if (style.color.alpha == Color::FullTransparent) {
+ return;
+ }
+ if (style.direction != LineExpansionDirection::Down && style.direction != LineExpansionDirection::Up) {
+ return;
+ }
+
+ for (Length i = 0; i < style.penWidth; ++i) {
+ const auto offset = (style.direction == LineExpansionDirection::Down) ? i : -i - 1;
+ draw(ctx, Point(start.x, start.y + offset), Point(start.x + width, start.y + offset), style.color);
+ }
+ }
+
+ void LineRenderer::drawVertical(Context *ctx, Point start, Length height, const DrawableStyle &style)
+ {
+ if (style.color.alpha == Color::FullTransparent) {
+ return;
+ }
+ if (style.direction != LineExpansionDirection::Left && style.direction != LineExpansionDirection::Right) {
+ return;
+ }
+
+ for (Length i = 0; i < style.penWidth; ++i) {
+ const auto offset = (style.direction == LineExpansionDirection::Right) ? i : -i - 1;
+ draw(ctx, Point(start.x + offset, start.y), Point(start.x + offset, start.y + height), style.color);
+ }
+ }
+
+ void LineRenderer::draw45deg(Context *ctx, Point start, Length length, const DrawableStyle &style, bool toRight)
+ {
+ // if color is fully transparent - return
+ if (style.color.alpha == Color::FullTransparent) {
+ return;
+ }
+
+ const auto end =
+ toRight ? Point(start.x + length, start.y + length) : Point(start.x - length, start.y + length);
+ drawSlanting(ctx, start, end, toSymmetricPenWidth(style.penWidth), style.color, style.direction);
+ }
+
+ void LineRenderer::drawSlanting(
+ Context *ctx, Point start, Point end, Length penWidth, Color color, LineExpansionDirection expansionDirection)
+ {
+ if (color.alpha == Color::FullTransparent) {
+ return;
+ }
+ if (expansionDirection != LineExpansionDirection::Left && expansionDirection != LineExpansionDirection::Right) {
+ return;
+ }
+
+ const int directionFactor = expansionDirection == LineExpansionDirection::Left ? -1 : 1;
+ for (Length row = 0; row < penWidth; ++row) {
+ draw(ctx,
+ Point(start.x + (directionFactor * row), start.y),
+ Point(end.x + (directionFactor * row), end.y),
+ color);
+ }
+ }
+} // namespace gui::renderer
A module-gui/gui/core/renderers/LineRenderer.hpp => module-gui/gui/core/renderers/LineRenderer.hpp +57 -0
@@ 0,0 1,57 @@
+#pragma once
+
+#include "Color.hpp"
+#include "Common.hpp"
+
+#include "DrawCommand.hpp"
+
+namespace gui
+{
+ class Context;
+} // namespace gui
+
+namespace gui::renderer
+{
+ enum class LineExpansionDirection
+ {
+ Up = 1,
+ Down = (1 << 1),
+ Left = (1 << 2),
+ Right = (1 << 3)
+ };
+
+ class LineRenderer
+ {
+ public:
+ struct DrawableStyle
+ {
+ Length penWidth{1};
+ Color color{ColorFullBlack};
+ LineExpansionDirection direction = LineExpansionDirection::Down;
+
+ static auto from(const CommandLine &command) -> DrawableStyle;
+
+ DrawableStyle &setExpansionDirection(LineExpansionDirection value) noexcept
+ {
+ direction = value;
+ return *this;
+ }
+ };
+
+ static void draw(Context *ctx, Point start, Point end, Color color);
+
+ static void drawHorizontal(Context *ctx, Point start, Length width, const DrawableStyle &style);
+
+ static void drawVertical(Context *ctx, Point start, Length height, const DrawableStyle &style);
+
+ static void draw45deg(Context *ctx, Point start, Length length, const DrawableStyle &style, bool toRight);
+
+ private:
+ static void drawSlanting(Context *ctx,
+ Point start,
+ Point end,
+ Length penWidth,
+ Color color,
+ LineExpansionDirection expansionDirection);
+ };
+} // namespace gui::renderer
A module-gui/gui/core/renderers/PixelRenderer.cpp => module-gui/gui/core/renderers/PixelRenderer.cpp +15 -0
@@ 0,0 1,15 @@
+#include "PixelRenderer.hpp"
+
+#include "Context.hpp"
+
+#include <cstring>
+
+namespace gui::renderer
+{
+ void PixelRenderer::draw(Context *ctx, Point point, Color color)
+ {
+ const auto contextWidth = ctx->getW();
+ const auto position = point.y * contextWidth + point.x;
+ std::memset(ctx->getData() + position, color.intensity, 1);
+ }
+} // namespace gui::renderer
A module-gui/gui/core/renderers/PixelRenderer.hpp => module-gui/gui/core/renderers/PixelRenderer.hpp +18 -0
@@ 0,0 1,18 @@
+#pragma once
+
+#include "Color.hpp"
+#include "Common.hpp"
+
+namespace gui
+{
+ class Context;
+} // namespace gui
+
+namespace gui::renderer
+{
+ class PixelRenderer
+ {
+ public:
+ static void draw(Context *ctx, Point point, Color color);
+ };
+} // namespace gui::renderer
A module-gui/gui/core/renderers/RectangleRenderer.cpp => module-gui/gui/core/renderers/RectangleRenderer.cpp +378 -0
@@ 0,0 1,378 @@
+#include "RectangleRenderer.hpp"
+
+#include "ArcRenderer.hpp"
+#include "LineRenderer.hpp"
+#include "PixelRenderer.hpp"
+
+#include "Context.hpp"
+
+#include <queue>
+
+namespace gui::renderer
+{
+ namespace
+ {
+ std::uint8_t getPixelColor(Context *ctx, const Point &point, std::uint8_t defaultColor)
+ {
+ const auto contextWidth = ctx->getW();
+ const auto position = point.y * contextWidth + point.x;
+ if (!ctx->addressInData(ctx->getData() + position)) {
+ return defaultColor;
+ }
+ return *(ctx->getData() + position);
+ }
+ } // namespace
+
+ auto RectangleRenderer::DrawableStyle::from(const CommandRectangle &command) -> DrawableStyle
+ {
+ return DrawableStyle{command.penWidth,
+ command.radius,
+ command.yapSize,
+ command.edges,
+ command.flatEdges,
+ command.corners,
+ command.yaps,
+ command.borderColor,
+ command.filled ? command.fillColor : ColorNoColor};
+ }
+
+ void RectangleRenderer::drawFlat(
+ Context *ctx, Point position, Length width, Length height, const DrawableStyle &style)
+ {
+ if (style.fillColor != ColorNoColor) {
+ fillFlatRectangle(ctx, position, width, height, style.fillColor);
+ }
+ drawSides(ctx, position, width, height, style.borderWidth, style.borderColor, style.edges);
+ }
+
+ void RectangleRenderer::fillFlatRectangle(Context *ctx, Point position, Length width, Length height, Color color)
+ {
+ for (unsigned int y = 1; y <= height; ++y) {
+ LineRenderer::drawHorizontal(ctx,
+ Point(position.x, position.y + y),
+ width,
+ LineRenderer::DrawableStyle{1, color, LineExpansionDirection::Up});
+ }
+ }
+
+ void RectangleRenderer::drawSides(
+ Context *ctx, Point position, Length width, Length height, Length penWidth, Color color, RectangleEdge sides)
+ {
+ if (sides & RectangleEdge::Top) {
+ drawTopSide(ctx, position, width, penWidth, color);
+ }
+ if (sides & RectangleEdge::Right) {
+ drawRightSide(ctx, position, width, height, penWidth, color);
+ }
+ if (sides & RectangleEdge::Bottom) {
+ drawBottomSide(ctx, position, width, height, penWidth, color);
+ }
+ if (sides & RectangleEdge::Left) {
+ drawLeftSide(ctx, position, height, penWidth, color);
+ }
+ }
+
+ void RectangleRenderer::draw(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style)
+ {
+ drawCorners(ctx,
+ position,
+ width,
+ height,
+ style.radius,
+ style.borderWidth,
+ style.borderColor,
+ style.roundedCorners,
+ style.flatEdges,
+ style.yaps);
+ drawSides(ctx,
+ position,
+ width,
+ height,
+ style.radius,
+ style.yapSize,
+ style.borderWidth,
+ style.flatEdges,
+ style.yaps,
+ style.borderColor,
+ style.edges);
+ if (style.fillColor != ColorNoColor) {
+ fill(ctx, Point(position.x + (width / 2), position.y + (height / 2)), style.borderColor, style.fillColor);
+ }
+ }
+
+ void RectangleRenderer::drawCorners(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length penWidth,
+ Color borderColor,
+ RectangleRoundedCorner rounded,
+ RectangleFlatEdge flats,
+ RectangleYap yaps)
+ {
+
+ const ArcRenderer::DrawableStyle arcStyle{penWidth, borderColor};
+
+ const auto topRightCenter = Point(position.x + width - radius, position.y + radius);
+ const auto topLeftCenter = Point(position.x + radius, topRightCenter.y);
+ const auto bottomRightCenter = Point(topRightCenter.x, position.y + height - radius);
+ const auto bottomLeftCenter = Point(topLeftCenter.x, bottomRightCenter.y);
+
+ const auto topRightCornerRounded = (rounded & RectangleRoundedCorner::TopRight) &&
+ !(flats & RectangleFlatEdge::TopRight) && !(yaps & RectangleYap::TopRight);
+ if (topRightCornerRounded) {
+ ArcRenderer::draw(ctx, topRightCenter, radius, -90, 90, arcStyle);
+ }
+
+ const auto topLeftCornerRounded = (rounded & RectangleRoundedCorner::TopLeft) &&
+ !(flats & RectangleFlatEdge::TopLeft) && !(yaps & RectangleYap::TopLeft);
+ if (topLeftCornerRounded) {
+ ArcRenderer::draw(ctx, topLeftCenter, radius, -180, 90, arcStyle);
+ }
+
+ const auto bottomRightCornerRounded = (rounded & RectangleRoundedCorner::BottomRight) &&
+ !(flats & RectangleFlatEdge::BottomRight) &&
+ !(yaps & RectangleYap::BottomRight);
+ if (bottomRightCornerRounded) {
+ ArcRenderer::draw(ctx, bottomRightCenter, radius, 0, 90, arcStyle);
+ }
+
+ const auto bottomLeftCornerRounded = (rounded & RectangleRoundedCorner::BottomLeft) &&
+ !(flats & RectangleFlatEdge::BottomLeft) &&
+ !(yaps & RectangleYap::BottomLeft);
+ if (bottomLeftCornerRounded) {
+ ArcRenderer::draw(ctx, bottomLeftCenter, radius, -270, 90, arcStyle);
+ }
+ }
+
+ void RectangleRenderer::drawSides(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flats,
+ RectangleYap yaps,
+ Color borderColor,
+ RectangleEdge sides)
+ {
+ if (sides & RectangleEdge::Top) {
+ drawTopSide(ctx, position, width, radius, yapSize, penWidth, flats, yaps, borderColor);
+ }
+ if (sides & RectangleEdge::Bottom) {
+ drawBottomSide(ctx, position, width, height, radius, yapSize, penWidth, flats, yaps, borderColor);
+ }
+ if (sides & RectangleEdge::Left) {
+ drawLeftSide(ctx, position, height, radius, yapSize, penWidth, flats, yaps, borderColor);
+ }
+ if (sides & RectangleEdge::Right) {
+ drawRightSide(ctx, position, width, height, radius, yapSize, penWidth, flats, yaps, borderColor);
+ }
+ }
+
+ void RectangleRenderer::fill(Context *ctx, Point startPosition, Color borderColor, Color fillColor)
+ {
+ std::queue<Point> q;
+ q.push(startPosition);
+
+ while (!q.empty()) {
+ const auto currPoint = q.front();
+ q.pop();
+ if (const auto color = getPixelColor(ctx, currPoint, borderColor.intensity);
+ color == borderColor.intensity || color == fillColor.intensity) {
+ continue;
+ }
+
+ PixelRenderer::draw(ctx, currPoint, fillColor);
+ q.push(Point{currPoint.x + 1, currPoint.y});
+ q.push(Point{currPoint.x - 1, currPoint.y});
+ q.push(Point{currPoint.x, currPoint.y + 1});
+ q.push(Point{currPoint.x, currPoint.y - 1});
+ }
+ }
+
+ void RectangleRenderer::drawTopSide(Context *ctx, Point position, Length length, Length penWidth, Color color)
+ {
+ LineRenderer::drawHorizontal(
+ ctx, position, length, LineRenderer::DrawableStyle{penWidth, color, LineExpansionDirection::Down});
+ }
+
+ void RectangleRenderer::drawTopSide(Context *ctx,
+ Point position,
+ Length width,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor)
+ {
+ int x = position.x;
+ if (yaps & RectangleYap::TopLeft) {
+ x -= yapSize;
+ width += yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::TopLeft)) {
+ x += radius;
+ width -= radius;
+ }
+
+ if (yaps & RectangleYap::TopRight) {
+ width += yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::TopRight)) {
+ width -= radius;
+ }
+ LineRenderer::drawHorizontal(ctx,
+ Point(x, position.y),
+ width,
+ LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Down});
+ }
+
+ void RectangleRenderer::drawRightSide(
+ Context *ctx, Point position, Length width, Length height, Length penWidth, Color color)
+ {
+ LineRenderer::drawVertical(ctx,
+ Point(position.x + width, position.y),
+ height,
+ LineRenderer::DrawableStyle{penWidth, color, LineExpansionDirection::Left});
+ }
+
+ void RectangleRenderer::drawRightSide(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor)
+ {
+ int x = position.x + width + 1;
+ int y = position.y;
+ int length = height;
+ if (yaps & RectangleYap::TopRight) {
+ LineRenderer::draw45deg(ctx,
+ Point(x + yapSize - 1, y),
+ yapSize,
+ LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Left},
+ false);
+ y += yapSize;
+ length -= yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::TopRight)) {
+ y += radius;
+ length -= radius;
+ }
+
+ if (yaps & RectangleYap::BottomRight) {
+ LineRenderer::draw45deg(ctx,
+ Point(x, y + height),
+ yapSize,
+ LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Left},
+ true);
+ length -= yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::BottomRight)) {
+ length -= radius;
+ }
+
+ LineRenderer::drawVertical(
+ ctx, Point(x, y), length, LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Left});
+ }
+
+ void RectangleRenderer::drawBottomSide(
+ Context *ctx, Point position, Length width, Length height, Length penWidth, Color color)
+ {
+ LineRenderer::drawHorizontal(ctx,
+ Point(position.x, position.y + height),
+ width,
+ LineRenderer::DrawableStyle{penWidth, color, LineExpansionDirection::Up});
+ }
+
+ void RectangleRenderer::drawBottomSide(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor)
+ {
+ int x = position.x;
+ int y = position.y + height + 1;
+ int length = width;
+ if (yaps & RectangleYap::BottomLeft) {
+ x -= yapSize;
+ length += yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::BottomLeft)) {
+ x += radius;
+ length -= radius;
+ }
+
+ if (yaps & RectangleYap::BottomRight) {
+ length += yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::BottomRight)) {
+ length -= radius;
+ }
+ LineRenderer::drawHorizontal(
+ ctx, Point(x, y), length, LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Up});
+ }
+
+ void RectangleRenderer::drawLeftSide(Context *ctx, Point position, Length height, Length penWidth, Color color)
+ {
+ LineRenderer::drawVertical(
+ ctx, position, height, LineRenderer::DrawableStyle{penWidth, color, LineExpansionDirection::Right});
+ }
+
+ void RectangleRenderer::drawLeftSide(Context *ctx,
+ Point position,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor)
+ {
+ int x = position.x;
+ int y = position.y;
+ int length = height;
+ if (yaps & RectangleYap::TopLeft) {
+ LineRenderer::draw45deg(ctx,
+ Point(x - yapSize, y),
+ yapSize,
+ LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Right},
+ true);
+ y += yapSize;
+ length -= yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::TopLeft)) {
+ y += radius;
+ length -= radius;
+ }
+
+ if (yaps & RectangleYap::BottomLeft) {
+ LineRenderer::draw45deg(ctx,
+ Point(x, y + height),
+ yapSize,
+ LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Right},
+ false);
+ length -= yapSize;
+ }
+ else if (!(flat & RectangleFlatEdge::BottomLeft)) {
+ length -= radius;
+ }
+ LineRenderer::drawVertical(ctx,
+ Point(x, y),
+ length,
+ LineRenderer::DrawableStyle{penWidth, borderColor, LineExpansionDirection::Right});
+ }
+} // namespace gui::renderer
A module-gui/gui/core/renderers/RectangleRenderer.hpp => module-gui/gui/core/renderers/RectangleRenderer.hpp +119 -0
@@ 0,0 1,119 @@
+#pragma once
+
+#include "Color.hpp"
+#include "Common.hpp"
+
+#include "DrawCommand.hpp"
+
+namespace gui
+{
+ class Context;
+} // namespace gui
+
+namespace gui::renderer
+{
+ class RectangleRenderer
+ {
+ public:
+ struct DrawableStyle
+ {
+ Length borderWidth{1};
+ Length radius{0};
+ Length yapSize{0};
+ RectangleEdge edges{RectangleEdge::All};
+ RectangleFlatEdge flatEdges{RectangleFlatEdge::None};
+ RectangleRoundedCorner roundedCorners{RectangleRoundedCorner::None};
+ RectangleYap yaps{RectangleYap::None};
+ Color borderColor{ColorFullBlack};
+ Color fillColor{ColorNoColor};
+
+ static auto from(const CommandRectangle &command) -> DrawableStyle;
+ };
+
+ static void drawFlat(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style);
+
+ static void draw(Context *ctx, Point position, Length width, Length height, const DrawableStyle &style);
+
+ private:
+ static void fillFlatRectangle(Context *ctx, Point position, Length width, Length height, Color color);
+ static void fill(Context *ctx, Point startPosition, Color borderColor, Color fillColor);
+
+ static void drawSides(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length penWidth,
+ Color color,
+ RectangleEdge sides);
+ static void drawSides(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flats,
+ RectangleYap yaps,
+ Color borderColor,
+ RectangleEdge sides);
+
+ static void drawCorners(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length penWidth,
+ Color borderColor,
+ RectangleRoundedCorner rounded,
+ RectangleFlatEdge flats,
+ RectangleYap yaps);
+
+ static void drawTopSide(Context *ctx, Point position, Length width, Length penWidth, Color color);
+ static void drawTopSide(Context *ctx,
+ Point position,
+ Length width,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor);
+
+ static void drawRightSide(
+ Context *ctx, Point position, Length width, Length height, Length penWidth, Color color);
+ static void drawRightSide(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor);
+
+ static void drawBottomSide(
+ Context *ctx, Point position, Length width, Length height, Length penWidth, Color color);
+ static void drawBottomSide(Context *ctx,
+ Point position,
+ Length width,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor);
+
+ static void drawLeftSide(Context *ctx, Point position, Length height, Length penWidth, Color color);
+ static void drawLeftSide(Context *ctx,
+ Point position,
+ Length height,
+ Length radius,
+ Length yapSize,
+ Length penWidth,
+ RectangleFlatEdge flat,
+ RectangleYap yaps,
+ Color borderColor);
+ };
+} // namespace gui::renderer
M module-gui/gui/widgets/CheckBox.cpp => module-gui/gui/widgets/CheckBox.cpp +1 -1
@@ 18,7 18,7 @@ namespace gui
bottomBarRestoreFromTemporaryMode(bottomBarRestoreFromTemporaryMode), textOnLeft(textOnLeft)
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ setEdges(RectangleEdge::Bottom);
setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
image = new Image("small_tick_W_M");
M module-gui/gui/widgets/Icon.cpp => module-gui/gui/widgets/Icon.cpp +2 -2
@@ 32,7 32,7 @@ Icon::Icon(Item *parent,
const UTF8 &str)
: Rect(parent, x, y, w, h)
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
setPenFocusWidth(style::window::default_border_no_focus_w);
setPenWidth(style::window::default_border_no_focus_w);
@@ 40,7 40,7 @@ Icon::Icon(Item *parent,
text = new Text(this, style::text::x, style::text::y, style::text::w, style::text::h);
text->setTextType(TextType::MULTI_LINE);
text->setEditMode(EditMode::BROWSE);
- text->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ text->setEdges(RectangleEdge::None);
text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
auto format = TextFormat(Font(27).raw(), Color(7, 0));
M module-gui/gui/widgets/ImageBox.cpp => module-gui/gui/widgets/ImageBox.cpp +3 -3
@@ 6,7 6,7 @@ ImageBox::ImageBox(
Item *parent, const uint32_t &x, const uint32_t &y, const uint32_t &w, const uint32_t &h, Image *image)
: HBox(parent, x, y, w, h)
{
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
setPenFocusWidth(style::window::default_border_focus_w);
setPenWidth(style::window::default_border_no_focus_w);
@@ 14,10 14,10 @@ ImageBox::ImageBox(
focusChangedCallback = [&](Item &item) {
if (focus) {
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
}
else {
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ setEdges(RectangleEdge::None);
}
return true;
};
M module-gui/gui/widgets/Label.hpp => module-gui/gui/widgets/Label.hpp +3 -4
@@ 38,10 38,9 @@ namespace gui
return *this;
}
uint32_t x = 0, y = 0, w = 0, h = 0;
- std::string font = style::window::font::medium;
- Alignment align = Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center);
- RectangleEdgeFlags edges =
- gui::RectangleEdgeFlags::GUI_RECT_EDGE_TOP | gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM;
+ std::string font = style::window::font::medium;
+ Alignment align = Alignment(gui::Alignment::Horizontal::Left, gui::Alignment::Vertical::Center);
+ RectangleEdge edges = gui::RectangleEdge::Top | gui::RectangleEdge::Bottom;
};
struct Label : public Rect
M module-gui/gui/widgets/ListItem.cpp => module-gui/gui/widgets/ListItem.cpp +1 -1
@@ 8,7 8,7 @@ namespace gui
ListItem::ListItem()
{
setRadius(0);
- setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM | RectangleEdgeFlags::GUI_RECT_EDGE_TOP);
+ setEdges(RectangleEdge::Bottom | RectangleEdge::Top);
setPenFocusWidth(style::window::default_border_focus_w);
setPenWidth(style::window::default_border_no_focus_w);
M module-gui/gui/widgets/ListView.cpp => module-gui/gui/widgets/ListView.cpp +1 -1
@@ 68,7 68,7 @@ namespace gui
body = new VBox{this, 0, 0, w, h};
body->setAlignment(Alignment::Vertical::Top);
- body->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ body->setEdges(RectangleEdge::None);
body->borderCallback = [this](const InputEvent &inputEvent) -> bool {
if (inputEvent.state != InputEvent::State::keyReleasedShort) {
M module-gui/gui/widgets/Rect.cpp => module-gui/gui/widgets/Rect.cpp +6 -6
@@ 49,16 49,16 @@ namespace gui
penFocusWidth = width;
}
- void Rect::setEdges(RectangleEdgeFlags edges)
+ void Rect::setEdges(RectangleEdge edges)
{
this->edges = edges;
}
- void Rect::setCorners(RectangleCornerFlags corners)
+ void Rect::setCorners(RectangleRoundedCorner corners)
{
this->corners = corners;
}
- void Rect::setFlat(RectangleFlatFlags flats)
+ void Rect::setFlat(RectangleFlatEdge flats)
{
flatEdges = flats;
}
@@ 68,16 68,16 @@ namespace gui
filled = val;
}
- void Rect::setYaps(RectangleYapFlags yaps)
+ void Rect::setYaps(RectangleYap yaps)
{
this->yaps = yaps;
- if (yaps & (RectangleYapFlags::GUI_RECT_YAP_BOTTOM_LEFT | RectangleYapFlags::GUI_RECT_YAP_TOP_LEFT)) {
+ if (yaps & (RectangleYap::BottomLeft | RectangleYap::TopLeft)) {
padding.left = yapSize;
}
else {
padding.left = 0;
}
- if (yaps & (RectangleYapFlags::GUI_RECT_YAP_BOTTOM_RIGHT | RectangleYapFlags::GUI_RECT_YAP_TOP_RIGHT)) {
+ if (yaps & (RectangleYap::BottomRight | RectangleYap::TopRight)) {
padding.right = yapSize;
}
else {
M module-gui/gui/widgets/Rect.hpp => module-gui/gui/widgets/Rect.hpp +8 -8
@@ 23,13 23,13 @@ namespace gui
/// mark if rectangle should be filled with fill color.
bool filled = false;
/// mark how to draw borders
- RectangleEdgeFlags edges{RectangleEdgeFlags::GUI_RECT_ALL_EDGES};
+ RectangleEdge edges{RectangleEdge::All};
/// mark which edge should be flat. This will disable roundness on both sides of the edge.
- RectangleFlatFlags flatEdges = {RectangleFlatFlags::GUI_RECT_FLAT_NO_FLAT};
+ RectangleFlatEdge flatEdges = {RectangleFlatEdge::None};
/// mark if given corners should be painted (only for rounded corners)
- RectangleCornerFlags corners = {RectangleCornerFlags::GUI_RECT_ALL_CORNERS};
+ RectangleRoundedCorner corners = {RectangleRoundedCorner::All};
/// mark if we japs should be painted. small protrusions indicating a speech bubble
- RectangleYapFlags yaps = {RectangleYapFlags::GUI_RECT_YAP_NO_YAPS};
+ RectangleYap yaps = {RectangleYap::None};
/// yap size in horizontal width.
unsigned short yapSize = style::window::default_rect_yaps;
@@ 41,10 41,10 @@ namespace gui
void setBorderColor(const Color &color);
void setPenWidth(uint8_t width);
void setPenFocusWidth(uint8_t width);
- void setEdges(RectangleEdgeFlags edges);
- void setCorners(RectangleCornerFlags corners);
- void setFlat(RectangleFlatFlags flats);
- virtual void setYaps(RectangleYapFlags yaps);
+ void setEdges(RectangleEdge edges);
+ void setCorners(RectangleRoundedCorner corners);
+ void setFlat(RectangleFlatEdge flats);
+ virtual void setYaps(RectangleYap yaps);
virtual void setYapSize(unsigned short value);
void setFilled(bool val);
std::list<DrawCommand *> buildDrawList() override;
M module-gui/gui/widgets/Style.cpp => module-gui/gui/widgets/Style.cpp +1 -1
@@ 11,7 11,7 @@ namespace style::window
}
el->setPenWidth(default_border_no_focus_w);
el->setPenFocusWidth(default_border_focus_w);
- el->setEdges(gui::RectangleEdgeFlags::GUI_RECT_EDGE_TOP | gui::RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ el->setEdges(gui::RectangleEdge::Top | gui::RectangleEdge::Bottom);
el->setFilled(false);
}
M module-gui/gui/widgets/Text.cpp => module-gui/gui/widgets/Text.cpp +1 -1
@@ 57,7 57,7 @@ namespace gui
buildDocument(text);
setBorderColor(gui::ColorFullBlack);
- setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ setEdges(RectangleEdge::All);
}
Text::Text() : Text(nullptr, 0, 0, 0, 0)
M module-gui/gui/widgets/TextBubble.cpp => module-gui/gui/widgets/TextBubble.cpp +2 -2
@@ 6,10 6,10 @@ namespace gui
TextBubble::TextBubble(Item *parent, Position x, Position y, Length w, Length h) : Text(parent, x, y, w, h)
{
setEditMode(EditMode::SCROLL);
- setEdges(RectangleEdgeFlags::GUI_RECT_ALL_EDGES);
+ setEdges(RectangleEdge::All);
}
- void TextBubble::setYaps(RectangleYapFlags yaps)
+ void TextBubble::setYaps(RectangleYap yaps)
{
if (this->yaps != yaps) {
this->yaps = yaps;
M module-gui/gui/widgets/TextBubble.hpp => module-gui/gui/widgets/TextBubble.hpp +1 -1
@@ 9,6 9,6 @@ namespace gui
{
public:
TextBubble(Item *parent, Position x, Position y, Length w, Length h);
- void setYaps(RectangleYapFlags yaps) override;
+ void setYaps(RectangleYap yaps) override;
};
} // namespace gui
M module-gui/gui/widgets/TextLine.cpp => module-gui/gui/widgets/TextLine.cpp +2 -2
@@ 17,7 17,7 @@ namespace gui
item->setFont(format->getFont());
item->setTextColor(format->getColor());
item->setSize(item->getTextNeedSpace(), item->getTextHeight());
- item->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_NO_EDGES);
+ item->setEdges(RectangleEdge::None);
return item;
}
@@ 265,7 265,7 @@ namespace gui
if (drawUnderline) {
underline = new Rect(nullptr, 0, 0, max_width, init_height);
- underline->setEdges(RectangleEdgeFlags::GUI_RECT_EDGE_BOTTOM);
+ underline->setEdges(RectangleEdge::Bottom);
if (drawUnderlineMode == UnderlineDrawMode::WholeLine) {
height_used = std::max(height_used, (Length)init_height);