diff --git a/apps/graph/graph/cursor_view.cpp b/apps/graph/graph/cursor_view.cpp index 82fd2cda6..0f8830b99 100644 --- a/apps/graph/graph/cursor_view.cpp +++ b/apps/graph/graph/cursor_view.cpp @@ -3,7 +3,10 @@ namespace Graph { void CursorView::drawRect(KDContext * ctx, KDRect rect) const { - ctx->fillRect(rect, KDColorRed); + KDCoordinate width = bounds().width(); + KDCoordinate height = bounds().height(); + ctx->fillRect(KDRect(width/2, 0, 1, height), KDColorBlack); + ctx->fillRect(KDRect(0, height/2, width, 1), KDColorBlack); } } diff --git a/apps/graph/graph/graph_view.cpp b/apps/graph/graph/graph_view.cpp index 9f326ca2f..5b436c8df 100644 --- a/apps/graph/graph/graph_view.cpp +++ b/apps/graph/graph/graph_view.cpp @@ -28,25 +28,25 @@ int GraphView::numberOfSubviews() const { }; View * GraphView::subviewAtIndex(int index) { - if (index == 0) { - return &m_cursorView; - } - if (index <= numberOfXLabels()) { + if (index < numberOfXLabels()) { float step = m_axisInterval->xScale(); char buffer[Constant::FloatBufferSizeInScientificMode]; // TODO: change the number of digits in mantissa once the numerical mode is implemented - Float(2.0f*step*(ceilf(min(Axis::Horizontal)/(2.0f*step)))+(index-1)*2.0f*step).convertFloatToText(buffer, Constant::FloatBufferSizeInScientificMode, Constant::NumberOfDigitsInMantissaInScientificMode); - m_xLabels[index-1].setText(buffer); - return &m_xLabels[index-1]; + Float(2.0f*step*(ceilf(min(Axis::Horizontal)/(2.0f*step)))+index*2.0f*step).convertFloatToText(buffer, Constant::FloatBufferSizeInScientificMode, Constant::NumberOfDigitsInMantissaInScientificMode); + m_xLabels[index].setText(buffer); + return &m_xLabels[index]; } - if (index <= numberOfXLabels() + numberOfYLabels()) { + if (index < numberOfXLabels() + numberOfYLabels()) { float step = m_axisInterval->yScale(); char buffer[Constant::FloatBufferSizeInScientificMode]; - int newIndex = index - 1 - numberOfXLabels(); + int newIndex = index - numberOfXLabels(); Float(2.0f*step*(ceilf(min(Axis::Vertical)/(2.0f*step)))+newIndex*2.0f*step).convertFloatToText(buffer, Constant::FloatBufferSizeInScientificMode, Constant::NumberOfDigitsInMantissaInScientificMode); m_yLabels[newIndex].setText(buffer); return &m_yLabels[newIndex]; } + if (index == numberOfXLabels() + numberOfYLabels()) { + return &m_cursorView; + } assert(false); } @@ -142,7 +142,7 @@ Function * GraphView::moveCursorDown() { } void GraphView::layoutSubviews() { - KDRect cursorFrame(m_cursorPosition, 10, 10); + KDRect cursorFrame(m_cursorPosition.translatedBy(KDPoint(-k_cursorSize/2, -k_cursorSize/2)), k_cursorSize, k_cursorSize); m_cursorView.setFrame(cursorFrame); float step = m_axisInterval->xScale(); float start = 2.0f*step*(ceilf(min(Axis::Horizontal)/(2.0f*step))); diff --git a/apps/graph/graph/graph_view.h b/apps/graph/graph/graph_view.h index d833a04b3..e0785fed8 100644 --- a/apps/graph/graph/graph_view.h +++ b/apps/graph/graph/graph_view.h @@ -83,6 +83,7 @@ private: CursorView m_cursorView; KDPoint m_cursorPosition; int m_indexFunctionSelectedByCursor; + constexpr static KDCoordinate k_cursorSize = 10; constexpr static KDCoordinate k_labelWidth = 32; constexpr static KDCoordinate k_labelHeight = 12; constexpr static KDCoordinate k_labelMargin = 4;