1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-12-27 13:41:09 +02:00

Center links horizontally

This commit is contained in:
Maarten ter Huurne 2013-08-05 00:36:40 +02:00
parent f65a59a02f
commit 8d7ac6e0ba

View File

@ -176,10 +176,13 @@ void Menu::paint(Surface &s) {
//Links
const uint linksPerPage = linkColumns * linkRows;
const int linkSpacingX = (width - 10 - linkColumns * linkWidth) / linkColumns;
const int linkMarginX = (
width - linkWidth * linkColumns - linkSpacingX * (linkColumns - 1)
) / 2;
const int linkSpacingY = (height - 35 - topBarHeight - linkRows * linkHeight) / linkRows;
for (uint i = iFirstDispRow * linkColumns; i < iFirstDispRow * linkColumns + linksPerPage && i < numLinks; i++) {
const int ir = i - iFirstDispRow * linkColumns;
const int x = (ir % linkColumns) * (linkWidth + linkSpacingX) + 6;
const int x = linkMarginX + (ir % linkColumns) * (linkWidth + linkSpacingX);
const int y = ir / linkColumns * (linkHeight + linkSpacingY) + topBarHeight + 2;
sectionLinks.at(i)->setPosition(x, y);