From cb4eb743fb436994434b0f05e517e33b4bc50e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 5 Dec 2016 14:43:38 +0100 Subject: [PATCH] [apps] clean Change-Id: I0f1709c1559109628ffe0f21a0b29751cfca46aa --- apps/graph/graph/graph_view.cpp | 84 ------------------------- apps/graph/graph/graph_view.h | 23 +------ apps/graph/values/values_controller.cpp | 1 - 3 files changed, 1 insertion(+), 107 deletions(-) diff --git a/apps/graph/graph/graph_view.cpp b/apps/graph/graph/graph_view.cpp index f9f96cf38..cca068b4a 100644 --- a/apps/graph/graph/graph_view.cpp +++ b/apps/graph/graph/graph_view.cpp @@ -10,11 +10,7 @@ constexpr KDColor GraphView::k_axisColor; constexpr KDColor GraphView::k_gridColor; GraphView::GraphView(FunctionStore * functionStore, AxisInterval * axisInterval) : -#if GRAPH_VIEW_IS_TILED - TiledView(), -#else View(), -#endif m_cursorView(CursorView()), m_xCursorPosition(-1.0f), m_yCursorPosition(-1.0f), @@ -234,41 +230,11 @@ void GraphView::layoutSubviews() { } } -#if GRAPH_VIEW_IS_TILED -KDColor * GraphView::tile() const { - return (KDColor *)m_tile; -} - -KDSize GraphView::tileSize() const { - return {kTileWidth, kTileHeight}; -} - -void GraphView::drawTile(KDContext * ctx, KDRect rect) const { -#else void GraphView::drawRect(KDContext * ctx, KDRect rect) const { -#endif ctx->fillRect(rect, KDColorWhite); drawGrid(ctx, rect); drawAxes(ctx, rect); drawFunction(ctx, rect); - /* - - constexpr int maskLength = 3; - uint8_t mask[maskLength] = { -#if 1 - 0x10, 0x70, 0xE0, -#else - 0x00, 0x30, 0x73, 0x30, 0x00, - 0x30, 0xfb, 0xff, 0xfb, 0x30, - 0x73, 0xff, 0xff, 0xff, 0x73, - 0x30, 0xfb, 0xff, 0xfb, 0x30, - 0x00, 0x30, 0x73, 0x30, 0x00 -#endif - }; - - KDColor red = KDColorRed; - KDBlitRect(rect, &red, 1, mask, maskLength); - */ } void GraphView::drawLine(KDContext * ctx, KDRect rect, Axis axis, float coordinate, KDColor color, KDCoordinate thickness) const { @@ -458,54 +424,4 @@ void GraphView::straightJoinDots(float pxf, float pyf, float puf, float pvf, KDC straightJoinDots(puf, pvf, pxf, pyf, color, ctx); } -#if 0 - -void GraphView::drawFunction(KDRect rect) const { - /* Naive algorithm: iterate on pixels horizontally - * Actually, this is kinda optimal. If two consecutive pixels don't touch - * (i.e. they have a y-difference greater than 1), just draw a vertical line. - * This may seem stupid but is kinda good actually. */ - KDCoordinate previousPixelY; - KDCoordinate pixelX; - - KDColor curveColor = KDColorRGB(0xFF, 0, 0); -#define ANTI_ALIASING -#ifdef ANTI_ALIASING - KDColor antiAliasingColor = KDColorRGB(0, 0xFF, 0); -#endif - - for (pixelX=rect.x; pixelX<(rect.x+rect.width); pixelX++) { - float x = pixelToFloat(Axis::Horizontal, pixelX); - float y = (x-1)*(x+1)*x; - KDCoordinate pixelY = floatToPixel(Axis::Vertical, y); - KDRect r; - r.x = pixelX; - if (pixelY < previousPixelY) { - r.y = pixelY; - r.height = previousPixelY-pixelY; - KDPoint p; - p.x = pixelX-1; - p.y = previousPixelY+3; - KDSetPixel(p, KDColorRGB(0x00, 0xFF, 0x00)); - p.x = pixelX; - p.y = pixelY-1; - KDSetPixel(p, KDColorRGB(0x00, 0xFF, 0x00)); - } else { - r.y = previousPixelY; - r.height = pixelY - previousPixelY; - } - if (r.height == 0) { - r.height = 1; - } - r.width = 1; - - r.width += 2; - r.height += 2; - //KDFillRectWithPattern(r, antialiasedDot); - KDFillRect(r, KDColorRGB(0xFF, 0, 0)); - previousPixelY = pixelY; - } -} -#endif - } diff --git a/apps/graph/graph/graph_view.h b/apps/graph/graph/graph_view.h index 580f327eb..900e27821 100644 --- a/apps/graph/graph/graph_view.h +++ b/apps/graph/graph/graph_view.h @@ -7,27 +7,12 @@ #include "../function_store.h" #include "../evaluate_context.h" -#define GRAPH_VIEW_IS_TILED 0 - namespace Graph { -class GraphView : public -#if GRAPH_VIEW_IS_TILED - TiledView -#else - View -#endif -{ +class GraphView : public View { public: GraphView(FunctionStore * functionStore, AxisInterval * axisInterval); - -#if GRAPH_VIEW_IS_TILED - KDColor * tile() const override; - KDSize tileSize() const override; - void drawTile(KDContext * ctx, KDRect rect) const override; -#else void drawRect(KDContext * ctx, KDRect rect) const override; -#endif float xPixelCursorPosition(); float xCursorPosition(); @@ -78,12 +63,6 @@ private: void stampAtLocation(float pxf, float pyf, KDColor color, KDContext * ctx) const; int numberOfXLabels() const; int numberOfYLabels() const; -#if GRAPH_VIEW_IS_TILED - static constexpr KDCoordinate kTileWidth = 32; - static constexpr KDCoordinate kTileHeight = 32; - KDColor m_tile[kTileWidth*kTileHeight]; -#endif - CursorView m_cursorView; float m_xCursorPosition; float m_yCursorPosition; diff --git a/apps/graph/values/values_controller.cpp b/apps/graph/values/values_controller.cpp index 15566244b..b00612be0 100644 --- a/apps/graph/values/values_controller.cpp +++ b/apps/graph/values/values_controller.cpp @@ -252,7 +252,6 @@ void ValuesController::editValue(const char * initialText) { } } int cursorLocation = strlen(initialTextContent) + cursorDelta; - EditableValueCell * cell = (EditableValueCell *)m_selectableTableView.cellAtLocation(0, activeRow()); cell->setParentResponder(&m_selectableTableView); cell->editValue(initialTextContent, cursorLocation, this,