diff --git a/rtgui/coarsepanel.cc b/rtgui/coarsepanel.cc index a09bd8f3b..44e19d870 100644 --- a/rtgui/coarsepanel.cc +++ b/rtgui/coarsepanel.cc @@ -109,7 +109,11 @@ void CoarsePanel::initBatchBehavior () { void CoarsePanel::rotateLeft () { - degree = (degree + 270) % 360; + //Rotate one way or the opposite depending if the image is already flipped or not + if ( (vflip->get_active()) == (hflip->get_active ()) ) + degree = (degree + 270) % 360; + else + degree = (degree + 90) % 360; degreechanged = true; if (listener) listener->panelChanged (EvCTRotate, Glib::ustring::format (degree)); @@ -117,7 +121,11 @@ void CoarsePanel::rotateLeft () { void CoarsePanel::rotateRight () { - degree = (degree + 90) % 360; + //Rotate one way or the opposite depending if the image is already flipped or not + if ( (vflip->get_active()) == (hflip->get_active ()) ) + degree = (degree + 90) % 360; + else + degree = (degree + 270) % 360; degreechanged = true; if (listener) listener->panelChanged (EvCTRotate, Glib::ustring::format (degree)); diff --git a/rtgui/crop.cc b/rtgui/crop.cc index f7f5530c1..c5ed3af33 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -494,32 +494,34 @@ void Crop::vFlipCrop () { g_idle_add (refreshSpinsUI, new RefreshSpinHelper (this, false)); } -void Crop::rotateCrop (int deg) { - - int tmp; - switch ((360+deg-lastRotationDeg)%360) { - case 90: - tmp = nx; - nx = maxh - ny - nh; - ny = tmp; - tmp = nw; - nw = nh; - nh = tmp; - break; - case 270: - tmp = ny; - ny = maxw - nx - nw; - nx = tmp; - tmp = nw; - nw = nh; - nh = tmp; - break; - case 180: - nx = maxw - nx - nw; - ny = maxh - ny - nh; - break; - } +void Crop::rotateCrop (int deg, bool hflip, bool vflip) { + int rotation = (360+deg-lastRotationDeg)%360; + if((hflip != vflip) && ((rotation%180)==90)) + rotation = (rotation + 180)%360; + int tmp; + switch (rotation) { + case 90: + tmp = nx; + nx = maxh - ny - nh; + ny = tmp; + tmp = nw; + nw = nh; + nh = tmp; + break; + case 270: + tmp = ny; + ny = maxw - nx - nw; + nx = tmp; + tmp = nw; + nw = nh; + nh = tmp; + break; + case 180: + nx = maxw - nx - nw; + ny = maxh - ny - nh; + break; + } lastRotationDeg = deg; g_idle_add (refreshSpinsUI, new RefreshSpinHelper (this, false)); } diff --git a/rtgui/crop.h b/rtgui/crop.h index 6e7ef5310..92ee5a2d0 100644 --- a/rtgui/crop.h +++ b/rtgui/crop.h @@ -111,7 +111,7 @@ class Crop : public Gtk::VBox, public CropGUIListener, public FoldableToolPanel, void resizeScaleChanged (double rsc); void hFlipCrop (); void vFlipCrop (); - void rotateCrop (int deg); + void rotateCrop (int deg, bool hflip, bool vflip); }; #endif diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 729043ae0..41c61ad0a 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -254,7 +254,7 @@ void ToolPanelCoordinator::panelChanged (rtengine::ProcEvent event, const Glib:: crop->write (params); } else if (event==rtengine::EvCTRotate) { - crop->rotateCrop (params->coarse.rotate); + crop->rotateCrop (params->coarse.rotate, params->coarse.hflip, params->coarse.vflip); crop->write (params); resize->update (params->crop.enabled, params->crop.w, params->crop.h, ipc->getFullWidth(), ipc->getFullHeight()); resize->write (params);