Skip to content

Commit 8c8f363

Browse files
committed
Use itemDrawArea in ProductListBox
1 parent 0693b58 commit 8c8f363

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

appOPHD/UI/ProductListBox.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,29 @@ void ProductListBox::update()
6767

6868
constexpr Color highlightColor{0, 185, 0, 75};
6969

70-
const auto itemSize = itemDrawSize();
71-
const auto firstStop = itemSize.x / 3;
72-
const auto secondStop = itemSize.x * 2 / 3;
73-
7470
for (std::size_t index = 0; index < mItems.size(); ++index)
7571
{
76-
const auto drawPosition = itemDrawPosition(index);
72+
const auto drawArea = itemDrawArea(index);
7773
const auto highlight = index == selectedIndex();
74+
const auto firstStop = drawArea.size.x / 3;
75+
const auto secondStop = drawArea.size.x * 2 / 3;
7876
const auto& item = *static_cast<ProductListBoxItem*>(mItems[index]);
7977

8078
// Draw highlight rect so as not to tint/hue colors of everything else
81-
if (highlight) { renderer.drawBoxFilled(NAS2D::Rectangle{drawPosition, itemSize}, highlightColor); }
79+
if (highlight) { renderer.drawBoxFilled(drawArea, highlightColor); }
8280

8381
// Draw item borders and column breaks
84-
renderer.drawBox(NAS2D::Rectangle{drawPosition, itemSize}.inset(2), constants::PrimaryColor);
85-
renderer.drawLine(drawPosition + NAS2D::Vector{firstStop, 2}, drawPosition + NAS2D::Vector{firstStop, itemSize.y - 2}, constants::PrimaryColor);
86-
renderer.drawLine(drawPosition + NAS2D::Vector{secondStop, 2}, drawPosition + NAS2D::Vector{secondStop, itemSize.y - 2}, constants::PrimaryColor);
82+
renderer.drawBox(drawArea.inset(2), constants::PrimaryColor);
83+
renderer.drawLine(drawArea.position + NAS2D::Vector{firstStop, 2}, drawArea.position + NAS2D::Vector{firstStop, drawArea.size.y - 2}, constants::PrimaryColor);
84+
renderer.drawLine(drawArea.position + NAS2D::Vector{secondStop, 2}, drawArea.position + NAS2D::Vector{secondStop, drawArea.size.y - 2}, constants::PrimaryColor);
8785

8886
// Draw item column contents
89-
renderer.drawText(mFontBold, item.text, drawPosition + NAS2D::Vector{5, 15 - mFontBold.height() / 2}, constants::PrimaryColor);
90-
renderer.drawText(mFont, "Quantity: " + std::to_string(item.count), drawPosition + NAS2D::Vector{firstStop + 5, 15 - mFontBold.height() / 2}, constants::PrimaryColor);
87+
renderer.drawText(mFontBold, item.text, drawArea.position + NAS2D::Vector{5, 15 - mFontBold.height() / 2}, constants::PrimaryColor);
88+
renderer.drawText(mFont, "Quantity: " + std::to_string(item.count), drawArea.position + NAS2D::Vector{firstStop + 5, 15 - mFontBold.height() / 2}, constants::PrimaryColor);
9189
drawProgressBar(
9290
item.capacityUsed,
9391
item.capacityTotal,
94-
{drawPosition + NAS2D::Vector{secondStop + 5, 10}, {firstStop - 10, 10}},
92+
{drawArea.position + NAS2D::Vector{secondStop + 5, 10}, {firstStop - 10, 10}},
9593
2
9694
);
9795
}

0 commit comments

Comments
 (0)