[apps/graph/list] draw function names align to expression baselines with colors

Change-Id: I381ef6c984db156fc61129a76a2ac086a769fe9a
This commit is contained in:
Émilie Feral
2016-09-30 17:57:40 +02:00
parent c5526a092c
commit 3bf5ff9007

View File

@@ -13,12 +13,17 @@ void FunctionNameView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(KDRect(0, 0, k_colorIndicatorThickness, height), functionColor);
// Select the background color according to the even line and the cursor selection
bool evenLine = m_even;
KDColor background = evenLine ? FunctionCell::k_evenLineBackgroundColor : FunctionCell::k_oddLineBackgroundColor;
background = m_highlighted ? FunctionCell::k_selectedLineBackgroundColor : background;
ctx->fillRect(KDRect(4, 0, width-4, height), background);
// Select text color according to the state of the function
KDColor backgroundColor = evenLine ? FunctionCell::k_evenLineBackgroundColor : FunctionCell::k_oddLineBackgroundColor;
backgroundColor = m_highlighted ? FunctionCell::k_selectedLineBackgroundColor : backgroundColor;
ctx->fillRect(KDRect(k_colorIndicatorThickness, 0, width-k_colorIndicatorThickness, height), backgroundColor);
// Select function name color and the tex color according to the state of the function
bool active = m_function->isActive();
KDColor text = active ? KDColorBlack : FunctionCell::k_desactiveTextColor;
ctx->drawString(m_function->name(), KDPoint(4, 0), text, background);
// m_function->layout()->draw(ctx, KDPointZero);
KDColor textColor = active ? KDColorBlack : FunctionCell::k_desactiveTextColor;
KDColor functionNameColor = active ? functionColor : FunctionCell::k_desactiveTextColor;
// Position the name of the function
const char * functionName = m_function->name();
KDCoordinate baseline = m_function->layout()->baseline();
KDSize nameSize = KDText::stringSize(functionName);
ctx->drawString(functionName, KDPoint(k_colorIndicatorThickness, baseline-nameSize.height()), functionNameColor, backgroundColor);
ctx->drawString("(x)", KDPoint(k_colorIndicatorThickness+nameSize.width(), baseline-nameSize.height()), textColor, backgroundColor);
}