From ccc882dbcff710778c09724e7a044bfebbc0233a Mon Sep 17 00:00:00 2001 From: heckflosse Date: Wed, 24 Oct 2018 17:12:11 +0200 Subject: [PATCH] Review idle_register.add() calls: wavelets, ciecam02, colortoning --- rtengine/improccoordinator.cc | 4 +- rtengine/rtengine.h | 2 +- rtgui/colorappearance.cc | 87 +++++++++++++++-------------------- rtgui/colorappearance.h | 5 -- rtgui/colortoning.cc | 49 +++++++------------- rtgui/colortoning.h | 6 +-- rtgui/wavelet.cc | 44 +++++++----------- rtgui/wavelet.h | 2 - 8 files changed, 75 insertions(+), 124 deletions(-) diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 5cc93d3c7..4a0072bea 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -611,7 +611,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) if (actListener && params.colorToning.enabled) { if (params.blackwhite.enabled && params.colorToning.autosat) { - actListener->autoColorTonChanged(0, satTH, satPR); //hide sliders only if autosat + actListener->autoColorTonChanged(satTH, satPR); //hide sliders only if autosat indi = 0; } else { if (params.colorToning.autosat) { @@ -656,7 +656,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange) printf("ImProcCoordinator / Auto CT: indi=%d satH=%d satPR=%d\n", indi, (int)colourToningSatLimit, (int) colourToningSatLimitOpacity); } - actListener->autoColorTonChanged(indi, (int) colourToningSatLimit, (int)colourToningSatLimitOpacity); //change sliders autosat + actListener->autoColorTonChanged((int) colourToningSatLimit, (int)colourToningSatLimitOpacity); //change sliders autosat } // correct GUI black and white with value diff --git a/rtengine/rtengine.h b/rtengine/rtengine.h index bc8c12fec..b47620ee9 100644 --- a/rtengine/rtengine.h +++ b/rtengine/rtengine.h @@ -347,7 +347,7 @@ class AutoColorTonListener { public: virtual ~AutoColorTonListener() = default; - virtual void autoColorTonChanged(int bwct, int satthres, int satprot) = 0; + virtual void autoColorTonChanged(int satthres, int satprot) = 0; }; class AutoBWListener diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index 094c6fc5d..14e630f3c 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -1451,75 +1451,64 @@ void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdit void ColorAppearance::autoCamChanged (double ccam, double ccamout) { - nextCcam = ccam; - nextCcamout = ccamout; + struct Data { + ColorAppearance *me; + double ccam; + double ccamout; + }; - const auto func = [] (gpointer data) -> gboolean { - static_cast (data)->autoCamComputed_(); + const auto func = [](gpointer data) -> gboolean { + Data *d = static_cast(data); + ColorAppearance *me = d->me; + me->disableListener(); + me->degree->setValue(d->ccam); + me->degreeout->setValue(d->ccamout); + me->enableListener(); + delete d; return FALSE; }; - idle_register.add (func, this); -} - -bool ColorAppearance::autoCamComputed_ () -{ - - disableListener (); -// degree->setEnabled (true); - degree->setValue (nextCcam); - degreeout->setValue (nextCcamout); - enableListener (); - - return false; + idle_register.add(func, new Data { this, ccam, ccamout }); } void ColorAppearance::adapCamChanged (double cadap) { - nextCadap = cadap; + struct Data { + ColorAppearance *me; + double cadap; + }; - const auto func = [] (gpointer data) -> gboolean { - static_cast (data)->adapCamComputed_(); + const auto func = [](gpointer data) -> gboolean { + Data *d = static_cast(data); + ColorAppearance *me = d->me; + me->disableListener(); + me->adapscen->setValue(d->cadap); + me->enableListener(); + delete d; return FALSE; }; - idle_register.add (func, this); -} - -bool ColorAppearance::adapCamComputed_ () -{ - - disableListener (); -// degree->setEnabled (true); - adapscen->setValue (nextCadap); -// ybscen->setValue (nextYbscn); - enableListener (); - - return false; + idle_register.add(func, new Data { this, cadap }); } void ColorAppearance::ybCamChanged (int ybsc) { - nextYbscn = ybsc; + struct Data { + ColorAppearance *me; + int ybsc; + }; - const auto func = [] (gpointer data) -> gboolean { - static_cast (data)->ybCamComputed_(); + const auto func = [](gpointer data) -> gboolean { + Data *d = static_cast(data); + ColorAppearance *me = d->me; + me->disableListener(); + me->ybscen->setValue(d->ybsc); + me->enableListener(); + delete d; return FALSE; }; - idle_register.add (func, this); -} - -bool ColorAppearance::ybCamComputed_ () -{ - - disableListener (); -// degree->setEnabled (true); -// adapscen->setValue (nextCadap); - ybscen->setValue (nextYbscn); - enableListener (); - - return false; + idle_register.add(func, new Data { this, ybsc }); } void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) diff --git a/rtgui/colorappearance.h b/rtgui/colorappearance.h index 5dd8a2e82..98947b5a5 100644 --- a/rtgui/colorappearance.h +++ b/rtgui/colorappearance.h @@ -59,11 +59,8 @@ public: void tonecie_toggled (); // void sharpcie_toggled (); void autoCamChanged (double ccam, double ccamout); - bool autoCamComputed_ (); void adapCamChanged (double cadap); - bool adapCamComputed_ (); void ybCamChanged (int yb); - bool ybCamComputed_ (); void curveChanged (CurveEditor* ce); void curveMode1Changed (); @@ -160,8 +157,6 @@ private: DiagonalCurveEditor* shape; DiagonalCurveEditor* shape2; DiagonalCurveEditor* shape3; - double nextCcam, nextCcamout, nextCadap; - int nextYbscn; bool lastAutoDegree; bool lastAutoAdapscen; bool lastAutoDegreeout; diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index 8b357c3f9..2f32d9b0b 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -13,7 +13,6 @@ using namespace rtengine::procparams; ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLORTONING_LABEL"), false, true) { - nextbw = 0; CurveListener::setMulti(true); //---------------method @@ -688,40 +687,26 @@ void ColorToning::setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool } -void ColorToning::autoColorTonChanged(int bwct, int satthres, int satprot) +void ColorToning::autoColorTonChanged(int satthres, int satprot) { - nextbw = bwct; - nextsatth = satthres; - nextsatpr = satprot; + struct Data { + ColorToning *me; + int satthres; + int satprot; + }; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->CTComp_(); - return FALSE; - }; + const auto func = [](gpointer data) -> gboolean { + Data *d = static_cast(data); + ColorToning *me = d->me; + me->disableListener(); + me->satProtectionThreshold->setValue(d->satthres); + me->saturatedOpacity->setValue(d->satprot); + me->enableListener (); + delete d; + return FALSE; + }; - idle_register.add(func, this); -} - -bool ColorToning::CTComp_ () -{ - - disableListener (); - saturatedOpacity->setValue (nextsatpr); - satProtectionThreshold->setValue (nextsatth); - /* if(nextbw==1) { - saturatedOpacity->show(); - satProtectionThreshold->show(); - autosat->show(); - } - else { - saturatedOpacity->hide(); - satProtectionThreshold->hide(); - autosat->hide(); - } - */ - enableListener (); - - return false; + idle_register.add(func, new Data { this, satthres, satprot }); } void ColorToning::adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop) diff --git a/rtgui/colortoning.h b/rtgui/colortoning.h index cb021e242..5ee5d5ec9 100644 --- a/rtgui/colortoning.h +++ b/rtgui/colortoning.h @@ -36,8 +36,7 @@ public: void setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool satOpacityAdd, bool strprotectAdd, bool balanceAdd); void neutral_pressed (); //void neutralCurves_pressed (); - void autoColorTonChanged (int bwct, int satthres, int satprot); - bool CTComp_ (); + void autoColorTonChanged (int satthres, int satprot); void adjusterChanged(ThresholdAdjuster* a, double newBottom, double newTop); void adjusterChanged(ThresholdAdjuster* a, double newBottomLeft, double newTopLeft, double newBottomRight, double newTopRight); @@ -99,9 +98,6 @@ private: Gtk::Button* neutral; Gtk::HBox* neutrHBox; - int nextbw; - int nextsatth; - int nextsatpr; Glib::ustring nextbalcolor; Glib::ustring balcolor; sigc::connection neutralconn, twocconn; //, neutralcurvesconn; diff --git a/rtgui/wavelet.cc b/rtgui/wavelet.cc index 81fc282ab..7aa03050a 100644 --- a/rtgui/wavelet.cc +++ b/rtgui/wavelet.cc @@ -144,7 +144,6 @@ Wavelet::Wavelet() : neutrHBox(Gtk::manage(new Gtk::HBox())) { CurveListener::setMulti(true); - nextnlevel = 7.; expsettings->signal_button_release_event().connect_notify( sigc::bind( sigc::mem_fun(this, &Wavelet::foldAllButMe), expsettings) ); @@ -886,36 +885,25 @@ Wavelet::~Wavelet () } void Wavelet::wavChanged (double nlevel) -{ - nextnlevel = nlevel; - - const auto func = [](gpointer data) -> gboolean { - GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected - static_cast(data)->wavComputed_(); - - return FALSE; - }; - - idle_register.add(func, this); -} - -bool Wavelet::wavComputed_ () -{ - disableListener (); - enableListener (); - updatewavLabel (); - return false; -} - -void Wavelet::updatewavLabel () { if (!batchMode) { - float lv; - lv = nextnlevel; - wavLabels->set_text( + struct Data { + Wavelet *me; + double nlevel; + }; + + const auto func = [](gpointer data) -> gboolean { + Data *d = static_cast(data); + Wavelet *me = d->me; + me->wavLabels->set_text( Glib::ustring::compose(M("TP_WAVELET_LEVLABEL"), - Glib::ustring::format(std::fixed, std::setprecision(0), lv)) - ); + Glib::ustring::format(std::fixed, std::setprecision(0), d->nlevel)) + ); + delete d; + return FALSE; + }; + + idle_register.add(func, new Data { this, nlevel }); } } diff --git a/rtgui/wavelet.h b/rtgui/wavelet.h index 5cbb5bfe3..4146fa17d 100644 --- a/rtgui/wavelet.h +++ b/rtgui/wavelet.h @@ -93,7 +93,6 @@ private: void neutral_pressed (); void neutralchPressed (); void tmrToggled (); - void updatewavLabel (); void wavChanged (double nlevel); void HSmethodUpdateUI(); @@ -252,7 +251,6 @@ private: sigc::connection neutralchPressedConn; bool lastmedian, lastmedianlev, lastlinkedg, lastavoid, lastlipst, lasttmr, lastcbenab; - int nextnlevel; IdleRegister idle_register; };