From a7ebc37b03ca2ef154191137b6548396485f1822 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 5 Apr 2015 08:50:01 -0600 Subject: [PATCH] Add a 'capped' boolean parameter to all drawline/drawLine functions/methods. The idea is that this will produce better joining between lines --- libnxwidgets/include/cbgwindow.hxx | 8 +++++--- libnxwidgets/include/cgraphicsport.hxx | 6 ++++-- libnxwidgets/include/cnxtkwindow.hxx | 8 +++++--- libnxwidgets/include/cnxtoolbar.hxx | 8 +++++--- libnxwidgets/include/cnxwindow.hxx | 7 +++++-- libnxwidgets/include/inxwindow.hxx | 8 +++++--- libnxwidgets/src/cbgwindow.cxx | 9 ++++++--- libnxwidgets/src/cgraphicsport.cxx | 18 ++++++++++-------- libnxwidgets/src/cnxtkwindow.cxx | 9 ++++++--- libnxwidgets/src/cnxtoolbar.cxx | 9 ++++++--- libnxwidgets/src/cnxwindow.cxx | 9 ++++++--- 11 files changed, 63 insertions(+), 36 deletions(-) diff --git a/libnxwidgets/include/cbgwindow.hxx b/libnxwidgets/include/cbgwindow.hxx index 90113cfe9..8a63633bd 100644 --- a/libnxwidgets/include/cbgwindow.hxx +++ b/libnxwidgets/include/cbgwindow.hxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/include/cbgwindow.hxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -285,13 +285,15 @@ namespace NXWidgets * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, - nxgl_mxpixel_t color); + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/cgraphicsport.hxx b/libnxwidgets/include/cgraphicsport.hxx index c5148c8bc..4d529c94d 100644 --- a/libnxwidgets/include/cgraphicsport.hxx +++ b/libnxwidgets/include/cgraphicsport.hxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/include/cgraphicsport.hxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -242,11 +242,13 @@ namespace NXWidgets * @param x2 The x coordinate of the end point of the line. * @param y2 The y coordinate of the end point of the line. * @param color The color of the line. + * @param capped Draw a circular cap both ends of the line to support + * better line joins */ void drawLine(nxgl_coord_t x1, nxgl_coord_t y1, nxgl_coord_t x2, nxgl_coord_t y2, - nxgl_mxpixel_t color); + nxgl_mxpixel_t color, bool capped); /** * Draw a filled rectangle of the specified start position, end position, diff --git a/libnxwidgets/include/cnxtkwindow.hxx b/libnxwidgets/include/cnxtkwindow.hxx index b20bc2a24..1ac801b95 100644 --- a/libnxwidgets/include/cnxtkwindow.hxx +++ b/libnxwidgets/include/cnxtkwindow.hxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/include/cnxtkwindow.hxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -306,13 +306,15 @@ namespace NXWidgets * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, - nxgl_mxpixel_t color); + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/cnxtoolbar.hxx b/libnxwidgets/include/cnxtoolbar.hxx index fd635b206..c7107678e 100644 --- a/libnxwidgets/include/cnxtoolbar.hxx +++ b/libnxwidgets/include/cnxtoolbar.hxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/include/cnxtoolbar.hxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -275,13 +275,15 @@ namespace NXWidgets * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to suppor + * better line joins * * @return True on success; false on failure. */ bool drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, - nxgl_mxpixel_t color); + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/cnxwindow.hxx b/libnxwidgets/include/cnxwindow.hxx index 98f89acc0..21a077954 100644 --- a/libnxwidgets/include/cnxwindow.hxx +++ b/libnxwidgets/include/cnxwindow.hxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/include/cnxwindow.hxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -279,12 +279,15 @@ namespace NXWidgets * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color); + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/inxwindow.hxx b/libnxwidgets/include/inxwindow.hxx index 3e2f6c4a1..23b99fe90 100644 --- a/libnxwidgets/include/inxwindow.hxx +++ b/libnxwidgets/include/inxwindow.hxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/include/inxwindow.hxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -249,13 +249,15 @@ namespace NXWidgets * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ virtual bool drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, - nxgl_mxpixel_t color) = 0; + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped) = 0; /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/src/cbgwindow.cxx b/libnxwidgets/src/cbgwindow.cxx index 2cb3d2389..979cb3aeb 100644 --- a/libnxwidgets/src/cbgwindow.cxx +++ b/libnxwidgets/src/cbgwindow.cxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/src/cbgwindow.cxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -308,16 +308,19 @@ bool CBgWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool CBgWindow::drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color) + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped) { // Draw a line with the specified color - return nx_drawline(m_hWindow, vector, width, &color) == OK; + return nx_drawline(m_hWindow, vector, width, &color, capped) == OK; } /** diff --git a/libnxwidgets/src/cgraphicsport.cxx b/libnxwidgets/src/cgraphicsport.cxx index 5791ab773..d3fcdd3b5 100644 --- a/libnxwidgets/src/cgraphicsport.cxx +++ b/libnxwidgets/src/cgraphicsport.cxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/src/cgraphicsport.cxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -241,16 +241,18 @@ void CGraphicsPort::drawVertLine(nxgl_coord_t x, nxgl_coord_t y, /** * Draw a line of a fixed color in the window. * - * @param x1 The x coordinate of the start point of the line. - * @param y1 The y coordinate of the start point of the line. - * @param x2 The x coordinate of the end point of the line. - * @param y2 The y coordinate of the end point of the line. - * @param color The color of the line. + * @param x1 - The x coordinate of the start point of the line. + * @param y1 - The y coordinate of the start point of the line. + * @param x2 - The x coordinate of the end point of the line. + * @param y2 - The y coordinate of the end point of the line. + * @param color - The color of the line. + * @param capped - Draw a circular cap both ends of the line to support + * - better line joins */ void CGraphicsPort::drawLine(nxgl_coord_t x1, nxgl_coord_t y1, nxgl_coord_t x2, nxgl_coord_t y2, - nxgl_mxpixel_t color) + nxgl_mxpixel_t color, bool capped) { struct nxgl_vector_s vector; @@ -259,7 +261,7 @@ void CGraphicsPort::drawLine(nxgl_coord_t x1, nxgl_coord_t y1, vector.pt2.x = x2; vector.pt2.y = y2; - if (!m_pNxWnd->drawLine(&vector, 1, color)) + if (!m_pNxWnd->drawLine(&vector, 1, color, capped)) { gdbg("INxWindow::drawLine failed\n"); } diff --git a/libnxwidgets/src/cnxtkwindow.cxx b/libnxwidgets/src/cnxtkwindow.cxx index 57ca5eb2b..14e07dbbb 100644 --- a/libnxwidgets/src/cnxtkwindow.cxx +++ b/libnxwidgets/src/cnxtkwindow.cxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/src/cnxtkwindow.cxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -442,16 +442,19 @@ bool CNxTkWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool CNxTkWindow::drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color) + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped) { // Draw a line with the specified color - return nxtk_drawlinewindow(m_hNxTkWindow, vector, width, &color) == OK; + return nxtk_drawlinewindow(m_hNxTkWindow, vector, width, &color, capped) == OK; } /** diff --git a/libnxwidgets/src/cnxtoolbar.cxx b/libnxwidgets/src/cnxtoolbar.cxx index 3c336f06a..01b72e32f 100644 --- a/libnxwidgets/src/cnxtoolbar.cxx +++ b/libnxwidgets/src/cnxtoolbar.cxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/src/cnxtoolbar.cxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -313,16 +313,19 @@ bool CNxToolbar::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool CNxToolbar::drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color) + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped) { // Draw a line with the specified color - return nxtk_drawlinetoolbar(m_hNxTkWindow, vector, width, &color) == OK; + return nxtk_drawlinetoolbar(m_hNxTkWindow, vector, width, &color, capped) == OK; } /** diff --git a/libnxwidgets/src/cnxwindow.cxx b/libnxwidgets/src/cnxwindow.cxx index 046660774..c600ecd1b 100644 --- a/libnxwidgets/src/cnxwindow.cxx +++ b/libnxwidgets/src/cnxwindow.cxx @@ -1,7 +1,7 @@ /**************************************************************************** * NxWidgets/libnxwidgets/src/cnxwindow.cxx * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -286,16 +286,19 @@ bool CNxWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, * @param vector - Describes the line to be drawn * @param width - The width of the line * @param color - The color to use to fill the line + * @param capped - Draw a circular cap both ends of the line to support + * better line joins * * @return True on success; false on failure. */ bool CNxWindow::drawLine(FAR struct nxgl_vector_s *vector, - nxgl_coord_t width, nxgl_mxpixel_t color) + nxgl_coord_t width, nxgl_mxpixel_t color, + bool capped) { // Draw a line with the specified color - return nx_drawline(m_hNxWindow, vector, width, &color) == OK; + return nx_drawline(m_hNxWindow, vector, width, &color, capped) == OK; } /**