Guest User

Untitled

a guest
Dec 16th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
  2.  
  3. var font = gdi.Font("ProFontWindows", 9, 0);
  4. var g_drag = 0;
  5.  
  6. var color =
  7. {
  8. background: RGB(27, 27, 27),
  9. frame: RGB(27, 27, 27),
  10. //progress: RGB(143, 99, 153), // DARK.COLOR.1
  11. progress: RGB(111, 153, 180),
  12. //proghead: RGB(9, 226, 229) // LIGHT.COLOR.2
  13. proghead: RGB(219, 219, 219)
  14. };
  15.  
  16. var barChar =
  17. {
  18. back: "▬",
  19. body: "▬",
  20. head: "▪"
  21. };
  22.  
  23. function on_paint(e)
  24. {
  25. e.SetTextRenderingHint(1);
  26.  
  27. var ww = window.Width,
  28. wh = window.Height,
  29. pos = ww * fb.PlaybackTime / (fb.PlaybackLength == 0 ? 1 : fb.PlaybackLength),
  30. background = barChar.back,
  31. progress = barChar.body,
  32. bgWidth = e.MeasureString(barChar.back, font, 0, 0, ww, wh).Width,
  33. bodyWidth = e.MeasureString(barChar.body, font, 0, 0, ww, wh).Width;
  34. headWidth = e.MeasureString(barChar.head, font, 0, 0, ww, wh).Width;
  35.  
  36. // generate background string
  37. for (var i = 0, MAX = Math.ceil(ww / bgWidth); i < MAX; i++)
  38. background += barChar.back;
  39.  
  40. // generate progress string
  41. if (pos > 4)
  42. for (var i = 0, MAX = Math.floor((pos - headWidth) / bodyWidth); i < MAX; i++)
  43. progress += barChar.body;
  44. else
  45. progress = "";
  46.  
  47. // Draw frame background
  48. e.FillSolidRect(0, 0, ww, wh, color.frame);
  49.  
  50. // Draw the background
  51. e.DrawString(background, font, color.background, 0, 0, ww, wh);
  52.  
  53. // Draw the progress
  54. e.DrawString(progress, font, color.progress, 0, 0, ww, wh);
  55.  
  56. // Draw the progress head
  57. if (pos > 0)
  58. e.DrawString(barChar.head, font, color.proghead,
  59. Math.floor((pos - headWidth) / bodyWidth) * bodyWidth + headWidth + 1, 0, ww, wh);
  60. }
  61.  
  62. function on_mouse_lbtn_down(x, y)
  63. {
  64. g_drag = 1;
  65. }
  66.  
  67. function on_mouse_lbtn_up(x, y)
  68. {
  69. on_mouse_move(x,y);
  70. g_drag = 0;
  71. }
  72.  
  73. function on_mouse_move(x, y)
  74. {
  75. if (g_drag)
  76. fb.PlaybackTime = x / window.Width * fb.PlaybackLength;
  77. }
  78.  
  79. function on_mouse_wheel(delta)
  80. {
  81. fb.PlaybackTime += delta;
  82. }
  83.  
  84. function on_mouse_mbtn_down(x, y) {
  85. fb.PlayOrPause();
  86. }
  87.  
  88. function on_playback_seek()
  89. {
  90. window.Repaint();
  91. }
  92.  
  93. function on_playback_time()
  94. {
  95. window.Repaint();
  96. }
  97.  
  98. function on_playback_stop()
  99. {
  100. window.Repaint();
  101. }
Advertisement
Add Comment
Please, Sign In to add comment