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