mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 20:25:54 +02:00
Minor cleanups in Menu::linkUp/Down() and setLinkIndex()
This commit is contained in:
parent
0d0eebe365
commit
6cdd5694d3
41
src/menu.cpp
41
src/menu.cpp
@ -605,24 +605,24 @@ 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) {
|
||||||
if (i<0)
|
const int numLinks = static_cast<int>(sectionLinks()->size());
|
||||||
i=sectionLinks()->size()-1;
|
if (i < 0)
|
||||||
else if (i>=(int)sectionLinks()->size())
|
i = numLinks - 1;
|
||||||
i=0;
|
else if (i >= numLinks)
|
||||||
|
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