// ==PREPROCESSOR==
// @name "Themed Seek Bar"
// @author "marc2003"
// @import "%fb2k_component_path%docs\helpers.txt"
// ==/PREPROCESSOR==

var tooltip = window.CreateTooltip();
var g_theme = window.CreateThemeManager("PROGRESS");
// seekbar is defined inside docs\helpers.txt
// 4 arguments are x, y, w, h
// y and w are dynamic based on panel size so we set those inside on_size function
var s = new seekbar(10, 0, 0, 20);

function on_size() {
	s.y = Math.floor((window.Height - 20) / 2);
	//because we've set x 10 pixels from the left, the seekbar width can be the panel
	//width minus 20 pixels to leave the same gap on the right side.
	s.w = window.Width - 20;
}

function on_paint(gr) {
	g_theme.SetPartAndStateID(1, 0);
	g_theme.DrawThemeBackground(gr, s.x, s.y, s.w, s.h);
	if (fb.IsPlaying && fb.PlaybackLength > 0) {
		g_theme.SetPartAndStateID(5, fb.IsPaused ? 3 : 1);
		g_theme.DrawThemeBackground(gr, s.x, s.y, s.pos(), s.h);
	}
}

function on_playback_seek() {
	s.playback_seek();
}

function on_playback_stop() {
	s.playback_stop();
}

function on_mouse_wheel(s) {
	s.wheel(s);
}

function on_mouse_move(x, y) {
	s.move(x, y);
}

function on_mouse_lbtn_down(x, y) {
	s.lbtn_down(x, y);
}

function on_mouse_lbtn_up(x, y) {
	s.lbtn_up(x, y);
}
