secret
Created

Toolbar

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
// ==PREPROCESSOR==
// @import "%fb2k_path%scripts\Helpers.txt"
// @import "%fb2k_path%scripts\Flags.txt"
// @import "%fb2k_path%scripts\getColoursFonts.js"
// @import "%fb2k_path%scripts\buttons.js"
// @import "%fb2k_path%scripts\menus.js"
// ==/PREPROCESSOR==
 
window.MaxHeight = tpad+bth;
window.MinHeight = tpad+bth;
 
function on_size()
{
ww = window.Width;
wh = window.Height;
buttons = {
back: new button('back', function(){fb.Prev();},"Previous",lpad),
stop: new button('stop', function(){fb.Stop();},"Stop",lpad+btw),
pop: new button((fb.IsPlaying&&!fb.IsPaused)?'pause':'play',function(){fb.PlayOrPause();},(fb.IsPlaying&&!fb.IsPaused)?"Pause":"Play",lpad+2*btw),
sac: new button(fb.StopAfterCurrent?'sac_on':'sac',function(){fb.StopAfterCurrent=!fb.StopAfterCurrent;},"Stop After Current "+(fb.StopAfterCurrent?"(On)":"(Off)"),lpad+3*btw),
next: new button('fwd', function(){fb.Next();},"Next",lpad+4*btw),
//
cfp: new button(fb.CursorFollowPlayback?'cfp_on':'cfp',function() { fb.CursorFollowPlayback=!fb.CursorFollowPlayback; },"Cursor Follows Playback "+(fb.CursorFollowPlayback?"(On)":"(Off)"), ww-rpad-3*btw),
pfc: new button(fb.PlaybackFollowCursor?'pfc_on':'pfc',function() { fb.PlaybackFollowCursor=!fb.PlaybackFollowCursor; },"Playback Follows Cursor "+(fb.PlaybackFollowCursor?"(On)":"(Off)"), ww-rpad-2*btw),
pbo: new button(PBOArray[fb.PlayBackOrder],function() { playbackorder(); },"Playback Order ("+PBOArray[fb.PlayBackOrder]+")", ww-rpad-1*btw),
//lfm: new button('lfm', function(){lastfm();},"Last.fm", ww-rpad-2*btw),
//menu: new button('menu', function(){runmenu();},"Run", ww-rpad-btw)
}
}
 
function on_paint(gr)
{
gr.FillSolidRect(0,0,ww,wh,utils.GetSysColor(15));
//bg_theme = window.CreateThemeManager("BUTTON");
//try { bg_theme.SetPartAndStateId(1, 1); }catch(e) {}
//try { bg_theme.DrawThemeBackground(gr, lpad, tpad, ww-lpad-rpad, bth); } catch(e) {}
gr.SetSmoothingMode(4);
gr.FillGradRect(lpad+1, tpad+1, ww-lpad-rpad-1, bth-3, 90, 0xfff4f4f4, 0xffe1e1e1, 1);
gr.DrawRoundRect(lpad, tpad, ww-lpad-rpad-2, bth-1, 3, 3, 1, 0xffb2b2b2);
gr.DrawRoundRect(lpad+1, tpad+1, ww-lpad-rpad-3, bth-3, 3, 3, 1, 0xfffafafa);
drawAllButtons(gr);
///Seekbar
 
gr.SetTextRenderingHint(5);
//For normal playback
if(fb.PlaybackLength>0)
{
gap = gr.CalcTextWidth(len.Eval(),font_labels)+8;
if(fb.PlaybackLength > fb.PlaybackTime)
{
if(g_drag)
pos = (ww-(2*lpad+2*rpad+8*btw)-2*gap) * g_drag_seek;
else
pos = (ww-(2*lpad+2*rpad+8*btw)-2*gap) * (fb.PlaybackTime / fb.PlaybackLength);
}
else
{
pos=0;
}
seekbg.DrawThemeBackground(gr,2*lpad+5*btw+gap-2,6,ww-(2*lpad+2*rpad+8*btw)-2*gap+4,18);
gr.GdiDrawText(elap.Eval(), font_labels, txtcol, 2*lpad+5*btw, 7, gap, wh-1, DT_CENTER);
gr.GdiDrawText(remain.Eval(), font_labels, txtcol, ww-gap-2*rpad-3*btw, 7, gap, wh-1, DT_CENTER);
seekfill.DrawThemeBackground(gr,2*lpad+5*btw+gap,8,pos,14);
}
//For streams
else if(fb.IsPlaying && (fb.PlaybackLength < 0 || filetype_eval == "mms"))
{
seekbg.DrawThemeBackground(gr,2*lpad+5*btw+2,6,ww-(2*lpad+2*rpad+10*btw)-4,18);
gr.GdiDrawText(elap.Eval()+" (continuous)", font_labels, txtcol, 0, 9, ww, wh, DT_CENTER);
}
 
}
 
function on_playback_stop()
{
if(g_timer){window.KillTimer(g_timer);}
buttons.pop.icon=gdi.Image(dir+"play"+".png");
buttons.pop.tooltiptxt="Play";
window.Repaint();
}
 
function on_playback_pause(is_paused)
{
buttons.pop.icon=is_paused?gdi.Image(dir+"play"+".png"):gdi.Image(dir+"pause"+".png");
buttons.pop.tooltiptxt=is_paused?"Play":"Pause";
window.Repaint();
}
function on_playback_starting(cmd, is_paused)
{
g_timer = window.CreateTimerInterval(40);
buttons.pop.icon=is_paused?gdi.Image(dir+"play"+".png"):gdi.Image(dir+"pause"+".png");
buttons.pop.tooltiptxt=is_paused?"Play":"Pause";
window.Repaint();
}
function on_playlist_stop_after_current_changed(state)
{
buttons.sac.icon=state?gdi.Image(dir+"sac_on"+".png"):gdi.Image(dir+"sac"+".png");
buttons.sac.tooltiptxt="Stop After Current "+(state?"(On)":"(Off)");
window.Repaint();
}
function on_cursor_follow_playback_changed(state)
{
buttons.cfp.icon=state?gdi.Image(dir+"cfp_on"+".png"):gdi.Image(dir+"cfp"+".png");
buttons.cfp.tooltiptxt="Cursor Follows Playback "+(state?"(On)":"(Off)");
window.Repaint();
}
 
function on_playback_follow_cursor_changed(state)
{
buttons.pfc.icon=state?gdi.Image(dir+"pfc_on"+".png"):gdi.Image(dir+"pfc"+".png");
buttons.pfc.tooltiptxt="Playback Follows Cursor "+(state?"(On)":"(Off)");
window.Repaint();
}
 
function on_playback_order_changed(new_order_index)
{
buttons.pbo.icon=gdi.Image(dir+PBOArray[fb.PlayBackOrder]+".png");
buttons.pbo.tooltiptxt = "Playback Order ("+PBOArray[fb.PlayBackOrder]+")";
window.Repaint();
}
 
function on_playback_seek(time)
{
window.Repaint();
}
 
function on_playback_time(time)
{
if(!g_timer){g_timer = window.CreateTimerInterval(40);}
window.Repaint();
}
 
function on_playback_new_track(metadb)
{
filetype_eval = filetype.Eval();
window.Repaint();
}
 
function on_timer(id)
{
window.RepaintRect(2*lpad+5*btw,0,ww-(2*lpad+2*rpad+10*btw),wh);
}
 
////Seekbar
 
var g_drag = 0;
var g_drag_seek = 0;
 
//Titleformatting
var len = fb.Titleformat("%length%");
var elap = fb.TitleFormat("%playback_time%");
var remain = fb.TitleFormat("$if2(%playback_time_remaining%,continuous)");
 
var pos = 0;
var gap = 0;
 
var g_timer;
var filetype = fb.TitleFormat("$left(%path%,3)");
var filetype_eval;
 
var seekbg = window.CreateThemeManager("Progress");
try { seekbg.SetPartAndStateID(1,1); }
catch(e){}
var seekfill = window.CreateThemeManager("Progress");
try { seekfill.SetPartAndStateID(3,1); }
catch(e){}
 
function on_item_focus_change() { window.Repaint(); }

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.