From f6604c7e5c25fffd630ffbb661fca23e931d8e55 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 5 Apr 2015 16:53:51 -0600 Subject: [PATCH] drawline/drawLine should not take a boolean to select non lines caps or capping at both ends. drawline/drawLine also needs to be able to put a line cap on one one end of a line --- libnxwidgets/include/cbgwindow.hxx | 4 ++-- libnxwidgets/include/cgraphicsport.hxx | 4 ++-- libnxwidgets/include/cnxtkwindow.hxx | 4 ++-- libnxwidgets/include/cnxtoolbar.hxx | 4 ++-- libnxwidgets/include/cnxwindow.hxx | 4 ++-- libnxwidgets/include/inxwindow.hxx | 12 ++++++++++-- libnxwidgets/src/cbgwindow.cxx | 6 +++--- libnxwidgets/src/cgraphicsport.cxx | 6 +++--- libnxwidgets/src/cnxtkwindow.cxx | 6 +++--- libnxwidgets/src/cnxtoolbar.cxx | 6 +++--- libnxwidgets/src/cnxwindow.cxx | 6 +++--- 11 files changed, 35 insertions(+), 27 deletions(-) diff --git a/libnxwidgets/include/cbgwindow.hxx b/libnxwidgets/include/cbgwindow.hxx index 8a63633bd..41184e43e 100644 --- a/libnxwidgets/include/cbgwindow.hxx +++ b/libnxwidgets/include/cbgwindow.hxx @@ -285,7 +285,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -293,7 +293,7 @@ namespace NXWidgets bool drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped); + enum ELineCaps caps); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/cgraphicsport.hxx b/libnxwidgets/include/cgraphicsport.hxx index 4d529c94d..df250f478 100644 --- a/libnxwidgets/include/cgraphicsport.hxx +++ b/libnxwidgets/include/cgraphicsport.hxx @@ -242,13 +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 + * @param caps Draw a circular cap on the 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, bool capped); + nxgl_mxpixel_t color, enum INxWindow::ELineCaps caps); /** * Draw a filled rectangle of the specified start position, end position, diff --git a/libnxwidgets/include/cnxtkwindow.hxx b/libnxwidgets/include/cnxtkwindow.hxx index 1ac801b95..bf0af4ad0 100644 --- a/libnxwidgets/include/cnxtkwindow.hxx +++ b/libnxwidgets/include/cnxtkwindow.hxx @@ -306,7 +306,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -314,7 +314,7 @@ namespace NXWidgets bool drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped); + enum ELineCaps caps); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/cnxtoolbar.hxx b/libnxwidgets/include/cnxtoolbar.hxx index c7107678e..6d16bad3e 100644 --- a/libnxwidgets/include/cnxtoolbar.hxx +++ b/libnxwidgets/include/cnxtoolbar.hxx @@ -275,7 +275,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to suppor * better line joins * * @return True on success; false on failure. @@ -283,7 +283,7 @@ namespace NXWidgets bool drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped); + enum ELineCaps caps); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/cnxwindow.hxx b/libnxwidgets/include/cnxwindow.hxx index 21a077954..092c38c32 100644 --- a/libnxwidgets/include/cnxwindow.hxx +++ b/libnxwidgets/include/cnxwindow.hxx @@ -279,7 +279,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -287,7 +287,7 @@ namespace NXWidgets bool drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped); + enum ELineCaps caps); /** * Draw a filled circle at the specified position, size, and color. diff --git a/libnxwidgets/include/inxwindow.hxx b/libnxwidgets/include/inxwindow.hxx index 23b99fe90..95de31cd8 100644 --- a/libnxwidgets/include/inxwindow.hxx +++ b/libnxwidgets/include/inxwindow.hxx @@ -83,6 +83,14 @@ namespace NXWidgets class INxWindow { public: + enum ELineCaps + { + LINECAP_NONE = NX_LINECAP_NONE, // No line caps + LINECAP_PT1 = NX_LINECAP_PT1, // Line cap on pt1 of the vector only + LINECAP_PT2 = NX_LINECAP_PT2, // Line cap on pt2 of the vector only + LINECAP_BOTH = NX_LINECAP_BOTH // Line cap on both ends of the vector only + }; + /** * A virtual destructor is required in order to override the INxWindow * destructor. We do this because if we delete INxWindow, we want the @@ -249,7 +257,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -257,7 +265,7 @@ namespace NXWidgets virtual bool drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped) = 0; + enum ELineCaps caps) = 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 979cb3aeb..6c849aacf 100644 --- a/libnxwidgets/src/cbgwindow.cxx +++ b/libnxwidgets/src/cbgwindow.cxx @@ -308,7 +308,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -316,11 +316,11 @@ bool CBgWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, bool CBgWindow::drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped) + enum ELineCaps caps) { // Draw a line with the specified color - return nx_drawline(m_hWindow, vector, width, &color, capped) == OK; + return nx_drawline(m_hWindow, vector, width, &color, (uint8_t)caps) == OK; } /** diff --git a/libnxwidgets/src/cgraphicsport.cxx b/libnxwidgets/src/cgraphicsport.cxx index d3fcdd3b5..62e3a6eb0 100644 --- a/libnxwidgets/src/cgraphicsport.cxx +++ b/libnxwidgets/src/cgraphicsport.cxx @@ -246,13 +246,13 @@ void CGraphicsPort::drawVertLine(nxgl_coord_t x, nxgl_coord_t y, * @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 + * @param caps - Draw a circular cap one the 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, bool capped) + nxgl_mxpixel_t color, enum INxWindow::ELineCaps caps) { struct nxgl_vector_s vector; @@ -261,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, capped)) + if (!m_pNxWnd->drawLine(&vector, 1, color, caps)) { gdbg("INxWindow::drawLine failed\n"); } diff --git a/libnxwidgets/src/cnxtkwindow.cxx b/libnxwidgets/src/cnxtkwindow.cxx index 14e07dbbb..fecedbb5a 100644 --- a/libnxwidgets/src/cnxtkwindow.cxx +++ b/libnxwidgets/src/cnxtkwindow.cxx @@ -442,7 +442,7 @@ 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 + * @param caps - Draw a circular cap on both ends of the line to support * better line joins * * @return True on success; false on failure. @@ -450,11 +450,11 @@ bool CNxTkWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, bool CNxTkWindow::drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped) + enum ELineCaps caps) { // Draw a line with the specified color - return nxtk_drawlinewindow(m_hNxTkWindow, vector, width, &color, capped) == OK; + return nxtk_drawlinewindow(m_hNxTkWindow, vector, width, &color, (uint8_t)caps) == OK; } /** diff --git a/libnxwidgets/src/cnxtoolbar.cxx b/libnxwidgets/src/cnxtoolbar.cxx index 01b72e32f..3c4e22a32 100644 --- a/libnxwidgets/src/cnxtoolbar.cxx +++ b/libnxwidgets/src/cnxtoolbar.cxx @@ -313,7 +313,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -321,11 +321,11 @@ bool CNxToolbar::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, bool CNxToolbar::drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped) + enum ELineCaps caps) { // Draw a line with the specified color - return nxtk_drawlinetoolbar(m_hNxTkWindow, vector, width, &color, capped) == OK; + return nxtk_drawlinetoolbar(m_hNxTkWindow, vector, width, &color, (uint8_t)caps) == OK; } /** diff --git a/libnxwidgets/src/cnxwindow.cxx b/libnxwidgets/src/cnxwindow.cxx index c600ecd1b..ba558bac0 100644 --- a/libnxwidgets/src/cnxwindow.cxx +++ b/libnxwidgets/src/cnxwindow.cxx @@ -286,7 +286,7 @@ 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 + * @param caps - Draw a circular cap on the ends of the line to support * better line joins * * @return True on success; false on failure. @@ -294,11 +294,11 @@ bool CNxWindow::fillTrapezoid(FAR const struct nxgl_rect_s *pClip, bool CNxWindow::drawLine(FAR struct nxgl_vector_s *vector, nxgl_coord_t width, nxgl_mxpixel_t color, - bool capped) + enum ELineCaps caps) { // Draw a line with the specified color - return nx_drawline(m_hNxWindow, vector, width, &color, capped) == OK; + return nx_drawline(m_hNxWindow, vector, width, &color, (uint8_t)caps) == OK; } /**