[apps/graph/graph] Correct banner view reloading

This commit is contained in:
Ruben Dashyan
2019-09-11 17:18:45 +02:00
parent 77262b02dc
commit 2d38419989
3 changed files with 5 additions and 10 deletions

View File

@@ -6,7 +6,6 @@
namespace Graph {
class BannerView : public Shared::XYBannerView {
friend class GraphController;
public:
BannerView(
Responder * parentResponder,

View File

@@ -31,7 +31,6 @@ void GraphController::viewWillAppear() {
m_view.drawTangent(false);
m_view.setCursorView(&m_cursorView);
FunctionGraphController::viewWillAppear();
// Update the cursor color and the derivative display in the banner view
selectFunctionWithCursor(indexFunctionSelectedByCursor());
}
@@ -128,19 +127,17 @@ void GraphController::selectFunctionWithCursor(int functionIndex) {
FunctionGraphController::selectFunctionWithCursor(functionIndex);
ExpiringPointer<CartesianFunction> 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() {
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor());
bool displayDerivative = m_displayDerivativeInBanner &&
functionStore()->modelForRecord(record)->plotType() == CartesianFunction::PlotType::Cartesian;
m_bannerView.setNumberOfSubviews(Shared::XYBannerView::k_numberOfSubviews + displayDerivative);
FunctionGraphController::reloadBannerView();
if (m_bannerView.numberOfSubviews() == k_numberOfBannerViewSubviewsWithoutDerivate) {
if (!displayDerivative) {
return;
}
Ion::Storage::Record record = functionStore()->activeRecordAtIndex(indexFunctionSelectedByCursor());
reloadDerivativeInBannerViewForCursorOnFunction(m_cursor, record);
}

View File

@@ -23,7 +23,6 @@ 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; }