[apps] Fix SumGraphController use of CodePointString

This commit is contained in:
Léa Saviot
2019-01-25 11:54:30 +01:00
committed by Émilie Feral
parent c476ea5380
commit 47e9be2574
2 changed files with 3 additions and 5 deletions

View File

@@ -242,18 +242,17 @@ void StorageSumGraphController::LegendView::setSumSymbol(Step step, double start
char buffer[PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits)];
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::MediumNumberOfSignificantDigits), Constant::MediumNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
m_sumLayout = CondensedSumLayout::Builder(
LayoutHelper::CodePointString(sigma, sizeof(sigma)),
LayoutHelper::CodePointString(sigma, sigmaLength),
LayoutHelper::String(buffer, strlen(buffer), k_font),
EmptyLayout::Builder(EmptyLayoutNode::Color::Yellow, false, k_font, false));
} else {
m_sumLayout = LayoutHelper::CodePointString(sigma, sizeof(sigma));
char buffer[2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)];
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
Layout start = LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont);
PrintFloat::convertFloatToText<double>(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
Layout end = LayoutHelper::String(buffer, strlen(buffer), k_font);
m_sumLayout = CondensedSumLayout::Builder(
LayoutHelper::CodePointString(sigma, sizeof(sigma)),
LayoutHelper::CodePointString(sigma, sigmaLength),
start,
end);
strlcpy(buffer, "= ", 3);

View File

@@ -245,7 +245,6 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl
LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont),
EmptyLayout::Builder(EmptyLayoutNode::Color::Yellow, false, KDFont::SmallFont, false));
} else {
m_sumLayout = LayoutHelper::CodePointString(sigma, sigmaSize);
constexpr size_t bufferSize = 2+PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits);
char buffer[bufferSize];
PrintFloat::convertFloatToText<double>(start, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
@@ -253,7 +252,7 @@ void SumGraphController::LegendView::setSumSymbol(Step step, double start, doubl
PrintFloat::convertFloatToText<double>(end, buffer, PrintFloat::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Preferences::PrintFloatMode::Decimal);
Layout end = LayoutHelper::String(buffer, strlen(buffer), KDFont::SmallFont);
m_sumLayout = CondensedSumLayout::Builder(
LayoutHelper::CodePointString(sigma, sizeof(sigma)),
LayoutHelper::CodePointString(sigma, sigmaSize),
start,
end);
strlcpy(buffer, "= ", bufferSize);