mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-25 16:50:50 +01:00
[apps/home] Cell selection
Change-Id: Iebfd7d6ba2c4ec2ce94929dd039fcbcba324218b
This commit is contained in:
@@ -11,16 +11,44 @@ Controller::Controller(Responder * parentResponder) :
|
||||
{
|
||||
}
|
||||
|
||||
bool Controller::handleEvent(Ion::Events::Event event) {
|
||||
int nextActiveIndex = 0;
|
||||
switch (event) {
|
||||
case Ion::Events::Event::DOWN_ARROW:
|
||||
nextActiveIndex = m_activeIndex+k_numberOfColumns;
|
||||
break;
|
||||
case Ion::Events::Event::UP_ARROW:
|
||||
nextActiveIndex = m_activeIndex-k_numberOfColumns;
|
||||
break;
|
||||
case Ion::Events::Event::LEFT_ARROW:
|
||||
nextActiveIndex = m_activeIndex-1;
|
||||
break;
|
||||
case Ion::Events::Event::RIGHT_ARROW:
|
||||
nextActiveIndex = m_activeIndex+1;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
if (nextActiveIndex < 0) {
|
||||
nextActiveIndex = 0;
|
||||
}
|
||||
if (nextActiveIndex >= k_numberOfApps) {
|
||||
nextActiveIndex = k_numberOfApps-1;
|
||||
}
|
||||
setActiveIndex(nextActiveIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
View * Controller::view() {
|
||||
return &m_tableView;
|
||||
}
|
||||
|
||||
int Controller::numberOfRows() {
|
||||
return 10;
|
||||
return ((k_numberOfApps-1)/k_numberOfColumns)+1;
|
||||
}
|
||||
|
||||
int Controller::numberOfColumns() {
|
||||
return 3;
|
||||
return k_numberOfColumns;
|
||||
}
|
||||
|
||||
KDCoordinate Controller::cellHeight() {
|
||||
@@ -39,4 +67,26 @@ int Controller::reusableCellCount() {
|
||||
return k_maxNumberOfCells;
|
||||
}
|
||||
|
||||
void Controller::setActiveIndex(int index) {
|
||||
if (m_activeIndex < 0 && m_activeIndex >= k_numberOfApps) {
|
||||
return;
|
||||
}
|
||||
if (index == m_activeIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
int j = m_activeIndex/k_numberOfColumns;
|
||||
int i = m_activeIndex-j*k_numberOfColumns; // Avoid modulo
|
||||
AppCell * previousCell = (AppCell *)m_tableView.cellAtLocation(i, j);
|
||||
previousCell->setActive(false);
|
||||
|
||||
m_activeIndex = index;
|
||||
|
||||
j = m_activeIndex/k_numberOfColumns;
|
||||
i = m_activeIndex-j*k_numberOfColumns; // Avoid modulo
|
||||
AppCell * nextCell = (AppCell *)m_tableView.cellAtLocation(i, j);
|
||||
nextCell->setActive(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user