From 6fc05745ab3b5e52caee69ecc426dd3e09123858 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 22 May 2020 16:13:16 +0100 Subject: [PATCH] WSelectList CWFs --- osdopenvg.cc | 4 ++-- wselectlist.cc | 47 ++++++++++++++++++++++------------------------- wselectlist.h | 4 ++-- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index 290fd1c..b5a7c03 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -504,8 +504,8 @@ void OsdOpenVG::renderLoop() if (ts != 0) { // OSDOVG-ROD-EXPERIMENT - // renderThreadCond.wait(ul, [this]{ return renderThreadReq != 0; }); // experiment! always wait, no time limit - renderThreadCond.wait_for(ul, std::chrono::milliseconds(ts), [this]{ return renderThreadReq != 0; }); + renderThreadCond.wait(ul, [this]{ return renderThreadReq != 0; }); // experiment! always wait, no time limit + //renderThreadCond.wait_for(ul, std::chrono::milliseconds(ts), [this]{ return renderThreadReq != 0; }); if (renderThreadReq == 2) { diff --git a/wselectlist.cc b/wselectlist.cc index 1eaff37..6367e6b 100644 --- a/wselectlist.cc +++ b/wselectlist.cc @@ -64,7 +64,7 @@ void WSelectList::setBackgroundColour(const DrawStyle& colour) void WSelectList::hintSetCurrent(int idx) { selectedOption = idx; - if (selectedOption >= options.size()) selectedOption = options.size() - 1; + if (selectedOption >= static_cast(options.size())) selectedOption = options.size() - 1; } void WSelectList::hintSetTop(int idx) @@ -94,36 +94,32 @@ void WSelectList::draw() numOptionsDisplayable = (area.h - 5) / ySeparation; if (selectedOption == (topOption + numOptionsDisplayable)) topOption++; - if (selectedOption == ((UINT)topOption - 1)) topOption--; + if (selectedOption == (topOption - 1)) topOption--; // if still not visible... - if ((selectedOption < (UINT)topOption) || (selectedOption > (topOption + numOptionsDisplayable))) + if ((selectedOption < topOption) || (selectedOption > (topOption + numOptionsDisplayable))) { topOption = selectedOption - (numOptionsDisplayable / 2); } if (topOption < 0) topOption = 0; - fillColour(backgroundColour); UINT ypos = 5; - for (UINT i = topOption; i < (topOption + numOptionsDisplayable); i++) + for (int i = topOption; i < (topOption + numOptionsDisplayable); i++) { - if (i == options.size()) return; + if (i == static_cast(options.size())) return; if ((ypos + ySeparation) > area.h) break; if (i == selectedOption && showseloption) { - - rectangle(0, ypos, area.w, (UINT)(fontHeight * linesPerOption-1), darkseloption ? DrawStyle::SELECTDARKHIGHLIGHT : DrawStyle::SELECTHIGHLIGHT); - + rectangle(0, ypos, area.w, static_cast(static_cast(fontHeight) * linesPerOption) - 1, darkseloption ? DrawStyle::SELECTDARKHIGHLIGHT : DrawStyle::SELECTHIGHLIGHT); drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::DARKTEXT, options[i].pict); } else { - rectangle(0, ypos, area.w, (UINT)(fontHeight * linesPerOption-1), DrawStyle::SELECTBACKGROUND); - - drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::LIGHTTEXT, options[i].pict); + rectangle(0, ypos, area.w, static_cast(static_cast(fontHeight) * linesPerOption) - 1, DrawStyle::SELECTBACKGROUND); + drawOptionLine(options[i].text, 5, ypos, area.w - 5, DrawStyle::LIGHTTEXT, options[i].pict); } ypos += ySeparation; } @@ -146,14 +142,15 @@ void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, cons UINT curline = 0; UINT taboffset = 0; int fontHeight = getFontHeight(); - float ypos_mod = ypos + (linesPerOption - floor(linesPerOption)) * ((float)fontHeight) * 0.5f; + float ypos_mod = static_cast(ypos) + (linesPerOption - floor(linesPerOption)) * static_cast(fontHeight) * 0.5f; int imagewidth = 0; int xposmod = xpos; if (numColumns > 1) imagewidth = columns[1] - columns[0]; if (pict) { - drawTVMedia(*pict, xpos, ypos, imagewidth, fontHeight * linesPerOption, TopLeftLimited); + drawTVMedia(*pict, static_cast(xpos), static_cast(ypos), static_cast(imagewidth), + static_cast(fontHeight) * linesPerOption, TopLeftLimited); taboffset++; xposmod += xpos; } @@ -173,7 +170,7 @@ void WSelectList::drawOptionLine(char* text, int xpos, int ypos, int width, cons pointer = STRTOKR(buffer, "\t\n", &savepointer); while(pointer) { - drawText(pointer, xposmod + columns[currentColumn], (int)(ypos_mod + curline * fontHeight), width - columns[currentColumn], colour); + drawText(pointer, xposmod + columns[currentColumn], (fontHeight * curline) + static_cast(ypos_mod), width - columns[currentColumn], colour); pointer = STRTOKR(NULL, "\t\n", &savepointer); if (pointer) @@ -207,7 +204,7 @@ void WSelectList::up() void WSelectList::down() { - if (selectedOption < options.size() - 1) + if (selectedOption < (static_cast(options.size()) - 1)) { selectedOption++; } @@ -227,7 +224,7 @@ void WSelectList::pageUp() void WSelectList::pageDown() { - if ((topOption + numOptionsDisplayable) >= options.size()) + if ((topOption + numOptionsDisplayable) >= static_cast(options.size())) { selectedOption = options.size() - 1; } @@ -288,7 +285,7 @@ bool WSelectList::mouseAndroidScroll(int /* x */, int /* y */, int /* sx */, int bool WSelectList::mouseMove(int x, int y) { int ml = getMouseLine(x - getRootBoxOffsetX(), y - getRootBoxOffsetY()); - if (ml >= 0 && ml != static_cast(selectedOption)) + if (ml >= 0 && ml != selectedOption) { selectedOption = ml; return true; @@ -299,7 +296,7 @@ bool WSelectList::mouseMove(int x, int y) bool WSelectList::mouseLBDOWN(int x, int y) { int ml = getMouseLine(x - getRootBoxOffsetX(), y - getRootBoxOffsetY()); - if (ml == static_cast(selectedOption)) + if (ml == selectedOption) { /* caller should generate a OK message*/ return true; @@ -307,25 +304,25 @@ bool WSelectList::mouseLBDOWN(int x, int y) return false; } -int WSelectList::getMouseLine(int x,int y) +int WSelectList::getMouseLine(int x, int y) { int fontHeight = getFontHeight(); int ySeparation = static_cast(static_cast(fontHeight) * linesPerOption) + gap; if (y < 0) return -1; - if (x < 0 || x > (int)area.w) return -1; - if (y > (int)(10 + numOptionsDisplayable * ySeparation)) return -1; + if (x < 0 || x > static_cast(area.w)) return -1; + if (y > (10 + numOptionsDisplayable * ySeparation)) return -1; int cy = y - 5; int selected = cy / ySeparation; if (y < 5) selected = -1; - if (selected > static_cast(numOptionsDisplayable)) return -1; + if (selected > numOptionsDisplayable) return -1; /* Important: should be the same algorithm used in draw! */ if (selectedOption == (topOption + numOptionsDisplayable)) topOption++; - if (selectedOption == static_cast(topOption - 1)) topOption--; + if (selectedOption == (topOption - 1)) topOption--; // if still not visible... - if ((selectedOption < static_cast(topOption)) || (selectedOption > (topOption + numOptionsDisplayable))) + if ((selectedOption < topOption) || (selectedOption > (topOption + numOptionsDisplayable))) { topOption = selectedOption - (numOptionsDisplayable / 2); } diff --git a/wselectlist.h b/wselectlist.h index 4643ea4..526a438 100644 --- a/wselectlist.h +++ b/wselectlist.h @@ -74,9 +74,9 @@ class WSelectList : public Boxx DrawStyle backgroundColour; std::vector options; - UINT selectedOption{}; + int selectedOption{}; int topOption{}; - UINT numOptionsDisplayable{}; + int numOptionsDisplayable{}; int columns[10]; int numColumns{}; int noLoop{}; -- 2.39.2