dialog.destroy ();
if (res == Gtk.ResponseType.OK) {
movie.julian_date = get_julian_date (date);
- movie.rating = 10 * rating.get_rating ();
+ movie.rating = rating.get_rating ();
Banner.show_information (parent_window, null, _("Rated movie '%s': %.1f").printf (movie.title, movie.rating/10.0));
foreach (Plugin plugin in CinaestProgram.plugins) {
foreach (MovieSource source in plugin.get_sources ()) {
public override bool expose_event (Gdk.EventExpose event) {
var cr = Gdk.cairo_create (this.window);
+ var radius = double.min (this.allocation.width / 20,
+ this.allocation.height / 2);
cr.rectangle (event.area.x, event.area.y, event.area.width, event.area.height);
cr.clip ();
- for (int i = 0; i < 10; i++) {
- draw_star (cr, i, (i >= rating) ? disabled_color : active_color);
- }
+ cr.save ();
+ cr.rectangle (radius * rating / 5.0, 0, this.allocation.width - radius * rating / 5.0, this.allocation.height);
+ cr.clip ();
+ for (int i = rating/10; i < 10; i++)
+ draw_star (cr, i, radius, disabled_color);
+ cr.restore ();
+
+ cr.new_path ();
+ cr.rectangle (0, 0, radius * rating / 5.0, this.allocation.height);
+ cr.clip ();
+ for (int i = 0; i < (rating+5)/10; i++)
+ draw_star (cr, i, radius, active_color);
return false;
}
- private void draw_star (Cairo.Context cr, int n, Gdk.Color color) {
- var radius = double.min (this.allocation.width / 20,
- this.allocation.height / 2);
+ private void draw_star (Cairo.Context cr, int n, double radius, Gdk.Color color) {
var x = radius * (2 * n + 1);
var y = this.allocation.height / 2;
public override bool button_press_event (Gdk.EventButton event) {
button_pressed = true;
- rate (10 * event.x / this.allocation.width);
+ rate (event.x);
return false;
}
public override bool motion_notify_event (Gdk.EventMotion event) {
if (button_pressed)
- rate (10 * event.x / this.allocation.width);
+ rate (event.x);
return false;
}
- private void rate (double r) {
- if (r <= 0)
+ private void rate (double x) {
+ double r = 10 * x / this.allocation.width;
+ if (r <= 0) {
rating = 0;
- else
- rating = (int) r + 1;
- if (rating > 10)
- rating = 10;
+ } else {
+ int star = (int) r;
+ rating = 10 * (star + 1);
+ r -= star;
+ if (r <= 0.333)
+ rating -= 5;
+ if (rating > 100)
+ rating = 100;
+ }
unowned Gdk.Region region = this.window.get_clip_region ();
// redraw the cairo canvas completely by exposing it