[shared] Temporarily duplicate shared controllers to take a

StorageFunction instead of a Function

The original controllers are to be deleted when Sequence uses Storage
This commit is contained in:
Émilie Feral
2018-10-12 09:35:55 +02:00
parent e290c928e0
commit d30e508bcd
13 changed files with 961 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
#ifndef SHARED_STORAGE_FUNCTION_GRAPH_CONTROLLER_H
#define SHARED_STORAGE_FUNCTION_GRAPH_CONTROLLER_H
#include <escher.h>
#include "initialisation_parameter_controller.h"
#include "storage_function_banner_delegate.h"
#include "interactive_curve_view_controller.h"
#include "storage_function_store.h"
#include "storage_function_graph_view.h"
#include "storage_function_curve_parameter_controller.h"
namespace Shared {
class StorageFunctionGraphController : public InteractiveCurveViewController, public StorageFunctionBannerDelegate {
public:
StorageFunctionGraphController(Responder * parentResponder, 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:
constexpr static float k_cursorTopMarginRatio = 0.068f; // (cursorHeight/2)/graphViewHeight
constexpr static float k_cursorBottomMarginRatio = 0.15f; // (cursorHeight/2+bannerHeigh)/graphViewHeight
void reloadBannerView() override;
bool handleEnter() override;
int indexFunctionSelectedByCursor() const {
return *m_indexFunctionSelectedByCursor;
}
virtual void selectFunctionWithCursor(int functionIndex);
virtual double defaultCursorAbscissa();
private:
/* 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 */
constexpr static float k_displayTopMarginRatio = 0.09f;
constexpr static float k_displayBottomMarginRatio = 0.2f;
// InteractiveCurveViewController
float displayTopMarginRatio() override { return k_displayTopMarginRatio; }
float displayBottomMarginRatio() override { return k_displayBottomMarginRatio; }
// InteractiveCurveViewRangeDelegate
InteractiveCurveViewRangeDelegate::Range computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) override;
void initRangeParameters() override;
void initCursorParameters() override;
bool moveCursorVertically(int direction) override;
CurveView * curveView() override;
uint32_t modelVersion() override;
uint32_t rangeVersion() override;
bool isCursorVisible() override;
virtual StorageFunctionGraphView * functionGraphView() = 0;
virtual View * cursorView() = 0;
virtual StorageFunctionStore * functionStore() const = 0;
virtual StorageFunctionCurveParameterController * curveParameterController() = 0;
InitialisationParameterController m_initialisationParameterController;
Poincare::Preferences::AngleUnit * m_angleUnitVersion;
int * m_indexFunctionSelectedByCursor;
};
}
#endif