mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 09:59:41 +02:00
Minor cleanups in Menu::linkUp/Down() and setLinkIndex()
This commit is contained in:
parent
0d0eebe365
commit
6cdd5694d3
35
src/menu.cpp
35
src/menu.cpp
@ -606,23 +606,23 @@ void Menu::linkRight() {
|
|||||||
void Menu::linkUp() {
|
void Menu::linkUp() {
|
||||||
int l = iLink - linkColumns;
|
int l = iLink - linkColumns;
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
unsigned int rows;
|
const auto numLinks = sectionLinks()->size();
|
||||||
rows = DIV_ROUND_UP(sectionLinks()->size(), linkColumns);
|
unsigned int rows = DIV_ROUND_UP(numLinks, linkColumns);
|
||||||
l = (rows * linkColumns) + l;
|
l = (rows * linkColumns) + l;
|
||||||
if (l >= (int)sectionLinks()->size())
|
if (l >= static_cast<int>(numLinks))
|
||||||
l -= linkColumns;
|
l -= linkColumns;
|
||||||
}
|
}
|
||||||
setLinkIndex(l);
|
setLinkIndex(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::linkDown() {
|
void Menu::linkDown() {
|
||||||
uint l = iLink + linkColumns;
|
int l = iLink + linkColumns;
|
||||||
if (l >= sectionLinks()->size()) {
|
const auto numLinks = sectionLinks()->size();
|
||||||
unsigned int rows, curCol;
|
if (l >= static_cast<int>(numLinks)) {
|
||||||
rows = DIV_ROUND_UP(sectionLinks()->size(), linkColumns);
|
unsigned int rows = DIV_ROUND_UP(numLinks, linkColumns);
|
||||||
curCol = DIV_ROUND_UP(iLink + 1, linkColumns);
|
unsigned int curCol = DIV_ROUND_UP(iLink + 1, linkColumns);
|
||||||
if (rows > curCol)
|
if (rows > curCol)
|
||||||
l = sectionLinks()->size() - 1;
|
l = numLinks - 1;
|
||||||
else
|
else
|
||||||
l %= linkColumns;
|
l %= linkColumns;
|
||||||
}
|
}
|
||||||
@ -643,17 +643,18 @@ LinkApp *Menu::selLinkApp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Menu::setLinkIndex(int i) {
|
void Menu::setLinkIndex(int i) {
|
||||||
|
const int numLinks = static_cast<int>(sectionLinks()->size());
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
i=sectionLinks()->size()-1;
|
i = numLinks - 1;
|
||||||
else if (i>=(int)sectionLinks()->size())
|
else if (i >= numLinks)
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
if (i >= (int)(iFirstDispRow * linkColumns + linkColumns * linkRows))
|
|
||||||
iFirstDispRow = i / linkColumns - linkRows + 1;
|
|
||||||
else if (i<(int)(iFirstDispRow * linkColumns))
|
|
||||||
iFirstDispRow = i / linkColumns;
|
|
||||||
|
|
||||||
iLink = i;
|
iLink = i;
|
||||||
|
|
||||||
|
int row = i / linkColumns;
|
||||||
|
if (row >= (int)(iFirstDispRow + linkRows))
|
||||||
|
iFirstDispRow = row - linkRows + 1;
|
||||||
|
else if (row < (int)iFirstDispRow)
|
||||||
|
iFirstDispRow = row;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBOPK
|
#ifdef HAVE_LIBOPK
|
||||||
|
Loading…
Reference in New Issue
Block a user