[apps/functions] Save if user want display derivative even when quitting the app

This commit is contained in:
Laury
2022-01-15 12:40:06 +01:00
parent cbbe7ef6ac
commit f591816122
4 changed files with 14 additions and 10 deletions

View File

@@ -27,7 +27,8 @@ const Image * App::Descriptor::icon() {
App::Snapshot::Snapshot() :
Shared::FunctionApp::Snapshot::Snapshot(),
m_functionStore(),
m_graphRange()
m_graphRange(),
m_shouldDisplayDerivative(false)
{
}
@@ -40,6 +41,7 @@ void App::Snapshot::reset() {
for (int i = 0; i < Shared::ContinuousFunction::k_numberOfPlotTypes; i++) {
m_interval[i].reset();
}
m_shouldDisplayDerivative = false;
}
App::Descriptor * App::Snapshot::descriptor() {
@@ -58,7 +60,7 @@ App::App(Snapshot * snapshot) :
m_listFooter(&m_listHeader, &m_listController, &m_listController, ButtonRowController::Position::Bottom, ButtonRowController::Style::EmbossedGray),
m_listHeader(&m_listStackViewController, &m_listFooter, &m_listController),
m_listStackViewController(&m_tabViewController, &m_listHeader),
m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), snapshot->rangeVersion(), &m_graphHeader),
m_graphController(&m_graphAlternateEmptyViewController, this, snapshot->graphRange(), snapshot->cursor(), snapshot->indexFunctionSelectedByCursor(), snapshot->rangeVersion(), &m_graphHeader, snapshot->shouldDisplayDerivative()),
m_graphAlternateEmptyViewController(&m_graphHeader, &m_graphController, &m_graphController),
m_graphHeader(&m_graphStackViewController, &m_graphAlternateEmptyViewController, &m_graphController),
m_graphStackViewController(&m_tabViewController, &m_graphHeader),

View File

@@ -31,11 +31,13 @@ public:
Shared::Interval * intervalForType(Shared::ContinuousFunction::PlotType plotType) {
return m_interval + static_cast<size_t>(plotType);
}
bool * shouldDisplayDerivative() { return &m_shouldDisplayDerivative; }
private:
void tidy() override;
ContinuousFunctionStore m_functionStore;
Shared::InteractiveCurveViewRange m_graphRange;
Shared::Interval m_interval[Shared::ContinuousFunction::k_numberOfPlotTypes];
bool m_shouldDisplayDerivative;
};
static App * app() {
return static_cast<App *>(Container::activeApp());

View File

@@ -7,13 +7,13 @@ using namespace Shared;
namespace Graph {
GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, ButtonRowController * header) :
GraphController::GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, ButtonRowController * header, bool * shouldDisplayDerivative) :
FunctionGraphController(parentResponder, inputEventHandlerDelegate, header, curveViewRange, &m_view, cursor, indexFunctionSelectedByCursor, rangeVersion),
m_bannerView(this, inputEventHandlerDelegate, this),
m_view(curveViewRange, m_cursor, &m_bannerView, &m_cursorView),
m_graphRange(curveViewRange),
m_curveParameterController(inputEventHandlerDelegate, curveViewRange, &m_bannerView, m_cursor, &m_view, this),
m_displayDerivativeInBanner(false)
m_displayDerivativeInBanner(shouldDisplayDerivative)
{
m_graphRange->setDelegate(this);
}
@@ -47,7 +47,7 @@ void GraphController::selectFunctionWithCursor(int functionIndex) {
void GraphController::reloadBannerView() {
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor());
bool displayDerivative = m_displayDerivativeInBanner &&
bool displayDerivative = *m_displayDerivativeInBanner &&
functionStore()->modelForRecord(record)->plotType() == ContinuousFunction::PlotType::Cartesian;
m_bannerView.setNumberOfSubviews(Shared::XYBannerView::k_numberOfSubviews + displayDerivative);
FunctionGraphController::reloadBannerView();

View File

@@ -15,13 +15,13 @@ namespace Graph {
class GraphController : public Shared::FunctionGraphController, public GraphControllerHelper {
public:
GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, ButtonRowController * header);
GraphController(Responder * parentResponder, ::InputEventHandlerDelegate * inputEventHandlerDelegate, Shared::InteractiveCurveViewRange * curveViewRange, Shared::CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * rangeVersion, ButtonRowController * header, bool * shouldDisplayDerivative);
I18n::Message emptyMessage() override;
void viewWillAppear() override;
bool displayDerivativeInBanner() const { return m_displayDerivativeInBanner; }
void setDisplayDerivativeInBanner(bool displayDerivative) { m_displayDerivativeInBanner = displayDerivative; }
bool displayDerivativeInBanner() const { return *m_displayDerivativeInBanner; }
void setDisplayDerivativeInBanner(bool displayDerivative) { *m_displayDerivativeInBanner = displayDerivative; }
private:
int estimatedBannerNumberOfLines() const override { return 1 + m_displayDerivativeInBanner; }
int estimatedBannerNumberOfLines() const override { return 1 + *m_displayDerivativeInBanner; }
void selectFunctionWithCursor(int functionIndex) override;
BannerView * bannerView() override { return &m_bannerView; }
void reloadBannerView() override;
@@ -41,7 +41,7 @@ private:
GraphView m_view;
Shared::InteractiveCurveViewRange * m_graphRange;
CurveParameterController m_curveParameterController;
bool m_displayDerivativeInBanner;
bool * m_displayDerivativeInBanner;
};
}