Advertisement
Guest User

Untitled

a guest
Jun 19th, 2012
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function RGB(r, g, b) {
  2.     return (0xff000000 | (r << 16) | (g << 8) | (b));
  3. }
  4.  
  5. var g_font = gdi.Font("Tahoma", 12, 0);
  6. var g_drag = 0;
  7. var g_hover = 0;
  8. var ww = 0;
  9. var wh = 0;
  10.  
  11. function on_size() {
  12.     ww = window.Width;
  13.     wh = window.Height;
  14. }
  15.  
  16. function on_paint(gr) {
  17.     gr.SetTextRenderingHint(5);
  18.     gr.FillGradRect(0, 0, ww, wh, 90, RGB(240, 240, 240), RGB(190, 190, 190));
  19.     if (g_hover) {
  20.         var volume = fb.Volume;
  21.         var pos = window.Width * Math.pow((100+fb.Volume)/100,2);
  22.         var txt = (Math.ceil(volume)) + "dB";
  23.         gr.FillGradRect(0, 0, pos, wh, 90, RGB(240, 240, 240), RGB(100, 230, 100));
  24.         gr.DrawString(txt, g_font, RGB(64, 64, 128), 0, 0, ww, wh, 0x11005000);
  25.     }
  26.     gr.DrawRect(0, 0, ww - 1, wh - 1, 1.0, RGB(150, 150, 150));
  27. }
  28.  
  29. function on_mouse_lbtn_down(x, y) {
  30.     g_drag = 1;
  31. }
  32.  
  33. function on_mouse_lbtn_up(x, y) {
  34.     on_mouse_move(x, y);
  35.     g_drag = 0;
  36. }
  37.  
  38. function on_mouse_move(x, y) {
  39.     if (!g_hover) {
  40.         g_hover = 1;
  41.         window.Repaint();
  42.     }
  43.     if (g_drag) {
  44.         var v = x / window.Width;
  45.         v = (v<0) ? 0 : (v<1) ? v : 1;
  46.         v = 100 * (Math.pow(v,1/2) - 1);
  47.         if (fb.Volume != v) fb.Volume = v;
  48.     }
  49. }
  50.  
  51. function on_mouse_leave() {
  52.     g_hover = 0;
  53.     window.Repaint();
  54. }
  55.  
  56. function on_mouse_wheel(delta) {
  57.     if (delta > 0) fb.VolumeUp();
  58.     else fb.VolumeDown();
  59. }
  60.  
  61. function on_volume_change(val) {
  62.     window.Repaint();
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement