mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 16:20:49 +01:00
[apps/graph/values] Enable function title cell to draw a derivative
function title Change-Id: I20f207bb73bf1459029601fb5900fbbd12ec3b77
This commit is contained in:
@@ -7,13 +7,22 @@ void FunctionTitleCell::setColor(KDColor color) {
|
||||
m_functionColor = color;
|
||||
}
|
||||
|
||||
void FunctionTitleCell::setDerivative(bool derivative) {
|
||||
m_derivative = derivative;
|
||||
}
|
||||
|
||||
void FunctionTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
EvenOddCell::drawRect(ctx, rect);
|
||||
// Write the "(x)"
|
||||
KDColor background = backgroundColor();
|
||||
KDSize textSize = KDText::stringSize("f");
|
||||
KDPoint origin(0.5f*(m_frame.width() - textSize.width()), 0.5f*(m_frame.height() - textSize.height()));
|
||||
ctx->drawString(Function::Parameter, origin.translatedBy(KDPoint(textSize.width(), 0)), m_functionColor , background);
|
||||
if (m_derivative) {
|
||||
ctx->drawString("'", origin.translatedBy(KDPoint(textSize.width(), 0)), m_functionColor , background);
|
||||
ctx->drawString(Function::Parameter, origin.translatedBy(KDPoint(2*textSize.width(), 0)), m_functionColor , background);
|
||||
} else {
|
||||
ctx->drawString(Function::Parameter, origin.translatedBy(KDPoint(textSize.width(), 0)), m_functionColor , background);
|
||||
}
|
||||
// Color the color indicator
|
||||
ctx->fillRect(KDRect(0, 0, bounds().width(), k_colorIndicatorThickness), m_functionColor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user