[escher] Change the function expression cell to inherit from

even odd expression cell
This commit is contained in:
Émilie Feral
2018-05-22 16:30:38 +02:00
parent c0d3b97c6b
commit e160282e06
14 changed files with 71 additions and 104 deletions

View File

@@ -1,58 +0,0 @@
#include "function_expression_cell.h"
#include <assert.h>
using namespace Poincare;
namespace Shared {
FunctionExpressionCell::FunctionExpressionCell() :
EvenOddCell(),
m_expressionView()
{
}
void FunctionExpressionCell::setExpressionLayout(ExpressionLayout * expressionLayout) {
m_expressionView.setExpressionLayout(expressionLayout);
}
void FunctionExpressionCell::setTextColor(KDColor textColor) {
m_expressionView.setTextColor(textColor);
}
void FunctionExpressionCell::setEven(bool even) {
EvenOddCell::setEven(even);
m_expressionView.setBackgroundColor(backgroundColor());
}
void FunctionExpressionCell::setHighlighted(bool highlight) {
if (highlight != EvenOddCell::isHighlighted()) {
EvenOddCell::setHighlighted(highlight);
m_expressionView.setBackgroundColor(backgroundColor());
}
}
int FunctionExpressionCell::numberOfSubviews() const {
return 1;
}
View * FunctionExpressionCell::subviewAtIndex(int index) {
assert(index == 0);
return &m_expressionView;
}
void FunctionExpressionCell::layoutSubviews() {
KDRect expressionFrame(k_separatorThickness+k_margin, 0, bounds().width() - k_separatorThickness-k_margin, bounds().height()-k_separatorThickness);
m_expressionView.setFrame(expressionFrame);
}
void FunctionExpressionCell::drawRect(KDContext * ctx, KDRect rect) const {
KDColor separatorColor = m_even ? Palette::WallScreen : KDColorWhite;
// Color the vertical separator
ctx->fillRect(KDRect(0, 0, k_separatorThickness, bounds().height()), Palette::GreyBright);
// Color the horizontal separator
ctx->fillRect(KDRect(k_separatorThickness, bounds().height()-k_separatorThickness, bounds().width()-k_separatorThickness, k_separatorThickness), separatorColor);
// Color the margin
ctx->fillRect(KDRect(k_separatorThickness, 0, k_margin, bounds().height()-k_separatorThickness), backgroundColor());
}
}