mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-28 10:09:53 +01:00
[apps/graph/graph] Improve cursor drawing
Change-Id: I6f8e29d107bac410bd502bf54b5f9b955ff9c9d7
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user