[niepce] Allow clicking left or right of the center of the start to change the rating + or -. This allow 0 ra
- From: Hubert FiguiÃre <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] Allow clicking left or right of the center of the start to change the rating + or -. This allow 0 ra
- Date: Sat, 12 Nov 2011 06:15:20 +0000 (UTC)
commit 9305723d34e0ddcd126ed16cd094f3d353194269
Author: Hub Figuiere <hub figuiere net>
Date: Sat Oct 29 10:15:20 2011 -0700
Allow clicking left or right of the center of the start to change
the rating + or -. This allow 0 rating.
src/fwk/toolkit/widgets/ratinglabel.cpp | 21 +++++----------------
src/fwk/toolkit/widgets/ratinglabel.hpp | 2 --
2 files changed, 5 insertions(+), 18 deletions(-)
---
diff --git a/src/fwk/toolkit/widgets/ratinglabel.cpp b/src/fwk/toolkit/widgets/ratinglabel.cpp
index 5662bd5..c4489c7 100644
--- a/src/fwk/toolkit/widgets/ratinglabel.cpp
+++ b/src/fwk/toolkit/widgets/ratinglabel.cpp
@@ -18,6 +18,8 @@
*/
+#include <cmath>
+
#include "fwk/base/debug.hpp"
#include "ratinglabel.hpp"
@@ -87,8 +89,8 @@ void RatingLabel::get_geometry(double & w, double & h)
int RatingLabel::rating_value_from_hit_x(double x)
{
- int width = get_star()->get_width();
- return (x / width) + 1;
+ double width = get_star()->get_width();
+ return round(x / width);
}
RatingLabel::RatingLabel(int rating)
@@ -147,19 +149,6 @@ bool RatingLabel::on_button_press_event (GdkEventButton* e)
}
-bool RatingLabel::on_button_release_event (GdkEventButton* e)
-{
- return true;
-}
-
-
-bool RatingLabel::on_motion_notify_event (GdkEventMotion* e)
-{
- return true;
-}
-
-
-
void RatingLabel::on_size_request(Gtk::Requisition* requisition)
{
*requisition = Gtk::Requisition();
@@ -169,7 +158,7 @@ void RatingLabel::on_size_request(Gtk::Requisition* requisition)
// DBG_OUT("size request is %d %d", requisition->width, requisition->height);
}
-bool RatingLabel::on_expose_event(GdkEventExpose *evt)
+bool RatingLabel::on_expose_event(GdkEventExpose * /*evt*/)
{
if (is_drawable()) {
const Gtk::Allocation& allocation = get_allocation();
diff --git a/src/fwk/toolkit/widgets/ratinglabel.hpp b/src/fwk/toolkit/widgets/ratinglabel.hpp
index 2b1b007..0f7e628 100644
--- a/src/fwk/toolkit/widgets/ratinglabel.hpp
+++ b/src/fwk/toolkit/widgets/ratinglabel.hpp
@@ -55,8 +55,6 @@ public:
protected:
virtual void on_realize();
virtual bool on_button_press_event (GdkEventButton* event);
- virtual bool on_button_release_event (GdkEventButton* event);
- virtual bool on_motion_notify_event (GdkEventMotion* event);
virtual void on_size_request (Gtk::Requisition* requisition);
virtual bool on_expose_event (GdkEventExpose *event);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]