mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] TableViewDataSource: implement default cumulatedWidthFromIndex,
cumulatedWidthFromIndex, indexFromCumulatedWidth, indexFromCumulatedHeight
This commit is contained in:
@@ -132,23 +132,6 @@ KDCoordinate CalculationController::rowHeight(int j) {
|
||||
return ResponderImageCell::k_oneCellHeight;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedWidthFromIndex(int j) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < j; k++) {
|
||||
result += columnWidth(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedWidth(KDCoordinate offsetX) {
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
while (result < offsetX && i < numberOfColumns()) {
|
||||
result += columnWidth(i++);
|
||||
}
|
||||
return (result < offsetX || offsetX == 0) ? i : i - 1;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedHeightFromIndex(int j) {
|
||||
return rowHeight(0) * j;
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@ public:
|
||||
int numberOfColumns() override;
|
||||
KDCoordinate columnWidth(int i) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
KDCoordinate cumulatedWidthFromIndex(int i) override;
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||
int indexFromCumulatedWidth(KDCoordinate offsetX) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
|
||||
@@ -30,23 +30,6 @@ KDCoordinate ExpressionModelListController::expressionRowHeight(int j) {
|
||||
return modelSize + Metric::StoreRowHeight - KDText::charSize().height();
|
||||
}
|
||||
|
||||
KDCoordinate ExpressionModelListController::cumulatedExpressionHeightFromIndex(int j) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < j; k++) {
|
||||
result += expressionRowHeight(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int ExpressionModelListController::indexFromCumulatedExpressionHeight(KDCoordinate offsetY) {
|
||||
int result = 0;
|
||||
int j = 0;
|
||||
while (result < offsetY && j < numberOfExpressionRows()) {
|
||||
result += expressionRowHeight(j++);
|
||||
}
|
||||
return (result < offsetY || offsetY == 0) ? j : j - 1;
|
||||
}
|
||||
|
||||
void ExpressionModelListController::willDisplayExpressionCellAtIndex(HighlightCell * cell, int j) {
|
||||
EvenOddExpressionCell * myCell = (EvenOddExpressionCell *)cell;
|
||||
ExpressionModel * m = modelStore()->modelAtIndex(j);
|
||||
|
||||
@@ -14,8 +14,6 @@ protected:
|
||||
/* Table Data Source */
|
||||
virtual int numberOfExpressionRows();
|
||||
virtual KDCoordinate expressionRowHeight(int j);
|
||||
KDCoordinate cumulatedExpressionHeightFromIndex(int j);
|
||||
int indexFromCumulatedExpressionHeight(KDCoordinate offsetY);
|
||||
virtual void willDisplayExpressionCellAtIndex(HighlightCell * cell, int j);
|
||||
/* Responder */
|
||||
bool handleEventOnExpression(Ion::Events::Event event);
|
||||
|
||||
@@ -23,13 +23,7 @@ public:
|
||||
return expressionRowHeight(j);
|
||||
}
|
||||
KDCoordinate columnWidth(int i) override;
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override {
|
||||
return cumulatedExpressionHeightFromIndex(j);
|
||||
}
|
||||
KDCoordinate cumulatedWidthFromIndex(int i) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override {
|
||||
return indexFromCumulatedExpressionHeight(offsetY);
|
||||
}
|
||||
int indexFromCumulatedWidth(KDCoordinate offsetX) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
|
||||
@@ -22,12 +22,6 @@ public:
|
||||
int numberOfRows() override {
|
||||
return numberOfExpressionRows();
|
||||
}
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override {
|
||||
return cumulatedExpressionHeightFromIndex(j);
|
||||
}
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override {
|
||||
return indexFromCumulatedExpressionHeight(offsetY);
|
||||
}
|
||||
KDCoordinate rowHeight(int j) override {
|
||||
return expressionRowHeight(j);
|
||||
}
|
||||
|
||||
@@ -209,23 +209,6 @@ KDCoordinate SolutionsController::rowHeight(int j) {
|
||||
return layoutHeight+ScrollableExactApproximateExpressionsCell::k_margin*2;
|
||||
}
|
||||
|
||||
KDCoordinate SolutionsController::cumulatedHeightFromIndex(int j) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < j; k++) {
|
||||
result += rowHeight(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int SolutionsController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
int result = 0;
|
||||
int j = 0;
|
||||
while (result < offsetY && j < numberOfRows()) {
|
||||
result += rowHeight(j++);
|
||||
}
|
||||
return (result < offsetY || offsetY == 0) ? j : j - 1;
|
||||
}
|
||||
|
||||
KDCoordinate SolutionsController::cumulatedWidthFromIndex(int i) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
|
||||
@@ -27,9 +27,7 @@ public:
|
||||
KDCoordinate columnWidth(int i) override;
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
KDCoordinate cumulatedWidthFromIndex(int i) override;
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||
int indexFromCumulatedWidth(KDCoordinate offsetX) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
|
||||
@@ -95,27 +95,11 @@ KDCoordinate CalculationController::rowHeight(int j) {
|
||||
return k_cellHeight;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedWidthFromIndex(int i) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < i; k++) {
|
||||
result += columnWidth(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
KDCoordinate CalculationController::cumulatedHeightFromIndex(int j) {
|
||||
return j*rowHeight(0);
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedWidth(KDCoordinate offsetX) {
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
while (result < offsetX && i < numberOfRows()) {
|
||||
result += rowHeight(i++);
|
||||
}
|
||||
return (result < offsetX || offsetX == 0) ? i : i - 1;
|
||||
}
|
||||
|
||||
int CalculationController::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
return (offsetY-1) / rowHeight(0);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ public:
|
||||
KDCoordinate rowHeight(int j) override;
|
||||
KDCoordinate cumulatedHeightFromIndex(int j) override;
|
||||
int indexFromCumulatedHeight(KDCoordinate offsetY) override;
|
||||
KDCoordinate cumulatedWidthFromIndex(int i) override;
|
||||
int indexFromCumulatedWidth(KDCoordinate offsetX) override;
|
||||
HighlightCell * reusableCell(int index, int type) override;
|
||||
int reusableCellCount(int type) override;
|
||||
int typeAtLocation(int i, int j) override;
|
||||
|
||||
@@ -13,14 +13,14 @@ public:
|
||||
virtual KDCoordinate rowHeight(int j) = 0;
|
||||
/* return the number of pixels to include in offset to display the column i at
|
||||
the top */
|
||||
virtual KDCoordinate cumulatedWidthFromIndex(int i) = 0;
|
||||
virtual KDCoordinate cumulatedHeightFromIndex(int j) = 0;
|
||||
virtual KDCoordinate cumulatedWidthFromIndex(int i);
|
||||
virtual KDCoordinate cumulatedHeightFromIndex(int j);
|
||||
/* return the number of columns (starting with first ones) that can be fully
|
||||
* displayed in offsetX pixels.
|
||||
* Caution: if the offset is exactly the size of n columns, the function
|
||||
* returns n-1. */
|
||||
virtual int indexFromCumulatedWidth(KDCoordinate offsetX) = 0;
|
||||
virtual int indexFromCumulatedHeight(KDCoordinate offsetY) = 0;
|
||||
virtual int indexFromCumulatedWidth(KDCoordinate offsetX);
|
||||
virtual int indexFromCumulatedHeight(KDCoordinate offsetY);
|
||||
virtual HighlightCell * reusableCell(int index, int type) = 0;
|
||||
virtual int reusableCellCount(int type) = 0;
|
||||
virtual int typeAtLocation(int i, int j) = 0;
|
||||
|
||||
@@ -2,3 +2,37 @@
|
||||
|
||||
void TableViewDataSource::willDisplayCellAtLocation(HighlightCell * cell, int i, int j) {
|
||||
}
|
||||
|
||||
KDCoordinate TableViewDataSource::cumulatedWidthFromIndex(int i) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < i; k++) {
|
||||
result += columnWidth(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
KDCoordinate TableViewDataSource::cumulatedHeightFromIndex(int j) {
|
||||
int result = 0;
|
||||
for (int k = 0; k < j; k++) {
|
||||
result += rowHeight(k);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int TableViewDataSource::indexFromCumulatedWidth(KDCoordinate offsetX) {
|
||||
int result = 0;
|
||||
int i = 0;
|
||||
while (result < offsetX && i < numberOfColumns()) {
|
||||
result += columnWidth(i++);
|
||||
}
|
||||
return (result < offsetX || offsetX == 0) ? i : i - 1;
|
||||
}
|
||||
|
||||
int TableViewDataSource::indexFromCumulatedHeight(KDCoordinate offsetY) {
|
||||
int result = 0;
|
||||
int j = 0;
|
||||
while (result < offsetY && j < numberOfRows()) {
|
||||
result += rowHeight(j++);
|
||||
}
|
||||
return (result < offsetY || offsetY == 0) ? j : j - 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user