From f20f3518d39dbd5e11ce5d2629f2d7731db2e2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 31 Jan 2017 14:47:11 +0100 Subject: [PATCH] [apps/graph/graph] Adjust display mode in banner view according to preferences Change-Id: Id634a6128c7e395a35ba5df40c904a372ae80661 --- apps/apps_container.cpp | 2 +- apps/graph/app.cpp | 7 ++++++- apps/graph/app.h | 5 ++++- apps/graph/graph/graph_controller.cpp | 7 ++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index e395b13af..5e189b92d 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -8,7 +8,7 @@ AppsContainer::AppsContainer() : Container(), m_window(AppsWindow()), m_homeApp(this), - m_graphApp(this, &m_globalContext), + m_graphApp(this, &m_globalContext, &m_preferences), m_probabilityApp(this), m_calculationApp(this, &m_globalContext, &m_preferences), m_regressionApp(this), diff --git a/apps/graph/app.cpp b/apps/graph/app.cpp index be898f627..a4cc1f27f 100644 --- a/apps/graph/app.cpp +++ b/apps/graph/app.cpp @@ -3,10 +3,11 @@ namespace Graph { -App::App(Container * container, Context * context) : +App::App(Container * container, Context * context, Preferences * preferences) : TextFieldDelegateApp(container, &m_inputViewController, "Fonctions", "FONCTIONS", ImageStore::GraphIcon), m_functionStore(FunctionStore()), m_xContext(VariableContext('x', context)), + m_preferences(preferences), m_listController(ListController(&m_listHeader, &m_functionStore, &m_listHeader)), m_listHeader(HeaderViewController(nullptr, &m_listController, &m_listController)), m_listStackViewController(StackViewController(&m_tabViewController, &m_listHeader)), @@ -31,4 +32,8 @@ Context * App::localContext() { return &m_xContext; } +Preferences * App::preferences() { + return m_preferences; +} + } diff --git a/apps/graph/app.h b/apps/graph/app.h index 6b17e2068..80bfa74ad 100644 --- a/apps/graph/app.h +++ b/apps/graph/app.h @@ -8,17 +8,20 @@ #include "list/list_controller.h" #include "values/values_controller.h" #include "../text_field_delegate_app.h" +#include "../preferences.h" namespace Graph { class App : public TextFieldDelegateApp { public: - App(Container * container, Context * context); + App(Container * container, Context * context, Preferences * preferences); InputViewController * inputViewController(); Context * localContext() override; + Preferences * preferences(); private: FunctionStore m_functionStore; VariableContext m_xContext; + Preferences * m_preferences; ListController m_listController; HeaderViewController m_listHeader; StackViewController m_listStackViewController; diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index 3f9dc1b9e..27339ab4f 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -109,11 +109,12 @@ bool GraphController::handleEnter() { } void GraphController::reloadBannerView() { + App * myApp = (App *)app(); char buffer[k_maxNumberOfCharacters+Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits)]; const char * legend = "x = "; int legendLength = strlen(legend); strlcpy(buffer, legend, legendLength+1); - Float(m_cursor.x()).convertFloatToText(buffer+ legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::DisplayMode::Auto); + Float(m_cursor.x()).convertFloatToText(buffer+ legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myApp->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 0); legend = "00(x) = "; @@ -121,7 +122,7 @@ void GraphController::reloadBannerView() { strlcpy(buffer, legend, legendLength+1); Function * f = m_functionStore->activeFunctionAtIndex(m_indexFunctionSelectedByCursor); buffer[1] = f->name()[0]; - Float(m_cursor.y()).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::DisplayMode::Auto); + Float(m_cursor.y()).convertFloatToText(buffer+legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myApp->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer+1, 1); if (m_bannerView.displayDerivative()) { @@ -129,7 +130,7 @@ void GraphController::reloadBannerView() { buffer[1] = '\''; App * graphApp = (Graph::App *)app(); float y = f->approximateDerivative(m_cursor.x(), graphApp->localContext()); - Float(y).convertFloatToText(buffer + legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, Expression::DisplayMode::Auto); + Float(y).convertFloatToText(buffer + legendLength, Float::bufferSizeForFloatsWithPrecision(Constant::LargeNumberOfSignificantDigits), Constant::LargeNumberOfSignificantDigits, myApp->preferences()->displayMode()); m_bannerView.setLegendAtIndex(buffer, 2); } }