mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/graph/values] Adjust the title of functions and derivatives in the
center of cells Change-Id: Ib09e0d22b4f5389d59e37f77f4ee069e5148c0a7
This commit is contained in:
@@ -9,6 +9,14 @@ void FunctionTitleCell::setColor(KDColor color) {
|
||||
|
||||
void FunctionTitleCell::setDerivative(bool derivative) {
|
||||
m_derivative = derivative;
|
||||
PointerTextView * pointerTextView = (PointerTextView *)subviewAtIndex(0);
|
||||
int textwidth = KDText::stringSize("f").width();
|
||||
// Here we compute the right horizontal alignment to center "f(x)" or "f'(x)"
|
||||
if (derivative) {
|
||||
pointerTextView->setAlignment(0.5f*(m_frame.width() - 5*textwidth)/(m_frame.width() - textwidth), 0.5f);
|
||||
} else {
|
||||
pointerTextView->setAlignment(0.5f*(m_frame.width() - 4*textwidth)/(m_frame.width() - textwidth), 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
@@ -16,8 +24,9 @@ void FunctionTitleCell::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
// 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()));
|
||||
KDPoint origin(0.5f*(m_frame.width() - 4*textSize.width()), 0.5f*(m_frame.height() - textSize.height()));
|
||||
if (m_derivative) {
|
||||
origin = KDPoint(0.5f*(m_frame.width() - 5*textSize.width()), 0.5f*(m_frame.height() - textSize.height()));
|
||||
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 {
|
||||
|
||||
Reference in New Issue
Block a user