// ==PREPROCESSOR==
// @name "Rating"
// @author "marc2003"
// @import "%fb2k_component_path%samples\complete\js\lodash.min.js"
// @import "%fb2k_component_path%samples\complete\js\helpers.js"
// @import "%fb2k_component_path%samples\complete\js\panel.js"
// @import "%fb2k_component_path%samples\complete\js\rating.js"
// ==/PREPROCESSOR==

/*
Now supports 3 modes:
1) foo_playcount, limited to 5 stars, access via %rating%
2) file tags, configurable max limit, access via custom tag. Use right click menu to set.
3) JScript Panel "Playback stats" database, configurable max limit, access via %jsp_rating%. Bound to "%artist% - %title%" so common tracks across different albums will share the rating.
*/

var panel = new _.panel('custom_background');
var rating = new _.rating(0, 0, 24, _.RGB(255, 128, 0)); // x, y, height, colour

panel.item_focus_change();

function on_size() {
	panel.size();
}

function on_paint(gr) {
	panel.paint(gr);
	rating.paint(gr);
}

function on_metadb_changed() {
	rating.metadb_changed();
}

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

function on_mouse_leave() {
	rating.leave();
}

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

function on_mouse_rbtn_up(x, y) {
	return panel.rbtn_up(x, y, rating);
}
