mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 09:17:23 +01:00
[apps/shared] Factorize tab table controller in a class
Change-Id: I0af0da6b9a1216c57c8a4b669d14d8a3473ac48b
This commit is contained in:
49
apps/shared/tab_table_controller.cpp
Normal file
49
apps/shared/tab_table_controller.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "tab_table_controller.h"
|
||||
|
||||
namespace Shared {
|
||||
|
||||
TabTableController::TabTableController(Responder * parentResponder, KDCoordinate topMargin,
|
||||
KDCoordinate rightMargin, KDCoordinate bottomMargin, KDCoordinate leftMargin, SelectableTableViewDelegate * delegate, bool showIndicators) :
|
||||
ViewController(parentResponder),
|
||||
m_selectableTableView(SelectableTableView(this, this, topMargin, rightMargin, bottomMargin, leftMargin,
|
||||
delegate, showIndicators, true, Palette::WallScreenDark))
|
||||
{
|
||||
}
|
||||
|
||||
View * TabTableController::view() {
|
||||
return &m_selectableTableView;
|
||||
}
|
||||
|
||||
void TabTableController::didBecomeFirstResponder() {
|
||||
app()->setFirstResponder(&m_selectableTableView);
|
||||
}
|
||||
|
||||
KDCoordinate TabTableController::cumulatedWidthFromIndex(int i) {
|
||||
return i*columnWidth(0);
|
||||
}
|
||||
|
||||
KDCoordinate TabTableController::cumulatedHeightFromIndex(int j) {
|
||||
return j*rowHeight(0);
|
||||
}
|
||||
|
||||
int TabTableController::indexFromCumulatedWidth(KDCoordinate offsetX) {
|
||||
return (offsetX-1) / columnWidth(0);
|
||||
}
|
||||
|
||||
int TabTableController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
return (offsetY-1) / rowHeight(0);
|
||||
}
|
||||
|
||||
void TabTableController::viewWillAppear() {
|
||||
m_selectableTableView.reloadData();
|
||||
}
|
||||
|
||||
void TabTableController::willExitResponderChain(Responder * nextFirstResponder) {
|
||||
if (nextFirstResponder == tabController()) {
|
||||
m_selectableTableView.deselectTable();
|
||||
m_selectableTableView.scrollToCell(0,0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user