diff --git a/rtdata/languages/Deutsch b/rtdata/languages/Deutsch index 5ec13a759..5f232a286 100644 --- a/rtdata/languages/Deutsch +++ b/rtdata/languages/Deutsch @@ -76,6 +76,7 @@ #75 02.12.2018 Erweiterung (TooWaBoo) RT 5.5 #76 11.12.2018 Erweiterung (TooWaBoo) RT 5.5 #77 16.12.2018 Korrektur Farbwähler-Tooltip (TooWaBoo) RT 5.5 +#78 19.01.2019 Erweiterung (TooWaBoo) RT 5.5 ABOUT_TAB_BUILD;Version ABOUT_TAB_CREDITS;Danksagungen @@ -2412,7 +2413,7 @@ ZOOMPANEL_ZOOMOUT;Herauszoomen\nTaste: - ! Untranslated keys follow; remove the ! prefix after an entry is translated. !!!!!!!!!!!!!!!!!!!!!!!!! -!HISTORY_MSG_SHARPENING_BLUR;Sharpening - Blur radius -!MAIN_TAB_FAVORITES;Favorites -!MAIN_TAB_FAVORITES_TOOLTIP;Shortcut: Alt-u -!TP_SHARPENING_BLUR;Blur radius +HISTORY_MSG_SHARPENING_BLUR;(Schärfung)\nWeichzeichnerradius +MAIN_TAB_FAVORITES;Favoriten +MAIN_TAB_FAVORITES_TOOLTIP;Taste: Alt + u +TP_SHARPENING_BLUR;Weichzeichnerradius diff --git a/rtdata/profiles/Pixel Shift/PS ISO Low.pp3 b/rtdata/profiles/Pixel Shift/PS ISO Low.pp3 index afd3b762c..5587b19e0 100644 --- a/rtdata/profiles/Pixel Shift/PS ISO Low.pp3 +++ b/rtdata/profiles/Pixel Shift/PS ISO Low.pp3 @@ -12,7 +12,7 @@ Enabled=true Contrast=15 Matrix=false Strength=20 -Uniformity=50 +Uniformity=5 [RAW] CA=true diff --git a/rtdata/profiles/Pixel Shift/PS No Motion.pp3 b/rtdata/profiles/Pixel Shift/PS No Motion.pp3 index af624912e..f1d889f97 100644 --- a/rtdata/profiles/Pixel Shift/PS No Motion.pp3 +++ b/rtdata/profiles/Pixel Shift/PS No Motion.pp3 @@ -12,7 +12,7 @@ Enabled=true Contrast=15 Matrix=false Strength=20 -Uniformity=50 +Uniformity=5 [RAW] CA=true diff --git a/rtengine/curves.h b/rtengine/curves.h index 817c34ccd..78d258d8a 100644 --- a/rtengine/curves.h +++ b/rtengine/curves.h @@ -49,8 +49,7 @@ namespace rtengine class ToneCurve; class ColorAppearance; -template -void setUnlessOOG(T &r, T &g, T &b, const T &rr, const T &gg, const T &bb) +inline void setUnlessOOG(float &r, float &g, float &b, const float &rr, const float &gg, const float &bb) { if (!OOG(r) || !OOG(g) || !OOG(b)) { r = rr; @@ -59,6 +58,22 @@ void setUnlessOOG(T &r, T &g, T &b, const T &rr, const T &gg, const T &bb) } } +#ifdef __SSE2__ +inline vmask OOG(const vfloat val) +{ + return vorm(vmaskf_lt(val, ZEROV), vmaskf_gt(val, F2V(65535.f))); +} + + +inline void setUnlessOOG(vfloat &r, vfloat &g, vfloat &b, const vfloat rr, const vfloat gg, const vfloat bb) +{ + vmask cond = vandm(vandm(OOG(r), OOG(g)), OOG(b)); + r = vself(cond, r, rr); + g = vself(cond, g, gg); + b = vself(cond, b, bb); +} +#endif + bool sanitizeCurve(std::vector& curve); namespace curves { @@ -1271,33 +1286,24 @@ inline void StandardToneCurve::BatchApply( break; #endif } - curves::setLutVal(lutToneCurve, r[i], g[i], b[i]); + setUnlessOOG(r[i], g[i], b[i], lutToneCurve[r[i]], lutToneCurve[g[i]], lutToneCurve[b[i]]); i++; } #ifdef __SSE2__ - float tmpr[4] ALIGNED16; - float tmpg[4] ALIGNED16; - float tmpb[4] ALIGNED16; - // float mv = lutToneCurve[MAXVALF]; for (; i + 3 < end; i += 4) { - __m128 r_val = LVF(r[i]); - __m128 g_val = LVF(g[i]); - __m128 b_val = LVF(b[i]); - STVF(tmpr[0], lutToneCurve[r_val]); - STVF(tmpg[0], lutToneCurve[g_val]); - STVF(tmpb[0], lutToneCurve[b_val]); - for (int j = 0; j < 4; ++j) { - setUnlessOOG(r[i+j], g[i+j], b[i+j], tmpr[j], tmpg[j], tmpb[j]); - // curves::setLutVal(r[i+j], tmpr[j], mv); - // curves::setLutVal(g[i+j], tmpg[j], mv); - // curves::setLutVal(b[i+j], tmpb[j], mv); - } + vfloat r_val = LVF(r[i]); + vfloat g_val = LVF(g[i]); + vfloat b_val = LVF(b[i]); + setUnlessOOG(r_val, g_val, b_val, lutToneCurve[r_val], lutToneCurve[g_val], lutToneCurve[b_val]); + STVF(r[i], r_val); + STVF(g[i], g_val); + STVF(b[i], b_val); } // Remainder in non-SSE. for (; i < end; ++i) { - curves::setLutVal(lutToneCurve, r[i], g[i], b[i]); + setUnlessOOG(r[i], g[i], b[i], lutToneCurve[r[i]], lutToneCurve[g[i]], lutToneCurve[b[i]]); } #endif @@ -1462,10 +1468,6 @@ inline void WeightedStdToneCurve::BatchApply(const size_t start, const size_t en const vfloat zd5v = F2V(0.5f); const vfloat zd25v = F2V(0.25f); - float tmpr[4] ALIGNED16; - float tmpg[4] ALIGNED16; - float tmpb[4] ALIGNED16; - for (; i + 3 < end; i += 4) { vfloat r_val = vclampf(LVF(r[i]), ZEROV, c65535v); vfloat g_val = vclampf(LVF(g[i]), ZEROV, c65535v); @@ -1482,12 +1484,16 @@ inline void WeightedStdToneCurve::BatchApply(const size_t start, const size_t en vfloat r3 = Triangle(b_val, b3, r_val); vfloat g3 = Triangle(b_val, b3, g_val); - STVF(tmpr[0], vclampf(r1 * zd5v + r2 * zd25v + r3 * zd25v, ZEROV, c65535v)); - STVF(tmpg[0], vclampf(g1 * zd25v + g2 * zd5v + g3 * zd25v, ZEROV, c65535v)); - STVF(tmpb[0], vclampf(b1 * zd25v + b2 * zd25v + b3 * zd5v, ZEROV, c65535v)); - for (int j = 0; j < 4; ++j) { - setUnlessOOG(r[i+j], g[i+j], b[i+j], tmpr[j], tmpg[j], tmpb[j]); - } + vfloat r_old = LVF(r[i]); + vfloat g_old = LVF(g[i]); + vfloat b_old = LVF(b[i]); + vfloat r_new = vclampf(r1 * zd5v + r2 * zd25v + r3 * zd25v, ZEROV, c65535v); + vfloat g_new = vclampf(g1 * zd25v + g2 * zd5v + g3 * zd25v, ZEROV, c65535v); + vfloat b_new = vclampf(b1 * zd25v + b2 * zd25v + b3 * zd5v, ZEROV, c65535v); + setUnlessOOG(r_old, g_old, b_old, r_new, g_new, b_new); + STVF(r[i], r_old); + STVF(g[i], g_old); + STVF(b[i], b_old); } // Remainder in non-SSE. diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 33972075c..b0248456a 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -255,14 +255,21 @@ bool get_RT_gamma_slope(cmsHPROFILE profile, double &gammatag, double &slopetag) modelDesc = utf32_to_utf8(buffer, count); #endif if (!modelDesc.empty()) { - std::size_t pos = modelDesc.find("g"); - std::size_t posmid = modelDesc.find("s"); - std::size_t posend = modelDesc.find("!"); - std::string strgamma = modelDesc.substr(pos + 1, (posmid - pos)); - gammatag = std::stod(strgamma.c_str()); - std::string strslope = modelDesc.substr(posmid + 1, (posend - posmid)); - slopetag = std::stod(strslope.c_str()); - return true; + try { + std::size_t pos = modelDesc.find("g"); + std::size_t posmid = modelDesc.find("s"); + std::size_t posend = modelDesc.find("!"); + if (pos == std::string::npos || posmid == std::string::npos || posend == std::string::npos) { + return false; + } + std::string strgamma = modelDesc.substr(pos + 1, (posmid - pos)); + gammatag = std::stod(strgamma.c_str()); + std::string strslope = modelDesc.substr(posmid + 1, (posend - posmid)); + slopetag = std::stod(strslope.c_str()); + return true; + } catch (std::invalid_argument &) { + return false; + } } } } diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index 940806419..0d978aa5b 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -143,9 +143,6 @@ void Imagefloat::getScanline (int row, unsigned char* buffer, int bps, bool isFl float ri = r(row, i); float gi = g(row, i); float bi = b(row, i); - if (ri > 65535.f || gi > 65535.f || bi > 65535.f) { - filmlike_clip(&ri, &gi, &bi); - } if (bps == 16) { sbuffer[ix++] = CLIP(ri); sbuffer[ix++] = CLIP(gi); diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 7a4605806..00f7c36b9 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -357,14 +357,39 @@ void ImProcFunctions::updateColorProfiles(const Glib::ustring& monitorProfile, R // flags |= cmsFLAGS_GAMUTCHECK; // } + const auto make_gamma_table = + [](cmsHPROFILE prof, cmsTagSignature tag) -> void + { + cmsToneCurve *tc = static_cast(cmsReadTag(prof, tag)); + if (tc) { + const cmsUInt16Number *table = cmsGetToneCurveEstimatedTable(tc); + cmsToneCurve *tc16 = cmsBuildTabulatedToneCurve16(nullptr, cmsGetToneCurveEstimatedTableEntries(tc), table); + if (tc16) { + cmsWriteTag(prof, tag, tc16); + cmsFreeToneCurve(tc16); + } + } + }; + + cmsHPROFILE softproof = ProfileContent(oprof).toProfile(); + if (softproof) { + make_gamma_table(softproof, cmsSigRedTRCTag); + make_gamma_table(softproof, cmsSigGreenTRCTag); + make_gamma_table(softproof, cmsSigBlueTRCTag); + } + monitorTransform = cmsCreateProofingTransform( iprof, TYPE_Lab_FLT, monitor, TYPE_RGB_FLT, - oprof, + softproof, //oprof, monitorIntent, outIntent, flags ); + if (softproof) { + cmsCloseProfile(softproof); + } + if (monitorTransform) { softProofCreated = true; } diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index 9ab8e1d01..04358f6af 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -41,9 +41,6 @@ inline void copyAndClampLine(const float *src, unsigned char *dst, const int W) float r = src[iy] * MAXVALF; float g = src[iy+1] * MAXVALF; float b = src[iy+2] * MAXVALF; - if (r > MAXVALF || g > MAXVALF || b > MAXVALF) { - filmlike_clip(&r, &g, &b); - } dst[iy] = uint16ToUint8Rounded(CLIP(r)); dst[iy+1] = uint16ToUint8Rounded(CLIP(g)); dst[iy+2] = uint16ToUint8Rounded(CLIP(b)); @@ -73,10 +70,6 @@ inline void copyAndClamp(const LabImage *src, unsigned char *dst, const double r Color::Lab2XYZ(rL[j], ra[j], rb[j], x_, y_, z_ ); Color::xyz2rgb(x_, y_, z_, R, G, B, rgb_xyz); - if (R > MAXVALF || G > MAXVALF || B > MAXVALF) { - filmlike_clip(&R, &G, &B); - } - dst[ix++] = uint16ToUint8Rounded(Color::gamma2curve[R]); dst[ix++] = uint16ToUint8Rounded(Color::gamma2curve[G]); dst[ix++] = uint16ToUint8Rounded(Color::gamma2curve[B]); diff --git a/rtengine/ipsharpen.cc b/rtengine/ipsharpen.cc index a70f12c61..63a07481d 100644 --- a/rtengine/ipsharpen.cc +++ b/rtengine/ipsharpen.cc @@ -746,7 +746,7 @@ BENCHFUN const int k = params->sharpenMicro.matrix ? 1 : 2; // k=2 matrix 5x5 k=1 matrix 3x3 const int width = W, height = H; - const int unif = params->sharpenMicro.uniformity / 10.0f; //put unif between 0 to 10 + const int unif = params->sharpenMicro.uniformity; const float amount = (k == 1 ? 2.7f : 1.f) * params->sharpenMicro.amount / 1500.0f; //amount 2000.0 quasi no artifacts ==> 1500 = maximum, after artifacts, 25/9 if 3x3 if (settings->verbose) { diff --git a/rtengine/procparams.cc b/rtengine/procparams.cc index f56118f62..4ae9d48fe 100644 --- a/rtengine/procparams.cc +++ b/rtengine/procparams.cc @@ -1149,7 +1149,7 @@ SharpenMicroParams::SharpenMicroParams() : matrix(false), amount(20.0), contrast(20.0), - uniformity(50.0) + uniformity(5) { } @@ -4431,8 +4431,13 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited) pedited->sharpenMicro.contrast = true; } } - - assignFromKeyfile(keyFile, "SharpenMicro", "Uniformity", pedited, sharpenMicro.uniformity, pedited->sharpenMicro.uniformity); + if (ppVersion >= 346) { + assignFromKeyfile(keyFile, "SharpenMicro", "Uniformity", pedited, sharpenMicro.uniformity, pedited->sharpenMicro.uniformity); + } else { + double temp; + assignFromKeyfile(keyFile, "SharpenMicro", "Uniformity", pedited, temp, pedited->sharpenMicro.uniformity); + sharpenMicro.uniformity = temp / 10; + } } if (keyFile.has_group("Vibrance")) { diff --git a/rtengine/procparams.h b/rtengine/procparams.h index a02a61a61..b21d931a7 100644 --- a/rtengine/procparams.h +++ b/rtengine/procparams.h @@ -550,7 +550,7 @@ struct SharpenMicroParams { bool matrix; double amount; double contrast; - double uniformity; + int uniformity; SharpenMicroParams(); diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index 40e6d9982..d5742cc0e 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -1376,7 +1376,7 @@ private: cmsHPROFILE jprof = nullptr; constexpr bool customGamma = false; constexpr bool useLCMS = false; - bool bwonly = params.blackwhite.enabled && !params.colorToning.enabled && !autili && !butili ; + bool bwonly = params.blackwhite.enabled && !params.colorToning.enabled && !autili && !butili && !params.colorappearance.enabled; ///////////// Custom output gamma has been removed, the user now has to create ///////////// a new output profile with the ICCProfileCreator diff --git a/rtgui/batchqueue.cc b/rtgui/batchqueue.cc index 6f09e25f1..f6c598df7 100644 --- a/rtgui/batchqueue.cc +++ b/rtgui/batchqueue.cc @@ -39,27 +39,6 @@ using namespace std; using namespace rtengine; -namespace -{ - -struct NLParams { - BatchQueueListener* listener; - int qsize; - bool queueRunning; - bool queueError; - Glib::ustring queueErrorMessage; -}; - -int bqnotifylistenerUI (void* data) -{ - NLParams* params = static_cast(data); - params->listener->queueSizeChanged (params->qsize, params->queueRunning, params->queueError, params->queueErrorMessage); - delete params; - return 0; -} - -} - BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCatalog(aFileCatalog), sequence(0), listener(nullptr) { @@ -107,6 +86,17 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCa BatchQueue::~BatchQueue () { + std::set removable_bqes; + + mutex_removable_batch_queue_entries.lock(); + removable_batch_queue_entries.swap(removable_bqes); + mutex_removable_batch_queue_entries.unlock(); + + for (const auto entry : removable_bqes) { + ::g_remove(entry->savedParamsFile.c_str()); + delete entry; + } + idle_register.destroy(); MYWRITERLOCK(l, entryRW); @@ -416,6 +406,8 @@ Glib::ustring BatchQueue::getTempFilenameForParams( const Glib::ustring &filenam void BatchQueue::cancelItems (const std::vector& items) { + std::set removable_bqes; + { MYWRITERLOCK(l, entryRW); @@ -438,16 +430,7 @@ void BatchQueue::cancelItems (const std::vector& items) if (entry->thumbnail) entry->thumbnail->imageRemovedFromQueue (); - const auto func = [](gpointer data) -> gboolean { - const BatchQueueEntry* const bqe = static_cast(data); - - ::g_remove(bqe->savedParamsFile.c_str()); - delete bqe; - - return FALSE; - }; - - idle_register.add(func, entry); + removable_bqes.insert(entry); } for (const auto entry : fd) @@ -457,6 +440,30 @@ void BatchQueue::cancelItems (const std::vector& items) selected.clear (); } + if (!removable_bqes.empty()) { + mutex_removable_batch_queue_entries.lock(); + removable_batch_queue_entries.insert(removable_bqes.begin(), removable_bqes.end()); + mutex_removable_batch_queue_entries.unlock(); + + idle_register.add( + [this]() -> bool + { + std::set removable_bqes; + + mutex_removable_batch_queue_entries.lock(); + removable_batch_queue_entries.swap(removable_bqes); + mutex_removable_batch_queue_entries.unlock(); + + for (const auto entry : removable_bqes) { + ::g_remove(entry->savedParamsFile.c_str()); + delete entry; + } + + return false; + } + ); + } + saveBatchQueue (); redraw (); @@ -610,12 +617,13 @@ void BatchQueue::setProgress(double p) } // No need to acquire the GUI, setProgressUI will do it - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->redraw(); - return FALSE; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + redraw(); + return false; + } + ); } void BatchQueue::setProgressStr(const Glib::ustring& str) @@ -640,12 +648,15 @@ void BatchQueue::error(const Glib::ustring& descr) } if (listener) { - NLParams* params = new NLParams; - params->listener = listener; - params->queueRunning = false; - params->queueError = true; - params->queueErrorMessage = descr; - idle_register.add(bqnotifylistenerUI, params); + BatchQueueListener* const bql = listener; + + idle_register.add( + [bql, descr]() -> bool + { + bql->queueSizeChanged(0, false, true, descr); + return false; + } + ); } } @@ -959,9 +970,7 @@ Glib::ustring BatchQueue::autoCompleteFileName (const Glib::ustring& fileName, c void BatchQueue::buttonPressed (LWButton* button, int actionCode, void* actionData) { - - std::vector bqe; - bqe.push_back (static_cast(actionData)); + const std::vector bqe = {static_cast(actionData)}; if (actionCode == 10) { // cancel cancelItems (bqe); @@ -976,15 +985,21 @@ void BatchQueue::notifyListener () { const bool queueRunning = processing; if (listener) { - NLParams* params = new NLParams; - params->listener = listener; + BatchQueueListener* const bql = listener; + + int qsize = 0; { MYREADERLOCK(l, entryRW); - params->qsize = fd.size(); + qsize = fd.size(); } - params->queueRunning = queueRunning; - params->queueError = false; - idle_register.add(bqnotifylistenerUI, params); + + idle_register.add( + [bql, qsize, queueRunning]() -> bool + { + bql->queueSizeChanged(qsize, queueRunning, false, {}); + return false; + } + ); } } diff --git a/rtgui/batchqueue.h b/rtgui/batchqueue.h index c05ca54fe..7751ec176 100644 --- a/rtgui/batchqueue.h +++ b/rtgui/batchqueue.h @@ -18,12 +18,16 @@ #ifndef _BATCHQUEUE_ #define _BATCHQUEUE_ +#include + #include -#include "threadutils.h" -#include "batchqueueentry.h" + #include "../rtengine/rtengine.h" -#include "options.h" + +#include "batchqueueentry.h" #include "lwbuttonset.h" +#include "options.h" +#include "threadutils.h" #include "thumbbrowserbase.h" class BatchQueueListener @@ -85,7 +89,7 @@ public: static Glib::ustring calcAutoFileNameBase (const Glib::ustring& origFileName, int sequence = 0); static int calcMaxThumbnailHeight(); -protected: +private: int getMaxThumbnailHeight() const override; void saveThumbnailHeight (int height) override; int getThumbnailHeight () override; @@ -111,6 +115,9 @@ protected: BatchQueueListener* listener; + std::set removable_batch_queue_entries; + MyMutex mutex_removable_batch_queue_entries; + IdleRegister idle_register; }; diff --git a/rtgui/batchqueuepanel.cc b/rtgui/batchqueuepanel.cc index 8c6472c70..55aea5f4f 100644 --- a/rtgui/batchqueuepanel.cc +++ b/rtgui/batchqueuepanel.cc @@ -172,13 +172,14 @@ BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) : parent(nullptr) show_all (); if (batchQueue->loadBatchQueue()) { - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->resizeLoadedQueue(); - - return FALSE; - }; - - idle_register.add(func, batchQueue, G_PRIORITY_LOW); + idle_register.add( + [this]() -> bool + { + batchQueue->resizeLoadedQueue(); + return false; + }, + G_PRIORITY_LOW + ); } } diff --git a/rtgui/bayerprocess.cc b/rtgui/bayerprocess.cc index 2a65a158e..74cf27dde 100644 --- a/rtgui/bayerprocess.cc +++ b/rtgui/bayerprocess.cc @@ -718,54 +718,39 @@ void BayerProcess::pixelShiftMotionMethodChanged () void BayerProcess::FrameCountChanged(int n, int frameNum) { - struct Data { - BayerProcess *me; - int n; - int frameNum; - }; - const auto func = [](gpointer data) -> gboolean { - Data *d = static_cast(data); - BayerProcess *me = d->me; - me->imageNumber->block (true); - int n = d->n; - int frameNum = d->frameNum; + idle_register.add( + [this, n, frameNum]() -> bool + { + imageNumber->block(true); - me->imageNumber->remove_all(); - me->imageNumber->append("1"); - for(int i = 2; i <= std::min(n, 4); ++i) { - std::ostringstream entry; - entry << i; - me->imageNumber->append(entry.str()); + imageNumber->remove_all(); + imageNumber->append("1"); + for (int i = 2; i <= std::min(n, 4); ++i) { + std::ostringstream entry; + entry << i; + imageNumber->append(entry.str()); + } + imageNumber->set_active(std::min(frameNum, n - 1)); + if (n == 1) { + imageNumberBox->hide(); + } else { + imageNumberBox->show(); + } + imageNumber->block (false); + return false; } - me->imageNumber->set_active(std::min(frameNum, n - 1)); - if(n == 1) { - me->imageNumberBox->hide(); - } else { - me->imageNumberBox->show(); - } - me->imageNumber->block (false); - delete d; - return FALSE; - }; - - idle_register.add(func, new Data { this, n, frameNum }); + ); } void BayerProcess::autoContrastChanged (double autoContrast) { - struct Data { - BayerProcess *me; - double autoContrast; - }; - const auto func = [](gpointer data) -> gboolean { - Data *d = static_cast(data); - BayerProcess *me = d->me; - me->disableListener(); - me->dualDemosaicContrast->setValue(d->autoContrast); - me->enableListener(); - delete d; - return FALSE; - }; - - idle_register.add(func, new Data { this, autoContrast }); + idle_register.add( + [this, autoContrast]() -> bool + { + disableListener(); + dualDemosaicContrast->setValue(autoContrast); + enableListener(); + return false; + } + ); } diff --git a/rtgui/blackwhite.cc b/rtgui/blackwhite.cc index 47ab24f5e..dcc5c7e01 100644 --- a/rtgui/blackwhite.cc +++ b/rtgui/blackwhite.cc @@ -375,12 +375,13 @@ void BlackWhite::BWChanged (double redbw, double greenbw, double bluebw) nextgreenbw = greenbw; nextbluebw = bluebw; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->BWComputed_(); - return FALSE; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + BWComputed_(); + return false; + } + ); } bool BlackWhite::BWComputed_ () diff --git a/rtgui/colorappearance.cc b/rtgui/colorappearance.cc index 07af3d0a4..dea55ced4 100644 --- a/rtgui/colorappearance.cc +++ b/rtgui/colorappearance.cc @@ -1447,75 +1447,42 @@ void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdit void ColorAppearance::autoCamChanged (double ccam, double ccamout) { - nextCcam = ccam; - nextCcamout = ccamout; - - const auto func = [] (gpointer data) -> gboolean { - static_cast (data)->autoCamComputed_(); - 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( + [this, ccam, ccamout]() -> bool + { + disableListener(); + degree->setValue(ccam); + degreeout->setValue(ccamout); + enableListener(); + return false; + } + ); } void ColorAppearance::adapCamChanged (double cadap) { - nextCadap = cadap; - - const auto func = [] (gpointer data) -> gboolean { - static_cast (data)->adapCamComputed_(); - 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( + [this, cadap]() -> bool + { + disableListener(); + adapscen->setValue(cadap); + enableListener(); + return false; + } + ); } void ColorAppearance::ybCamChanged (int ybsc) { - nextYbscn = ybsc; - - const auto func = [] (gpointer data) -> gboolean { - static_cast (data)->ybCamComputed_(); - 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( + [this, ybsc]() -> bool + { + disableListener(); + ybscen->setValue(ybsc); + enableListener(); + return false; + } + ); } void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index effd76eca..025acb55f 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -356,7 +356,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR btn->set_size_request(-1, 20); box->pack_start(*btn, false, false); }; - + EvLabRegionList = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_LIST"); EvLabRegionAB = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_AB"); EvLabRegionSaturation = m->newEvent(LUMINANCECURVE, "HISTORY_MSG_COLORTONING_LABREGION_SATURATION"); @@ -405,7 +405,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR add_button(labRegionCopy, vb); hb->pack_start(*vb, Gtk::PACK_SHRINK); labRegionBox->pack_start(*hb, true, true); - + labRegionAB = Gtk::manage(new LabGrid(EvLabRegionAB, M("TP_COLORTONING_LABREGION_ABVALUES"), false)); labRegionBox->pack_start(*labRegionAB); @@ -433,7 +433,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR labRegionChannel->append(M("TP_COLORTONING_LABREGION_CHANNEL_B")); labRegionChannel->set_active(0); labRegionChannel->signal_changed().connect(sigc::mem_fun(*this, &ColorToning::labRegionChannelChanged)); - + hb->pack_start(*Gtk::manage(new Gtk::Label(M("TP_COLORTONING_LABREGION_CHANNEL") + ": ")), Gtk::PACK_SHRINK); hb->pack_start(*labRegionChannel); labRegionBox->pack_start(*hb); @@ -468,7 +468,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR auto n = labRegionList->append("1"); labRegionList->set_text(n, 1, "a=0 b=0 s=0 l=0"); } - + labRegionEditorG->curveListComplete(); labRegionEditorG->show(); labRegionBox->pack_start(*labRegionEditorG, Gtk::PACK_SHRINK, 2); @@ -490,7 +490,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR labRegionPower->delay = options.adjusterMaxDelay; labRegionMaskBlur->delay = options.adjusterMaxDelay; //------------------------------------------------------------------------ - + show_all(); disableListener(); @@ -575,7 +575,7 @@ void ColorToning::read (const ProcParams* pp, const ParamsEdited* pedited) } else { labRegionSelected = 0; labRegionShowMask->set_active(false); - } + } labRegionPopulateList(); labRegionShow(labRegionSelected); @@ -824,7 +824,7 @@ void ColorToning::setDefaults (const ProcParams* defParams, const ParamsEdited* shadowsColSat->setDefault (defParams->colorToning.shadowsColSat); strength->setDefault (defParams->colorToning.strength); labgrid->setDefault(defParams->colorToning.labgridALow / ColorToningParams::LABGRID_CORR_MAX, defParams->colorToning.labgridBLow / ColorToningParams::LABGRID_CORR_MAX, defParams->colorToning.labgridAHigh / ColorToningParams::LABGRID_CORR_MAX, defParams->colorToning.labgridBHigh / ColorToningParams::LABGRID_CORR_MAX); - + if (pedited) { redlow->setDefaultEditedState (pedited->colorToning.redlow ? Edited : UnEdited); @@ -891,34 +891,16 @@ void ColorToning::autoColorTonChanged(int bwct, int satthres, int satprot) nextsatth = satthres; nextsatpr = satprot; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->CTComp_(); - 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(); + idle_register.add( + [this]() -> bool + { + disableListener(); + saturatedOpacity->setValue(nextsatpr); + satProtectionThreshold->setValue(nextsatth); + enableListener(); + return false; } - else { - saturatedOpacity->hide(); - satProtectionThreshold->hide(); - autosat->hide(); - } - */ - enableListener (); - - return false; + ); } void ColorToning::adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop) @@ -1248,9 +1230,9 @@ void ColorToning::colorForValue (double valX, double valY, enum ColorCaller::Ele } x = log2lin(x, 3.f); // float x = valX; - Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); + Color::hsv2rgb01(x, 0.5f, 0.5f, R, G, B); } else if (callerId == ID_LABREGION_HUE+1) { - Color::hsv2rgb01(float(valY), float(valX), 0.5f, R, G, B); + Color::hsv2rgb01(float(valY), float(valX), 0.5f, R, G, B); } caller->ccRed = double(R); @@ -1440,7 +1422,7 @@ void ColorToning::labRegionGet(int idx) if (idx < 0 || size_t(idx) >= labRegionData.size()) { return; } - + auto &r = labRegionData[idx]; double la, lb; labRegionAB->getParams(la, lb, r.a, r.b); @@ -1544,7 +1526,7 @@ void ColorToning::labRegionPopulateList() ConnectionBlocker b(labRegionSelectionConn); labRegionList->clear_items(); rtengine::ColorToningParams::LabCorrectionRegion dflt; - + for (size_t i = 0; i < labRegionData.size(); ++i) { auto &r = labRegionData[i]; auto j = labRegionList->append(std::to_string(i+1)); diff --git a/rtgui/crop.cc b/rtgui/crop.cc index 1ba3171bc..1cd87b80a 100644 --- a/rtgui/crop.cc +++ b/rtgui/crop.cc @@ -28,31 +28,6 @@ extern Options options; namespace { -class RefreshSpinHelper -{ - -public: - Crop* crop; - bool notify; - RefreshSpinHelper (Crop* _crop, bool _notify) - : crop(_crop), notify(_notify) {} -}; - -int refreshSpinsUI (void* data) -{ - RefreshSpinHelper* rsh = static_cast(data); - rsh->crop->refreshSpins (rsh->notify); - delete rsh; - return 0; -} - -int notifyListenerUI (void* data) -{ - static_cast(data)->notifyListener(); - return 0; -} - - inline void get_custom_ratio(int w, int h, double &rw, double &rh) { if (w < h) { @@ -122,28 +97,28 @@ Crop::Crop(): Gtk::Label* xlab = Gtk::manage (new Gtk::Label (M("TP_CROP_X") + ":")); setExpandAlignProperties(xlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + x = Gtk::manage (new MySpinButton ()); setExpandAlignProperties(x, true, false, Gtk::ALIGN_END, Gtk::ALIGN_CENTER); x->set_width_chars(6); Gtk::Label* ylab = Gtk::manage (new Gtk::Label (M("TP_CROP_Y") + ":")); setExpandAlignProperties(ylab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + y = Gtk::manage (new MySpinButton ()); setExpandAlignProperties(y, true, false, Gtk::ALIGN_END, Gtk::ALIGN_CENTER); y->set_width_chars(6); - + Gtk::Label* wlab = Gtk::manage (new Gtk::Label (M("TP_CROP_W") + ":")); setExpandAlignProperties(wlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + w = Gtk::manage (new MySpinButton ()); setExpandAlignProperties(w, true, false, Gtk::ALIGN_END, Gtk::ALIGN_CENTER); w->set_width_chars(6); Gtk::Label* hlab = Gtk::manage (new Gtk::Label (M("TP_CROP_H") + ":")); setExpandAlignProperties(hlab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + h = Gtk::manage (new MySpinButton ()); setExpandAlignProperties(h, true, false, Gtk::ALIGN_END, Gtk::ALIGN_CENTER); h->set_width_chars(6); @@ -157,7 +132,7 @@ Crop::Crop(): setExpandAlignProperties(resetCrop, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); resetCrop->get_style_context()->add_class("independent"); resetCrop->set_image (*Gtk::manage (new RTImage ("undo-small.png"))); - + methodgrid->attach (*xlab, 0, 0, 1, 1); methodgrid->attach (*x, 1, 0, 1, 1); methodgrid->attach (*ylab, 2, 0, 1, 1); @@ -169,7 +144,7 @@ Crop::Crop(): methodgrid->attach (*selectCrop, 0, 2, 2, 1); methodgrid->attach (*resetCrop, 2, 2, 2, 1); pack_start (*methodgrid, Gtk::PACK_EXPAND_WIDGET, 0 ); - + Gtk::HSeparator* methodseparator = Gtk::manage (new Gtk::HSeparator()); methodseparator->get_style_context()->add_class("grid-row-separator"); pack_start (*methodseparator, Gtk::PACK_SHRINK, 0); @@ -181,7 +156,7 @@ Crop::Crop(): fixr = Gtk::manage (new Gtk::CheckButton (M("TP_CROP_FIXRATIO"))); setExpandAlignProperties(fixr, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); fixr->set_active (1); - + Gtk::Grid* ratiogrid = Gtk::manage(new Gtk::Grid()); ratiogrid->get_style_context()->add_class("grid-spacing"); setExpandAlignProperties(ratiogrid, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); @@ -195,15 +170,15 @@ Crop::Crop(): customRatioLabel = Gtk::manage(new Gtk::Label("")); customRatioLabel->hide(); setExpandAlignProperties(customRatioLabel, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - + ratiogrid->set_column_homogeneous (true); ratiogrid->attach (*ratio, 0, 0, 1, 1); ratiogrid->attach (*customRatioLabel, 1, 0, 1, 1); ratiogrid->attach (*orientation, 1, 0, 1, 1); - + Gtk::Label* guidelab = Gtk::manage (new Gtk::Label (M("TP_CROP_GUIDETYPE"))); setExpandAlignProperties(guidelab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + guide = Gtk::manage (new MyComboBoxText ()); setExpandAlignProperties(guide, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); @@ -222,27 +197,27 @@ Crop::Crop(): Gtk::HSeparator* ppiseparator = Gtk::manage (new Gtk::HSeparator()); ppiseparator->get_style_context()->add_class("grid-row-separator"); - + Gtk::Grid* ppisubgrid = Gtk::manage(new Gtk::Grid()); ppisubgrid->get_style_context()->add_class("grid-spacing"); setExpandAlignProperties(ppisubgrid, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); Gtk::Label* ppilab = Gtk::manage (new Gtk::Label (M("TP_CROP_PPI"))); setExpandAlignProperties(ppilab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + ppi = Gtk::manage (new MySpinButton ()); setExpandAlignProperties(ppi, true, false, Gtk::ALIGN_END, Gtk::ALIGN_CENTER); ppi->set_width_chars(6); - + ppisubgrid->attach (*ppilab, 0, 0, 1, 1); ppisubgrid->attach (*ppi, 1, 0, 1, 1); sizecm = Gtk::manage (new Gtk::Label (M("GENERAL_NA") + " cm x " + M("GENERAL_NA") + " cm")); setExpandAlignProperties(sizecm, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - + sizein = Gtk::manage (new Gtk::Label (M("GENERAL_NA") + " in x " + M("GENERAL_NA") + " in")); setExpandAlignProperties(sizein, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER); - + ppigrid->attach (*ppiseparator, 0, 0, 2, 1); ppigrid->attach (*sizecm, 1, 1, 1, 1); ppigrid->attach (*sizein, 1, 2, 1, 1); @@ -328,7 +303,7 @@ Crop::Crop(): ppisubgrid->set_column_spacing(4); #endif //GTK318 - + show_all (); } @@ -425,7 +400,7 @@ void Crop::read (const ProcParams* pp, const ParamsEdited* pedited) } else if (pp->crop.ratio == "Current") { ratio->set_active(1); updateCurrentRatio(); - customRatioLabel->show(); + customRatioLabel->show(); orientation->hide(); } else { ratio->set_active_text (pp->crop.ratio); @@ -591,7 +566,13 @@ void Crop::doresetCrop () int W = maxw; int H = maxh; cropResized (X, Y, W, H); - idle_register.add(notifyListenerUI, this); + idle_register.add( + [this]() -> bool + { + notifyListener(); + return false; + } + ); refreshSpins(); } @@ -629,16 +610,26 @@ void Crop::enabledChanged () void Crop::hFlipCrop () { - nx = maxw - nx - nw; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::vFlipCrop () { - ny = maxh - ny - nh; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::rotateCrop (int deg, bool hflip, bool vflip) @@ -678,7 +669,13 @@ void Crop::rotateCrop (int deg, bool hflip, bool vflip) } lastRotationDeg = deg; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::positionChanged () @@ -692,7 +689,13 @@ void Crop::positionChanged () int W = nw; int H = nh; cropMoved (X, Y, W, H); - idle_register.add(notifyListenerUI, this); + idle_register.add( + [this]() -> bool + { + notifyListener(); + return false; + } + ); } void Crop::widthChanged () @@ -705,7 +708,13 @@ void Crop::widthChanged () int W = (int)w->get_value (); int H = nh; cropWidth2Resized (X, Y, W, H); - idle_register.add(notifyListenerUI, this); + idle_register.add( + [this]() -> bool + { + notifyListener(); + return false; + } + ); } void Crop::heightChanged () @@ -718,7 +727,13 @@ void Crop::heightChanged () int W = nw; int H = (int)h->get_value (); cropHeight2Resized (X, Y, W, H); - idle_register.add(notifyListenerUI, this); + idle_register.add( + [this]() -> bool + { + notifyListener(); + return false; + } + ); } // Fixed ratio toggle button @@ -751,7 +766,7 @@ void Crop::ratioChanged () orientation->show(); customRatioLabel->hide(); } - + if (!fixr->get_active ()) { fixr->set_active(true); // will adjust ratio anyway } else { @@ -812,7 +827,13 @@ void Crop::adjustCropToRatio() } // This will save the options - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, true)); + idle_register.add( + [this]() -> bool + { + refreshSpins(true); + return false; + } + ); } void Crop::refreshSize () @@ -886,26 +907,13 @@ void Crop::setDimensions (int mw, int mh) void Crop::sizeChanged(int x, int y, int ow, int oh) { - struct Params { - Crop* crop; - int x; - int y; - }; - - Params* const params = new Params{ - this, - x, - y - }; - - const auto func = [](gpointer data) -> gboolean { - Params* const params = static_cast(data); - params->crop->setDimensions(params->x, params->y); - delete params; - return FALSE; - }; - - idle_register.add(func, params); + idle_register.add( + [this, x, y]() -> bool + { + setDimensions(x, y); + return false; + } + ); } bool Crop::refreshSpins (bool notify) @@ -973,7 +981,13 @@ void Crop::cropMoved (int &X, int &Y, int &W, int &H) nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); // Glib::signal_idle().connect (sigc::mem_fun(*this, &Crop::refreshSpins)); } @@ -1017,7 +1031,13 @@ void Crop::cropWidth1Resized (int &X, int &Y, int &W, int &H, float custom_ratio nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1057,7 +1077,13 @@ void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H, float custom_ratio nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1100,7 +1126,13 @@ void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H, float custom_rati nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1140,7 +1172,13 @@ void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H, float custom_rati nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1182,7 +1220,13 @@ void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H, float custom_rati nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1222,7 +1266,13 @@ void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H, float custom_rat nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1262,7 +1312,13 @@ void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H, float custom_r nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H, float custom_ratio) @@ -1299,7 +1355,13 @@ void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H, float custom_ nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropInit (int &x, int &y, int &w, int &h) @@ -1413,12 +1475,24 @@ void Crop::cropResized (int &x, int &y, int& x2, int& y2) nw = W; nh = H; - idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false)); + idle_register.add( + [this]() -> bool + { + refreshSpins(false); + return false; + } + ); } void Crop::cropManipReady () { - idle_register.add(notifyListenerUI, this); + idle_register.add( + [this]() -> bool + { + notifyListener(); + return false; + } + ); } double Crop::getRatio () const diff --git a/rtgui/crophandler.cc b/rtgui/crophandler.cc index c00cccf6c..fdb920269 100644 --- a/rtgui/crophandler.cc +++ b/rtgui/crophandler.cc @@ -338,70 +338,69 @@ void CropHandler::setDetailedCrop( bool expected = false; if (redraw_needed.compare_exchange_strong(expected, true)) { - const auto func = [](gpointer data) -> gboolean { - CropHandler* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + cimg.lock (); - self->cimg.lock (); + if (redraw_needed.exchange(false)) { + cropPixbuf.clear (); - if (self->redraw_needed.exchange(false)) { - self->cropPixbuf.clear (); - - if (!self->enabled) { - self->cropimg.clear(); - self->cropimgtrue.clear(); - self->cimg.unlock (); - return FALSE; - } - - if (!self->cropimg.empty()) { - if (self->cix == self->cropX && self->ciy == self->cropY && self->ciw == self->cropW && self->cih == self->cropH && self->cis == (self->zoom >= 1000 ? 1 : self->zoom / 10)) { - // calculate final image size - float czoom = self->zoom >= 1000 ? - self->zoom / 1000.f : - float((self->zoom/10) * 10) / float(self->zoom); - int imw = self->cropimg_width * czoom; - int imh = self->cropimg_height * czoom; - - if (imw > self->ww) { - imw = self->ww; - } - - if (imh > self->wh) { - imh = self->wh; - } - - Glib::RefPtr tmpPixbuf = Gdk::Pixbuf::create_from_data (self->cropimg.data(), Gdk::COLORSPACE_RGB, false, 8, self->cropimg_width, self->cropimg_height, 3 * self->cropimg_width); - self->cropPixbuf = Gdk::Pixbuf::create (Gdk::COLORSPACE_RGB, false, 8, imw, imh); - tmpPixbuf->scale (self->cropPixbuf, 0, 0, imw, imh, 0, 0, czoom, czoom, Gdk::INTERP_TILES); - tmpPixbuf.clear (); - - Glib::RefPtr tmpPixbuftrue = Gdk::Pixbuf::create_from_data (self->cropimgtrue.data(), Gdk::COLORSPACE_RGB, false, 8, self->cropimg_width, self->cropimg_height, 3 * self->cropimg_width); - self->cropPixbuftrue = Gdk::Pixbuf::create (Gdk::COLORSPACE_RGB, false, 8, imw, imh); - tmpPixbuftrue->scale (self->cropPixbuftrue, 0, 0, imw, imh, 0, 0, czoom, czoom, Gdk::INTERP_TILES); - tmpPixbuftrue.clear (); + if (!enabled) { + cropimg.clear(); + cropimgtrue.clear(); + cimg.unlock (); + return false; } - self->cropimg.clear(); - self->cropimgtrue.clear(); - } + if (!cropimg.empty()) { + if (cix == cropX && ciy == cropY && ciw == cropW && cih == cropH && cis == (zoom >= 1000 ? 1 : zoom / 10)) { + // calculate final image size + float czoom = zoom >= 1000 ? + zoom / 1000.f : + float((zoom/10) * 10) / float(zoom); + int imw = cropimg_width * czoom; + int imh = cropimg_height * czoom; - self->cimg.unlock (); + if (imw > ww) { + imw = ww; + } - if (self->displayHandler) { - self->displayHandler->cropImageUpdated (); + if (imh > wh) { + imh = wh; + } - if (self->initial.exchange(false)) { - self->displayHandler->initialImageArrived (); + Glib::RefPtr tmpPixbuf = Gdk::Pixbuf::create_from_data (cropimg.data(), Gdk::COLORSPACE_RGB, false, 8, cropimg_width, cropimg_height, 3 * cropimg_width); + cropPixbuf = Gdk::Pixbuf::create (Gdk::COLORSPACE_RGB, false, 8, imw, imh); + tmpPixbuf->scale (cropPixbuf, 0, 0, imw, imh, 0, 0, czoom, czoom, Gdk::INTERP_TILES); + tmpPixbuf.clear (); + + Glib::RefPtr tmpPixbuftrue = Gdk::Pixbuf::create_from_data (cropimgtrue.data(), Gdk::COLORSPACE_RGB, false, 8, cropimg_width, cropimg_height, 3 * cropimg_width); + cropPixbuftrue = Gdk::Pixbuf::create (Gdk::COLORSPACE_RGB, false, 8, imw, imh); + tmpPixbuftrue->scale (cropPixbuftrue, 0, 0, imw, imh, 0, 0, czoom, czoom, Gdk::INTERP_TILES); + tmpPixbuftrue.clear (); + } + + cropimg.clear(); + cropimgtrue.clear(); } + + cimg.unlock (); + + if (displayHandler) { + displayHandler->cropImageUpdated (); + + if (initial.exchange(false)) { + displayHandler->initialImageArrived (); + } + } + } else { + cimg.unlock(); } - } else { - self->cimg.unlock(); + + return false; } - - return FALSE; - }; - - idle_register.add(func, this/*, G_PRIORITY_HIGH_IDLE*/); + ); } } diff --git a/rtgui/dirpyrdenoise.cc b/rtgui/dirpyrdenoise.cc index c2fb31902..613dc8d44 100644 --- a/rtgui/dirpyrdenoise.cc +++ b/rtgui/dirpyrdenoise.cc @@ -44,8 +44,6 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP Gtk::VBox * lumaVBox = Gtk::manage ( new Gtk::VBox()); lumaVBox->set_spacing(2); - - ctboxL = Gtk::manage (new Gtk::HBox ()); Gtk::Label* labmL = Gtk::manage (new Gtk::Label (M("TP_DIRPYRDENOISE_LUMINANCE_CONTROL") + ":")); ctboxL->pack_start (*labmL, Gtk::PACK_SHRINK, 1); @@ -66,11 +64,10 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP lshape->setIdentityValue(0.); lshape->setResetCurve(FlatCurveType(defaultCurve.at(0)), defaultCurve); - //lshape->setEditID(EUID_Lab_LCurve, BT_SINGLEPLANE_FLOAT); milestones.push_back( GradientMilestone(0., 0., 0., 0.) ); milestones.push_back( GradientMilestone(1., 1., 1., 1.) ); lshape->setBottomBarBgGradient(milestones); - //lshape->setLeftBarBgGradient(milestones); + milestones.push_back( GradientMilestone(0., 0., 0., 0.) ); milestones.push_back( GradientMilestone(1., 1., 1., 1.) ); NoiscurveEditorG->curveListComplete(); @@ -107,7 +104,6 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP C2method->set_active(0); C2methodconn = C2method->signal_changed().connect ( sigc::mem_fun(*this, &DirPyrDenoise::C2methodChanged) ); - NoiseLabels = Gtk::manage(new Gtk::Label("---", Gtk::ALIGN_CENTER)); NoiseLabels->set_tooltip_text(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEWRESIDUAL_INFO_TOOLTIP")); @@ -129,7 +125,6 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP hb1->pack_end (*dmethod, Gtk::PACK_EXPAND_WIDGET, 1); pack_start(*hb1, Gtk::PACK_SHRINK, 1); - dmethodconn = dmethod->signal_changed().connect ( sigc::mem_fun(*this, &DirPyrDenoise::dmethodChanged) ); luma->setAdjusterListener (this); @@ -150,9 +145,6 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP CCcurveEditorG->curveListComplete(); - - //----------------------------------------- - luma->hide(); Ldetail->show(); @@ -162,8 +154,6 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP chroma->show(); redchro->show(); bluechro->show(); -// perform->show(); -// perform->set_active (true); // ---- Median FIltering ---- @@ -225,10 +215,7 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP smethod = Gtk::manage (new MyComboBoxText ()); smethod->append (M("TP_DIRPYRDENOISE_MAIN_MODE_CONSERVATIVE")); -// smethod->append (M("TP_DIRPYRDENOISE_MAIN_MODE_SHBI")); smethod->append (M("TP_DIRPYRDENOISE_MAIN_MODE_AGGRESSIVE")); -// smethod->append (M("TP_DIRPYRDENOISE_MAIN_MODE_SHALAL")); -// smethod->append (M("TP_DIRPYRDENOISE_MAIN_MODE_SHBIBI")); smethod->set_active(1); hb11->pack_start (*smethod, Gtk::PACK_EXPAND_WIDGET, 1); pack_start( *hb11, Gtk::PACK_SHRINK, 1); @@ -272,17 +259,9 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP chromaFrame->add(*chromaVBox); pack_start (*chromaFrame); -// pack_start( *hb11, Gtk::PACK_SHRINK, 4); - -// pack_start (*median); - ctboxm->pack_start (*methodmed); ctbox->pack_start (*medmethod); ctboxrgb->pack_start (*rgbmethod); -// pack_start (*ctboxm); -// pack_start (*ctbox); -// pack_start (*ctboxrgb); -// pack_start (*passes,Gtk::PACK_SHRINK, 1); medianVBox->pack_start (*ctboxm); medianVBox->pack_start (*ctbox); @@ -292,11 +271,8 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP pack_start (*medianFrame); - -// pack_start (*perform); medianConn = median->signal_toggled().connect( sigc::mem_fun(*this, &DirPyrDenoise::medianChanged) ); ctboxrgb->hide(); - } DirPyrDenoise::~DirPyrDenoise () @@ -313,24 +289,18 @@ void DirPyrDenoise::chromaChanged (double autchroma, double autred, double autbl nextred = autred; nextblue = autblue; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->chromaComputed_(); - return false; - }; - - idle_register.add(func, this); -} - -bool DirPyrDenoise::chromaComputed_ () -{ - - disableListener (); - chroma->setValue (nextchroma); - redchro->setValue (nextred); - bluechro->setValue (nextblue); - enableListener (); - updateNoiseLabel (); - return false; + idle_register.add( + [this]() -> bool + { + disableListener(); + chroma->setValue(nextchroma); + redchro->setValue(nextred); + bluechro->setValue(nextblue); + enableListener(); + updateNoiseLabel(); + return false; + } + ); } void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP) @@ -342,22 +312,16 @@ void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, i nextsizeT = sizeT; nextsizeP = sizeP; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->TilePrevComputed_(); - return false; - }; - - idle_register.add(func, this); -} - -bool DirPyrDenoise::TilePrevComputed_ () -{ - - disableListener (); - enableListener (); - updateTileLabel (); - updatePrevLabel (); - return false; + idle_register.add( + [this]() -> bool + { + disableListener(); + enableListener(); + updateTileLabel(); + updatePrevLabel(); + return false; + } + ); } void DirPyrDenoise::updateTileLabel () @@ -368,14 +332,12 @@ void DirPyrDenoise::updateTileLabel () sT = nextsizeT; nX = nexttileX; nY = nexttileY; - { - TileLabels->set_text( - Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_TILEINFO"), - Glib::ustring::format(std::fixed, std::setprecision(0), sT), - Glib::ustring::format(std::fixed, std::setprecision(0), nX), - Glib::ustring::format(std::fixed, std::setprecision(0), nY)) - ); - } + TileLabels->set_text( + Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_TILEINFO"), + Glib::ustring::format(std::fixed, std::setprecision(0), sT), + Glib::ustring::format(std::fixed, std::setprecision(0), nX), + Glib::ustring::format(std::fixed, std::setprecision(0), nY)) + ); } } void DirPyrDenoise::updatePrevLabel () @@ -386,14 +348,12 @@ void DirPyrDenoise::updatePrevLabel () sP = nextsizeP; pX = nextprevX; pY = nextprevY; - { - PrevLabels->set_text( - Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_INFO"), - Glib::ustring::format(std::fixed, std::setprecision(0), sP), - Glib::ustring::format(std::fixed, std::setprecision(0), pX), - Glib::ustring::format(std::fixed, std::setprecision(0), pY)) - ); - } + PrevLabels->set_text( + Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_INFO"), + Glib::ustring::format(std::fixed, std::setprecision(0), sP), + Glib::ustring::format(std::fixed, std::setprecision(0), pX), + Glib::ustring::format(std::fixed, std::setprecision(0), pY)) + ); } } @@ -402,24 +362,18 @@ void DirPyrDenoise::noiseChanged (double nresid, double highresid) nextnresid = nresid; nexthighresid = highresid; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->noiseComputed_(); - return false; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + disableListener(); + enableListener(); + updateNoiseLabel(); + return false; + } + ); } -bool DirPyrDenoise::noiseComputed_ () -{ - - disableListener (); - enableListener (); - updateNoiseLabel (); - return false; -} - -void DirPyrDenoise::updateNoiseLabel () +void DirPyrDenoise::updateNoiseLabel() { if (!batchMode) { float nois, high; @@ -438,8 +392,6 @@ void DirPyrDenoise::updateNoiseLabel () } } - - void DirPyrDenoise::read (const ProcParams* pp, const ParamsEdited* pedited) { @@ -647,7 +599,7 @@ void DirPyrDenoise::read (const ProcParams* pp, const ParamsEdited* pedited) medmethodconn.block(false); rgbmethodconn.block(false); methodmedconn.block(false); - updateNoiseLabel (); + updateNoiseLabel(); enableListener (); diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index c9fe1c7a1..f35fa3632 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -38,37 +38,15 @@ using namespace rtengine::procparams; namespace { -struct spparams { - double val; - Glib::ustring str; - MyProgressBar *pProgress; - Glib::RefPtr cssProvider; -}; - -int setprogressStrUI ( void *p ) +void setprogressStrUI(double val, const Glib::ustring str, MyProgressBar* pProgress) { - spparams *s = static_cast (p); - - if ( ! s->str.empty() ) { - s->pProgress->set_text ( M (s->str) ); + if (!str.empty()) { + pProgress->set_text(M(str)); } - if ( s->val >= 0 ) { - s->pProgress->set_fraction ( s->val ); - - if (s->cssProvider) { - if ( s->val < 1.0 ) { - s->cssProvider->load_from_data ("ProgressBar { background-color: red }"); - } else { - s->cssProvider->load_from_data ("ProgressBar { background-color: grey }"); - } - - s->pProgress->get_style_context()->set_background (s->pProgress->get_window()); - } + if (val >= 0.0) { + pProgress->set_fraction(val); } - - delete s; - return FALSE; } @@ -498,7 +476,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) // build left side panel leftbox = new Gtk::Paned (Gtk::ORIENTATION_VERTICAL); - + // make a subbox to allow resizing of the histogram (if it's on the left) leftsubbox = new Gtk::Box (Gtk::ORIENTATION_VERTICAL); leftsubbox->set_size_request (230, 250); @@ -520,7 +498,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) leftsubbox->pack_start (*history); leftsubbox->show_all (); - + leftbox->pack2 (*leftsubbox, true, true); leftbox->show_all (); @@ -638,14 +616,14 @@ EditorPanel::EditorPanel (FilePanel* filePanel) // build right side panel vboxright = new Gtk::Paned (Gtk::ORIENTATION_VERTICAL); - + vsubboxright = new Gtk::Box (Gtk::ORIENTATION_VERTICAL, 0); vsubboxright->set_size_request (300, 250); vsubboxright->pack_start (*ppframe, Gtk::PACK_SHRINK, 2); // main notebook vsubboxright->pack_start (*tpc->toolPanelNotebook); - + vboxright->pack2 (*vsubboxright, true, true); // Save buttons @@ -862,7 +840,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) if (tbTopPanel_1) { tbTopPanel_1->signal_toggled().connect ( sigc::mem_fun (*this, &EditorPanel::tbTopPanel_1_toggled) ); } - + } EditorPanel::~EditorPanel () @@ -1193,58 +1171,54 @@ void EditorPanel::clearParamChanges() void EditorPanel::setProgress(double p) { - spparams *s = new spparams; - s->val = p; - s->pProgress = progressLabel; - idle_register.add(setprogressStrUI, s); + MyProgressBar* const pl = progressLabel; + + idle_register.add( + [p, pl]() -> bool + { + setprogressStrUI(p, {}, pl); + return false; + } + ); } void EditorPanel::setProgressStr(const Glib::ustring& str) { - spparams *s = new spparams; - s->str = str; - s->val = -1; - s->pProgress = progressLabel; - idle_register.add(setprogressStrUI, s); + MyProgressBar* const pl = progressLabel; + + idle_register.add( + [str, pl]() -> bool + { + setprogressStrUI(-1.0, str, pl); + return false; + } + ); } void EditorPanel::setProgressState(bool inProcessing) { - struct spsparams { - bool inProcessing; - EditorPanelIdleHelper* epih; - }; - epih->pending++; - spsparams* p = new spsparams; - p->inProcessing = inProcessing; - p->epih = epih; - - const auto func = [] (gpointer data) -> gboolean { - spsparams* const p = static_cast (data); - - if (p->epih->destroyed) + idle_register.add( + [this, inProcessing]() -> bool { - if (p->epih->pending == 1) { - delete p->epih; - } else { - p->epih->pending--; + if (epih->destroyed) + { + if (epih->pending == 1) { + delete epih; + } else { + --epih->pending; + } + + return false; } - delete p; + epih->epanel->refreshProcessingState(inProcessing); + --epih->pending; - return 0; + return false; } - - p->epih->epanel->refreshProcessingState (p->inProcessing); - p->epih->pending--; - delete p; - - return FALSE; - }; - - idle_register.add (func, p); + ); } void EditorPanel::error(const Glib::ustring& descr) @@ -1253,42 +1227,27 @@ void EditorPanel::error(const Glib::ustring& descr) void EditorPanel::error(const Glib::ustring& title, const Glib::ustring& descr) { - struct errparams { - Glib::ustring descr; - Glib::ustring title; - EditorPanelIdleHelper* epih; - }; - epih->pending++; - errparams* const p = new errparams; - p->descr = descr; - p->title = title; - p->epih = epih; - const auto func = [] (gpointer data) -> gboolean { - errparams* const p = static_cast (data); - - if (p->epih->destroyed) + idle_register.add( + [this, descr, title]() -> bool { - if (p->epih->pending == 1) { - delete p->epih; - } else { - p->epih->pending--; + if (epih->destroyed) { + if (epih->pending == 1) { + delete epih; + } else { + --epih->pending; + } + + return false; } - delete p; + epih->epanel->displayError(title, descr); + --epih->pending; - return 0; + return false; } - - p->epih->epanel->displayError (p->title, p->descr); - p->epih->pending--; - delete p; - - return FALSE; - }; - - idle_register.add (func, p); + ); } void EditorPanel::displayError(const Glib::ustring& title, const Glib::ustring& descr) @@ -1309,16 +1268,16 @@ void EditorPanel::displayError(const Glib::ustring& title, const Glib::ustring& // This is only called from the ThreadUI, so within the gtk thread void EditorPanel::refreshProcessingState (bool inProcessingP) { - spparams *s = new spparams; - s->pProgress = progressLabel; + double val; + Glib::ustring str; if (inProcessingP) { if (processingStartedTime == 0) { processingStartedTime = ::time (nullptr); } - s->str = "PROGRESSBAR_PROCESSING"; - s->val = 1.0; + val = 1.0; + str = "PROGRESSBAR_PROCESSING"; } else { // Set proc params of thumbnail. It saves it into the cache and updates the file browser. if (ipc && openThm && tpc->getChangedState()) { @@ -1339,8 +1298,8 @@ void EditorPanel::refreshProcessingState (bool inProcessingP) } // Set progress bar "done" - s->str = "PROGRESSBAR_READY"; - s->val = 0.0; + val = 0.0; + str = "PROGRESSBAR_READY"; #ifdef WIN32 @@ -1355,7 +1314,7 @@ void EditorPanel::refreshProcessingState (bool inProcessingP) isProcessing = inProcessingP; - setprogressStrUI (s); + setprogressStrUI(val, str, progressLabel); } void EditorPanel::info_toggled () @@ -2385,7 +2344,7 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) leftbox->pack1(*histogramPanel, false, false); histogramPanel->unreference(); } - + leftbox->set_position(options.histogramHeight); histogramPanel->reorder (Gtk::POS_LEFT); break; @@ -2405,14 +2364,14 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) vboxright->pack1 (*histogramPanel, false, false); histogramPanel->unreference(); } - - vboxright->set_position(options.histogramHeight); + + vboxright->set_position(options.histogramHeight); histogramPanel->reorder (Gtk::POS_RIGHT); break; } iareapanel->imageArea->setPointerMotionHListener (histogramPanel); - + } diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index 14ecfc8b4..d579c7f00 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -565,32 +565,22 @@ void FileBrowser::doubleClicked (ThumbBrowserEntryBase* entry) void FileBrowser::addEntry (FileBrowserEntry* entry) { - struct addparams { - FileBrowser *browser; - FileBrowserEntry *entry; - unsigned int session_id; - }; + entry->setParent(this); - addparams* const ap = new addparams; - entry->setParent (this); - ap->browser = this; - ap->entry = entry; - ap->session_id = session_id(); + const unsigned int sid = session_id(); - const auto func = [](gpointer data) -> gboolean { - addparams* const ap = static_cast(data); - if (ap->session_id != ap->browser->session_id()) { - delete ap->entry; - delete ap; - } else { - ap->browser->addEntry_(ap->entry); - delete ap; + idle_register.add( + [this, entry, sid]() -> bool + { + if (sid != session_id()) { + delete entry; + } else { + addEntry_(entry); + } + + return false; } - - return FALSE; - }; - - idle_register.add(func, ap); + ); } void FileBrowser::addEntry_ (FileBrowserEntry* entry) @@ -1927,20 +1917,15 @@ void FileBrowser::openNextPreviousEditorImage (Glib::ustring fname, eRTNav nextP } } -void FileBrowser::_thumbRearrangementNeeded () -{ - refreshThumbImages (); // arrangeFiles is NOT enough -} - void FileBrowser::thumbRearrangementNeeded () { - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->_thumbRearrangementNeeded(); - - return FALSE; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + refreshThumbImages();// arrangeFiles is NOT enough + return false; + } + ); } void FileBrowser::selectionChanged () diff --git a/rtgui/filebrowser.h b/rtgui/filebrowser.h index f15c7c5e8..209399135 100644 --- a/rtgui/filebrowser.h +++ b/rtgui/filebrowser.h @@ -192,7 +192,6 @@ public: #endif void thumbRearrangementNeeded () override; - void _thumbRearrangementNeeded (); void selectionChanged () override; diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index c91f95912..70d2fc128 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -217,47 +217,27 @@ void FileBrowserEntry::updateImage(rtengine::IImage8* img, double scale, const r redrawRequests++; feih->pending++; - struct tiupdate { - FileBrowserEntryIdleHelper* feih; - rtengine::IImage8* img; - double scale; - rtengine::procparams::CropParams cropParams; - }; + idle_register.add( + [this, img, scale, cropParams]() -> bool + { + if (feih->destroyed) { + if (feih->pending == 1) { + delete feih; + } else { + --feih->pending; + } - tiupdate* param = new tiupdate{ - feih, - img, - scale, - cropParams - }; - - const gint priority = G_PRIORITY_LOW; - - const auto func = [](gpointer data) -> gboolean { - tiupdate* const params = static_cast(data); - FileBrowserEntryIdleHelper* const feih = params->feih; - - if (feih->destroyed) { - if (feih->pending == 1) { - delete feih; - } else { - feih->pending--; + img->free(); + return false; } - params->img->free (); - delete params; - return 0; - } + feih->fbentry->_updateImage(img, scale, cropParams); + --feih->pending; - feih->fbentry->_updateImage (params->img, params->scale, params->cropParams); - feih->pending--; - - delete params; - - return FALSE; - }; - - idle_register.add(func, param, priority); + return false; + }, + G_PRIORITY_LOW + ); } void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rtengine::procparams::CropParams& cropParams) diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index 9e19f8dfe..5ebac5e12 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -855,13 +855,13 @@ void FileCatalog::previewsFinished (int dir_id) currentEFS = dirEFS; } - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->previewsFinishedUI(); - - return FALSE; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + previewsFinishedUI(); + return false; + } + ); } void FileCatalog::setEnabled (bool e) @@ -900,10 +900,9 @@ void FileCatalog::refreshHeight () set_size_request(0, newHeight + 2); // HOMBRE: yeah, +2, there's always 2 pixels missing... sorry for this dirty hack O:) } -void FileCatalog::_openImage (std::vector tmb) +void FileCatalog::_openImage(const std::vector& tmb) { - - if (enabled && listener != nullptr) { + if (enabled && listener) { bool continueToLoad = true; for (size_t i = 0; i < tmb.size() && continueToLoad; i++) { @@ -918,42 +917,30 @@ void FileCatalog::_openImage (std::vector tmb) } } -struct FCOIParams { - FileCatalog* catalog; - std::vector tmb; -}; - -int openRequestedUI (void* p) -{ - FCOIParams* params = static_cast(p); - params->catalog->_openImage (params->tmb); - delete params; - - return 0; -} - void FileCatalog::filterApplied() { - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->_refreshProgressBar(); - - return FALSE; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + _refreshProgressBar(); + return false; + } + ); } void FileCatalog::openRequested(const std::vector& tmb) { - FCOIParams* params = new FCOIParams; - params->catalog = this; - params->tmb = tmb; - - for (size_t i = 0; i < tmb.size(); i++) { - tmb[i]->increaseRef (); + for (const auto thumb : tmb) { + thumb->increaseRef(); } - idle_register.add(openRequestedUI, params); + idle_register.add( + [this, tmb]() -> bool + { + _openImage(tmb); + return false; + } + ); } void FileCatalog::deleteRequested(const std::vector& tbe, bool inclBatchProcessed) @@ -1822,11 +1809,14 @@ void FileCatalog::addAndOpenFile (const Glib::ustring& fname) FileBrowserEntry* entry = new FileBrowserEntry (tmb, file->get_parse_name ()); previewReady (selectedDirectoryId, entry); // open the file - FCOIParams* params = new FCOIParams; - params->catalog = this; - params->tmb.push_back (tmb); tmb->increaseRef (); - idle_register.add(openRequestedUI, params); + idle_register.add( + [this, tmb]() -> bool + { + _openImage({tmb}); + return false; + } + ); } catch(Gio::Error&) {} } diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index 7e613a2b4..8b5b14ed2 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -239,7 +239,7 @@ public: void on_realize() override; void reparseDirectory (); - void _openImage (std::vector tmb); + void _openImage (const std::vector& tmb); void zoomIn (); void zoomOut (); diff --git a/rtgui/filepanel.cc b/rtgui/filepanel.cc index aef2b0a22..5a344c8ba 100644 --- a/rtgui/filepanel.cc +++ b/rtgui/filepanel.cc @@ -139,12 +139,13 @@ FilePanel::FilePanel () : parent(nullptr), error(0) fileCatalog->setFileSelectionListener (this); - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->init(); - return FALSE; - }; - - idle_register.add(func, this); + idle_register.add( + [this]() -> bool + { + init(); + return false; + } + ); show_all (); } diff --git a/rtgui/flatfield.cc b/rtgui/flatfield.cc index 057ce731c..86d27aacf 100644 --- a/rtgui/flatfield.cc +++ b/rtgui/flatfield.cc @@ -411,19 +411,13 @@ void FlatField::setShortcutPath(const Glib::ustring& path) void FlatField::flatFieldAutoClipValueChanged(int n) { - struct Data { - FlatField *me; - int n; - }; - const auto func = [](gpointer data) -> gboolean { - Data *d = static_cast(data); - FlatField *me = d->me; - me->disableListener(); - me->flatFieldClipControl->setValue (d->n); - me->enableListener(); - delete d; - return FALSE; - }; - - idle_register.add(func, new Data { this, n }); -} \ No newline at end of file + idle_register.add( + [this, n]() -> bool + { + disableListener(); + flatFieldClipControl->setValue(n); + enableListener(); + return false; + } + ); +} diff --git a/rtgui/guiutils.cc b/rtgui/guiutils.cc index f8129b0fb..a645846d1 100644 --- a/rtgui/guiutils.cc +++ b/rtgui/guiutils.cc @@ -43,27 +43,28 @@ IdleRegister::~IdleRegister() destroy(); } -void IdleRegister::add(GSourceFunc function, gpointer data, gint priority) +void IdleRegister::add(std::function function, gint priority) { - const auto dispatch = [](gpointer data) -> gboolean { - DataWrapper* const data_wrapper = static_cast(data); + const auto dispatch = + [](gpointer data) -> gboolean + { + DataWrapper* const data_wrapper = static_cast(data); - if (!data_wrapper->function(data_wrapper->data)) { - data_wrapper->self->mutex.lock(); - data_wrapper->self->ids.erase(data_wrapper); - data_wrapper->self->mutex.unlock(); + if (!data_wrapper->function()) { + data_wrapper->self->mutex.lock(); + data_wrapper->self->ids.erase(data_wrapper); + data_wrapper->self->mutex.unlock(); - delete data_wrapper; - return FALSE; - } + delete data_wrapper; + return FALSE; + } - return TRUE; - }; + return TRUE; + }; DataWrapper* const data_wrapper = new DataWrapper{ this, - function, - data + std::move(function) }; mutex.lock(); @@ -1278,7 +1279,7 @@ MyFileChooserButton::MyFileChooserButton(const Glib::ustring &title, Gtk::FileCh if (GTK_MINOR_VERSION < 20) { set_border_width(2); // margin doesn't work on GTK < 3.20 } - + set_name("MyFileChooserButton"); } @@ -1368,7 +1369,7 @@ std::vector> MyFileChooserButton::list_filters() return file_filters_; } - + bool MyFileChooserButton::set_current_folder(const std::string &filename) { current_folder_ = filename; diff --git a/rtgui/guiutils.h b/rtgui/guiutils.h index 074e3bacc..a5705630f 100644 --- a/rtgui/guiutils.h +++ b/rtgui/guiutils.h @@ -19,6 +19,7 @@ #ifndef __GUI_UTILS_ #define __GUI_UTILS_ +#include #include #include @@ -50,14 +51,13 @@ class IdleRegister final : public: ~IdleRegister(); - void add(GSourceFunc function, gpointer data, gint priority = G_PRIORITY_DEFAULT_IDLE); + void add(std::function function, gint priority = G_PRIORITY_DEFAULT_IDLE); void destroy(); private: struct DataWrapper { IdleRegister* const self; - GSourceFunc function; - gpointer data; + std::function function; }; std::map ids; @@ -399,7 +399,7 @@ public: sigc::signal &signal_selection_changed(); sigc::signal &signal_file_set(); - + std::string get_filename() const; bool set_filename(const std::string &filename); @@ -407,7 +407,7 @@ public: void remove_filter(const Glib::RefPtr &filter); void set_filter(const Glib::RefPtr &filter); std::vector> list_filters(); - + bool set_current_folder(const std::string &filename); std::string get_current_folder() const; diff --git a/rtgui/histogrampanel.cc b/rtgui/histogrampanel.cc index 7c136cbfe..b6756a59c 100644 --- a/rtgui/histogrampanel.cc +++ b/rtgui/histogrampanel.cc @@ -44,11 +44,11 @@ HistogramPanel::HistogramPanel () histogramArea = Gtk::manage (new HistogramArea (this)); setExpandAlignProperties(histogramArea, true, true, Gtk::ALIGN_FILL, Gtk::ALIGN_FILL); - + histogramRGBArea = Gtk::manage (new HistogramRGBArea ()); setExpandAlignProperties(histogramRGBArea, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_END); histogramRGBArea->show(); - + // connecting the two childs histogramArea->signal_factor_changed().connect( sigc::mem_fun(*histogramRGBArea, &HistogramRGBArea::factorChanged) ); @@ -78,7 +78,7 @@ HistogramPanel::HistogramPanel () chroImage_g = new RTImage ("histogram-gold-off-small.png"); rawImage_g = new RTImage ("histogram-bayer-off-small.png"); barImage_g = new RTImage ("histogram-bar-off-small.png"); - + mode0Image = new RTImage ("histogram-mode-linear-small.png"); mode1Image = new RTImage ("histogram-mode-logx-small.png"); mode2Image = new RTImage ("histogram-mode-logxy-small.png"); @@ -226,9 +226,9 @@ void HistogramPanel::resized (Gtk::Allocation& req) histogramRGBArea->updateBackBuffer(-1, -1, -1); histogramRGBArea->queue_draw (); - // Store current height of the histogram + // Store current height of the histogram options.histogramHeight = get_height(); - + } void HistogramPanel::red_toggled () @@ -346,7 +346,7 @@ void HistogramPanel::reorder (Gtk::PositionType align) // DrawModeListener interface: void HistogramPanel::toggleButtonMode () -{ +{ if (options.histogramDrawMode == 0) showMode->set_image(*mode0Image); else if (options.histogramDrawMode == 1) @@ -562,28 +562,27 @@ void HistogramRGBArea::update (int valh, int rh, int gh, int bh) harih->pending++; - const auto func = [](gpointer data) -> gboolean { - HistogramRGBAreaIdleHelper* const harih = static_cast(data); + idle_register.add( + [this]() -> bool + { + if (harih->destroyed) { + if (harih->pending == 1) { + delete harih; + } else { + --harih->pending; + } - if (harih->destroyed) { - if (harih->pending == 1) { - delete harih; - } else { - harih->pending--; + return false; } - return 0; + harih->harea->updateBackBuffer(-1, -1, -1); + harih->harea->queue_draw (); + + --harih->pending; + + return false; } - - harih->harea->updateBackBuffer(-1, -1, -1); - harih->harea->queue_draw (); - - harih->pending--; - - return FALSE; - }; - - idle_register.add(func, harih); + ); } void HistogramRGBArea::updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, bool bar) @@ -655,7 +654,7 @@ void HistogramRGBArea::factorChanged (double newFactor) // // // HistogramArea -HistogramArea::HistogramArea (DrawModeListener *fml) : +HistogramArea::HistogramArea (DrawModeListener *fml) : valid(false), drawMode(options.histogramDrawMode), myDrawModeListener(fml), oldwidth(-1), oldheight(-1), needRed(options.histogramRed), needGreen(options.histogramGreen), needBlue(options.histogramBlue), @@ -703,14 +702,14 @@ void HistogramArea::get_preferred_height_vfunc (int &minimum_height, int &natura void HistogramArea::get_preferred_width_vfunc (int &minimum_width, int &natural_width) const { - + minimum_width = 200; natural_width = 400; } void HistogramArea::get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const { - + minimum_height = 0; natural_height = 0; } @@ -722,7 +721,7 @@ void HistogramArea::get_preferred_width_for_height_vfunc (int height, int &minim void HistogramArea::updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, int mode) { - + options.histogramRed = needRed = r; options.histogramGreen = needGreen = g; options.histogramBlue = needBlue = b; @@ -760,30 +759,30 @@ void HistogramArea::update( } haih->pending++; - // Can be done outside of the GUI thread - const auto func = [](gpointer data) -> gboolean { - HistogramAreaIdleHelper* const haih = static_cast(data); - if (haih->destroyed) { - if (haih->pending == 1) { - delete haih; - } else { - haih->pending--; + // Can be done outside of the GUI thread + idle_register.add( + [this]() -> bool + { + if (haih->destroyed) { + if (haih->pending == 1) { + delete haih; + } else { + --haih->pending; + } + + return false; } - return 0; + haih->harea->setDirty(true); + haih->harea->updateBackBuffer(); + haih->harea->queue_draw(); + + --haih->pending; + + return false; } - - haih->harea->setDirty (true); - haih->harea->updateBackBuffer (); - haih->harea->queue_draw (); - - haih->pending--; - - return FALSE; - }; - - idle_register.add(func, haih); + ); } void HistogramArea::updateBackBuffer () @@ -889,7 +888,7 @@ void HistogramArea::updateBackBuffer () // Compute the highest point of the histogram for scaling // Values at far left and right end (0 and 255) are handled differently - + unsigned int histheight = 0; for (int i = 1; i < 255; i++) { @@ -915,7 +914,7 @@ void HistogramArea::updateBackBuffer () } int realhistheight = histheight; - + if (realhistheight < winh - 2) { realhistheight = winh - 2; } @@ -960,7 +959,7 @@ void HistogramArea::updateBackBuffer () cr->stroke (); drawMarks(cr, bhchanged, realhistheight, w, ui, oi); } - + } // Draw the frame's border @@ -1044,16 +1043,16 @@ bool HistogramArea::on_button_press_event (GdkEventButton* event) { isPressed = true; movingPosition = event->x; - + if (event->type == GDK_2BUTTON_PRESS && event->button == 1) { - + drawMode = (drawMode + 1) % 3; options.histogramDrawMode = (options.histogramDrawMode + 1) % 3; - + if (myDrawModeListener) { myDrawModeListener->toggleButtonMode (); } - + updateBackBuffer (); queue_draw (); } @@ -1072,19 +1071,19 @@ bool HistogramArea::on_motion_notify_event (GdkEventMotion* event) if (isPressed) { double mod = 1 + (event->x - movingPosition) / get_width(); - + factor /= mod; if (factor < 1.0) factor = 1.0; if (factor > 100.0) factor = 100.0; - + sigFactorChanged.emit(factor); - + setDirty(true); queue_draw (); } - + return true; } diff --git a/rtgui/locallab.cc b/rtgui/locallab.cc index 330f66a7c..74179343b 100644 --- a/rtgui/locallab.cc +++ b/rtgui/locallab.cc @@ -833,6 +833,8 @@ Locallab::Locallab(): Locallab::~Locallab() { + idle_register.destroy(); + delete llCurveEditorG; delete curveEditorG; delete curveEditorGG; @@ -955,24 +957,23 @@ void Locallab::refChanged (double huer, double lumar, double chromar) } nexthuer = h; //printf("nh=%f nl=%f nc=%f\n", nexthuer, nextlumar, nextchromar); - 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)->refComputed_(); - return FALSE; - }; - idle_register.add (func, this); + idle_register.add( + [this]() -> bool + { + GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected + // FIXME: The above can't be true?! + disableListener(); + enableListener(); + updateLabel(); + return false; + } + ); + + } -bool Locallab::refComputed_ () -{ - - disableListener (); - enableListener (); - updateLabel (); - return false; -} void Locallab::updateLabel () { diff --git a/rtgui/locallab.h b/rtgui/locallab.h index ea987a7e5..cf25baeb7 100644 --- a/rtgui/locallab.h +++ b/rtgui/locallab.h @@ -338,7 +338,6 @@ public: void writeOptions(std::vector &tpOpen); void updateToolState(std::vector &tpOpen); void refChanged(double huer, double lumar, double chromar); - bool refComputed_(); void updateLabel(); // Mask visibility management functions diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index f70f4af0f..4980f9bd9 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -1518,28 +1518,27 @@ void MyDiagonalCurve::updateBackgroundHistogram (LUTu & hist) mcih->pending++; - const auto func = [](gpointer data) -> gboolean { - MyCurveIdleHelper* const mcih = static_cast(data); + idle_register.add( + [this]() -> bool + { + if (mcih->destroyed) { + if (mcih->pending == 1) { + delete mcih; + } else { + --mcih->pending; + } - if (mcih->destroyed) { - if (mcih->pending == 1) { - delete mcih; - } else { - mcih->pending--; + return false; } - return 0; + mcih->clearPixmap(); + mcih->myCurve->queue_draw(); + + --mcih->pending; + + return false; } - - mcih->clearPixmap (); - mcih->myCurve->queue_draw (); - - mcih->pending--; - - return FALSE; - }; - - idle_register.add(func, mcih); + ); } void MyDiagonalCurve::reset(const std::vector &resetCurve, double identityValue) diff --git a/rtgui/ppversion.h b/rtgui/ppversion.h index f853741f0..4343cc209 100644 --- a/rtgui/ppversion.h +++ b/rtgui/ppversion.h @@ -1,13 +1,15 @@ #pragma once // This number has to be incremented whenever the PP3 file format is modified or the behaviour of a tool changes -#define PPVERSION 346 +#define PPVERSION 347 #define PPVERSION_AEXP 301 //value of PPVERSION when auto exposure algorithm was modified /* Log of version changes - 346 2018-09-25 + 347 2018-09-25 Added Locallab tool parameters + 346 2019-01-01 + changed microcontrast uniformity 345 2018-10-21 dual demosaic auto contrast threshold 344 2018-10-04 diff --git a/rtgui/previewhandler.cc b/rtgui/previewhandler.cc index a251986bf..2315b8c91 100644 --- a/rtgui/previewhandler.cc +++ b/rtgui/previewhandler.cc @@ -23,18 +23,6 @@ using namespace rtengine; using namespace rtengine::procparams; -namespace -{ - -struct iaimgpar { - IImage8* image; - PreviewHandlerIdleHelper* pih; - double scale; - CropParams cp; -}; - -} - PreviewHandler::PreviewHandler () : image(nullptr), previewScale(1.) { @@ -61,46 +49,36 @@ void PreviewHandler::setImage(rtengine::IImage8* i, double scale, const rtengine { pih->pending++; - iaimgpar* iap = new iaimgpar; - iap->image = i; - iap->pih = pih; - iap->scale = scale; - iap->cp = cp; + idle_register.add( + [this, i, scale, cp]() -> bool + { + if (pih->destroyed) { + if (pih->pending == 1) { + delete pih; + } else { + --pih->pending; + } - const auto func = [](gpointer data) -> gboolean { - iaimgpar* const iap = static_cast(data); - PreviewHandlerIdleHelper* const pih = iap->pih; - - if (pih->destroyed) { - if (pih->pending == 1) { - delete pih; - } else { - pih->pending--; + return false; } - delete iap; + if (pih->phandler->image) { + IImage8* const oldImg = pih->phandler->image; - return FALSE; + oldImg->getMutex().lock(); + pih->phandler->image = i; + oldImg->getMutex().unlock(); + } else { + pih->phandler->image = i; + } + + pih->phandler->cropParams = cp; + pih->phandler->previewScale = scale; + --pih->pending; + + return false; } - - if (pih->phandler->image) { - IImage8* const oldImg = pih->phandler->image; - oldImg->getMutex().lock (); - pih->phandler->image = iap->image; - oldImg->getMutex().unlock (); - } else { - pih->phandler->image = iap->image; - } - - pih->phandler->cropParams = iap->cp; - pih->phandler->previewScale = iap->scale; - pih->pending--; - delete iap; - - return FALSE; - }; - - idle_register.add(func, iap); + ); } @@ -108,82 +86,66 @@ void PreviewHandler::delImage(IImage8* i) { pih->pending++; - iaimgpar* iap = new iaimgpar; - iap->image = i; - iap->pih = pih; + idle_register.add( + [this, i]() -> bool + { + if (pih->destroyed) { + if (pih->pending == 1) { + delete pih; + } else { + --pih->pending; + } - const auto func = [](gpointer data) -> gboolean { - iaimgpar* iap = static_cast(data); - PreviewHandlerIdleHelper* pih = iap->pih; - - if (pih->destroyed) { - if (pih->pending == 1) { - delete pih; - } else { - pih->pending--; + return false; } - delete iap; + if (pih->phandler->image) { + IImage8* oldImg = pih->phandler->image; + oldImg->getMutex().lock(); + pih->phandler->image = nullptr; + oldImg->getMutex().unlock(); + } - return FALSE; + i->free(); + pih->phandler->previewImgMutex.lock(); + pih->phandler->previewImg.clear(); + pih->phandler->previewImgMutex.unlock(); + + --pih->pending; + + return false; } - - if (pih->phandler->image) { - IImage8* oldImg = pih->phandler->image; - oldImg->getMutex().lock (); - pih->phandler->image = nullptr; - oldImg->getMutex().unlock (); - } - - iap->image->free (); - pih->phandler->previewImgMutex.lock (); - pih->phandler->previewImg.clear (); - pih->phandler->previewImgMutex.unlock (); - - pih->pending--; - delete iap; - - return FALSE; - }; - - idle_register.add(func, iap); + ); } void PreviewHandler::imageReady(const rtengine::procparams::CropParams& cp) { pih->pending++; - iaimgpar* iap = new iaimgpar; - iap->pih = pih; - iap->cp = cp; - const auto func = [](gpointer data) -> gboolean { - iaimgpar* const iap = static_cast(data); - PreviewHandlerIdleHelper* pih = iap->pih; + idle_register.add( + [this, cp]() -> bool + { + if (pih->destroyed) { + if (pih->pending == 1) { + delete pih; + } else { + --pih->pending; + } - if (pih->destroyed) { - if (pih->pending == 1) { - delete pih; - } else { - pih->pending--; + return false; } - delete iap; + pih->phandler->previewImgMutex.lock(); + pih->phandler->previewImg = Gdk::Pixbuf::create_from_data(pih->phandler->image->getData(), Gdk::COLORSPACE_RGB, false, 8, pih->phandler->image->getWidth(), pih->phandler->image->getHeight(), 3 * pih->phandler->image->getWidth()); + pih->phandler->previewImgMutex.unlock (); - return FALSE; + pih->phandler->cropParams = cp; + pih->phandler->previewImageChanged (); + --pih->pending; + + return false; } - - pih->phandler->previewImgMutex.lock (); - pih->phandler->previewImg = Gdk::Pixbuf::create_from_data (pih->phandler->image->getData(), Gdk::COLORSPACE_RGB, false, 8, pih->phandler->image->getWidth(), pih->phandler->image->getHeight(), 3 * pih->phandler->image->getWidth()); - pih->phandler->previewImgMutex.unlock (); - pih->phandler->cropParams = iap->cp; - pih->phandler->previewImageChanged (); - pih->pending--; - delete iap; - - return FALSE; - }; - - idle_register.add(func, iap); + ); } Glib::RefPtr PreviewHandler::getRoughImage (int x, int y, int w, int h, double zoom) diff --git a/rtgui/resize.cc b/rtgui/resize.cc index 0de1f7db0..fc0f51191 100644 --- a/rtgui/resize.cc +++ b/rtgui/resize.cc @@ -95,7 +95,7 @@ Resize::Resize () : FoldableToolPanel(this, "resize", M("TP_RESIZE_LABEL"), fals allowUpscaling = Gtk::manage(new Gtk::CheckButton(M("TP_RESIZE_ALLOW_UPSCALING"))); sizeBox->pack_start(*allowUpscaling); allowUpscaling->signal_toggled().connect(sigc::mem_fun(*this, &Resize::allowUpscalingChanged)); - + sizeBox->show_all (); sizeBox->reference (); @@ -366,76 +366,75 @@ void Resize::sizeChanged(int mw, int mh, int ow, int oh) void Resize::setDimensions () { - const auto func = [](gpointer data) -> gboolean { - Resize* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + wconn.block(true); + hconn.block(true); + scale->block(true); - self->wconn.block(true); - self->hconn.block(true); - self->scale->block(true); + int refw, refh; - int refw, refh; + if (appliesTo->get_active_row_number() == 0 && cropw) { + // Applies to Cropped area + refw = cropw; + refh = croph; + } else { + // Applies to Full image or crop is disabled + refw = maxw; + refh = maxh; + } - if (self->appliesTo->get_active_row_number() == 0 && self->cropw) { - // Applies to Cropped area - refw = self->cropw; - refh = self->croph; - } else { - // Applies to Full image or crop is disabled - refw = self->maxw; - refh = self->maxh; + w->set_range(32, MAX_SCALE * refw); + h->set_range(32, MAX_SCALE * refh); + + switch (spec->get_active_row_number()) { + case 0: { + // Scale mode + w->set_value(static_cast(static_cast(static_cast(refw) * scale->getValue() + 0.5))); + h->set_value(static_cast(static_cast(static_cast(refh) * scale->getValue() + 0.5))); + break; + } + + case 1: { + // Width mode + const double tmp_scale = w->get_value() / static_cast(refw); + scale->setValue(tmp_scale); + h->set_value(static_cast(static_cast(static_cast(refh) * tmp_scale + 0.5))); + break; + } + + case 2: { + // Height mode + const double tmp_scale = h->get_value() / static_cast(refh); + scale->setValue(tmp_scale); + w->set_value(static_cast(static_cast(static_cast(refw) * tmp_scale + 0.5))); + break; + } + + case 3: { + // Bounding box mode + const double tmp_scale = + w->get_value() / h->get_value() < static_cast(refw) / static_cast(refh) + ? w->get_value() / static_cast(refw) + : h->get_value() / static_cast(refh); + + scale->setValue(tmp_scale); + break; + } + + default: { + break; + } + } + + scale->block(false); + wconn.block(false); + hconn.block(false); + + return false; } - - self->w->set_range(32, MAX_SCALE * refw); - self->h->set_range(32, MAX_SCALE * refh); - - switch (self->spec->get_active_row_number()) { - case 0: { - // Scale mode - self->w->set_value(static_cast(static_cast(static_cast(refw) * self->scale->getValue() + 0.5))); - self->h->set_value(static_cast(static_cast(static_cast(refh) * self->scale->getValue() + 0.5))); - break; - } - - case 1: { - // Width mode - const double tmp_scale = self->w->get_value() / static_cast(refw); - self->scale->setValue(tmp_scale); - self->h->set_value(static_cast(static_cast(static_cast(refh) * tmp_scale + 0.5))); - break; - } - - case 2: { - // Height mode - const double tmp_scale = self->h->get_value() / static_cast(refh); - self->scale->setValue(tmp_scale); - self->w->set_value(static_cast(static_cast(static_cast(refw) * tmp_scale + 0.5))); - break; - } - - case 3: { - // Bounding box mode - const double tmp_scale = - self->w->get_value() / self->h->get_value() < static_cast(refw) / static_cast(refh) - ? self->w->get_value() / static_cast(refw) - : self->h->get_value() / static_cast(refh); - - self->scale->setValue(tmp_scale); - break; - } - - default: { - break; - } - } - - self->scale->block(false); - self->wconn.block(false); - self->hconn.block(false); - - return FALSE; - }; - - idle_register.add(func, this); + ); } void Resize::fitBoxScale() diff --git a/rtgui/retinex.cc b/rtgui/retinex.cc index a271efc0a..544ace535 100644 --- a/rtgui/retinex.cc +++ b/rtgui/retinex.cc @@ -672,26 +672,20 @@ void Retinex::minmaxChanged (double cdma, double cdmin, double mini, double maxi nextminT = Tmin; nextmaxT = Tmax; - 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)->minmaxComputed_(); - - return FALSE; - }; - - idle_register.add (func, this); + idle_register.add( + [this]() -> bool + { + GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected + // FIXME: The above can't be true?! + disableListener(); + enableListener(); + updateLabel(); + updateTrans(); + return false; + } + ); } -bool Retinex::minmaxComputed_ () -{ - - disableListener (); - enableListener (); - updateLabel (); - updateTrans (); - return false; - -} void Retinex::updateLabel () { if (!batchMode) { diff --git a/rtgui/retinex.h b/rtgui/retinex.h index b9ed3c927..8703ec607 100644 --- a/rtgui/retinex.h +++ b/rtgui/retinex.h @@ -108,7 +108,6 @@ public: void autoOpenCurve () override; void medianmapChanged (); void minmaxChanged (double cdma, double cdmin, double mini, double maxi, double Tmean, double Tsigma, double Tmin, double Tmax) override; - bool minmaxComputed_ (); void updateLabel (); void updateTrans (); void neutral_pressed (); diff --git a/rtgui/sharpenmicro.cc b/rtgui/sharpenmicro.cc index 7e981db96..8686b747b 100644 --- a/rtgui/sharpenmicro.cc +++ b/rtgui/sharpenmicro.cc @@ -40,7 +40,7 @@ SharpenMicro::SharpenMicro () : FoldableToolPanel(this, "sharpenmicro", M("TP_SH amount->setAdjusterListener (this); amount->show(); - uniformity = Gtk::manage(new Adjuster (M("TP_SHARPENMICRO_UNIFORMITY"), 0, 100, 10, 50)); + uniformity = Gtk::manage(new Adjuster (M("TP_SHARPENMICRO_UNIFORMITY"), 0, 10, 1, 5)); uniformity->setAdjusterListener (this); uniformity->show(); diff --git a/rtgui/tonecurve.cc b/rtgui/tonecurve.cc index b0a03cccc..b4157e58a 100644 --- a/rtgui/tonecurve.cc +++ b/rtgui/tonecurve.cc @@ -45,7 +45,7 @@ ToneCurve::ToneCurve () : FoldableToolPanel(this, "tonecurve", M("TP_EXPOSURE_LA pack_start(*clampOOG); pack_start (*Gtk::manage (new Gtk::HSeparator())); clampOOG->signal_toggled().connect(sigc::mem_fun(*this, &ToneCurve::clampOOGChanged)); - + //----------- Auto Levels ---------------------------------- abox = Gtk::manage (new Gtk::HBox ()); abox->set_spacing (4); @@ -238,7 +238,7 @@ void ToneCurve::read (const ProcParams* pp, const ParamsEdited* pedited) if (!black->getAddMode() && !batchMode) { shcompr->set_sensitive(!((int)black->getValue () == 0)); //at black=0 shcompr value has no effect } - + if (!hlcompr->getAddMode() && !batchMode) { hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect } @@ -604,7 +604,7 @@ void ToneCurve::adjusterChanged(Adjuster* a, double newval) if (a != expcomp && a != hlcompr && a != hlcomprthresh) { setHistmatching(false); } - + Glib::ustring costr; if (a == expcomp) { @@ -629,7 +629,7 @@ void ToneCurve::adjusterChanged(Adjuster* a, double newval) listener->panelChanged (EvSaturation, costr); } else if (a == hlcompr) { listener->panelChanged (EvHLCompr, costr); - + if (!hlcompr->getAddMode() && !batchMode) { hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect } @@ -650,7 +650,7 @@ void ToneCurve::neutral_pressed () // and sets neutral values to params in exposure panel setHistmatching(false); - + if (batchMode) { autolevels->set_inconsistent (false); autoconn.block (true); @@ -680,7 +680,7 @@ void ToneCurve::neutral_pressed () if (!black->getAddMode() && !batchMode) { shcompr->set_sensitive(!((int)black->getValue () == 0)); //at black=0 shcompr value has no effect } - + if (!hlcompr->getAddMode() && !batchMode) { hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect } @@ -754,7 +754,7 @@ void ToneCurve::autolevels_toggled () if (!black->getAddMode()) { shcompr->set_sensitive(!((int)black->getValue () == 0)); //at black=0 shcompr value has no effect } - + if (!hlcompr->getAddMode() && !batchMode) { hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect } @@ -832,41 +832,6 @@ void ToneCurve::enableAll () histmatching->set_sensitive(true); } -bool ToneCurve::autoExpComputed_ () -{ - - GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected - disableListener (); - enableAll (); - expcomp->setValue (nextExpcomp); - brightness->setValue (nextBrightness); - contrast->setValue (nextContrast); - black->setValue (nextBlack); - hlcompr->setValue (nextHlcompr); - hlcomprthresh->setValue (nextHlcomprthresh); - enaconn.block (true); - hrenabled->set_active (nextHLRecons); - enaconn.block (false); - - if (nextHLRecons) { - hlrbox->show(); - } else if (!batchMode) { - hlrbox->hide(); - } - - if (!black->getAddMode() && !batchMode) { - shcompr->set_sensitive(!((int)black->getValue () == 0)); //at black=0 shcompr value has no effect - } - - if (!hlcompr->getAddMode() && !batchMode) { - hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect - } - - enableListener (); - - return false; -} - void ToneCurve::setBatchMode (bool batchMode) { ToolPanel::setBatchMode (batchMode); @@ -967,42 +932,6 @@ void ToneCurve::histmatchingToggled() } } -bool ToneCurve::histmatchingComputed() -{ - GThreadLock lock; - disableListener(); - enableAll(); - brightness->setValue(0); - contrast->setValue(0); - black->setValue(0); - - if (!black->getAddMode() && !batchMode) { - shcompr->set_sensitive(!((int)black->getValue() == 0)); - } - - if (!hlcompr->getAddMode() && !batchMode) { - hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect - } - - if (autolevels->get_active() ) { - expcomp->setValue(0); - autoconn.block(true); - autolevels->set_active(false); - autoconn.block(false); - autolevels->set_inconsistent(false); - } - - toneCurveMode->set_active(rtengine::toUnderlying(nextToneCurveMode)); - shape->setCurve(nextToneCurve); - shape2->setCurve({ DCT_Linear }); - shape->openIfNonlinear(); - - enableListener(); - fromHistMatching = true; - - return false; -} - void ToneCurve::autoExpChanged(double expcomp, int bright, int contr, int black, int hlcompr, int hlcomprthresh, bool hlrecons) { nextBlack = black; @@ -1013,13 +942,41 @@ void ToneCurve::autoExpChanged(double expcomp, int bright, int contr, int black, nextHlcomprthresh = hlcomprthresh; nextHLRecons = hlrecons; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->autoExpComputed_(); + idle_register.add( + [this]() -> bool + { + GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected + // FIXME: We don't need the GThreadLock, don't we? + disableListener(); + enableAll(); + this->expcomp->setValue(nextExpcomp); + brightness->setValue(nextBrightness); + contrast->setValue(nextContrast); + this->black->setValue(nextBlack); + this->hlcompr->setValue(nextHlcompr); + this->hlcomprthresh->setValue(nextHlcomprthresh); + enaconn.block(true); + hrenabled->set_active(nextHLRecons); + enaconn.block(false); - return FALSE; - }; + if (nextHLRecons) { + hlrbox->show(); + } else if (!batchMode) { + hlrbox->hide(); + } - idle_register.add(func, this); + if (!this->black->getAddMode() && !batchMode) { + shcompr->set_sensitive(static_cast(this->black->getValue())); //at black=0 shcompr value has no effect + } + + if (!this->hlcompr->getAddMode() && !batchMode) { + this->hlcomprthresh->set_sensitive(static_cast(this->hlcompr->getValue())); //at hlcompr=0 hlcomprthresh value has no effect + } + + enableListener(); + return false; + } + ); } void ToneCurve::autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParams::TcMode curveMode, const std::vector& curve) @@ -1027,11 +984,41 @@ void ToneCurve::autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParam nextToneCurveMode = curveMode; nextToneCurve = curve; - const auto func = [](gpointer data) -> gboolean { - static_cast(data)->histmatchingComputed(); + idle_register.add( + [this]() -> bool + { + GThreadLock lock; // FIXME: Obsolete + disableListener(); + enableAll(); + brightness->setValue(0); + contrast->setValue(0); + black->setValue(0); - return FALSE; - }; + if (!black->getAddMode() && !batchMode) { + shcompr->set_sensitive(static_cast(black->getValue())); + } - idle_register.add(func, this); + if (!hlcompr->getAddMode() && !batchMode) { + hlcomprthresh->set_sensitive(static_cast(hlcompr->getValue())); //at hlcompr=0 hlcomprthresh value has no effect + } + + if (autolevels->get_active() ) { + expcomp->setValue(0); + autoconn.block(true); + autolevels->set_active(false); + autoconn.block(false); + autolevels->set_inconsistent(false); + } + + toneCurveMode->set_active(rtengine::toUnderlying(nextToneCurveMode)); + shape->setCurve(nextToneCurve); + shape2->setCurve({DCT_Linear}); + shape->openIfNonlinear(); + + enableListener(); + fromHistMatching = true; + + return false; + } + ); } diff --git a/rtgui/tonecurve.h b/rtgui/tonecurve.h index d95049d1c..2cf7b9d12 100644 --- a/rtgui/tonecurve.h +++ b/rtgui/tonecurve.h @@ -72,7 +72,7 @@ protected: rtengine::ProcEvent EvHistMatching; rtengine::ProcEvent EvHistMatchingBatch; rtengine::ProcEvent EvClampOOG; - + // used temporarily in eventing double nextExpcomp; int nextBrightness; @@ -108,7 +108,6 @@ public: void clip_changed (); bool clip_changed_ (); void waitForAutoExp (); - bool autoExpComputed_ (); void enableAll (); void curveChanged (CurveEditor* ce) override; void curveMode1Changed (); @@ -131,7 +130,6 @@ public: ); void histmatchingToggled(); - bool histmatchingComputed(); void autoExpChanged(double expcomp, int bright, int contr, int black, int hlcompr, int hlcomprthresh, bool hlrecons) override; void autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParams::TcMode curveMode, const std::vector& curve) override; diff --git a/rtgui/toolpanelcoord.cc b/rtgui/toolpanelcoord.cc index 753ad0e18..debb4ac16 100644 --- a/rtgui/toolpanelcoord.cc +++ b/rtgui/toolpanelcoord.cc @@ -328,72 +328,72 @@ void ToolPanelCoordinator::imageTypeChanged(bool isRaw, bool isBayer, bool isXtr { if (isRaw) { if (isBayer) { - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + rawPanelSW->set_sensitive(true); + sensorxtrans->FoldableToolPanel::hide(); + sensorbayer->FoldableToolPanel::show(); + preprocess->FoldableToolPanel::show(); + flatfield->FoldableToolPanel::show(); + retinex->FoldableToolPanel::setGrayedOut(false); - self->rawPanelSW->set_sensitive(true); - self->sensorxtrans->FoldableToolPanel::hide(); - self->sensorbayer->FoldableToolPanel::show(); - self->preprocess->FoldableToolPanel::show(); - self->flatfield->FoldableToolPanel::show(); - self->retinex->FoldableToolPanel::setGrayedOut(false); - - return FALSE; - }; - idle_register.add(func, this); + return false; + } + ); } else if (isXtrans) { - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + rawPanelSW->set_sensitive(true); + sensorxtrans->FoldableToolPanel::show(); + sensorbayer->FoldableToolPanel::hide(); + preprocess->FoldableToolPanel::show(); + flatfield->FoldableToolPanel::show(); + retinex->FoldableToolPanel::setGrayedOut(false); - self->rawPanelSW->set_sensitive(true); - self->sensorxtrans->FoldableToolPanel::show(); - self->sensorbayer->FoldableToolPanel::hide(); - self->preprocess->FoldableToolPanel::show(); - self->flatfield->FoldableToolPanel::show(); - self->retinex->FoldableToolPanel::setGrayedOut(false); - - return FALSE; - }; - idle_register.add(func, this); + return false; + } + ); } else if (isMono) { - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + rawPanelSW->set_sensitive(true); + sensorbayer->FoldableToolPanel::hide(); + sensorxtrans->FoldableToolPanel::hide(); + preprocess->FoldableToolPanel::hide(); + flatfield->FoldableToolPanel::show(); + retinex->FoldableToolPanel::setGrayedOut(false); - self->rawPanelSW->set_sensitive(true); - self->sensorbayer->FoldableToolPanel::hide(); - self->sensorxtrans->FoldableToolPanel::hide(); - self->preprocess->FoldableToolPanel::hide(); - self->flatfield->FoldableToolPanel::show(); - self->retinex->FoldableToolPanel::setGrayedOut(false); - - return FALSE; - }; - idle_register.add(func, this); + return false; + } + ); } else { - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + rawPanelSW->set_sensitive(true); + sensorbayer->FoldableToolPanel::hide(); + sensorxtrans->FoldableToolPanel::hide(); + preprocess->FoldableToolPanel::hide(); + flatfield->FoldableToolPanel::hide(); + retinex->FoldableToolPanel::setGrayedOut(false); - self->rawPanelSW->set_sensitive(true); - self->sensorbayer->FoldableToolPanel::hide(); - self->sensorxtrans->FoldableToolPanel::hide(); - self->preprocess->FoldableToolPanel::hide(); - self->flatfield->FoldableToolPanel::hide(); - self->retinex->FoldableToolPanel::setGrayedOut(false); - - return FALSE; - }; - idle_register.add(func, this); + return false; + } + ); } } else { - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); + idle_register.add( + [this]() -> bool + { + rawPanelSW->set_sensitive(false); + retinex->FoldableToolPanel::setGrayedOut(true); - self->rawPanelSW->set_sensitive (false); - self->retinex->FoldableToolPanel::setGrayedOut(true); - - return FALSE; - }; - idle_register.add(func, this); + return false; + } + ); } } @@ -474,22 +474,22 @@ void ToolPanelCoordinator::panelChanged(const rtengine::ProcEvent& event, const // Locallab spot curves are set visible if at least one photo has been loaded (to avoid // segfault) and locallab panel is active // When a new photo is loaded, Locallab spot curves need to be set visible again - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); +const auto func = + [this]() -> bool + { + if (photoLoadedOnce && (toolPanelNotebook->get_nth_page(toolPanelNotebook->get_current_page()) == locallabPanelSW)) { + locallab->subscribe(); + } - if (self->photoLoadedOnce && (self->toolPanelNotebook->get_nth_page(self->toolPanelNotebook->get_current_page()) == self->locallabPanelSW)) - { - self->locallab->subscribe(); - } - - return FALSE; + return false; }; - if (event == rtengine::EvPhotoLoaded) { - idle_register.add(func, this); - } +if (event == rtengine::EvPhotoLoaded) { + idle_register.add(func); +} photoLoadedOnce = true; + } void ToolPanelCoordinator::profileChange( @@ -587,20 +587,19 @@ void ToolPanelCoordinator::profileChange( // Locallab spot curves are set visible if at least one photo has been loaded (to avoid // segfault) and locallab panel is active // When a new photo is loaded, Locallab spot curves need to be set visible again - const auto func = [](gpointer data) -> gboolean { - ToolPanelCoordinator* const self = static_cast(data); - - if (self->photoLoadedOnce && (self->toolPanelNotebook->get_nth_page(self->toolPanelNotebook->get_current_page()) == self->locallabPanelSW)) - { - self->locallab->subscribe(); +const auto func = + [this]() -> bool + { + if (photoLoadedOnce && (toolPanelNotebook->get_nth_page(toolPanelNotebook->get_current_page()) == locallabPanelSW)) { + locallab->subscribe(); } - return FALSE; + return false; }; - if (event == rtengine::EvPhotoLoaded) { - idle_register.add(func, this); - } +if (event == rtengine::EvPhotoLoaded) { + idle_register.add(func); +} photoLoadedOnce = true; } diff --git a/rtgui/wavelet.cc b/rtgui/wavelet.cc index 81fc282ab..60915fa02 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,35 +885,19 @@ 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( - Glib::ustring::compose(M("TP_WAVELET_LEVLABEL"), - Glib::ustring::format(std::fixed, std::setprecision(0), lv)) + idle_register.add( + [this, nlevel]() -> bool + { + wavLabels->set_text( + Glib::ustring::compose( + M("TP_WAVELET_LEVLABEL"), + Glib::ustring::format(std::fixed, std::setprecision(0), nlevel) + ) + ); + return false; + } ); } } diff --git a/rtgui/whitebalance.cc b/rtgui/whitebalance.cc index 6cbca5637..02fb8d793 100644 --- a/rtgui/whitebalance.cc +++ b/rtgui/whitebalance.cc @@ -149,11 +149,11 @@ static double wbTemp2Slider(double temp) WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WBALANCE_LABEL"), false, true), wbp(nullptr), wblistener(nullptr) { - + Gtk::Grid* methodgrid = Gtk::manage(new Gtk::Grid()); methodgrid->get_style_context()->add_class("grid-spacing"); setExpandAlignProperties(methodgrid, true, false, Gtk::ALIGN_FILL, Gtk::ALIGN_CENTER); - + Gtk::Label* lab = Gtk::manage (new Gtk::Label (M("TP_WBALANCE_METHOD") + ":")); setExpandAlignProperties(lab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); @@ -263,7 +263,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB Gtk::Label* slab = Gtk::manage (new Gtk::Label (M("TP_WBALANCE_SIZE"))); setExpandAlignProperties(slab, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - + Gtk::Grid* wbsizehelper = Gtk::manage(new Gtk::Grid()); wbsizehelper->set_name("WB-Size-Helper"); setExpandAlignProperties(wbsizehelper, false, false, Gtk::ALIGN_START, Gtk::ALIGN_CENTER); @@ -299,14 +299,14 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB if (options.whiteBalanceSpotSize == 32) { spotsize->set_active(4); } - + wbsizehelper->attach (*spotsize, 0, 0, 1, 1); spotgrid->attach (*spotbutton, 0, 0, 1, 1); spotgrid->attach (*slab, 1, 0, 1, 1); spotgrid->attach (*wbsizehelper, 2, 0, 1, 1); pack_start (*spotgrid, Gtk::PACK_SHRINK, 0 ); - + Gtk::HSeparator *separator = Gtk::manage (new Gtk::HSeparator()); separator->get_style_context()->add_class("grid-row-separator"); pack_start (*separator, Gtk::PACK_SHRINK, 0); @@ -700,7 +700,7 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited) set_inconsistent(multiImage && !pedited->wb.enabled); } - + methconn.block (false); enableListener (); } @@ -913,28 +913,18 @@ inline Gtk::TreeRow WhiteBalance::getActiveMethod () void WhiteBalance::WBChanged(double temperature, double greenVal) { - struct Data { - WhiteBalance* self; - double temperature; - double green_val; - }; + idle_register.add( + [this, temperature, greenVal]() -> bool + { + disableListener(); + setEnabled(true); + temp->setValue(temperature); + green->setValue(greenVal); + temp->setDefault(temperature); + green->setDefault(greenVal); + enableListener(); - const auto func = [](gpointer data) -> gboolean { - WhiteBalance* const self = static_cast(static_cast(data)->self); - const double temperature = static_cast(data)->temperature; - const double green_val = static_cast(data)->green_val; - delete static_cast(data); - - self->disableListener(); - self->setEnabled(true); - self->temp->setValue(temperature); - self->green->setValue(green_val); - self->temp->setDefault(temperature); - self->green->setDefault(green_val); - self->enableListener(); - - return FALSE; - }; - - idle_register.add(func, new Data{this, temperature, greenVal}); + return false; + } + ); } diff --git a/rtgui/xtransprocess.cc b/rtgui/xtransprocess.cc index 47556e54f..9639ce29d 100644 --- a/rtgui/xtransprocess.cc +++ b/rtgui/xtransprocess.cc @@ -254,19 +254,13 @@ void XTransProcess::checkBoxToggled (CheckBox* c, CheckValue newval) void XTransProcess::autoContrastChanged (double autoContrast) { - struct Data { - XTransProcess *me; - double autoContrast; - }; - const auto func = [](gpointer data) -> gboolean { - Data *d = static_cast(data); - XTransProcess *me = d->me; - me->disableListener(); - me->dualDemosaicContrast->setValue(d->autoContrast); - me->enableListener(); - delete d; - return FALSE; - }; - - idle_register.add(func, new Data { this, autoContrast }); + idle_register.add( + [this, autoContrast]() -> bool + { + disableListener(); + dualDemosaicContrast->setValue(autoContrast); + enableListener(); + return false; + } + ); }