All pastes #806619 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-12-05 19:34 UTC
rendered paste body
alias draw.playlist {
  drawrect -rfn @PlayList $hget(player, col.bg) 1 0 0 $window(@PlayList).w $window(@PlayList).h
  drawrect -rn @PlayList $rgb(180,180,180) 1 0 0 $window(@PlayList).w $window(@PlayList).h
  drawline -rn @PlayList $hget(player, col.hl) 1 1 $calc($window(@PlayList).h -2) 1 1 $calc($window(@PlayList).w - 2) 1
  drawline -rn @PlayList $hget(player, col.sh) 1 1 $calc($window(@PlayList).h - 2) $calc($window(@PlayList).w - 2) $calc($window(@PlayList).h - 2) $calc($window(@PlayList).w - 2) 1
  draw.detail @PlayList 10 10 $calc($window(@PlayList).w - 20) $calc($window(@PlayList).h - 22)
  draw.detail @PlayList 12 12 $calc($window(@PlayList).w - 24) 15 1
  draw.text @PlayList tahoma -7 18 13 Playlist
  drawdot -rn @PlayList $hget(player, col.hl) 4 $calc($window(@PlayList).w - 5) $calc($window(@PlayList).h - 5)
  var %l = $int($calc(($window(@PlayList).h - 45) / 13))
  hadd -m playlist disp.lines %l
  hadd -m scrollbar 1 $calc($window(@PlayList).w - 24) 28 13 $calc($window(@PlayList).h -  40) $iif($hget(playlist, FILE0), $ifmatch, 0) %l
  draw.scroll $hget(playlist, inlist)
  draw.buffer $calc($hget(playlist, line.start) - 1)
  drawdot @PlayList
}

alias draw.scroll {
  var %p = $iif($1, $ifmatch, 0)
  tokenize 32 $hget(scrollbar, 1)
  var %s = $iif($5 <= $6, 1, $iif($calc($6 / $5) < 0.07, 0.07, $v1))), %x = $1, %y = $int($calc(((%p / 100 * $4) * (1 - %s)) + $2)), %w = $calc($3 - 1), %h = $ceil($calc($4 * %s - 1))
  drawrect -rnf @PlayList $hget(player, col.bg) 1 $1 $2 $3 $4
  draw.detail @PlayList %x %y %w %h 1
  drawdot @playlist
}

alias draw.buffer {
  var %x = 12, %y = 28, %w = $calc($window(@PlayList).w - 36), %h = $calc($window(@PlayList).h - 41), %a = 1, %b = $hget(playlist, disp.lines), %c = $hget(playlist, FILE0), %l, %z
  if ($1 isnum) { 
    if ($1 isnum) {
      %l = $ifmatch
      else { %l = 0 }
    }
  }
  elseif ($active == @PlayList) {
    %l = $int($calc((($mouse.y - 27) / %h) * (%c - %b)))
    if (%l !isnum 0- $+ %c) { return }
  }
  else { %l = $hget(playlist, line.start) }
  if ($calc(%b + 13) > %h) { dec %b 13 }
  hadd -m playlist line.start $calc(%l + 1)
  hadd -m playlist line.end $calc(%l + %b)
  drawrect -rfn @PlayList $hget(player, col.mg) 1 %x %y %w %h
  while (%a <= %b) {
    %z = $calc(%a + %l)
    if ($hget(playlist, FILE $+ %z)) {
      draw.text -c @PlayList "verdana" -7 18 $calc((13 * %a) + 17) $calc(%w - 10) 14 $gettok($ifmatch, 1, 9)
    }
    else { break }
    inc %a
  }
  draw.select | check.buffer %l %b
}

alias check.buffer {
  var %a = 1, %b = $2, %c = $1, %d, %f, %l
  if ($mouse.key) {
    .timercheck_buffer 1 0 check.buffer $1-
    return
  }
  while (%a <= %b) && ($whilefix) {
    %d = $calc(%a + %c)
    if ($hget(playlist, FILE $+ %d)) { %f = $ifmatch }
    else { break }
    if ("*" iswm %f) {
      %l =  $duration($calc($sound(%f).length / 1000), 3)
      if ($gettok(%l, 1, 58) == 00) {
        %l = $gettok(%l, 2-, 58)
      }
      tokenize 32 $+($iif($sound(%f).artist, $ifmatch $+(-, $chr(32))), $iif($sound(%f).title, $ifmatch, $nopath(%f)) [, %l, $iif($sound(%f).bitrate,  $+($chr(32), -, $chr(32), $ifmatch kbps)), ])
      hadd playlist FILE $+ %d $+($1-, $chr(9), %f)
      drawrect -rfn @PlayList $hget(player, col.mg) 1 12 $calc((13 * %a) + 18) $calc($window(@PlayList).w - 36) 13
      draw.text -c @PlayList "verdana" -7 18 $calc((13 * %a) + 18) $calc($window(@PlayList).w - 45) 14 $1-
      drawdot @PlayList
    }
    inc %a
  }
  draw.select
}

alias draw.select {
  var %w = $calc($window(@PlayList).w - 41), %x, %y = $hget(playlist, line.start), %z = $hget(playlist, line.end)
  if ($1) {
    if ($hget(playlist, select)) {
      %x = $ifmatch
      if (%x isnum $+(%y, -, %z)) { 
        var %a = $calc(((%x - %y) * 13) + 31)
        drawreplace -nr @PlayList $hget(player, col.bg) $hget(player, col.mg) 14 %a %w 14
        drawrect -rn @PlayList $hget(player, col.mg) 1 14 %a %w 14
      }
    }
    hadd playlist select $calc((%y + $1) - 1)
  }
  %x = $hget(playlist, select)
  if (%x isnum $+(%y, -, %z)) { 
    var %a = $calc(((%x - %y) * 13) + 31)
    drawreplace -nr @PlayList $hget(player, col.mg) $hget(player, col.bg) 14 %a %w 14
    drawrect -nr @PlayList $rgb(157,167,177) 1 14 %a %w 14
  }
  drawdot @PlayList
}