]> git.vomp.tv Git - vompclient.git/commitdiff
WSelectList CWFs
authorChris Tallon <chris@vomp.tv>
Fri, 22 May 2020 15:13:16 +0000 (16:13 +0100)
committerChris Tallon <chris@vomp.tv>
Fri, 22 May 2020 15:13:16 +0000 (16:13 +0100)
osdopenvg.cc
wselectlist.cc
wselectlist.h

index 290fd1c0cbb056af4162407ec3c9a34f431016e8..b5a7c03e0f9509b2b0e1d402ba487b1b33a69955 100644 (file)
@@ -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)
       {
index 1eaff37bdffe67aa571e435df73eaf24b1bc5fac..6367e6b4abdf6651bbc4e60edaf1d3079bd675c9 100644 (file)
@@ -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<int>(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<int>(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<UINT>(static_cast<float>(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<UINT>(static_cast<float>(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<float>(ypos) + (linesPerOption - floor(linesPerOption)) * static_cast<float>(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<float>(xpos), static_cast<float>(ypos), static_cast<float>(imagewidth),
+                static_cast<float>(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<int>(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<int>(options.size()) - 1))
   {
     selectedOption++;
   }
@@ -227,7 +224,7 @@ void WSelectList::pageUp()
 
 void WSelectList::pageDown()
 {
-  if ((topOption + numOptionsDisplayable) >= options.size())
+  if ((topOption + numOptionsDisplayable) >= static_cast<int>(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<int>(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<int>(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<int>(static_cast<float>(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<int>(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<int>(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<UINT>(topOption - 1)) topOption--;
+  if (selectedOption == (topOption - 1)) topOption--;
   // if still not visible...
-  if ((selectedOption < static_cast<UINT>(topOption)) || (selectedOption > (topOption + numOptionsDisplayable)))
+  if ((selectedOption < topOption) || (selectedOption > (topOption + numOptionsDisplayable)))
   {
     topOption = selectedOption - (numOptionsDisplayable / 2);
   }
index 4643ea474c2659335a19b414876a75b9649a1d79..526a438e5718f3e2ae17b83b65be6b21363dfad1 100644 (file)
@@ -74,9 +74,9 @@ class WSelectList : public Boxx
 
     DrawStyle backgroundColour;
     std::vector<wsloption> options;
-    UINT selectedOption{};
+    int selectedOption{};
     int topOption{};
-    UINT numOptionsDisplayable{};
+    int numOptionsDisplayable{};
     int columns[10];
     int numColumns{};
     int noLoop{};