diff --git a/apps/graph/graph/banner_view.h b/apps/graph/graph/banner_view.h index d53702c2a..c096122eb 100644 --- a/apps/graph/graph/banner_view.h +++ b/apps/graph/graph/banner_view.h @@ -6,6 +6,7 @@ namespace Graph { class BannerView : public Shared::XYBannerView { + friend class GraphController; public: BannerView( Responder * parentResponder, diff --git a/apps/graph/graph/graph_controller.cpp b/apps/graph/graph/graph_controller.cpp index a077fc0ef..3cb315609 100644 --- a/apps/graph/graph/graph_controller.cpp +++ b/apps/graph/graph/graph_controller.cpp @@ -30,9 +30,9 @@ I18n::Message GraphController::emptyMessage() { void GraphController::viewWillAppear() { m_view.drawTangent(false); m_view.setCursorView(&m_cursorView); - m_bannerView.setNumberOfSubviews(Shared::XYBannerView::k_numberOfSubviews + m_displayDerivativeInBanner); FunctionGraphController::viewWillAppear(); - selectFunctionWithCursor(indexFunctionSelectedByCursor()); // update the color of the cursor + // Update the cursor color and the derivative display in the banner view + selectFunctionWithCursor(indexFunctionSelectedByCursor()); } void GraphController::interestingFunctionRange(ExpiringPointer f, float tMin, float tMax, float step, float * xm, float * xM, float * ym, float * yM) const { @@ -130,11 +130,16 @@ void GraphController::selectFunctionWithCursor(int functionIndex) { FunctionGraphController::selectFunctionWithCursor(functionIndex); ExpiringPointer f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(functionIndex)); m_cursorView.setColor(f->color()); + int numberBannerViewSubviews = k_numberOfBannerViewSubviewsWithoutDerivate + (m_displayDerivativeInBanner && f->plotType() == CartesianFunction::PlotType::Cartesian); + if (m_bannerView.numberOfSubviews() != numberBannerViewSubviews) { + m_bannerView.setNumberOfSubviews(numberBannerViewSubviews); + reloadBannerView(); + } } void GraphController::reloadBannerView() { FunctionGraphController::reloadBannerView(); - if (!m_displayDerivativeInBanner) { + if (m_bannerView.numberOfSubviews() == k_numberOfBannerViewSubviewsWithoutDerivate) { return; } Ion::Storage::Record record = functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor()); diff --git a/apps/graph/graph/graph_controller.h b/apps/graph/graph/graph_controller.h index 21fe08b0d..21b4ca7ac 100644 --- a/apps/graph/graph/graph_controller.h +++ b/apps/graph/graph/graph_controller.h @@ -23,6 +23,7 @@ public: float interestingXHalfRange() const override; void interestingRanges(float * xm, float * xM, float * ym, float * yM) const override; private: + static constexpr int k_numberOfBannerViewSubviewsWithoutDerivate = Shared::XYBannerView::k_numberOfSubviews; int estimatedBannerNumberOfLines() const override { return 1 + m_displayDerivativeInBanner; } void selectFunctionWithCursor(int functionIndex) override; BannerView * bannerView() override { return &m_bannerView; }