Files
Upsilon/apps/shared/function_graph_controller.h
Ruben Dashyan d8f97d62a4 [apps] Factorize Shared::InteractiveCurveViewController methods
cursorBottomMarginRatio(), displayBottomMarginRatio(),
estimatedBannerHeight() and k_viewHeight moved to
Shared::InteractiveCurveViewController from derived classes.

estimatedBannerNumberOfLines() moved from
Shared::FunctionGraphController to
Shared::InteractiveCurveViewController and implemented in
Regresssion::GraphController.
2019-05-03 15:54:21 +02:00

61 lines
2.6 KiB
C++

#ifndef SHARED_FUNCTION_GRAPH_CONTROLLER_H
#define SHARED_FUNCTION_GRAPH_CONTROLLER_H
#include <escher.h>
#include "initialisation_parameter_controller.h"
#include "function_banner_delegate.h"
#include "interactive_curve_view_controller.h"
#include "function_store.h"
#include "function_graph_view.h"
#include "function_curve_parameter_controller.h"
namespace Shared {
class FunctionGraphController : public InteractiveCurveViewController, public FunctionBannerDelegate {
public:
FunctionGraphController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate, ButtonRowController * header, InteractiveCurveViewRange * interactiveRange, CurveView * curveView, CurveViewCursor * cursor, int * indexFunctionSelectedByCursor, uint32_t * modelVersion, uint32_t * rangeVersion, Poincare::Preferences::AngleUnit * angleUnitVersion);
bool isEmpty() const override;
ViewController * initialisationParameterController() override;
void viewWillAppear() override;
protected:
float cursorTopMarginRatio() override { return 0.068f; }
void reloadBannerView() override;
bool handleEnter() override;
int indexFunctionSelectedByCursor() const { return *m_indexFunctionSelectedByCursor; }
virtual void selectFunctionWithCursor(int functionIndex);
virtual double defaultCursorAbscissa();
virtual FunctionStore * functionStore() const;
private:
virtual FunctionGraphView * functionGraphView() = 0;
virtual FunctionCurveParameterController * curveParameterController() = 0;
// InteractiveCurveViewController
/* When y auto is ticked, we use a display margin to be ensure that the user
* can move the cursor along the curve without panning the window */
float displayTopMarginRatio() override { return 0.09f; } // cursorHeight/graphViewHeight
// InteractiveCurveViewRangeDelegate
InteractiveCurveViewRangeDelegate::Range computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) override;
// InteractiveCurveViewController
void initCursorParameters() override;
bool moveCursorVertically(int direction) override;
CurveView * curveView() override;
uint32_t modelVersion() override;
uint32_t rangeVersion() override;
bool isCursorVisible() override;
bool closestCurveIndexIsSuitable(int newIndex, int currentIndex) const override;
double yValue(int curveIndex, double x, Poincare::Context * context) const override;
int numberOfCurves() const override;
InitialisationParameterController m_initialisationParameterController;
Poincare::Preferences::AngleUnit * m_angleUnitVersion;
int * m_indexFunctionSelectedByCursor;
};
}
#endif