Skip to content

Commit

Permalink
ScrollableListWidget: Add borderColor support
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jun 12, 2024
1 parent f476ec0 commit aa1994b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 16 additions & 2 deletions lib/widget/scrollablelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void ScrollableListWidget::initialize()
scrollBar->show(false);
scrollbarWidth = SCROLLBAR_WIDTH;
backgroundColor.rgba = 0;
borderColor.rgba = 0;
}

void ScrollableListWidget::geometryChanged()
Expand Down Expand Up @@ -196,6 +197,11 @@ void ScrollableListWidget::setBackgroundColor(PIELIGHT const &color)
backgroundColor = color;
}

void ScrollableListWidget::setBorderColor(PIELIGHT const &color)
{
borderColor = color;
}

void ScrollableListWidget::setSnapOffset(bool value)
{
snapOffset = value;
Expand All @@ -213,12 +219,20 @@ void ScrollableListWidget::setItemSpacing(uint32_t value)

void ScrollableListWidget::display(int xOffset, int yOffset)
{
int x0 = x() + xOffset;
int y0 = y() + yOffset;

if (backgroundColor.rgba != 0)
{
int x0 = x() + xOffset;
int y0 = y() + yOffset;
pie_UniTransBoxFill(x0, y0, x0 + width(), y0 + height(), backgroundColor);
}

if (borderColor.rgba != 0)
{
int x1 = x0 + width();
int y1 = y0 + height();
iV_Box(x0, y0, x1, y1, borderColor);
}
}

void ScrollableListWidget::displayRecursive(WidgetGraphicsContext const& context)
Expand Down
2 changes: 2 additions & 0 deletions lib/widget/scrollablelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class ScrollableListWidget : public WIDGET
void setPadding(Padding const &rect);
void setSnapOffset(bool value);
void setBackgroundColor(PIELIGHT const &color);
void setBorderColor(PIELIGHT const &color);
void setItemSpacing(uint32_t value);
uint32_t getItemSpacing() const { return itemSpacing; }
uint32_t calculateListViewHeight() const;
Expand Down Expand Up @@ -84,6 +85,7 @@ class ScrollableListWidget : public WIDGET
bool layoutDirty = false;
Padding padding = {0, 0, 0, 0};
PIELIGHT backgroundColor;
PIELIGHT borderColor;
uint32_t itemSpacing = 0;
int scrollbarWidth = 0;
bool expandWidthWhenScrollbarInvisible = true;
Expand Down

0 comments on commit aa1994b

Please sign in to comment.