[escher] Optimize redrawing when changing features in cells (color,

highlight, even)

Change-Id: I0afa8b6fad656d578bb8e071183646196bc816f9
This commit is contained in:
Émilie Feral
2017-11-21 14:45:33 +01:00
parent 5e822a8001
commit 35b979798d
6 changed files with 24 additions and 9 deletions

View File

@@ -126,6 +126,7 @@ void ListController::willDisplayCellAtLocation(HighlightCell * cell, int i, int
EvenOddCell * myCell = (EvenOddCell *)cell;
myCell->setEven(j%2 == 0);
myCell->setHighlighted(i == selectedColumn() && j == selectedRow());
myCell->reloadCell();
}
int ListController::numberOfButtons(ButtonRowController::Position position) const {

View File

@@ -9,8 +9,13 @@ NewFunctionCell::NewFunctionCell(I18n::Message text) :
{
}
void NewFunctionCell::reloadCell() {
EvenOddCell::reloadCell();
void NewFunctionCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_messageTextView.setBackgroundColor(backgroundColor());
}
void NewFunctionCell::setHighlighted(bool highlight) {
EvenOddCell::setHighlighted(highlight);
m_messageTextView.setBackgroundColor(backgroundColor());
}

View File

@@ -8,7 +8,8 @@ namespace Shared {
class NewFunctionCell : public EvenOddCell {
public:
NewFunctionCell(I18n::Message text);
void reloadCell() override;
void setEven(bool even) override;
void setHighlighted(bool highlight) override;
int numberOfSubviews() const override;
View * subviewAtIndex(int index) override;
void layoutSubviews() override;

View File

@@ -8,8 +8,10 @@ EvenOddCell::EvenOddCell() :
}
void EvenOddCell::setEven(bool even) {
if (even != m_even) {
m_even = even;
reloadCell();
}
}
KDColor EvenOddCell::backgroundColor() const {

View File

@@ -21,13 +21,17 @@ void ExpressionView::setExpression(ExpressionLayout * expressionLayout) {
}
void ExpressionView::setBackgroundColor(KDColor backgroundColor) {
m_backgroundColor = backgroundColor;
markRectAsDirty(bounds());
if (m_backgroundColor != backgroundColor) {
m_backgroundColor = backgroundColor;
markRectAsDirty(bounds());
}
}
void ExpressionView::setTextColor(KDColor textColor) {
m_textColor = textColor;
markRectAsDirty(bounds());
if (textColor != m_textColor) {
m_textColor = textColor;
markRectAsDirty(bounds());
}
}
void ExpressionView::setAlignment(float horizontalAlignment, float verticalAlignment) {

View File

@@ -7,8 +7,10 @@ HighlightCell::HighlightCell() :
}
void HighlightCell::setHighlighted(bool highlight) {
m_highlighted = highlight;
reloadCell();
if (m_highlighted != highlight) {
m_highlighted = highlight;
reloadCell();
}
}
bool HighlightCell::isHighlighted() const {