Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 11th, 2010  |  syntax: None  |  size: 6.35 KB  |  views: 131  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Index: apps/gui/skin_engine/skin_parser.c
  2. ===================================================================
  3. --- apps/gui/skin_engine/skin_parser.c  (revision 25508)
  4. +++ apps/gui/skin_engine/skin_parser.c  (working copy)
  5. @@ -322,7 +322,8 @@
  6.      { WPS_TOKEN_PROGRESSBAR,              "pb",  WPS_REFRESH_PLAYER_PROGRESS,
  7.                                                           parse_progressbar },
  8.  
  9. -    { WPS_TOKEN_VOLUME,                   "pv",  WPS_REFRESH_DYNAMIC, NULL },
  10. +    { WPS_TOKEN_VOLUME,                   "pv",  WPS_REFRESH_DYNAMIC,
  11. +                                                         parse_progressbar },
  12.  
  13.      { WPS_TOKEN_TRACK_ELAPSED_PERCENT,    "px",  WPS_REFRESH_DYNAMIC, NULL },
  14.      { WPS_TOKEN_TRACK_TIME_ELAPSED,       "pc",  WPS_REFRESH_DYNAMIC, NULL },
  15. @@ -900,7 +901,6 @@
  16.      /* %Vl|<label>|<rest of tags>| */
  17.      skin_vp->hidden_flags = 0;
  18.      skin_vp->label = VP_NO_LABEL;
  19. -    skin_vp->pb = NULL;
  20.      skin_vp->lines  = NULL;
  21.      if (curr_line)
  22.      {
  23. @@ -1118,7 +1118,7 @@
  24.  
  25.      return skip;
  26.  }
  27. -
  28. +  
  29.  static int parse_progressbar(const char *wps_bufptr,
  30.                               struct wps_token *token,
  31.                               struct wps_data *wps_data)
  32. @@ -1153,6 +1153,7 @@
  33.          line_num++;
  34.          line = line->next;
  35.      }
  36. +    pb->vp = vp;
  37.      pb->have_bitmap_pb = false;
  38.      pb->bm.data = NULL; /* no bitmap specified */
  39.      pb->follow_lang_direction = follow_lang_direction > 0;
  40. @@ -1163,8 +1164,8 @@
  41.          pb->width = vp->width;
  42.          pb->height = SYSFONT_HEIGHT-2;
  43.          pb->y = -line_num - 1; /* Will be computed during the rendering */
  44. -
  45. -        curr_vp->pb = pb;
  46. +        if (token->type == WPS_TOKEN_VOLUME)
  47. +            return 0; /* dont add it, let the regular token handling do the work */
  48.          add_to_ll_chain(&wps_data->progressbars, item);
  49.          return 0;
  50.      }
  51. @@ -1220,9 +1221,10 @@
  52.      else
  53.          pb->y = -line_num - 1; /* Will be computed during the rendering */
  54.  
  55. -    curr_vp->pb = pb;
  56.      add_to_ll_chain(&wps_data->progressbars, item);
  57. -
  58. +    if (token->type == WPS_TOKEN_VOLUME)
  59. +        token->type = WPS_TOKEN_VOLUMEBAR;
  60. +    pb->type = token->type;
  61.      /* Skip the rest of the line */
  62.      return skip_end_of_line(wps_bufptr)-1;
  63.  #else
  64. @@ -2205,7 +2207,6 @@
  65.  
  66.      /* Initialise the first (default) viewport */
  67.      curr_vp->label         = VP_DEFAULT_LABEL;
  68. -    curr_vp->pb            = NULL;
  69.      curr_vp->hidden_flags  = 0;
  70.      curr_vp->lines         = NULL;
  71.      
  72. Index: apps/gui/skin_engine/skin_display.c
  73. ===================================================================
  74. --- apps/gui/skin_engine/skin_display.c (revision 25508)
  75. +++ apps/gui/skin_engine/skin_display.c (working copy)
  76. @@ -26,6 +26,7 @@
  77.  #include "font.h"
  78.  #include "system.h"
  79.  #include "rbunicode.h"
  80. +#include "sound.h"
  81.  #ifdef DEBUG
  82.  #include "debug.h"
  83.  #endif
  84. @@ -115,29 +116,35 @@
  85.  }
  86.  
  87.  static void draw_progressbar(struct gui_wps *gwps,
  88. -                             struct skin_viewport *wps_vp)
  89. +                             struct progressbar *pb)
  90.  {
  91.      struct screen *display = gwps->display;
  92. +    struct viewport *vp = pb->vp;
  93.      struct wps_state *state = gwps->state;
  94. -    struct progressbar *pb = wps_vp->pb;
  95.      struct mp3entry *id3 = state->id3;
  96.      int y = pb->y, height = pb->height;
  97.      unsigned long length, elapsed;
  98.      
  99.      if (height < 0)
  100. -        height = font_get(wps_vp->vp.font)->height;
  101. +        height = font_get(vp->font)->height;
  102.  
  103.      if (y < 0)
  104.      {
  105. -        int line_height = font_get(wps_vp->vp.font)->height;
  106. +        int line_height = font_get(vp->font)->height;
  107.          /* center the pb in the line, but only if the line is higher than the pb */
  108.          int center = (line_height-height)/2;
  109.          /* if Y was not set calculate by font height,Y is -line_number-1 */
  110.          y = (-y -1)*line_height + (0 > center ? 0 : center);
  111.      }
  112.  
  113. -    if (id3 && id3->length)
  114. +    if (pb->type == WPS_TOKEN_VOLUMEBAR)
  115.      {
  116. +        int minvol = sound_min(SOUND_VOLUME);
  117. +        length = -minvol;
  118. +        elapsed = global_settings.volume > 0 ? length : global_settings.volume-minvol;
  119. +    }
  120. +    else if (id3 && id3->length)
  121. +    {
  122.          length = id3->length;
  123.          elapsed = id3->elapsed + state->ff_rewind_count;
  124.      }
  125. @@ -155,7 +162,7 @@
  126.          gui_scrollbar_draw(display, pb->x, y, pb->width, height,
  127.                             length, 0, elapsed, HORIZONTAL);
  128.  
  129. -    if (id3 && id3->length)
  130. +    if (pb->type == WPS_TOKEN_PROGRESSBAR && id3 && id3->length)
  131.      {
  132.  #ifdef AB_REPEAT_ENABLE
  133.          if (ab_repeat_mode_enabled())
  134. @@ -1248,9 +1255,15 @@
  135.          /* progressbar */
  136.          if (vp_refresh_mode & WPS_REFRESH_PLAYER_PROGRESS)
  137.          {
  138. -            if (skin_viewport->pb)
  139. +            struct skin_token_list *bar = gwps->data->progressbars;
  140. +            while (bar)
  141.              {
  142. -                draw_progressbar(gwps, skin_viewport);
  143. +                struct progressbar *thisbar = (struct progressbar*)bar->token->value.data;
  144. +                if (thisbar->vp == &skin_viewport->vp)
  145. +                {
  146. +                    draw_progressbar(gwps, thisbar);
  147. +                }
  148. +                bar = bar->next;
  149.              }
  150.          }
  151.          /* Now display any images in this viewport */
  152. Index: apps/gui/skin_engine/skin_tokens.h
  153. ===================================================================
  154. --- apps/gui/skin_engine/skin_tokens.h  (revision 25508)
  155. +++ apps/gui/skin_engine/skin_tokens.h  (working copy)
  156. @@ -202,6 +202,7 @@
  157.  #endif
  158.      /* Volume level */
  159.      WPS_TOKEN_VOLUME,
  160. +    WPS_TOKEN_VOLUMEBAR,
  161.      /* hold */
  162.      WPS_TOKEN_MAIN_HOLD,
  163.  #ifdef HAS_REMOTE_BUTTON_HOLD
  164. Index: apps/gui/skin_engine/wps_internals.h
  165. ===================================================================
  166. --- apps/gui/skin_engine/wps_internals.h        (revision 25508)
  167. +++ apps/gui/skin_engine/wps_internals.h        (working copy)
  168. @@ -91,6 +91,8 @@
  169.  
  170.  
  171.  struct progressbar {
  172. +    enum wps_token_type type;
  173. +    struct viewport *vp;
  174.      /* regular pb */
  175.      short x;
  176.      /* >=0: explicitly set in the tag -> y-coord within the viewport
  177. @@ -202,7 +204,6 @@
  178.  #define VP_INFO_LABEL       '_'
  179.  struct skin_viewport {
  180.      struct viewport vp;   /* The LCD viewport struct */
  181. -    struct progressbar *pb;
  182.      struct skin_line *lines;
  183.      char hidden_flags;
  184.      char label;
clone this paste RAW Paste Data