Advertisement
wwww

fb2k WSH Panel: Progress bar

Dec 23rd, 2012
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
  2.  
  3. var g_drag = 0;
  4.  
  5. var color =
  6. {
  7.     background: RGB(206, 219, 213),
  8.     frame:      RGB(191, 208, 199),
  9.     progress:   RGB(188, 145, 148),
  10.     proghead:   RGB(164, 79, 85)
  11. };
  12.  
  13. function on_paint(e)
  14. {
  15.     e.SetTextRenderingHint(1);
  16.    
  17.     var ww         = window.Width-2,
  18.         wh         = window.Height-2,
  19.         pos        = fb.PlaybackLength == 0 ? ww : (ww * fb.PlaybackTime / fb.PlaybackLength),
  20.         headwidth  = 8;
  21.    
  22.     // Draw background
  23.     e.FillSolidRect(1, 1, ww, wh, color.background);
  24.    
  25.     // Draw progress
  26.     e.FillSolidRect(1, 1, pos-1, wh, color.progress);
  27.    
  28.     // Draw progress head
  29.     e.FillSolidRect(pos-headwidth < 1 ? 1 : pos-headwidth, 1, headwidth, wh, color.proghead);
  30.  
  31.     // Draw frame background
  32.     e.DrawRect(0, 0, ww+1, wh+1, 1, color.frame);
  33. }
  34.  
  35. function on_mouse_lbtn_down(x, y)
  36. {
  37.     g_drag = 1;
  38. }
  39.  
  40. function on_mouse_lbtn_up(x, y)
  41. {
  42.     on_mouse_move(x,y);
  43.     g_drag = 0;
  44. }
  45.  
  46. function on_mouse_move(x, y)
  47. {
  48.     if (g_drag)
  49.         fb.PlaybackTime = x / window.Width * fb.PlaybackLength;
  50. }
  51.  
  52. function on_mouse_wheel(delta)
  53. {
  54.     fb.PlaybackTime += delta;
  55. }
  56.  
  57. function on_mouse_mbtn_down(x, y) {
  58.     fb.PlayOrPause();
  59. }
  60.  
  61. function on_playback_seek()
  62. {
  63.     window.Repaint();
  64. }
  65.  
  66. function on_playback_time()
  67. {
  68.     window.Repaint();
  69. }
  70.  
  71. function on_playback_stop()
  72. {
  73.     window.Repaint();
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement