mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps] Shared: the cursor view own its size instead of the curve view
This commit is contained in:
committed by
EmilieNumworks
parent
8ccb69f2e2
commit
c9b86d0c86
@@ -9,4 +9,8 @@ void CursorView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(KDRect(0, height/2, width, 1), KDColorBlack);
|
||||
}
|
||||
|
||||
KDSize CursorView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(k_size, k_size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ class CursorView : public View {
|
||||
public:
|
||||
using View::View;
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_size = 25;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -424,10 +424,6 @@ int CurveView::numberOfLabels(Axis axis) const {
|
||||
return std::ceil((max(axis) - min(axis))/(2*gridUnit(axis)));
|
||||
}
|
||||
|
||||
KDSize CurveView::cursorSize() {
|
||||
return KDSize(k_cursorSize, k_cursorSize);
|
||||
}
|
||||
|
||||
void CurveView::jointDots(KDContext * ctx, KDRect rect, EvaluateModelWithParameter evaluation, void * model, void * context, float x, float y, float u, float v, KDColor color, int maxNumberOfRecursion) const {
|
||||
float pyf = floatToPixel(Axis::Vertical, y);
|
||||
float pvf = floatToPixel(Axis::Vertical, v);
|
||||
@@ -525,12 +521,13 @@ void CurveView::layoutSubviews() {
|
||||
KDRect CurveView::cursorFrame() {
|
||||
KDRect cursorFrame = KDRectZero;
|
||||
if (m_cursorView && m_mainViewSelected && !std::isnan(m_curveViewCursor->x()) && !std::isnan(m_curveViewCursor->y())) {
|
||||
KDSize cursorSize = m_cursorView->minimalSizeForOptimalDisplay();
|
||||
KDCoordinate xCursorPixelPosition = std::round(floatToPixel(Axis::Horizontal, m_curveViewCursor->x()));
|
||||
KDCoordinate yCursorPixelPosition = std::round(floatToPixel(Axis::Vertical, m_curveViewCursor->y()));
|
||||
cursorFrame = KDRect(xCursorPixelPosition - cursorSize().width()/2, yCursorPixelPosition - cursorSize().height()/2, cursorSize().width(), cursorSize().height());
|
||||
if (cursorSize().height() == 0) {
|
||||
cursorFrame = KDRect(xCursorPixelPosition - cursorSize.width()/2, yCursorPixelPosition - cursorSize.height()/2, cursorSize.width(), cursorSize.height());
|
||||
if (cursorSize.height() == 0) {
|
||||
KDCoordinate bannerHeight = m_bannerView != nullptr ? m_bannerView->minimalSizeForOptimalDisplay().height() : 0;
|
||||
cursorFrame = KDRect(xCursorPixelPosition - cursorSize().width()/2, 0, cursorSize().width(),bounds().height()-bannerHeight);
|
||||
cursorFrame = KDRect(xCursorPixelPosition - cursorSize.width()/2, 0, cursorSize.width(),bounds().height()-bannerHeight);
|
||||
}
|
||||
}
|
||||
return cursorFrame;
|
||||
|
||||
@@ -36,7 +36,6 @@ protected:
|
||||
constexpr static KDCoordinate k_labelGraduationLength = 6;
|
||||
constexpr static int k_maxNumberOfXLabels = CurveViewRange::k_maxNumberOfXGridUnits;
|
||||
constexpr static int k_maxNumberOfYLabels = CurveViewRange::k_maxNumberOfYGridUnits;
|
||||
constexpr static KDCoordinate k_cursorSize = 25;
|
||||
constexpr static int k_externRectMargin = 2;
|
||||
float pixelToFloat(Axis axis, KDCoordinate p) const;
|
||||
float floatToPixel(Axis axis, float f) const;
|
||||
@@ -54,7 +53,6 @@ protected:
|
||||
bool fillBar, KDColor defaultColor, KDColor highlightColor, float highlightLowerBound = INFINITY, float highlightUpperBound = -INFINITY) const;
|
||||
void computeLabels(Axis axis);
|
||||
void drawLabels(KDContext * ctx, KDRect rect, Axis axis, bool shiftOrigin) const;
|
||||
virtual KDSize cursorSize();
|
||||
View * m_bannerView;
|
||||
CurveViewCursor * m_curveViewCursor;
|
||||
private:
|
||||
|
||||
@@ -28,7 +28,6 @@ ViewController * FunctionGraphController::initialisationParameterController() {
|
||||
}
|
||||
|
||||
void FunctionGraphController::viewWillAppear() {
|
||||
functionGraphView()->setVerticalCursor(false);
|
||||
functionGraphView()->setCursorView(&m_cursorView);
|
||||
functionGraphView()->setBannerView(bannerView());
|
||||
functionGraphView()->setAreaHighlight(NAN,NAN);
|
||||
|
||||
@@ -10,7 +10,6 @@ FunctionGraphView::FunctionGraphView(InteractiveCurveViewRange * graphRange,
|
||||
CurveViewCursor * cursor, BannerView * bannerView, View * cursorView) :
|
||||
CurveView(graphRange, cursor, bannerView, cursorView),
|
||||
m_selectedFunction(nullptr),
|
||||
m_verticalCursor(false),
|
||||
m_highlightedStart(NAN),
|
||||
m_highlightedEnd(NAN),
|
||||
m_shouldColorHighlighted(false),
|
||||
@@ -44,10 +43,6 @@ void FunctionGraphView::selectFunction(Function * function) {
|
||||
}
|
||||
}
|
||||
|
||||
void FunctionGraphView::setVerticalCursor(bool verticalCursor) {
|
||||
m_verticalCursor = verticalCursor;
|
||||
}
|
||||
|
||||
void FunctionGraphView::setAreaHighlight(float start, float end) {
|
||||
if (m_highlightedStart != start || m_highlightedEnd != end) {
|
||||
float dirtyStart = start > m_highlightedStart ? m_highlightedStart : start;
|
||||
@@ -74,13 +69,6 @@ void FunctionGraphView::setAreaHighlightColor(bool highlightColor) {
|
||||
}
|
||||
}
|
||||
|
||||
KDSize FunctionGraphView::cursorSize() {
|
||||
if (m_verticalCursor) {
|
||||
return KDSize(1, 0);
|
||||
}
|
||||
return CurveView::cursorSize();
|
||||
}
|
||||
|
||||
char * FunctionGraphView::label(Axis axis, int index) const {
|
||||
return (axis == Axis::Horizontal ? (char *)m_xLabels[index] : (char *)m_yLabels[index]);
|
||||
}
|
||||
|
||||
@@ -17,18 +17,15 @@ public:
|
||||
void setContext(Poincare::Context * context);
|
||||
Poincare::Context * context() const;
|
||||
void selectFunction(Function * function);
|
||||
void setVerticalCursor(bool verticalCursor);
|
||||
void setAreaHighlight(float start, float end);
|
||||
virtual void setAreaHighlightColor(bool highlightColor);
|
||||
protected:
|
||||
void reloadBetweenBounds(float start, float end);
|
||||
Function * m_selectedFunction;
|
||||
bool m_verticalCursor;
|
||||
float m_highlightedStart;
|
||||
float m_highlightedEnd;
|
||||
bool m_shouldColorHighlighted;
|
||||
private:
|
||||
KDSize cursorSize() override;
|
||||
char * label(Axis axis, int index) const override;
|
||||
char m_xLabels[k_maxNumberOfXLabels][Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)];
|
||||
char m_yLabels[k_maxNumberOfYLabels][Poincare::PrintFloat::bufferSizeForFloatsWithPrecision(Constant::ShortNumberOfSignificantDigits)];
|
||||
|
||||
@@ -27,7 +27,6 @@ SumGraphController::SumGraphController(Responder * parentResponder, FunctionGrap
|
||||
|
||||
void SumGraphController::viewWillAppear() {
|
||||
m_graphRange->panToMakePointVisible(m_cursor->x(), m_cursor->y(), k_cursorTopMarginRatio, k_cursorRightMarginRatio, k_cursorBottomMarginRatio, k_cursorLeftMarginRatio);
|
||||
m_graphView->setVerticalCursor(true);
|
||||
m_graphView->setBannerView(&m_legendView);
|
||||
m_graphView->setCursorView(&m_cursorView);
|
||||
m_graphView->setOkView(nullptr);
|
||||
|
||||
@@ -7,4 +7,8 @@ void VerticalCursorView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(KDRect(0, 0, 1, height), KDColorBlack);
|
||||
}
|
||||
|
||||
KDSize VerticalCursorView::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ class VerticalCursorView : public View {
|
||||
public:
|
||||
using View::View;
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user