From 6949bd989ce82eb56ee695b6f38dca44dc945615 Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Mon, 11 Jul 2011 16:37:36 +0200 Subject: [PATCH] Little fixed crop usability enhancement see issue 837 --- rtgui/crop.cc | 32 ++++++++++++++++++++++---------- rtgui/crop.h | 4 +++- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/rtgui/crop.cc b/rtgui/crop.cc index f72f64ecd..5d4441a9e 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -198,7 +198,7 @@ Crop::Crop (): Gtk::VBox(), FoldableToolPanel(this) { wconn = w->signal_value_changed().connect ( sigc::mem_fun(*this, &Crop::widthChanged), true); hconn = h->signal_value_changed().connect ( sigc::mem_fun(*this, &Crop::heightChanged), true); econn = enabled->signal_toggled().connect( sigc::mem_fun(*this, &Crop::enabledChanged) ); - fconn = fixr->signal_toggled().connect( sigc::mem_fun(*this, &Crop::ratioChanged) ); + fconn = fixr->signal_toggled().connect( sigc::mem_fun(*this, &Crop::ratioFixedChanged) ); rconn = ratio->signal_changed().connect( sigc::mem_fun(*this, &Crop::ratioChanged) ); oconn = orientation->signal_changed().connect( sigc::mem_fun(*this, &Crop::ratioChanged) ); gconn = guide->signal_changed().connect( sigc::mem_fun(*this, &Crop::notifyListener) ); @@ -305,7 +305,7 @@ void Crop::read (const ProcParams* pp, const ParamsEdited* pedited) { } lastEnabled = pp->crop.enabled; - lastAspect = pp->crop.fixratio; + lastFixRatio = pp->crop.fixratio; xconn.block (false); yconn.block (false); @@ -527,23 +527,34 @@ void Crop::heightChanged () { g_idle_add (notifyListenerUI, this); } - -void Crop::ratioChanged () { - - if (batchMode && lastAspect != fixr->get_active ()) { +// Fixed ratio toggle button +void Crop::ratioFixedChanged () { + // Batch mode handling when enabling/disabling fixed crop + if (batchMode && lastFixRatio != fixr->get_active ()) { if (fixr->get_inconsistent()) { fixr->set_inconsistent (false); fconn.block (true); fixr->set_active (false); fconn.block (false); } - else if (lastAspect) + else if (lastFixRatio) fixr->set_inconsistent (true); - - lastAspect = fixr->get_active (); } + lastFixRatio = fixr->get_active (); + adjustCropToRatio(); +} +// change to orientation or ration +void Crop::ratioChanged () { + if (!fixr->get_active ()) + fixr->set_active(true); // will ajust ratio anyway + else + adjustCropToRatio(); +} + +// Correct current crop if it doesn't fit +void Crop::adjustCropToRatio() { if (fixr->get_active() && !fixr->get_inconsistent()) { // int W = w->get_value (); @@ -556,10 +567,11 @@ void Crop::ratioChanged () { cropWidth2Resized (X, Y, W, H); else cropHeight2Resized (X, Y, W, H); + } + // This will safe the options g_idle_add (refreshSpinsUI, new RefreshSpinHelper (this, true)); } -} void Crop::refreshSize () { diff --git a/rtgui/crop.h b/rtgui/crop.h index ce3f5727d..eb8111882 100644 --- a/rtgui/crop.h +++ b/rtgui/crop.h @@ -54,7 +54,8 @@ class Crop : public Gtk::VBox, public CropGUIListener, public FoldableToolPanel, int nx, ny, nw, nh; int lastRotationDeg; sigc::connection xconn, yconn, wconn, hconn, econn, fconn, rconn, oconn, gconn; - bool wDirty, hDirty, xDirty, yDirty, lastEnabled, lastAspect; + bool wDirty, hDirty, xDirty, yDirty, lastEnabled, lastFixRatio; + void adjustCropToRatio(); public: @@ -65,6 +66,7 @@ class Crop : public Gtk::VBox, public CropGUIListener, public FoldableToolPanel, void setBatchMode (bool batchMode); void ratioChanged (); + void ratioFixedChanged (); // The toggle button void refreshSize (); void selectPressed (); void setDimensions (int mw, int mh);