[PATCH] 2nd button mouse clicks




The following improves the computation of position for clicking
with button 2. (It takes into account the stepper arrows at
the end, so you can, by clicking on the main part of the trough,
get all the way from the beginning to the end of the range)

Regards,
                                        Owen

--- gtk+0.99.5/gtk/gtkrange.c	Mon Mar  9 23:42:40 1998
+++ gtk+/gtk/gtkrange.c	Tue Mar 10 12:47:56 1998
@@ -387,33 +387,36 @@
 				 gint      y,
 				 gfloat	  *jump_perc)
 {
-  gint xthickness;
   gint ythickness;
   gint trough_width;
   gint trough_height;
   gint slider_x;
+  gint slider_length;
+  gint left, right;
 
   g_return_val_if_fail (range != NULL, GTK_TROUGH_NONE);
   g_return_val_if_fail (GTK_IS_RANGE (range), GTK_TROUGH_NONE);
 
-  xthickness = GTK_WIDGET (range)->style->klass->xthickness;
   ythickness = GTK_WIDGET (range)->style->klass->ythickness;
 
-  if ((x > xthickness) && (y > ythickness))
+  gtk_range_trough_hdims (range, &left, &right);
+  gdk_window_get_size (range->slider, &slider_length, NULL);
+  right += slider_length;
+	      
+  if ((x > left) && (y > ythickness))
     {
       gdk_window_get_size (range->trough, &trough_width, &trough_height);
 
-      if ((x < (trough_width - xthickness) && (y < (trough_height - ythickness))))
+      if ((x < right) && (y < (trough_height - ythickness)))
 	{
-	  gdk_window_get_position (range->slider, &slider_x, NULL);
-	  
 	  if (jump_perc)
 	    {
-	      *jump_perc = ((double) x) / ((double) trough_width);
-
+	      *jump_perc = ((gdouble) (x - left)) / ((gdouble) (right - left));
 	      return GTK_TROUGH_JUMP;
 	    }
 	  
+	  gdk_window_get_position (range->slider, &slider_x, NULL);
+	  
 	  if (x < slider_x)
 	    return GTK_TROUGH_START;
 	  else
@@ -431,31 +434,35 @@
 				 gfloat   *jump_perc)
 {
   gint xthickness;
-  gint ythickness;
   gint trough_width;
   gint trough_height;
   gint slider_y;
+  gint top, bottom;
+  gint slider_length;
 
   g_return_val_if_fail (range != NULL, GTK_TROUGH_NONE);
   g_return_val_if_fail (GTK_IS_RANGE (range), GTK_TROUGH_NONE);
 
   xthickness = GTK_WIDGET (range)->style->klass->xthickness;
-  ythickness = GTK_WIDGET (range)->style->klass->ythickness;
 
-  if ((x > xthickness) && (y > ythickness))
+  gtk_range_trough_vdims (range, &top, &bottom);
+  gdk_window_get_size (range->slider, NULL, &slider_length);
+  bottom += slider_length;
+	      
+  if ((x > xthickness) && (y > top))
     {
       gdk_window_get_size (range->trough, &trough_width, &trough_height);
 
-      if ((x < (trough_width - xthickness) && (y < (trough_height - ythickness))))
+      if ((x < (trough_width - xthickness) && (y < bottom)))
 	{
-	  gdk_window_get_position (range->slider, NULL, &slider_y);
-	  
 	  if (jump_perc)
 	    {
-	      *jump_perc = ((double) y) / ((double) trough_height);
+	      *jump_perc = ((gdouble) (y - top)) / ((gdouble) (bottom - top));
 
 	      return GTK_TROUGH_JUMP;
 	    }
+	  
+	  gdk_window_get_position (range->slider, NULL, &slider_y);
 	  
 	  if (y < slider_y)
 	    return GTK_TROUGH_START;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]