mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/calculation] Fix relayouting when highlighted cell changed
This fixes the following scenario: add "1.2" 5 times, go up three times, and down three times, the last cell was not correctly relayout.
This commit is contained in:
@@ -192,7 +192,7 @@ void HistoryController::willDisplayCellForIndex(HighlightCell * cell, int index)
|
||||
HistoryViewCell * myCell = (HistoryViewCell *)cell;
|
||||
myCell->setCalculation(calculationAtIndex(index).pointer(), index == selectedRow() && selectedSubviewType() == SubviewType::Output);
|
||||
myCell->setEven(index%2 == 0);
|
||||
myCell->setHighlighted(myCell->isHighlighted());
|
||||
myCell->reloadSubviewHighlight();
|
||||
}
|
||||
|
||||
KDCoordinate HistoryController::rowHeight(int j) {
|
||||
|
||||
@@ -22,7 +22,7 @@ void HistoryViewCellDataSource::setSelectedSubviewType(SubviewType subviewType,
|
||||
HistoryViewCell * previouslySelectedCell = nullptr;
|
||||
historyViewCellDidChangeSelection(&selectedCell, &previouslySelectedCell, previousSelectedCellX, previousSelectedCellY);
|
||||
if (selectedCell) {
|
||||
selectedCell->setHighlighted(selectedCell->isHighlighted());
|
||||
selectedCell->reloadSubviewHighlight();
|
||||
selectedCell->cellDidSelectSubview(subviewType);
|
||||
}
|
||||
if (previouslySelectedCell) {
|
||||
@@ -56,8 +56,16 @@ void HistoryViewCell::setEven(bool even) {
|
||||
}
|
||||
|
||||
void HistoryViewCell::setHighlighted(bool highlight) {
|
||||
assert(m_dataSource);
|
||||
if (m_highlighted == highlight) {
|
||||
return;
|
||||
}
|
||||
m_highlighted = highlight;
|
||||
// Re-layout as the ellispsis subview might have appear/disappear
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
void HistoryViewCell::reloadSubviewHighlight() {
|
||||
assert(m_dataSource);
|
||||
m_inputView.setExpressionBackgroundColor(backgroundColor());
|
||||
m_scrollableOutputView.evenOddCell()->setHighlighted(false);
|
||||
m_ellipsis.setHighlighted(false);
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
void cellDidSelectSubview(HistoryViewCellDataSource::SubviewType type);
|
||||
void setEven(bool even) override;
|
||||
void setHighlighted(bool highlight) override;
|
||||
void reloadSubviewHighlight();
|
||||
void setDataSource(HistoryViewCellDataSource * dataSource) { m_dataSource = dataSource; }
|
||||
Responder * responder() override {
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user