On Fri, Oct 02, 2009 at 05:24:24AM +0200, Niels Kristian Bech Jensen wrote:
> 
> > Date: Thu, 1 Oct 2009 14:32:35 +0200
> > From: [email protected]
> > To: [email protected]
> > Subject: Re: [UFRaw-Devel] latest CVS broke rotation/flip logic
> > 
> > A couple of rotate fixes + minor cleanup:
> > 
> > -   The flip/rotate interaction is fixed by reverting a small part
> >     of latest CVS commit.
> > -   Rotate changes via flip_image() are now properly saved in CFG.
> > -   Rotate reset button is now greyed out when it should.
> > -   The reset button simply sets the UI rotation angle to zero
> >     and no longer calls set_rotation_angle() directly. The latter is
> >     an implementation issue reset doesn't need to be aware of.
> > 
> There is still something not working properly. Try rotating an image 1 
> degrees and the flip it 90 degrees left or right. The first flip shows the 
> correct angle. Then flip it another 90 degrees. Now the rotation angle shows 
> up as 180 degrees. It you flip it back twice the rotation angle is shown as 0 
> degrees while the preview image still show the original rotation.

ah, I see. The remainder call in flip_image() is necessary after all.
FreezeDialog protects at least two cases: call via flip_image() and UI
construction and it's not possible to see the difference.

I fixed yet another minor detail but it's questionable: the slider is
clipped at -180..180 degrees which prevents the 360 degree remainder logic
doing its job when pressing page/cursor-up or down when the widget has
focus and close to/at -180 or 180 degrees. This is fixed by increasing
the range slightly. I don't suppose GTK has a kind of circular slider
with begin and end connected... that would be more appropriate.


diff --git a/ufraw_preview.c b/ufraw_preview.c
index 4710628..1e1242a 100644
--- a/ufraw_preview.c
+++ b/ufraw_preview.c
@@ -2205,14 +2205,9 @@ static void flip_image(GtkWidget *widget, int flip)
            data->unnormalized_angle -= 90;
            break;
        case 1:
-           data->unnormalized_angle = 180-data->unnormalized_angle;
-           if ( (data->reference_orientation&4) == 4)
-               data->unnormalized_angle += 180;
-           break;
        case 2:
+           data->reference_orientation ^= flip;
            data->unnormalized_angle = -data->unnormalized_angle;
-           if ( (data->reference_orientation&4) == 4)
-               data->unnormalized_angle += 180;
            break;
        default:
            g_error("flip_image(): flip:%d invalid", flip);
@@ -2963,18 +2958,19 @@ static void set_rotation_angle(preview_data *data, 
double angle)
 {
     int d;
 
-    if (data->FreezeDialog)
-       return;
-
     /* 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(angle, 360);
-    gtk_adjustment_set_value(data->RotationAdjustment,
-           data->unnormalized_angle);
     CFG->rotationAngle = data->unnormalized_angle;
     CFG->orientation = data->reference_orientation;
     ufraw_normalize_rotation(data->UF);
+    if (data->FreezeDialog)
+       return;
+    gtk_adjustment_set_value(data->RotationAdjustment,
+           data->unnormalized_angle);
+    gtk_widget_set_sensitive(data->ResetRotationAdjustment,
+           data->unnormalized_angle != 0);
     ufraw_get_image_dimensions(data->UF->raw, data->UF);
     d = MIN(CFG->CropX1, CFG->CropX2 - data->UF->rotatedWidth);
     if (d > 0) {
@@ -3018,15 +3014,17 @@ static void set_rotation_angle(preview_data *data, 
double angle)
 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;
+    set_rotation_angle(data, gtk_adjustment_get_value(adj));
 }
 
 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;
+    gtk_adjustment_set_value(data->RotationAdjustment, 0);
 }
 
 GtkWidget *reset_button(const char *tip, GCallback callback, void *data)
@@ -4934,10 +4932,12 @@ static void transformations_fill_interface(preview_data 
*data, GtkWidget *page)
     data->RotationAdjustment = adjustment_scale(
        table, 0, 0, _("Rotation"),
        data->unnormalized_angle, &data->unnormalized_angle,
-       -180, 180, 0.1, 1, 2, _("Rotation Angle"),
+       -190, 190, 0.1, 1, 2, _("Rotation Angle"),
        G_CALLBACK(adjustment_update_rotation),
        &data->ResetRotationAdjustment, _("Reset Rotation Angle"),
        G_CALLBACK(adjustment_reset_rotation));
+    gtk_widget_set_sensitive(data->ResetRotationAdjustment,
+           data->unnormalized_angle != 0);
 
     // drawLines toggle button
     GtkWidget *subtable = gtk_table_new(10, 10, FALSE);

-- 
Frank

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
ufraw-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ufraw-devel

Reply via email to