Advertisement
svenhoefer

Untitled

Apr 5th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.18 KB | None | 0 0
  1. diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp
  2. index 41e7af0..3dcaa1f 100644
  3. --- a/src/gui/channellist.cpp
  4. +++ b/src/gui/channellist.cpp
  5. @@ -103,6 +103,33 @@ static CComponentsChannelLogoScalable* CChannelLogo = NULL;
  6.  static CComponentsHeader *header = NULL;
  7.  extern bool timeset;
  8.  
  9. +enum
  10. +{
  11. +   ICON_RECORD = 0,
  12. +   ICON_TIMESHIFT,
  13. +   ICON_PIP,
  14. +   ICON_STREAMING,
  15. +   ICON_SCRAMBLED,
  16. +   STATUS_ICONS_MAX
  17. +};
  18. +
  19. +struct status_icons
  20. +{
  21. +   const char * name;
  22. +   int width;
  23. +   int height;
  24. +   bool active;
  25. +};
  26. +
  27. +static struct status_icons status_icon[]=
  28. +{
  29. +   {NEUTRINO_ICON_REC        , 0, 0, false},
  30. +   {NEUTRINO_ICON_AUTO_SHIFT , 0, 0, false},
  31. +   {NEUTRINO_ICON_PIP        , 0, 0, false},
  32. +   {NEUTRINO_ICON_STREAMING  , 0, 0, false},
  33. +   {NEUTRINO_ICON_SCRAMBLED  , 0, 0, false}
  34. +};
  35. +
  36.  CChannelList::CChannelList(const char * const pName, bool phistoryMode, bool _vlist)
  37.  {
  38.     frameBuffer = CFrameBuffer::getInstance();
  39. @@ -530,6 +557,51 @@ void CChannelList::calcSize()
  40.     else
  41.         pig_height = 0;
  42.     infozone_height = height - theight - pig_height - footerHeight;
  43. +
  44. +   // reset/init status icons struct
  45. +   for (int i = 0; i < STATUS_ICONS_MAX; i++)
  46. +   {
  47. +       frameBuffer->getIconSize(status_icon[i].name, &status_icon[i].width, &status_icon[i].height);
  48. +       status_icon[i].active = false;
  49. +   }
  50. +
  51. +   /*
  52. +      Check for any record, timeshift, pip, webtv or scrabled channel in
  53. +      this list.
  54. +
  55. +      This is to get the same space on the right side of whole list for a
  56. +      smoother view.
  57. +
  58. +      We have 5 icons in 3 'sections'. From left to right these are:
  59. +
  60. +      * record or timeshift
  61. +      * pip
  62. +      * streaming or scrabled
  63. +   */
  64. +   status_icons_space = 0;
  65. +   for (uint32_t i = 0; i < (*chanlist).size(); i++)
  66. +   {
  67. +       int space = 0;
  68. +
  69. +       if (CRecordManager::getInstance()->GetRecordMode((*chanlist)[i]->getChannelID()))
  70. +       {
  71. +           space += max(status_icon[ICON_RECORD].width, status_icon[ICON_TIMESHIFT].width) + OFFSET_INNER_MID;
  72. +       }
  73. +
  74. +#ifdef ENABLE_PIP
  75. +       if ((*chanlist)[i]->getChannelID() == CZapit::getInstance()->GetPipChannelID())
  76. +       {
  77. +           space += status_icon[ICON_PIP].width + OFFSET_INNER_MID;
  78. +       }
  79. +#endif
  80. +
  81. +       if (!(*chanlist)[i]->getUrl().empty() || (*chanlist)[i]->scrambled)
  82. +       {
  83. +           space += max(status_icon[ICON_STREAMING].width, status_icon[ICON_SCRAMBLED].width) + OFFSET_INNER_MID;
  84. +       }
  85. +
  86. +       status_icons_space = std::max(status_icons_space, space);
  87. +   }
  88.  }
  89.  
  90.  bool CChannelList::updateSelection(int newpos)
  91. @@ -1919,7 +1991,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint)
  92.         CZapitChannel* chan = (*chanlist)[curr];
  93.         int prg_offset = 0;
  94.         int title_offset = 0;
  95. -       int rec_mode;
  96. +
  97.         if(g_settings.theme.progressbar_design_channellist != CProgressBar::PB_OFF)
  98.         {
  99.             prg_offset = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("00:00");
  100. @@ -1934,75 +2006,42 @@ void CChannelList::paintItem(int pos, const bool firstpaint)
  101.         else
  102.             p_event = &chan->currentEvent;
  103.  
  104. -       //record check
  105. -       rec_mode = CRecordManager::getInstance()->GetRecordMode((*chanlist)[curr]->getChannelID());
  106. +       // reset active status icons
  107. +       for (int i = 0; i < STATUS_ICONS_MAX; i++)
  108. +           status_icon[i].active = false;
  109. +
  110. +       // record check
  111. +       int record_mode = CRecordManager::getInstance()->GetRecordMode((*chanlist)[curr]->getChannelID());
  112.  
  113. -       //set recording icon
  114. -       const char *record_icon = NULL;
  115. -       if (rec_mode & CRecordManager::RECMODE_REC)
  116. -           record_icon = NEUTRINO_ICON_REC;
  117. -       else if (rec_mode & CRecordManager::RECMODE_TSHIFT)
  118. -           record_icon = NEUTRINO_ICON_AUTO_SHIFT;
  119. +       // activate record/timeshift icon
  120. +       if (record_mode & CRecordManager::RECMODE_REC)
  121. +           status_icon[ICON_RECORD].active = true;
  122. +       else if (record_mode & CRecordManager::RECMODE_TSHIFT)
  123. +           status_icon[ICON_TIMESHIFT].active = true;
  124.  
  125. -       //set pip icon
  126. -       const char *pip_icon = NULL;
  127.  #ifdef ENABLE_PIP
  128. +       // activate pip icon
  129.         if ((*chanlist)[curr]->getChannelID() == CZapit::getInstance()->GetPipChannelID())
  130. -           pip_icon = NEUTRINO_ICON_PIP;
  131. +           status_icon[ICON_PIP].active = true;
  132.  #endif
  133.  
  134. -       //set webtv icon
  135. -       const char *webtv_icon = NULL;
  136. +       // activate webtv icon
  137.         if (!chan->getUrl().empty())
  138. -           webtv_icon = NEUTRINO_ICON_STREAMING;
  139. +           status_icon[ICON_STREAMING].active = true;
  140.  
  141. -       //set scramble icon
  142. -       const char *scramble_icon = NULL;
  143. +       // activate scramble icon
  144.         if (chan->scrambled)
  145. -           scramble_icon = NEUTRINO_ICON_SCRAMBLED;
  146. +           status_icon[ICON_SCRAMBLED].active = true;
  147.  
  148. -       //calculate and paint right status icons
  149. -       int icon_w = 0;
  150. -       int icon_h = 0;
  151. -       int offset_right = OFFSET_INNER_MID;
  152. -       int icon_x_right = x + width - 15 - offset_right;
  153. -
  154. -       if (scramble_icon)
  155. -       {
  156. -           frameBuffer->getIconSize(scramble_icon, &icon_w, &icon_h);
  157. -           if (frameBuffer->paintIcon(scramble_icon, icon_x_right - icon_w, ypos, fheight))
  158. -           {
  159. -               offset_right += icon_w + OFFSET_INNER_MID;
  160. -               icon_x_right -= icon_w + OFFSET_INNER_MID;
  161. -           }
  162. -       }
  163. +       // calculate and paint right status icons
  164. +       int icon_x_right = x + width - 15 - OFFSET_INNER_MID;
  165.  
  166. -       if (webtv_icon)
  167. +       for (int i = STATUS_ICONS_MAX - 1; i >= 0; i--)
  168.         {
  169. -           frameBuffer->getIconSize(webtv_icon, &icon_w, &icon_h);
  170. -           if (frameBuffer->paintIcon(webtv_icon, icon_x_right - icon_w, ypos, fheight))
  171. +           if (status_icon[i].active)
  172.             {
  173. -               offset_right += icon_w + OFFSET_INNER_MID;
  174. -               icon_x_right -= icon_w + OFFSET_INNER_MID;
  175. -           }
  176. -       }
  177. -
  178. -       if (pip_icon)
  179. -       {
  180. -           frameBuffer->getIconSize(pip_icon, &icon_w, &icon_h);
  181. -           if (frameBuffer->paintIcon(pip_icon, icon_x_right - icon_w, ypos, fheight))
  182. -           {
  183. -               offset_right += icon_w + OFFSET_INNER_MID;
  184. -               icon_x_right -= icon_w + OFFSET_INNER_MID;
  185. -           }
  186. -       }
  187. -
  188. -       if (record_icon)
  189. -       {
  190. -           frameBuffer->getIconSize(record_icon, &icon_w, &icon_h);
  191. -           if (frameBuffer->paintIcon(record_icon, icon_x_right - icon_w, ypos, fheight))
  192. -           {
  193. -               offset_right += icon_w + OFFSET_INNER_MID;
  194. +               if (frameBuffer->paintIcon(status_icon[i].name, icon_x_right - status_icon[i].width, ypos, fheight))
  195. +                   icon_x_right -= status_icon[i].width + OFFSET_INNER_MID;
  196.             }
  197.         }
  198.  
  199. @@ -2011,6 +2050,8 @@ void CChannelList::paintItem(int pos, const bool firstpaint)
  200.             paintButtonBar(is_available);
  201.  
  202.         //channel numbers
  203. +       int icon_w = 0;
  204. +       int icon_h = 0;
  205.         if (curr == selected && move_state == beMoving)
  206.         {
  207.             frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_YELLOW, &icon_w, &icon_h);
  208. @@ -2060,7 +2101,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint)
  209.             unsigned int ch_name_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(nameAndDescription);
  210.             unsigned int ch_desc_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(p_event->description);
  211.  
  212. -           int max_desc_len = width - numwidth - prg_offset - ch_name_len - 15 - 2*OFFSET_INNER_MID - offset_right; // 15 = scrollbar
  213. +           int max_desc_len = width - numwidth - prg_offset - ch_name_len - 15 - 3*OFFSET_INNER_MID - status_icons_space; // 15 = scrollbar
  214.  
  215.             if (max_desc_len < 0)
  216.                 max_desc_len = 0;
  217. @@ -2093,7 +2134,7 @@ void CChannelList::paintItem(int pos, const bool firstpaint)
  218.             g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + OFFSET_INNER_SMALL + numwidth + OFFSET_INNER_MID + prg_offset, ypos + fheight, width - numwidth - 4*OFFSET_INNER_MID - 15 - prg_offset, nameAndDescription, color);
  219.             if (g_settings.channellist_epgtext_align_right) {
  220.                 // align right
  221. -               g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + width - 15 - offset_right - ch_desc_len, ypos + fheight, ch_desc_len, p_event->description, ecolor);
  222. +               g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + width - 15 - OFFSET_INNER_MID - status_icons_space - ch_desc_len, ypos + fheight, ch_desc_len, p_event->description, ecolor);
  223.             }
  224.             else {
  225.                 // align left
  226. diff --git a/src/gui/channellist.h b/src/gui/channellist.h
  227. index f5addbe..4feb097 100644
  228. --- a/src/gui/channellist.h
  229. +++ b/src/gui/channellist.h
  230. @@ -118,6 +118,7 @@ private:
  231.     int         infozone_width;
  232.     int         infozone_height;
  233.     int         previous_channellist_additional;
  234. +   int         status_icons_space;
  235.  
  236.     int         paint_events_index;
  237.     sem_t           paint_events_sem;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement