mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[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.
This commit is contained in:
committed by
Émilie Feral
parent
e32419ce63
commit
d8f97d62a4
@@ -75,19 +75,6 @@ Poincare::Context * GraphController::globalContext() {
|
||||
return const_cast<AppsContainer *>(static_cast<const AppsContainer *>(app()->container()))->globalContext();
|
||||
}
|
||||
|
||||
float GraphController::cursorBottomMarginRatio() {
|
||||
float f = (m_view.cursorView()->minimalSizeForOptimalDisplay().height()/2 + 2 + estimatedBannerHeight())/k_viewHeight;
|
||||
return f;
|
||||
}
|
||||
|
||||
float GraphController::estimatedBannerHeight() const {
|
||||
if (selectedSeriesIndex() < 0) {
|
||||
return KDFont::SmallFont->glyphSize().height() * 3;
|
||||
}
|
||||
float result = KDFont::SmallFont->glyphSize().height() * m_store->modelForSeries(selectedSeriesIndex())->bannerLinesCount();
|
||||
return result;
|
||||
}
|
||||
|
||||
// SimpleInteractiveCurveViewController
|
||||
|
||||
void GraphController::reloadBannerView() {
|
||||
@@ -382,13 +369,12 @@ int GraphController::numberOfCurves() const {
|
||||
return Store::k_numberOfSeries;
|
||||
}
|
||||
|
||||
float GraphController::displayTopMarginRatio() {
|
||||
return 0.12f; // cursorHeight/graphViewHeight
|
||||
int GraphController::estimatedBannerNumberOfLines() const {
|
||||
return (selectedSeriesIndex() < 0) ? 3 : m_store->modelForSeries(selectedSeriesIndex())->bannerLinesCount();
|
||||
}
|
||||
|
||||
float GraphController::displayBottomMarginRatio() {
|
||||
float f = (m_view.cursorView()->minimalSizeForOptimalDisplay().height() + 2 + estimatedBannerHeight())/k_viewHeight;
|
||||
return f;
|
||||
float GraphController::displayTopMarginRatio() {
|
||||
return 0.12f; // cursorHeight/graphViewHeight
|
||||
}
|
||||
|
||||
InteractiveCurveViewRangeDelegate::Range GraphController::computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) {
|
||||
|
||||
@@ -31,11 +31,8 @@ public:
|
||||
private:
|
||||
constexpr static int k_maxLegendLength = 16;
|
||||
constexpr static int k_maxNumberOfCharacters = 50;
|
||||
constexpr static float k_viewHeight = 174.0f;
|
||||
|
||||
Poincare::Context * globalContext();
|
||||
float cursorBottomMarginRatio() override;
|
||||
float estimatedBannerHeight() const;
|
||||
|
||||
// SimpleInteractiveCurveViewController
|
||||
void reloadBannerView() override;
|
||||
@@ -52,10 +49,10 @@ private:
|
||||
double yValue(int curveIndex, double x, Poincare::Context * context) const override;
|
||||
bool suitableYValue(double y) const override;
|
||||
int numberOfCurves() const override;
|
||||
int estimatedBannerNumberOfLines() const override;
|
||||
|
||||
// InteractiveCurveViewRangeDelegate
|
||||
float displayTopMarginRatio() override;
|
||||
float displayBottomMarginRatio() override;
|
||||
Shared::InteractiveCurveViewRangeDelegate::Range computeYRange(Shared::InteractiveCurveViewRange * interactiveCurveViewRange) override;
|
||||
|
||||
Shared::CursorView m_crossCursorView;
|
||||
|
||||
@@ -55,10 +55,6 @@ void FunctionGraphController::selectFunctionWithCursor(int functionIndex) {
|
||||
*m_indexFunctionSelectedByCursor = functionIndex;
|
||||
}
|
||||
|
||||
float FunctionGraphController::cursorBottomMarginRatio() {
|
||||
return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height()/2+estimatedBannerHeight())/k_viewHeight;
|
||||
}
|
||||
|
||||
void FunctionGraphController::reloadBannerView() {
|
||||
if (functionStore()->numberOfActiveFunctions() == 0) {
|
||||
return;
|
||||
@@ -67,14 +63,6 @@ void FunctionGraphController::reloadBannerView() {
|
||||
reloadBannerViewForCursorOnFunction(m_cursor, record, functionStore(), functionStore()->symbol());
|
||||
}
|
||||
|
||||
float FunctionGraphController::displayBottomMarginRatio() {
|
||||
return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height() + 2 + estimatedBannerHeight()) / k_viewHeight;
|
||||
}
|
||||
|
||||
float FunctionGraphController::estimatedBannerHeight() const {
|
||||
return BannerView::HeightGivenNumberOfLines(estimatedBannerNumberOfLines());
|
||||
}
|
||||
|
||||
InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) {
|
||||
FunctionApp * myApp = static_cast<FunctionApp *>(app());
|
||||
float min = FLT_MAX;
|
||||
|
||||
@@ -20,7 +20,6 @@ public:
|
||||
|
||||
protected:
|
||||
float cursorTopMarginRatio() override { return 0.068f; }
|
||||
float cursorBottomMarginRatio() override;
|
||||
void reloadBannerView() override;
|
||||
bool handleEnter() override;
|
||||
int indexFunctionSelectedByCursor() const { return *m_indexFunctionSelectedByCursor; }
|
||||
@@ -29,8 +28,6 @@ protected:
|
||||
virtual FunctionStore * functionStore() const;
|
||||
|
||||
private:
|
||||
constexpr static float k_viewHeight = 174.0f; // TODO Taken from Regresssion/graph_controller. Maybe we should compute and/or put in common ?
|
||||
|
||||
virtual FunctionGraphView * functionGraphView() = 0;
|
||||
virtual FunctionCurveParameterController * curveParameterController() = 0;
|
||||
|
||||
@@ -38,12 +35,9 @@ 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 */
|
||||
float displayTopMarginRatio() override { return 0.09f; } // cursorHeight/graphViewHeight
|
||||
float displayBottomMarginRatio() override;
|
||||
|
||||
// InteractiveCurveViewRangeDelegate
|
||||
InteractiveCurveViewRangeDelegate::Range computeYRange(InteractiveCurveViewRange * interactiveCurveViewRange) override;
|
||||
float estimatedBannerHeight() const;
|
||||
virtual int estimatedBannerNumberOfLines() const { return 1; }
|
||||
|
||||
// InteractiveCurveViewController
|
||||
void initCursorParameters() override;
|
||||
|
||||
@@ -247,4 +247,16 @@ int InteractiveCurveViewController::closestCurveIndexVertically(bool goingUp, in
|
||||
return nextCurveIndex;
|
||||
}
|
||||
|
||||
float InteractiveCurveViewController::cursorBottomMarginRatio() {
|
||||
return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height()/2+estimatedBannerHeight())/k_viewHeight;
|
||||
}
|
||||
|
||||
float InteractiveCurveViewController::estimatedBannerHeight() const {
|
||||
return BannerView::HeightGivenNumberOfLines(estimatedBannerNumberOfLines());
|
||||
}
|
||||
|
||||
float InteractiveCurveViewController::displayBottomMarginRatio() {
|
||||
return (curveView()->cursorView()->minimalSizeForOptimalDisplay().height() + 2 + estimatedBannerHeight()) / k_viewHeight;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -46,12 +46,19 @@ protected:
|
||||
virtual bool suitableYValue(double y) const { return true; }
|
||||
virtual int numberOfCurves() const = 0;
|
||||
|
||||
// SimpleInteractiveCurveViewController
|
||||
float cursorBottomMarginRatio() override;
|
||||
|
||||
OkView m_okView;
|
||||
private:
|
||||
constexpr static float k_viewHeight = 174.0f;
|
||||
float estimatedBannerHeight() const;
|
||||
virtual int estimatedBannerNumberOfLines() const { return 1; }
|
||||
|
||||
// InteractiveCurveViewRangeDelegate
|
||||
float addMargin(float x, float range, bool isMin) override;
|
||||
virtual float displayTopMarginRatio() = 0;
|
||||
virtual float displayBottomMarginRatio() = 0;
|
||||
float displayBottomMarginRatio();
|
||||
|
||||
uint32_t * m_modelVersion;
|
||||
uint32_t * m_rangeVersion;
|
||||
|
||||
Reference in New Issue
Block a user