mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/shared] Move apps/graph/list/function_expression_cell in shared
folder to be used by sequence Change-Id: I4a019c322cc7cb864479b200ee56d05234f5491c
This commit is contained in:
52
apps/shared/function_expression_cell.cpp
Normal file
52
apps/shared/function_expression_cell.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "function_expression_cell.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
FunctionExpressionCell::FunctionExpressionCell() :
|
||||
EvenOddCell(),
|
||||
m_function(nullptr),
|
||||
m_expressionView(ExpressionView())
|
||||
{
|
||||
}
|
||||
|
||||
void FunctionExpressionCell::setFunction(Function * f) {
|
||||
m_function = f;
|
||||
m_expressionView.setExpression(m_function->layout());
|
||||
}
|
||||
|
||||
void FunctionExpressionCell::reloadCell() {
|
||||
EvenOddCell::reloadCell();
|
||||
m_expressionView.setBackgroundColor(backgroundColor());
|
||||
if (m_function) {
|
||||
bool active = m_function->isActive();
|
||||
KDColor textColor = active ? KDColorBlack : Palette::GreyDark;
|
||||
m_expressionView.setTextColor(textColor);
|
||||
}
|
||||
}
|
||||
|
||||
Function * FunctionExpressionCell::function() {
|
||||
return m_function;
|
||||
}
|
||||
|
||||
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());
|
||||
m_expressionView.setFrame(expressionFrame);
|
||||
}
|
||||
|
||||
void FunctionExpressionCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
EvenOddCell::drawRect(ctx, rect);
|
||||
// Color the separator
|
||||
ctx->fillRect(KDRect(0, 0, k_separatorThickness, bounds().height()), Palette::GreyBright);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user