Files
Upsilon/apps/shared/function_expression_cell.cpp
Émilie Feral 5c8b5492e8 [apps/sequence/list] Improve cell rendering
Change-Id: I64e713a3beae2574593f96fa05717f346e5ffd07
2017-02-20 10:52:03 +01:00

55 lines
1.6 KiB
C++

#include "function_expression_cell.h"
#include <assert.h>
using namespace Poincare;
namespace Shared {
FunctionExpressionCell::FunctionExpressionCell() :
EvenOddCell(),
m_expressionView(ExpressionView())
{
}
void FunctionExpressionCell::setExpression(ExpressionLayout * expressionLayout) {
m_expressionView.setExpression(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) {
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, 0, bounds().width() - k_separatorThickness, 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);
}
}