[apps] Shared: Move part of the implementation of TermSumController to

shared (Integral Graph Controller) and improve bound edition in
TermSumController.
This commit is contained in:
Émilie Feral
2018-01-10 14:07:26 +01:00
committed by EmilieNumworks
parent 31afd260a4
commit 7ea0dbeb56
15 changed files with 506 additions and 356 deletions

View File

@@ -10,12 +10,29 @@ 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),
m_xLabels{},
m_yLabels{},
m_context(nullptr)
{
}
void FunctionGraphView::reload() {
CurveView::reload();
if (!std::isnan(m_highlightedStart)) {
float pixelLowerBound = floatToPixel(Axis::Horizontal, m_highlightedStart)-2.0;
float pixelUpperBound = floatToPixel(Axis::Horizontal, m_highlightedEnd)+4.0;
/* We exclude the banner frame from the dirty zone to avoid unnecessary
* redrawing */
KDRect dirtyZone(KDRect(pixelLowerBound, 0, pixelUpperBound-pixelLowerBound,
bounds().height()-m_bannerView->bounds().height()));
markRectAsDirty(dirtyZone);
}
}
void FunctionGraphView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, KDColorWhite);
drawGrid(ctx, rect);
@@ -41,6 +58,34 @@ 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) {
reload();
m_highlightedStart = start;
m_highlightedEnd = end;
reload();
}
}
void FunctionGraphView::setAreaHighlightColor(bool highlightColor) {
if (m_shouldColorHighlighted != highlightColor) {
reload();
m_shouldColorHighlighted = highlightColor;
reload();
}
}
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]);
}