mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/shared/sum_graph_controller] Factor constexpr
This commit is contained in:
committed by
LeaNumworks
parent
f0ef84b3bc
commit
afb1d18d65
@@ -3,7 +3,6 @@
|
||||
#include <poincare/empty_layout.h>
|
||||
#include <poincare/condensed_sum_layout.h>
|
||||
#include <poincare/layout_helper.h>
|
||||
#include <poincare/preferences.h>
|
||||
#include "poincare_helpers.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -178,10 +177,8 @@ void SumGraphController::LegendView::setLegendMessage(I18n::Message message, Ste
|
||||
}
|
||||
|
||||
void SumGraphController::LegendView::setEditableZone(double d) {
|
||||
constexpr int precision = Preferences::MediumNumberOfSignificantDigits;
|
||||
constexpr int bufferSize = PrintFloat::charSizeForFloatsWithPrecision(precision);
|
||||
char buffer[bufferSize];
|
||||
PoincareHelpers::ConvertFloatToTextWithDisplayMode<double>(d, buffer, bufferSize, precision, Preferences::PrintFloatMode::Decimal);
|
||||
char buffer[k_valuesBufferSize];
|
||||
PoincareHelpers::ConvertFloatToTextWithDisplayMode<double>(d, buffer, k_valuesBufferSize, k_valuesPrecision, Preferences::PrintFloatMode::Decimal);
|
||||
m_editableZone.setText(buffer);
|
||||
}
|
||||
|
||||
@@ -191,23 +188,21 @@ void SumGraphController::LegendView::setSumLayout(Step step, double start, doubl
|
||||
const CodePoint sigma[sigmaLength] = {' ', m_sumSymbol};
|
||||
Poincare::Layout sumLayout = LayoutHelper::CodePointString(sigma, sigmaLength);
|
||||
if (step != Step::FirstParameter) {
|
||||
constexpr int precision = Preferences::MediumNumberOfSignificantDigits;
|
||||
constexpr int bufferSize = PrintFloat::charSizeForFloatsWithPrecision(precision);
|
||||
char buffer[bufferSize];
|
||||
char buffer[k_valuesBufferSize];
|
||||
Layout endLayout;
|
||||
if (step == Step::SecondParameter) {
|
||||
endLayout = EmptyLayout::Builder(EmptyLayoutNode::Color::Yellow, false, k_font, false);
|
||||
} else {
|
||||
PoincareHelpers::ConvertFloatToTextWithDisplayMode<double>(end, buffer, bufferSize, precision, Preferences::PrintFloatMode::Decimal);
|
||||
PoincareHelpers::ConvertFloatToTextWithDisplayMode<double>(end, buffer, k_valuesBufferSize, k_valuesPrecision, Preferences::PrintFloatMode::Decimal);
|
||||
endLayout = LayoutHelper::String(buffer, strlen(buffer), k_font);
|
||||
}
|
||||
PoincareHelpers::ConvertFloatToTextWithDisplayMode<double>(start, buffer, bufferSize, precision, Preferences::PrintFloatMode::Decimal);
|
||||
PoincareHelpers::ConvertFloatToTextWithDisplayMode<double>(start, buffer, k_valuesBufferSize, k_valuesPrecision, Preferences::PrintFloatMode::Decimal);
|
||||
sumLayout = CondensedSumLayout::Builder(
|
||||
sumLayout,
|
||||
LayoutHelper::String(buffer, strlen(buffer), k_font),
|
||||
endLayout);
|
||||
if (step == Step::Result) {
|
||||
PoincareHelpers::ConvertFloatToText<double>(result, buffer, bufferSize, precision);
|
||||
PoincareHelpers::ConvertFloatToText<double>(result, buffer, k_valuesBufferSize, k_valuesPrecision);
|
||||
sumLayout = HorizontalLayout::Builder(
|
||||
sumLayout,
|
||||
functionLayout,
|
||||
|
||||
@@ -58,6 +58,8 @@ private:
|
||||
void setSumLayout(Step step, double start, double end, double result, Poincare::Layout functionLayout);
|
||||
private:
|
||||
constexpr static size_t k_editableZoneBufferSize = Poincare::PrintFloat::k_maxFloatCharSize;
|
||||
constexpr static int k_valuesPrecision = Poincare::Preferences::MediumNumberOfSignificantDigits;
|
||||
constexpr static int k_valuesBufferSize = Poincare::PrintFloat::charSizeForFloatsWithPrecision(k_valuesPrecision);
|
||||
constexpr static KDCoordinate k_legendHeight = 35;
|
||||
constexpr static const KDFont * k_font = KDFont::SmallFont;
|
||||
static KDCoordinate editableZoneWidth() { return 12*k_font->glyphSize().width(); }
|
||||
|
||||
Reference in New Issue
Block a user