From c7942adb8f0c74f409a0f99063170ba75bfb0ba7 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Mon, 7 Nov 2016 13:45:55 +0100 Subject: [PATCH] - listframe: allow round borders --- src/gui/widget/listframe.cpp | 51 ++++++++++++++++++++---------------- src/gui/widget/listframe.h | 7 +++++ 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 01cbcd52c..b2a0028d4 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -190,9 +190,11 @@ void CListFrame::initVar(void) m_nCurrentPage = 0; m_nSelectedLine = 0; + m_nBgRadius = RADIUS_NONE; + m_cFrame.iX = frameBuffer->getScreenX() + ((frameBuffer->getScreenWidth() - MIN_WINDOW_WIDTH) >>1); - m_cFrame.iWidth = MIN_WINDOW_WIDTH; m_cFrame.iY = frameBuffer->getScreenY() + ((frameBuffer->getScreenHeight() - MIN_WINDOW_HEIGHT) >>1); + m_cFrame.iWidth = MIN_WINDOW_WIDTH; m_cFrame.iHeight = MIN_WINDOW_HEIGHT; m_nMaxHeight = MAX_WINDOW_HEIGHT; @@ -236,8 +238,8 @@ void CListFrame::initFramesRel(void) if(m_nMode & TITLE) { - m_cFrameTitleRel.iX = 0; - m_cFrameTitleRel.iY = 0; + m_cFrameTitleRel.iX = 0; + m_cFrameTitleRel.iY = 0; m_cFrameTitleRel.iHeight = m_nFontTitleHeight +2 ; m_cFrameTitleRel.iWidth = m_cFrame.iWidth ; } @@ -245,44 +247,44 @@ void CListFrame::initFramesRel(void) { m_cFrameTitleRel.iX = 0; m_cFrameTitleRel.iY = 0; - m_cFrameTitleRel.iHeight= 0; - m_cFrameTitleRel.iWidth = 0; + m_cFrameTitleRel.iHeight = 0; + m_cFrameTitleRel.iWidth = 0; } if(m_nMode & HEADER_LINE) { - m_cFrameHeaderListRel.iX = 0; - m_cFrameHeaderListRel.iY = 0 + m_cFrameTitleRel.iHeight; + m_cFrameHeaderListRel.iX = 0; + m_cFrameHeaderListRel.iY = 0 + m_cFrameTitleRel.iHeight; m_cFrameHeaderListRel.iHeight = m_nFontHeaderListHeight ; } else { - m_cFrameHeaderListRel.iX = 0; - m_cFrameHeaderListRel.iY = 0; + m_cFrameHeaderListRel.iX = 0; + m_cFrameHeaderListRel.iY = 0; m_cFrameHeaderListRel.iHeight = 0; m_cFrameHeaderListRel.iWidth = 0; } m_cFrameListRel.iX = 0; m_cFrameListRel.iY = m_cFrameHeaderListRel.iHeight + m_cFrameTitleRel.iHeight; - m_cFrameListRel.iHeight = m_cFrame.iHeight - m_cFrameHeaderListRel.iHeight - m_cFrameTitleRel.iHeight; + m_cFrameListRel.iHeight = m_cFrame.iHeight - m_cFrameHeaderListRel.iHeight - m_cFrameTitleRel.iHeight; if(m_nMode & SCROLL) { m_cFrameScrollRel.iX = m_cFrame.iWidth - SCROLL_FRAME_WIDTH; m_cFrameScrollRel.iY = m_cFrameTitleRel.iHeight; m_cFrameScrollRel.iWidth = SCROLL_FRAME_WIDTH; - m_cFrameScrollRel.iHeight = m_cFrameListRel.iHeight + m_cFrameHeaderListRel.iHeight; + m_cFrameScrollRel.iHeight = m_cFrameHeaderListRel.iHeight + m_cFrameListRel.iHeight - m_nBgRadius; } else { m_cFrameScrollRel.iX = 0; m_cFrameScrollRel.iY = 0; - m_cFrameScrollRel.iHeight = 0; m_cFrameScrollRel.iWidth = 0; + m_cFrameScrollRel.iHeight = 0; } - m_cFrameListRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth; + m_cFrameListRel.iWidth = m_cFrame.iWidth - m_cFrameScrollRel.iWidth; if(m_nMode & HEADER_LINE) { @@ -354,7 +356,8 @@ void CListFrame::refreshTitle(void) if( frameBuffer == NULL) return; frameBuffer->paintBoxRel(m_cFrameTitleRel.iX+m_cFrame.iX, m_cFrameTitleRel.iY+m_cFrame.iY, - m_cFrameTitleRel.iWidth, m_cFrameTitleRel.iHeight, TITLE_BACKGROUND_COLOR); + m_cFrameTitleRel.iWidth, m_cFrameTitleRel.iHeight, TITLE_BACKGROUND_COLOR, + m_nBgRadius, CORNER_TOP); m_pcFontTitle->RenderString(m_cFrameTitleRel.iX + TEXT_BORDER_WIDTH + m_cFrame.iX, m_cFrameTitleRel.iY + m_cFrameTitleRel.iHeight + m_cFrame.iY, @@ -376,7 +379,8 @@ void CListFrame::refreshScroll(void) if (1) { frameBuffer->paintBoxRel(m_cFrameScrollRel.iX+m_cFrame.iX, m_cFrameScrollRel.iY+m_cFrame.iY, - m_cFrameScrollRel.iWidth, m_cFrameScrollRel.iHeight, COL_MENUCONTENT_PLUS_0); + m_cFrameScrollRel.iWidth, m_cFrameHeaderListRel.iHeight + m_cFrameListRel.iHeight, COL_MENUCONTENT_PLUS_0, + m_nBgRadius, CORNER_BOTTOM_RIGHT); } if (m_nNrOfPages > 1) @@ -408,16 +412,17 @@ int CListFrame::paintListIcon(int x, int y, int line) void CListFrame::refreshList(void) { //TRACE("[CListFrame]->refreshList: %d\r\n",m_nCurrentLine); - if( frameBuffer == NULL) return; - frameBuffer->paintBoxRel(m_cFrameListRel.iX+m_cFrame.iX, m_cFrameListRel.iY+m_cFrame.iY, - m_cFrameListRel.iWidth, m_cFrameListRel.iHeight, COL_MENUCONTENT_PLUS_0); - - if( m_nNrOfLines <= 0) + if (frameBuffer == NULL) return; - for(int line = m_nCurrentLine; - line < m_nNrOfLines && line < m_nCurrentLine + m_nLinesPerPage; - line++) + frameBuffer->paintBoxRel(m_cFrameListRel.iX+m_cFrame.iX, m_cFrameListRel.iY+m_cFrame.iY, + m_cFrameListRel.iWidth, m_cFrameListRel.iHeight, COL_MENUCONTENT_PLUS_0, + m_nBgRadius, CORNER_BOTTOM_LEFT); + + if (m_nNrOfLines <= 0) + return; + + for (int line = m_nCurrentLine; line < m_nNrOfLines && line < m_nCurrentLine + m_nLinesPerPage; line++) { refreshLine(line); } diff --git a/src/gui/widget/listframe.h b/src/gui/widget/listframe.h index 97fc72ca9..35332b4c9 100644 --- a/src/gui/widget/listframe.h +++ b/src/gui/widget/listframe.h @@ -104,6 +104,8 @@ class CListFrame int m_nCurrentPage; int m_nSelectedLine; + int m_nBgRadius; + bool m_showSelection; Font* m_pcFontTitle; @@ -141,6 +143,11 @@ class CListFrame bool setTitle(char* title); bool setSelectedLine(int selection); void setSelectedMarked(bool enable); + void setBackGroundRadius(const int radius) + { + m_nBgRadius = radius; + initFramesRel(); + }; void clearMarked() { if (m_pLines)