[apps/graph/graph] Adjust display mode in banner view according to

preferences

Change-Id: Id634a6128c7e395a35ba5df40c904a372ae80661
This commit is contained in:
Émilie Feral
2017-01-31 14:47:11 +01:00
parent 5e3de6eec9
commit f20f3518d3
4 changed files with 15 additions and 6 deletions

View File

@@ -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),

View File

@@ -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;
}
}

View File

@@ -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;

View File

@@ -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);
}
}