diff --git a/radio/src/thirdparty/libopenui/.idea/codeStyles/Project.xml b/radio/src/thirdparty/libopenui/.idea/codeStyles/Project.xml new file mode 100644 index 000000000..efad3ce27 --- /dev/null +++ b/radio/src/thirdparty/libopenui/.idea/codeStyles/Project.xml @@ -0,0 +1,32 @@ + + + + \ No newline at end of file diff --git a/radio/src/thirdparty/libopenui/.idea/codeStyles/codeStyleConfig.xml b/radio/src/thirdparty/libopenui/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 000000000..79ee123c2 --- /dev/null +++ b/radio/src/thirdparty/libopenui/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp b/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp index 3c74f87fb..078ebdf7b 100755 --- a/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp +++ b/radio/src/thirdparty/libopenui/src/bitmapbuffer.cpp @@ -126,6 +126,57 @@ void BitmapBuffer::drawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat } } +void BitmapBuffer::drawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags flags) +{ + // Offsets + x1 += offsetX; + y1 += offsetY; + x2 += offsetX; + y2 += offsetY; + + pixel_t color = lcdColorTable[COLOR_IDX(flags)]; + + int dx = x2 - x1; /* the horizontal distance of the line */ + int dy = y2 - y1; /* the vertical distance of the line */ + int dxabs = abs(dx); + int dyabs = abs(dy); + int sdx = sgn(dx); + int sdy = sgn(dy); + int x = dyabs >> 1; + int y = dxabs >> 1; + int px = x1; + int py = y1; + + if (dxabs >= dyabs) { + /* the line is more horizontal than vertical */ + for (int i = 0; i <= dxabs; i++) { + if ((1 << (px % 8)) & pat) { + drawPixel(px, py, color); + } + y += dyabs; + if (y >= dxabs) { + y -= dxabs; + py += sdy; + } + px += sdx; + } + } + else { + /* the line is more vertical than horizontal */ + for (int i = 0; i <= dyabs; i++) { + if ((1 << (py % 8)) & pat) { + drawPixel(px, py, color); + } + x += dxabs; + if (x >= dyabs) { + x -= dyabs; + px += sdx; + } + py += sdy; + } + } +} + void BitmapBuffer::drawRect(coord_t x, coord_t y, coord_t w, coord_t h, uint8_t thickness, uint8_t pat, LcdFlags att) { for (int i=0; i void drawVerticalLine(coord_t x, coord_t y, coord_t h, uint8_t pat = SOLID, LcdFlags flags = 0); + void drawLine(coord_t x1, coord_t y1, coord_t x2, coord_t y2, uint8_t pat, LcdFlags att); + inline void drawSolidHorizontalLine(coord_t x, coord_t y, coord_t w, LcdFlags flags) { drawSolidFilledRect(x, y, w, 1, flags); diff --git a/radio/src/thirdparty/libopenui/src/libopenui_helpers.h b/radio/src/thirdparty/libopenui/src/libopenui_helpers.h index 640f05046..508dd1548 100644 --- a/radio/src/thirdparty/libopenui/src/libopenui_helpers.h +++ b/radio/src/thirdparty/libopenui/src/libopenui_helpers.h @@ -53,6 +53,12 @@ inline int divRoundClosest(const int n, const int d) return ((n < 0) ^ (d < 0)) ? ((n - d/2)/d) : ((n + d/2)/d); } +template +inline T sgn(T a) +{ + return a > 0 ? 1 : (a < 0 ? -1 : 0); +} + // TODO duplicated code inline std::string TEXT_AT_INDEX(const char * val, uint8_t idx) {