Advertisement
wwww

fb2k WSH Panel: Vertical Volume Bar

Dec 23rd, 2012
223
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. var ww     = 0;
  5. var wh     = 0;
  6.  
  7. function on_size() {
  8.     ww = window.Width;
  9.     wh = window.Height;
  10. }
  11.  
  12. var color =
  13. {
  14.     background: RGB(206, 219, 213),
  15.     frame:      RGB(191, 208, 199),
  16.     progress:   RGB(188, 145, 148),
  17.     proghead:   RGB(164, 79, 85)
  18. };
  19.  
  20. function on_paint(e)
  21. {
  22.     e.SetTextRenderingHint(1);
  23.    
  24.     var ww         = window.Width-2,
  25.         wh         = window.Height-2,
  26.         pos        = wh * (1 - Math.pow((100 + fb.Volume) / 100, 2));
  27.         headwidth  = 8;
  28.  
  29.     // Draw frame background
  30.     e.FillSolidRect(0, 0, ww+2, wh+2, color.frame);
  31.    
  32.     // Draw background
  33.     // e.FillSolidRect(1, 1, ww, wh, color.background);
  34.     e.FillSolidRect(1, 1, ww, wh+1, color.progress);
  35.    
  36.     // Draw progress
  37.     // e.FillSolidRect(1, 1, pos, wh, color.progress);
  38.    
  39.     // Draw progress head
  40.     e.FillSolidRect(1,pos, ww, headwidth, color.proghead);
  41. }
  42. function on_mouse_lbtn_down(x, y)
  43. {
  44.     g_drag = 1;
  45. }
  46.  
  47. function on_mouse_lbtn_up(x, y)
  48. {
  49.     on_mouse_move(x, y);
  50.     g_drag = 0;
  51. }
  52. function on_mouse_move(x, y)
  53. {
  54.     if (g_drag)
  55.     {
  56.         var v = 1 - (y / wh);
  57.         v = v < 0 ? 0 : (v < 1 ? v : 1);
  58.         v = 100 * (Math.pow(v, 1 / 2) - 1);
  59.          fb.Volume = v;
  60.     }
  61. }
  62. function on_mouse_wheel(delta)
  63. {
  64.     if (delta > 0)
  65.         fb.VolumeUp();
  66.     else
  67.         fb.VolumeDown();
  68. }
  69. function on_mouse_mbtn_down(x, y) {
  70.     fb.VolumeMute();
  71. }
  72. function on_volume_change(val)
  73. {
  74.     window.Repaint();
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement