Hi.

The attached patch adds a much needed reset button to the rotation
adjustment UI.  Since I tend to use this rotation mostly for fixing
tilted horizons, I decreased the large/small adjustment steps from 5/0.5
degrees to 1/0.1 degrees.

This pointed out an oddity on my system at least.  When I tap the up or
down arrows on the rotation spinner, the adjustment changes by double
the small step instead of just single (0.2 instead of 0.1).  It doesn't
for any of the other spinners, and the scale works correctly too.  Any
ideas why this one goes double?

-- 
Bruce Guenter <[email protected]>                http://untroubled.org/
diff --git a/ufraw_preview.c b/ufraw_preview.c
index bb5a4e1..4c0d9f6 100644
--- a/ufraw_preview.c
+++ b/ufraw_preview.c
@@ -2863,18 +2863,16 @@ GtkWidget *stock_icon_button(const gchar *stock_id,
  * are valid. Try to preserve them over a rotate forth and back and try to
  * preserve their geometry.
  */
-static void adjustment_update_rotation(GtkAdjustment *adj, gpointer user_data)
+static void set_rotation_angle(preview_data *data, double angle)
 {
-    preview_data *data = get_preview_data(adj);
     int d;
 
-    (void)user_data;
-    data->unnormalized_angle = gtk_adjustment_get_value(adj);
     /* Normalize the "unnormalized" value displayed to the user to
      * -180 < a <= 180, though we later normalize to an orientation
      * and flip plus 0 <= a < 90 rotation for processing.  */
-    data->unnormalized_angle = remainder(data->unnormalized_angle, 360);
-    gtk_adjustment_set_value(adj, data->unnormalized_angle);
+    data->unnormalized_angle = remainder(angle, 360);
+    gtk_adjustment_set_value(data->RotationAdjustment,
+                            data->unnormalized_angle);
     if (data->FreezeDialog)
        return;
     CFG->rotationAngle = data->unnormalized_angle;
@@ -2920,6 +2918,20 @@ static void adjustment_update_rotation(GtkAdjustment 
*adj, gpointer user_data)
     update_scales(data);
 }
 
+static void adjustment_update_rotation(GtkAdjustment *adj, gpointer user_data)
+{
+    preview_data *data = get_preview_data(adj);
+    set_rotation_angle(data, gtk_adjustment_get_value(adj));
+    (void)user_data;
+}
+
+static void adjustment_reset_rotation(GtkAdjustment *adj, gpointer user_data)
+{
+    preview_data *data = get_preview_data(adj);
+    set_rotation_angle(data, 0);
+    (void)user_data;
+}
+
 GtkWidget *reset_button(const char *tip, GCallback callback, void *data)
 {
     return stock_icon_button(GTK_STOCK_REFRESH, tip, callback, data);
@@ -4764,18 +4776,13 @@ static void transformations_fill_interface(preview_data 
*data,
     data->unnormalized_angle = CFG->rotationAngle;
     data->reference_orientation = CFG->orientation;
     table = GTK_TABLE(table_with_frame(page, NULL, TRUE));
-    label = gtk_label_new(_("Rotation"));
-    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, 0, 0, 0, 0);
-    data->RotationAdjustment = GTK_ADJUSTMENT(gtk_adjustment_new(
-           data->unnormalized_angle, -1e100, 1e100, 0.5, 5, 0));
-    data->RotationSpin = GTK_SPIN_BUTTON(gtk_spin_button_new(
-           data->RotationAdjustment, 0.5, 3));
-    g_object_set_data(G_OBJECT(data->RotationAdjustment), "Parent-Widget",
-           data->RotationSpin);
-    g_signal_connect(G_OBJECT(data->RotationAdjustment), "value-changed",
-           G_CALLBACK(adjustment_update_rotation), NULL);
-    gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(data->RotationSpin),
-           1, 2, 0, 1, 0, 0, 0, 0);
+    data->RotationAdjustment = adjustment_scale(
+       table, 0, 0, _("Rotation"),
+       data->unnormalized_angle, &data->unnormalized_angle,
+       -360, 360, 0.1, 1, 2, _("Rotation Angle"),
+       G_CALLBACK(adjustment_update_rotation),
+       &data->ResetRotationAdjustment, _("Reset Rotation Angle"),
+       G_CALLBACK(adjustment_reset_rotation));
 
     /* End of transformation page */
 }
diff --git a/ufraw_ui.h b/ufraw_ui.h
index 9150f06..2c67ba4 100644
--- a/ufraw_ui.h
+++ b/ufraw_ui.h
@@ -83,7 +83,6 @@ typedef struct {
     GtkSpinButton *ShrinkSpin;
     GtkSpinButton *HeightSpin;
     GtkSpinButton *WidthSpin;
-    GtkSpinButton *RotationSpin;
     /* We need the adjustments for update_scale() */
     GtkAdjustment *WBTuningAdjustment;
     GtkAdjustment *TemperatureAdjustment;
@@ -112,6 +111,7 @@ typedef struct {
     GtkAdjustment *HeightAdjustment;
     GtkAdjustment *WidthAdjustment;
     GtkAdjustment *RotationAdjustment;
+    GtkWidget *ResetRotationAdjustment;
     GtkAdjustment *GrayscaleMixers[3];
 #ifdef HAVE_LENSFUN
     /* The GtkEntry with camera maker/model name */

Attachment: pgpQug1W9rb5h.pgp
Description: PGP signature

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
ufraw-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-devel

Reply via email to