Review IdleRegister
(#4892)
This turns `IdleRegister::add()` into a template function to make the provided function pointers type safe. It also adds a `delete_data` parameter to manage the provided data pointer even in `destroy()`.
This commit is contained in:
parent
7038104a20
commit
5906329485
@ -50,12 +50,10 @@ struct NLParams {
|
||||
Glib::ustring queueErrorMessage;
|
||||
};
|
||||
|
||||
int bqnotifylistenerUI (void* data)
|
||||
bool bqnotifylistenerUI(NLParams* params)
|
||||
{
|
||||
NLParams* params = static_cast<NLParams*>(data);
|
||||
params->listener->queueSizeChanged (params->qsize, params->queueEmptied, params->queueError, params->queueErrorMessage);
|
||||
delete params;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -438,16 +436,12 @@ void BatchQueue::cancelItems (const std::vector<ThumbBrowserEntryBase*>& items)
|
||||
if (entry->thumbnail)
|
||||
entry->thumbnail->imageRemovedFromQueue ();
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
const BatchQueueEntry* const bqe = static_cast<BatchQueueEntry*>(data);
|
||||
|
||||
const auto func = [](BatchQueueEntry* bqe) -> bool {
|
||||
::g_remove(bqe->savedParamsFile.c_str());
|
||||
delete bqe;
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, entry);
|
||||
idle_register.add<BatchQueueEntry>(func, entry, true);
|
||||
}
|
||||
|
||||
for (const auto entry : fd)
|
||||
@ -608,12 +602,14 @@ void BatchQueue::setProgress(double p)
|
||||
}
|
||||
|
||||
// No need to acquire the GUI, setProgressUI will do it
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<BatchQueue*>(data)->redraw();
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](BatchQueue* bq) -> bool
|
||||
{
|
||||
bq->redraw();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<BatchQueue>(func, this, false);
|
||||
}
|
||||
|
||||
void BatchQueue::setProgressStr(const Glib::ustring& str)
|
||||
@ -643,7 +639,7 @@ void BatchQueue::error(const Glib::ustring& descr)
|
||||
params->queueEmptied = false;
|
||||
params->queueError = true;
|
||||
params->queueErrorMessage = descr;
|
||||
idle_register.add(bqnotifylistenerUI, params);
|
||||
idle_register.add<NLParams>(bqnotifylistenerUI, params, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -985,7 +981,7 @@ void BatchQueue::notifyListener (bool queueEmptied)
|
||||
}
|
||||
params->queueEmptied = queueEmptied;
|
||||
params->queueError = false;
|
||||
idle_register.add(bqnotifylistenerUI, params);
|
||||
idle_register.add<NLParams>(bqnotifylistenerUI, params, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,13 +170,14 @@ BatchQueuePanel::BatchQueuePanel (FileCatalog* aFileCatalog) : parent(nullptr)
|
||||
show_all ();
|
||||
|
||||
if (batchQueue->loadBatchQueue()) {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<BatchQueue*>(data)->resizeLoadedQueue();
|
||||
const auto func =
|
||||
[](BatchQueue* bq) -> bool
|
||||
{
|
||||
bq->resizeLoadedQueue();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, batchQueue, G_PRIORITY_LOW);
|
||||
idle_register.add<BatchQueue>(func, batchQueue, false, G_PRIORITY_LOW);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -723,49 +723,51 @@ void BayerProcess::FrameCountChanged(int n, int frameNum)
|
||||
int n;
|
||||
int frameNum;
|
||||
};
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
BayerProcess *me = d->me;
|
||||
me->imageNumber->block (true);
|
||||
int n = d->n;
|
||||
int frameNum = d->frameNum;
|
||||
|
||||
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());
|
||||
}
|
||||
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;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* d) -> bool
|
||||
{
|
||||
BayerProcess *me = d->me;
|
||||
me->imageNumber->block (true);
|
||||
int n = d->n;
|
||||
int frameNum = d->frameNum;
|
||||
|
||||
idle_register.add(func, new Data { this, n, frameNum });
|
||||
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());
|
||||
}
|
||||
me->imageNumber->set_active(std::min(frameNum, n - 1));
|
||||
if(n == 1) {
|
||||
me->imageNumberBox->hide();
|
||||
} else {
|
||||
me->imageNumberBox->show();
|
||||
}
|
||||
me->imageNumber->block (false);
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add<Data>(func, new Data{this, n, frameNum}, true);
|
||||
}
|
||||
|
||||
void BayerProcess::autoContrastChanged (double autoContrast)
|
||||
{
|
||||
struct Data {
|
||||
BayerProcess *me;
|
||||
BayerProcess* self;
|
||||
double autoContrast;
|
||||
};
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(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 });
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
BayerProcess* const self = data->self;
|
||||
self->disableListener();
|
||||
self->dualDemosaicContrast->setValue(data->autoContrast);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add<Data>(func, new Data{this, autoContrast}, true);
|
||||
}
|
||||
|
@ -375,12 +375,14 @@ void BlackWhite::BWChanged (double redbw, double greenbw, double bluebw)
|
||||
nextgreenbw = greenbw;
|
||||
nextbluebw = bluebw;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<BlackWhite*>(data)->BWComputed_();
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](BlackWhite* self) -> bool
|
||||
{
|
||||
self->BWComputed_();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<BlackWhite>(func, this, false);
|
||||
}
|
||||
|
||||
bool BlackWhite::BWComputed_ ()
|
||||
|
@ -1452,63 +1452,63 @@ void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdit
|
||||
void ColorAppearance::autoCamChanged (double ccam, double ccamout)
|
||||
{
|
||||
struct Data {
|
||||
ColorAppearance *me;
|
||||
ColorAppearance* me;
|
||||
double ccam;
|
||||
double ccamout;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
ColorAppearance *me = d->me;
|
||||
me->disableListener();
|
||||
me->degree->setValue(d->ccam);
|
||||
me->degreeout->setValue(d->ccamout);
|
||||
me->enableListener();
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
ColorAppearance* const self = data->me;
|
||||
self->disableListener();
|
||||
self->degree->setValue(data->ccam);
|
||||
self->degreeout->setValue(data->ccamout);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, ccam, ccamout });
|
||||
idle_register.add<Data>(func, new Data{this, ccam, ccamout}, true);
|
||||
}
|
||||
|
||||
void ColorAppearance::adapCamChanged (double cadap)
|
||||
{
|
||||
struct Data {
|
||||
ColorAppearance *me;
|
||||
ColorAppearance* self;
|
||||
double cadap;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
ColorAppearance *me = d->me;
|
||||
me->disableListener();
|
||||
me->adapscen->setValue(d->cadap);
|
||||
me->enableListener();
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
ColorAppearance* const self = data->self;
|
||||
self->disableListener();
|
||||
self->adapscen->setValue(data->cadap);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, cadap });
|
||||
idle_register.add<Data>(func, new Data{this, cadap}, true);
|
||||
}
|
||||
|
||||
void ColorAppearance::ybCamChanged (int ybsc)
|
||||
{
|
||||
struct Data {
|
||||
ColorAppearance *me;
|
||||
ColorAppearance* self;
|
||||
int ybsc;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
ColorAppearance *me = d->me;
|
||||
me->disableListener();
|
||||
me->ybscen->setValue(d->ybsc);
|
||||
me->enableListener();
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
ColorAppearance* self = data->self;
|
||||
self->disableListener();
|
||||
self->ybscen->setValue(data->ybsc);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, ybsc });
|
||||
idle_register.add<Data>(func, new Data{this, ybsc}, true);
|
||||
}
|
||||
|
||||
void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller)
|
||||
|
@ -689,24 +689,24 @@ void ColorToning::setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool
|
||||
|
||||
void ColorToning::autoColorTonChanged(int satthres, int satprot)
|
||||
{
|
||||
struct Data {
|
||||
ColorToning *me;
|
||||
int satthres;
|
||||
int satprot;
|
||||
struct Data {
|
||||
ColorToning *self;
|
||||
int satthres;
|
||||
int satprot;
|
||||
};
|
||||
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
ColorToning* const self = data->self;
|
||||
self->disableListener();
|
||||
self->satProtectionThreshold->setValue(data->satthres);
|
||||
self->saturatedOpacity->setValue(data->satprot);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
ColorToning *me = d->me;
|
||||
me->disableListener();
|
||||
me->satProtectionThreshold->setValue(d->satthres);
|
||||
me->saturatedOpacity->setValue(d->satprot);
|
||||
me->enableListener ();
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, satthres, satprot });
|
||||
idle_register.add<Data>(func, new Data{this, satthres, satprot}, true);
|
||||
}
|
||||
|
||||
void ColorToning::adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop)
|
||||
|
@ -38,18 +38,16 @@ public:
|
||||
: crop(_crop), notify(_notify) {}
|
||||
};
|
||||
|
||||
int refreshSpinsUI (void* data)
|
||||
bool refreshSpinsUI(RefreshSpinHelper* rsh)
|
||||
{
|
||||
RefreshSpinHelper* rsh = static_cast<RefreshSpinHelper*>(data);
|
||||
rsh->crop->refreshSpins (rsh->notify);
|
||||
delete rsh;
|
||||
return 0;
|
||||
rsh->crop->refreshSpins(rsh->notify);
|
||||
return false;
|
||||
}
|
||||
|
||||
int notifyListenerUI (void* data)
|
||||
bool notifyListenerUI(Crop* self)
|
||||
{
|
||||
static_cast<Crop*>(data)->notifyListener();
|
||||
return 0;
|
||||
self->notifyListener();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -515,16 +513,14 @@ void Crop::enabledChanged ()
|
||||
|
||||
void Crop::hFlipCrop ()
|
||||
{
|
||||
|
||||
nx = maxw - nx - nw;
|
||||
idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
|
||||
idle_register.add<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::vFlipCrop ()
|
||||
{
|
||||
|
||||
ny = maxh - ny - nh;
|
||||
idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
|
||||
idle_register.add<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::rotateCrop (int deg, bool hflip, bool vflip)
|
||||
@ -564,7 +560,7 @@ void Crop::rotateCrop (int deg, bool hflip, bool vflip)
|
||||
}
|
||||
|
||||
lastRotationDeg = deg;
|
||||
idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
|
||||
idle_register.add<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::positionChanged ()
|
||||
@ -578,7 +574,7 @@ void Crop::positionChanged ()
|
||||
int W = nw;
|
||||
int H = nh;
|
||||
cropMoved (X, Y, W, H);
|
||||
idle_register.add(notifyListenerUI, this);
|
||||
idle_register.add<Crop>(notifyListenerUI, this, false);
|
||||
}
|
||||
|
||||
void Crop::widthChanged ()
|
||||
@ -591,7 +587,7 @@ 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<Crop>(notifyListenerUI, this, false);
|
||||
}
|
||||
|
||||
void Crop::heightChanged ()
|
||||
@ -604,7 +600,7 @@ 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<Crop>(notifyListenerUI, this, false);
|
||||
}
|
||||
|
||||
// Fixed ratio toggle button
|
||||
@ -656,7 +652,7 @@ void Crop::adjustCropToRatio()
|
||||
}
|
||||
|
||||
// This will save the options
|
||||
idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, true));
|
||||
idle_register.add<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, true), true);
|
||||
}
|
||||
|
||||
void Crop::refreshSize ()
|
||||
@ -742,14 +738,14 @@ void Crop::sizeChanged(int x, int y, int ow, int oh)
|
||||
y
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Params* const params = static_cast<Params*>(data);
|
||||
params->crop->setDimensions(params->x, params->y);
|
||||
delete params;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Params* params) -> bool
|
||||
{
|
||||
params->crop->setDimensions(params->x, params->y);
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, params);
|
||||
idle_register.add<Params>(func, params, true);
|
||||
}
|
||||
|
||||
bool Crop::refreshSpins (bool notify)
|
||||
@ -813,7 +809,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
// Glib::signal_idle().connect (sigc::mem_fun(*this, &Crop::refreshSpins));
|
||||
}
|
||||
|
||||
@ -857,7 +853,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -897,7 +893,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -940,7 +936,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -980,7 +976,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -1022,7 +1018,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -1062,7 +1058,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -1102,7 +1098,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H, float custom_ratio)
|
||||
@ -1139,7 +1135,7 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropInit (int &x, int &y, int &w, int &h)
|
||||
@ -1253,12 +1249,12 @@ 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<RefreshSpinHelper>(refreshSpinsUI, new RefreshSpinHelper(this, false), true);
|
||||
}
|
||||
|
||||
void Crop::cropManipReady ()
|
||||
{
|
||||
idle_register.add(notifyListenerUI, this);
|
||||
idle_register.add<Crop>(notifyListenerUI, this, false);
|
||||
}
|
||||
|
||||
double Crop::getRatio () const
|
||||
|
@ -338,9 +338,9 @@ 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<CropHandler*>(data);
|
||||
|
||||
const auto func =
|
||||
[](CropHandler* self) -> bool
|
||||
{
|
||||
self->cimg.lock ();
|
||||
|
||||
if (self->redraw_needed.exchange(false)) {
|
||||
@ -350,7 +350,7 @@ void CropHandler::setDetailedCrop(
|
||||
self->cropimg.clear();
|
||||
self->cropimgtrue.clear();
|
||||
self->cimg.unlock ();
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!self->cropimg.empty()) {
|
||||
@ -398,10 +398,10 @@ void CropHandler::setDetailedCrop(
|
||||
self->cimg.unlock();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, this/*, G_PRIORITY_HIGH_IDLE*/);
|
||||
idle_register.add<CropHandler>(func, this, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -284,32 +284,32 @@ DirPyrDenoise::~DirPyrDenoise ()
|
||||
void DirPyrDenoise::chromaChanged (double autchroma, double autred, double autblue)
|
||||
{
|
||||
struct Data {
|
||||
DirPyrDenoise *me;
|
||||
DirPyrDenoise* self;
|
||||
double autchroma;
|
||||
double autred;
|
||||
double autblue;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
DirPyrDenoise *me = d->me;
|
||||
me->disableListener();
|
||||
me->chroma->setValue(d->autchroma);
|
||||
me->redchro->setValue(d->autred);
|
||||
me->bluechro->setValue(d->autblue);
|
||||
me->enableListener();
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
DirPyrDenoise* const self = data->self;
|
||||
self->disableListener();
|
||||
self->chroma->setValue(data->autchroma);
|
||||
self->redchro->setValue(data->autred);
|
||||
self->bluechro->setValue(data->autblue);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, autchroma, autred, autblue });
|
||||
idle_register.add<Data>(func, new Data{this, autchroma, autred, autblue}, true);
|
||||
}
|
||||
|
||||
void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP)
|
||||
{
|
||||
if (!batchMode) {
|
||||
struct Data {
|
||||
DirPyrDenoise *me;
|
||||
DirPyrDenoise* self;
|
||||
int tileX;
|
||||
int tileY;
|
||||
int prevX;
|
||||
@ -318,26 +318,26 @@ void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, i
|
||||
int sizeP;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
DirPyrDenoise *me = d->me;
|
||||
me->TileLabels->set_text(
|
||||
Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_TILEINFO"),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->sizeT),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->tileX),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->tileY))
|
||||
);
|
||||
me->PrevLabels->set_text(
|
||||
Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_INFO"),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->sizeP),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->prevX),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->prevY))
|
||||
);
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
DirPyrDenoise* self = data->self;
|
||||
self->TileLabels->set_text(
|
||||
Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_TILEINFO"),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->sizeT),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->tileX),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->tileY))
|
||||
);
|
||||
self->PrevLabels->set_text(
|
||||
Glib::ustring::compose(M("TP_DIRPYRDENOISE_CHROMINANCE_PREVIEW_INFO"),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->sizeP),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->prevX),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->prevY))
|
||||
);
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, tileX, tileY, prevX, prevY, sizeT, sizeP });
|
||||
idle_register.add<Data>(func, new Data{this, tileX, tileY, prevX, prevY, sizeT, sizeP}, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,20 +345,20 @@ void DirPyrDenoise::noiseChanged (double nresid, double highresid)
|
||||
{
|
||||
if (!batchMode) {
|
||||
struct Data {
|
||||
DirPyrDenoise *me;
|
||||
DirPyrDenoise* self;
|
||||
double nresid;
|
||||
double highresid;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
DirPyrDenoise *me = d->me;
|
||||
me->updateNoiseLabel(d->nresid, d->highresid);
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
DirPyrDenoise* const self = data->self;
|
||||
self->updateNoiseLabel(data->nresid, data->highresid);
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, nresid, highresid });
|
||||
idle_register.add<Data>(func, new Data{this, nresid, highresid}, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,10 +45,8 @@ struct spparams {
|
||||
Glib::RefPtr<Gtk::CssProvider> cssProvider;
|
||||
};
|
||||
|
||||
int setprogressStrUI ( void *p )
|
||||
bool setprogressStrUI(spparams* s)
|
||||
{
|
||||
spparams *s = static_cast<spparams*> (p);
|
||||
|
||||
if ( ! s->str.empty() ) {
|
||||
s->pProgress->set_text ( M (s->str) );
|
||||
}
|
||||
@ -67,8 +65,7 @@ int setprogressStrUI ( void *p )
|
||||
}
|
||||
}
|
||||
|
||||
delete s;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -498,7 +495,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 +517,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
|
||||
leftsubbox->pack_start (*history);
|
||||
|
||||
leftsubbox->show_all ();
|
||||
|
||||
|
||||
leftbox->pack2 (*leftsubbox, true, true);
|
||||
leftbox->show_all ();
|
||||
|
||||
@ -638,14 +635,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 +859,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
|
||||
if (tbTopPanel_1) {
|
||||
tbTopPanel_1->signal_toggled().connect ( sigc::mem_fun (*this, &EditorPanel::tbTopPanel_1_toggled) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
EditorPanel::~EditorPanel ()
|
||||
@ -1192,7 +1189,7 @@ void EditorPanel::setProgress(double p)
|
||||
spparams *s = new spparams;
|
||||
s->val = p;
|
||||
s->pProgress = progressLabel;
|
||||
idle_register.add(setprogressStrUI, s);
|
||||
idle_register.add<spparams>(setprogressStrUI, s, true);
|
||||
}
|
||||
|
||||
void EditorPanel::setProgressStr(const Glib::ustring& str)
|
||||
@ -1201,7 +1198,7 @@ void EditorPanel::setProgressStr(const Glib::ustring& str)
|
||||
s->str = str;
|
||||
s->val = -1;
|
||||
s->pProgress = progressLabel;
|
||||
idle_register.add(setprogressStrUI, s);
|
||||
idle_register.add<spparams>(setprogressStrUI, s, true);
|
||||
}
|
||||
|
||||
void EditorPanel::setProgressState(bool inProcessing)
|
||||
@ -1217,30 +1214,27 @@ void EditorPanel::setProgressState(bool inProcessing)
|
||||
p->inProcessing = inProcessing;
|
||||
p->epih = epih;
|
||||
|
||||
const auto func = [] (gpointer data) -> gboolean {
|
||||
spsparams* const p = static_cast<spsparams*> (data);
|
||||
|
||||
if (p->epih->destroyed)
|
||||
const auto func =
|
||||
[](spsparams* p) -> bool
|
||||
{
|
||||
if (p->epih->pending == 1) {
|
||||
delete p->epih;
|
||||
} else {
|
||||
p->epih->pending--;
|
||||
if (p->epih->destroyed)
|
||||
{
|
||||
if (p->epih->pending == 1) {
|
||||
delete p->epih;
|
||||
} else {
|
||||
p->epih->pending--;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
delete p;
|
||||
p->epih->epanel->refreshProcessingState (p->inProcessing);
|
||||
p->epih->pending--;
|
||||
|
||||
return 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
p->epih->epanel->refreshProcessingState (p->inProcessing);
|
||||
p->epih->pending--;
|
||||
delete p;
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add (func, p);
|
||||
idle_register.add<spsparams>(func, p, true);
|
||||
}
|
||||
|
||||
void EditorPanel::error(const Glib::ustring& descr)
|
||||
@ -1261,30 +1255,27 @@ void EditorPanel::error(const Glib::ustring& title, const Glib::ustring& descr)
|
||||
p->title = title;
|
||||
p->epih = epih;
|
||||
|
||||
const auto func = [] (gpointer data) -> gboolean {
|
||||
errparams* const p = static_cast<errparams*> (data);
|
||||
|
||||
if (p->epih->destroyed)
|
||||
const auto func =
|
||||
[](errparams* p) -> bool
|
||||
{
|
||||
if (p->epih->pending == 1) {
|
||||
delete p->epih;
|
||||
} else {
|
||||
p->epih->pending--;
|
||||
if (p->epih->destroyed)
|
||||
{
|
||||
if (p->epih->pending == 1) {
|
||||
delete p->epih;
|
||||
} else {
|
||||
p->epih->pending--;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
delete p;
|
||||
p->epih->epanel->displayError (p->title, p->descr);
|
||||
p->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);
|
||||
idle_register.add<errparams>(func, p, true);
|
||||
}
|
||||
|
||||
void EditorPanel::displayError(const Glib::ustring& title, const Glib::ustring& descr)
|
||||
@ -2376,7 +2367,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;
|
||||
@ -2396,14 +2387,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);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -568,31 +568,30 @@ void FileBrowser::doubleClicked (ThumbBrowserEntryBase* entry)
|
||||
void FileBrowser::addEntry (FileBrowserEntry* entry)
|
||||
{
|
||||
struct addparams {
|
||||
FileBrowser *browser;
|
||||
FileBrowserEntry *entry;
|
||||
FileBrowser* self;
|
||||
FileBrowserEntry* entry;
|
||||
unsigned int session_id;
|
||||
};
|
||||
|
||||
addparams* const ap = new addparams;
|
||||
entry->setParent (this);
|
||||
ap->browser = this;
|
||||
ap->self = this;
|
||||
ap->entry = entry;
|
||||
ap->session_id = session_id();
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
addparams* const ap = static_cast<addparams*>(data);
|
||||
if (ap->session_id != ap->browser->session_id()) {
|
||||
delete ap->entry;
|
||||
delete ap;
|
||||
} else {
|
||||
ap->browser->addEntry_(ap->entry);
|
||||
delete ap;
|
||||
}
|
||||
const auto func =
|
||||
[](addparams* ap) -> bool
|
||||
{
|
||||
if (ap->session_id != ap->self->session_id()) {
|
||||
delete ap->entry;
|
||||
} else {
|
||||
ap->self->addEntry_(ap->entry);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, ap);
|
||||
idle_register.add<addparams>(func, ap, true);
|
||||
}
|
||||
|
||||
void FileBrowser::addEntry_ (FileBrowserEntry* entry)
|
||||
@ -1935,13 +1934,14 @@ void FileBrowser::_thumbRearrangementNeeded ()
|
||||
|
||||
void FileBrowser::thumbRearrangementNeeded ()
|
||||
{
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<FileBrowser*>(data)->_thumbRearrangementNeeded();
|
||||
const auto func =
|
||||
[](FileBrowser* self) -> bool
|
||||
{
|
||||
self->_thumbRearrangementNeeded();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<FileBrowser>(func, this, false);
|
||||
}
|
||||
|
||||
void FileBrowser::selectionChanged ()
|
||||
|
@ -233,31 +233,29 @@ void FileBrowserEntry::updateImage(rtengine::IImage8* img, double scale, const r
|
||||
|
||||
const gint priority = G_PRIORITY_LOW;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
tiupdate* const params = static_cast<tiupdate*>(data);
|
||||
FileBrowserEntryIdleHelper* const feih = params->feih;
|
||||
const auto func =
|
||||
[](tiupdate* params) -> bool
|
||||
{
|
||||
FileBrowserEntryIdleHelper* const feih = params->feih;
|
||||
|
||||
if (feih->destroyed) {
|
||||
if (feih->pending == 1) {
|
||||
delete feih;
|
||||
} else {
|
||||
feih->pending--;
|
||||
if (feih->destroyed) {
|
||||
if (feih->pending == 1) {
|
||||
delete feih;
|
||||
} else {
|
||||
feih->pending--;
|
||||
}
|
||||
|
||||
params->img->free ();
|
||||
return false;
|
||||
}
|
||||
|
||||
params->img->free ();
|
||||
delete params;
|
||||
return 0;
|
||||
}
|
||||
feih->fbentry->_updateImage (params->img, params->scale, params->cropParams);
|
||||
feih->pending--;
|
||||
|
||||
feih->fbentry->_updateImage (params->img, params->scale, params->cropParams);
|
||||
feih->pending--;
|
||||
return false;
|
||||
};
|
||||
|
||||
delete params;
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, param, priority);
|
||||
idle_register.add<tiupdate>(func, param, true, priority);
|
||||
}
|
||||
|
||||
void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rtengine::procparams::CropParams& cropParams)
|
||||
|
@ -873,13 +873,14 @@ void FileCatalog::previewsFinished (int dir_id)
|
||||
currentEFS = dirEFS;
|
||||
}
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<FileCatalog*>(data)->previewsFinishedUI();
|
||||
const auto func =
|
||||
[](FileCatalog* self) -> bool
|
||||
{
|
||||
self->previewsFinishedUI();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<FileCatalog>(func, this, false);
|
||||
}
|
||||
|
||||
void FileCatalog::setEnabled (bool e)
|
||||
@ -941,24 +942,22 @@ struct FCOIParams {
|
||||
std::vector<Thumbnail*> tmb;
|
||||
};
|
||||
|
||||
int openRequestedUI (void* p)
|
||||
bool openRequestedUI(FCOIParams* params)
|
||||
{
|
||||
FCOIParams* params = static_cast<FCOIParams*>(p);
|
||||
params->catalog->_openImage (params->tmb);
|
||||
delete params;
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void FileCatalog::filterApplied()
|
||||
{
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<FileCatalog*>(data)->_refreshProgressBar();
|
||||
const auto func =
|
||||
[](FileCatalog* self) -> bool
|
||||
{
|
||||
self->_refreshProgressBar();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<FileCatalog>(func, this, false);
|
||||
}
|
||||
|
||||
void FileCatalog::openRequested(const std::vector<Thumbnail*>& tmb)
|
||||
@ -971,7 +970,7 @@ void FileCatalog::openRequested(const std::vector<Thumbnail*>& tmb)
|
||||
tmb[i]->increaseRef ();
|
||||
}
|
||||
|
||||
idle_register.add(openRequestedUI, params);
|
||||
idle_register.add<FCOIParams>(openRequestedUI, params, true);
|
||||
}
|
||||
|
||||
void FileCatalog::deleteRequested(const std::vector<FileBrowserEntry*>& tbe, bool inclBatchProcessed)
|
||||
@ -1229,7 +1228,7 @@ void FileCatalog::developRequested(const std::vector<FileBrowserEntry*>& tbe, bo
|
||||
params.resize.width = options.fastexport_resize_width;
|
||||
params.resize.height = options.fastexport_resize_height;
|
||||
}
|
||||
|
||||
|
||||
params.resize.enabled = options.fastexport_resize_enabled;
|
||||
params.resize.scale = options.fastexport_resize_scale;
|
||||
params.resize.appliesTo = options.fastexport_resize_appliesTo;
|
||||
@ -1903,7 +1902,7 @@ void FileCatalog::addAndOpenFile (const Glib::ustring& fname)
|
||||
params->catalog = this;
|
||||
params->tmb.push_back (tmb);
|
||||
tmb->increaseRef ();
|
||||
idle_register.add(openRequestedUI, params);
|
||||
idle_register.add<FCOIParams>(openRequestedUI, params, true);
|
||||
|
||||
} catch(Gio::Error&) {}
|
||||
}
|
||||
|
@ -139,12 +139,14 @@ FilePanel::FilePanel () : parent(nullptr), error(0)
|
||||
|
||||
fileCatalog->setFileSelectionListener (this);
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<FilePanel*>(data)->init();
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](FilePanel* self) -> bool
|
||||
{
|
||||
self->init();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<FilePanel>(func, this, false);
|
||||
|
||||
show_all ();
|
||||
}
|
||||
|
@ -412,18 +412,19 @@ void FlatField::setShortcutPath(const Glib::ustring& path)
|
||||
void FlatField::flatFieldAutoClipValueChanged(int n)
|
||||
{
|
||||
struct Data {
|
||||
FlatField *me;
|
||||
FlatField* self;
|
||||
int n;
|
||||
};
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(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 });
|
||||
}
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
FlatField* const self = data->self;
|
||||
self->disableListener();
|
||||
self->flatFieldClipControl->setValue (data->n);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add<Data>(func, new Data{this, n}, true);
|
||||
}
|
||||
|
@ -43,39 +43,14 @@ IdleRegister::~IdleRegister()
|
||||
destroy();
|
||||
}
|
||||
|
||||
void IdleRegister::add(GSourceFunc function, gpointer data, gint priority)
|
||||
{
|
||||
const auto dispatch = [](gpointer data) -> gboolean {
|
||||
DataWrapper* const data_wrapper = static_cast<DataWrapper*>(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();
|
||||
|
||||
delete data_wrapper;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
DataWrapper* const data_wrapper = new DataWrapper{
|
||||
this,
|
||||
function,
|
||||
data
|
||||
};
|
||||
|
||||
mutex.lock();
|
||||
ids[data_wrapper] = gdk_threads_add_idle_full(priority, dispatch, data_wrapper, nullptr);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void IdleRegister::destroy()
|
||||
{
|
||||
mutex.lock();
|
||||
for (const auto& id : ids) {
|
||||
g_source_remove(id.second);
|
||||
if (id.first->deleter) {
|
||||
id.first->deleter(id.first->data);
|
||||
}
|
||||
delete id.first;
|
||||
}
|
||||
ids.clear();
|
||||
@ -1278,7 +1253,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 +1343,7 @@ std::vector<Glib::RefPtr<Gtk::FileFilter>> MyFileChooserButton::list_filters()
|
||||
return file_filters_;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MyFileChooserButton::set_current_folder(const std::string &filename)
|
||||
{
|
||||
current_folder_ = filename;
|
||||
|
@ -50,7 +50,54 @@ class IdleRegister final :
|
||||
public:
|
||||
~IdleRegister();
|
||||
|
||||
void add(GSourceFunc function, gpointer data, gint priority = G_PRIORITY_DEFAULT_IDLE);
|
||||
template<typename DATA>
|
||||
void add(bool (*function)(DATA*), DATA* data, bool delete_data, gint priority = G_PRIORITY_DEFAULT_IDLE)
|
||||
{
|
||||
const auto dispatch =
|
||||
[](gpointer data) -> gboolean
|
||||
{
|
||||
DataWrapper* const data_wrapper = static_cast<DataWrapper*>(data);
|
||||
|
||||
// This is safe as per https://en.cppreference.com/w/cpp/language/reinterpret_cast item 7)
|
||||
if (!reinterpret_cast<bool (*)(DATA*)>(data_wrapper->function)(static_cast<DATA*>(data_wrapper->data))) {
|
||||
data_wrapper->self->mutex.lock();
|
||||
data_wrapper->self->ids.erase(data_wrapper);
|
||||
data_wrapper->self->mutex.unlock();
|
||||
|
||||
if (data_wrapper->deleter) {
|
||||
data_wrapper->deleter(data_wrapper->data);
|
||||
}
|
||||
|
||||
delete data_wrapper;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
};
|
||||
|
||||
DataWrapper* const data_wrapper = new DataWrapper{
|
||||
this,
|
||||
reinterpret_cast<GSourceFunc>(function),
|
||||
data,
|
||||
[delete_data]() -> GSourceFunc
|
||||
{
|
||||
if (delete_data) {
|
||||
return
|
||||
[](gpointer data) -> gboolean
|
||||
{
|
||||
delete static_cast<DATA*>(data);
|
||||
return TRUE;
|
||||
};
|
||||
}
|
||||
return nullptr;
|
||||
}()
|
||||
};
|
||||
|
||||
mutex.lock();
|
||||
ids[data_wrapper] = gdk_threads_add_idle_full(priority, dispatch, data_wrapper, nullptr);
|
||||
mutex.unlock();
|
||||
}
|
||||
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
@ -58,6 +105,7 @@ private:
|
||||
IdleRegister* const self;
|
||||
GSourceFunc function;
|
||||
gpointer data;
|
||||
GSourceFunc deleter;
|
||||
};
|
||||
|
||||
std::map<const DataWrapper*, guint> ids;
|
||||
@ -399,7 +447,7 @@ public:
|
||||
|
||||
sigc::signal<void> &signal_selection_changed();
|
||||
sigc::signal<void> &signal_file_set();
|
||||
|
||||
|
||||
std::string get_filename() const;
|
||||
bool set_filename(const std::string &filename);
|
||||
|
||||
@ -407,7 +455,7 @@ public:
|
||||
void remove_filter(const Glib::RefPtr<Gtk::FileFilter> &filter);
|
||||
void set_filter(const Glib::RefPtr<Gtk::FileFilter> &filter);
|
||||
std::vector<Glib::RefPtr<Gtk::FileFilter>> list_filters();
|
||||
|
||||
|
||||
bool set_current_folder(const std::string &filename);
|
||||
std::string get_current_folder() const;
|
||||
|
||||
|
@ -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,28 @@ void HistogramRGBArea::update (int valh, int rh, int gh, int bh)
|
||||
|
||||
harih->pending++;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
HistogramRGBAreaIdleHelper* const harih = static_cast<HistogramRGBAreaIdleHelper*>(data);
|
||||
const auto func =
|
||||
[](HistogramRGBAreaIdleHelper* harih) -> 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->harea->updateBackBuffer(-1, -1, -1);
|
||||
harih->harea->queue_draw ();
|
||||
harih->pending--;
|
||||
|
||||
harih->pending--;
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, harih);
|
||||
idle_register.add<HistogramRGBAreaIdleHelper>(func, harih, false);
|
||||
}
|
||||
|
||||
void HistogramRGBArea::updateOptions (bool r, bool g, bool b, bool l, bool c, bool raw, bool bar)
|
||||
@ -655,7 +655,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 +703,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 +722,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;
|
||||
@ -761,29 +761,29 @@ void HistogramArea::update(
|
||||
|
||||
haih->pending++;
|
||||
// Can be done outside of the GUI thread
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
HistogramAreaIdleHelper* const haih = static_cast<HistogramAreaIdleHelper*>(data);
|
||||
const auto func =
|
||||
[](HistogramAreaIdleHelper* haih) -> bool
|
||||
{
|
||||
if (haih->destroyed) {
|
||||
if (haih->pending == 1) {
|
||||
delete haih;
|
||||
} else {
|
||||
haih->pending--;
|
||||
}
|
||||
|
||||
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->harea->setDirty (true);
|
||||
haih->harea->updateBackBuffer ();
|
||||
haih->harea->queue_draw ();
|
||||
haih->pending--;
|
||||
|
||||
haih->pending--;
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, haih);
|
||||
idle_register.add<HistogramAreaIdleHelper>(func, haih, false);
|
||||
}
|
||||
|
||||
void HistogramArea::updateBackBuffer ()
|
||||
@ -889,7 +889,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 +915,7 @@ void HistogramArea::updateBackBuffer ()
|
||||
}
|
||||
|
||||
int realhistheight = histheight;
|
||||
|
||||
|
||||
if (realhistheight < winh - 2) {
|
||||
realhistheight = winh - 2;
|
||||
}
|
||||
@ -960,7 +960,7 @@ void HistogramArea::updateBackBuffer ()
|
||||
cr->stroke ();
|
||||
drawMarks(cr, bhchanged, realhistheight, w, ui, oi);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Draw the frame's border
|
||||
@ -1044,16 +1044,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 +1072,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;
|
||||
}
|
||||
|
||||
|
@ -1516,28 +1516,28 @@ void MyDiagonalCurve::updateBackgroundHistogram (LUTu & hist)
|
||||
|
||||
mcih->pending++;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
MyCurveIdleHelper* const mcih = static_cast<MyCurveIdleHelper*>(data);
|
||||
const auto func =
|
||||
[](MyCurveIdleHelper* mcih) -> 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->clearPixmap ();
|
||||
mcih->myCurve->queue_draw ();
|
||||
mcih->pending--;
|
||||
|
||||
mcih->pending--;
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, mcih);
|
||||
idle_register.add<MyCurveIdleHelper>(func, mcih, false);
|
||||
}
|
||||
|
||||
void MyDiagonalCurve::reset(const std::vector<double> &resetCurve, double identityValue)
|
||||
|
@ -67,40 +67,38 @@ void PreviewHandler::setImage(rtengine::IImage8* i, double scale, const rtengine
|
||||
iap->scale = scale;
|
||||
iap->cp = cp;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
iaimgpar* const iap = static_cast<iaimgpar*>(data);
|
||||
PreviewHandlerIdleHelper* const pih = iap->pih;
|
||||
const auto func =
|
||||
[](iaimgpar* iap) -> bool
|
||||
{
|
||||
PreviewHandlerIdleHelper* const pih = iap->pih;
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
pih->phandler->cropParams = iap->cp;
|
||||
pih->phandler->previewScale = iap->scale;
|
||||
pih->pending--;
|
||||
|
||||
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;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
pih->phandler->cropParams = iap->cp;
|
||||
pih->phandler->previewScale = iap->scale;
|
||||
pih->pending--;
|
||||
delete iap;
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, iap);
|
||||
idle_register.add<iaimgpar>(func, iap, true);
|
||||
}
|
||||
|
||||
|
||||
@ -112,41 +110,39 @@ void PreviewHandler::delImage(IImage8* i)
|
||||
iap->image = i;
|
||||
iap->pih = pih;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
iaimgpar* iap = static_cast<iaimgpar*>(data);
|
||||
PreviewHandlerIdleHelper* pih = iap->pih;
|
||||
const auto func =
|
||||
[](iaimgpar* iap) -> bool
|
||||
{
|
||||
PreviewHandlerIdleHelper* const pih = iap->pih;
|
||||
|
||||
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;
|
||||
if (pih->phandler->image) {
|
||||
IImage8* oldImg = pih->phandler->image;
|
||||
oldImg->getMutex().lock ();
|
||||
pih->phandler->image = nullptr;
|
||||
oldImg->getMutex().unlock ();
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
iap->image->free ();
|
||||
pih->phandler->previewImgMutex.lock ();
|
||||
pih->phandler->previewImg.clear ();
|
||||
pih->phandler->previewImgMutex.unlock ();
|
||||
|
||||
if (pih->phandler->image) {
|
||||
IImage8* oldImg = pih->phandler->image;
|
||||
oldImg->getMutex().lock ();
|
||||
pih->phandler->image = nullptr;
|
||||
oldImg->getMutex().unlock ();
|
||||
}
|
||||
pih->pending--;
|
||||
|
||||
iap->image->free ();
|
||||
pih->phandler->previewImgMutex.lock ();
|
||||
pih->phandler->previewImg.clear ();
|
||||
pih->phandler->previewImgMutex.unlock ();
|
||||
return false;
|
||||
};
|
||||
|
||||
pih->pending--;
|
||||
delete iap;
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, iap);
|
||||
idle_register.add<iaimgpar>(func, iap, true);
|
||||
}
|
||||
|
||||
void PreviewHandler::imageReady(const rtengine::procparams::CropParams& cp)
|
||||
@ -156,34 +152,32 @@ void PreviewHandler::imageReady(const rtengine::procparams::CropParams& cp)
|
||||
iap->pih = pih;
|
||||
iap->cp = cp;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
iaimgpar* const iap = static_cast<iaimgpar*>(data);
|
||||
PreviewHandlerIdleHelper* pih = iap->pih;
|
||||
const auto func =
|
||||
[](iaimgpar* iap) -> bool
|
||||
{
|
||||
PreviewHandlerIdleHelper* const pih = iap->pih;
|
||||
|
||||
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 ();
|
||||
pih->phandler->cropParams = iap->cp;
|
||||
pih->phandler->previewImageChanged ();
|
||||
pih->pending--;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
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);
|
||||
idle_register.add<iaimgpar>(func, iap, true);
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Pixbuf> PreviewHandler::getRoughImage (int x, int y, int w, int h, double zoom)
|
||||
|
126
rtgui/resize.cc
126
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,76 @@ 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<Resize*>(data);
|
||||
const auto func =
|
||||
[](Resize* self) -> bool
|
||||
{
|
||||
self->wconn.block(true);
|
||||
self->hconn.block(true);
|
||||
self->scale->block(true);
|
||||
|
||||
self->wconn.block(true);
|
||||
self->hconn.block(true);
|
||||
self->scale->block(true);
|
||||
int refw, refh;
|
||||
|
||||
int refw, refh;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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<double>(static_cast<int>(static_cast<double>(refw) * self->scale->getValue() + 0.5)));
|
||||
self->h->set_value(static_cast<double>(static_cast<int>(static_cast<double>(refh) * self->scale->getValue() + 0.5)));
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
case 1: {
|
||||
// Width mode
|
||||
const double tmp_scale = self->w->get_value() / static_cast<double>(refw);
|
||||
self->scale->setValue(tmp_scale);
|
||||
self->h->set_value(static_cast<double>(static_cast<int>(static_cast<double>(refh) * tmp_scale + 0.5)));
|
||||
break;
|
||||
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<double>(static_cast<int>(static_cast<double>(refw) * self->scale->getValue() + 0.5)));
|
||||
self->h->set_value(static_cast<double>(static_cast<int>(static_cast<double>(refh) * self->scale->getValue() + 0.5)));
|
||||
break;
|
||||
}
|
||||
|
||||
case 1: {
|
||||
// Width mode
|
||||
const double tmp_scale = self->w->get_value() / static_cast<double>(refw);
|
||||
self->scale->setValue(tmp_scale);
|
||||
self->h->set_value(static_cast<double>(static_cast<int>(static_cast<double>(refh) * tmp_scale + 0.5)));
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: {
|
||||
// Height mode
|
||||
const double tmp_scale = self->h->get_value() / static_cast<double>(refh);
|
||||
self->scale->setValue(tmp_scale);
|
||||
self->w->set_value(static_cast<double>(static_cast<int>(static_cast<double>(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<double>(refw) / static_cast<double>(refh)
|
||||
? self->w->get_value() / static_cast<double>(refw)
|
||||
: self->h->get_value() / static_cast<double>(refh);
|
||||
|
||||
self->scale->setValue(tmp_scale);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case 2: {
|
||||
// Height mode
|
||||
const double tmp_scale = self->h->get_value() / static_cast<double>(refh);
|
||||
self->scale->setValue(tmp_scale);
|
||||
self->w->set_value(static_cast<double>(static_cast<int>(static_cast<double>(refw) * tmp_scale + 0.5)));
|
||||
break;
|
||||
}
|
||||
self->scale->block(false);
|
||||
self->wconn.block(false);
|
||||
self->hconn.block(false);
|
||||
|
||||
case 3: {
|
||||
// Bounding box mode
|
||||
const double tmp_scale =
|
||||
self->w->get_value() / self->h->get_value() < static_cast<double>(refw) / static_cast<double>(refh)
|
||||
? self->w->get_value() / static_cast<double>(refw)
|
||||
: self->h->get_value() / static_cast<double>(refh);
|
||||
return false;
|
||||
};
|
||||
|
||||
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);
|
||||
idle_register.add<Resize>(func, this, false);
|
||||
}
|
||||
|
||||
void Resize::fitBoxScale()
|
||||
|
@ -673,14 +673,16 @@ 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<Retinex*> (data)->minmaxComputed_();
|
||||
const auto func =
|
||||
[](Retinex* self) -> bool
|
||||
{
|
||||
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected
|
||||
// FIXME: The above can't be true?!
|
||||
self->minmaxComputed_();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add (func, this);
|
||||
idle_register.add<Retinex>(func, this, false);
|
||||
}
|
||||
|
||||
bool Retinex::minmaxComputed_ ()
|
||||
|
@ -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 (10);
|
||||
@ -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
|
||||
}
|
||||
@ -857,7 +857,7 @@ bool ToneCurve::autoExpComputed_ ()
|
||||
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
|
||||
}
|
||||
@ -979,7 +979,7 @@ bool ToneCurve::histmatchingComputed()
|
||||
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
|
||||
}
|
||||
@ -1013,13 +1013,14 @@ void ToneCurve::autoExpChanged(double expcomp, int bright, int contr, int black,
|
||||
nextHlcomprthresh = hlcomprthresh;
|
||||
nextHLRecons = hlrecons;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<ToneCurve*>(data)->autoExpComputed_();
|
||||
const auto func =
|
||||
[](ToneCurve* self) -> bool
|
||||
{
|
||||
self->autoExpComputed_();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<ToneCurve>(func, this, false);
|
||||
}
|
||||
|
||||
void ToneCurve::autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParams::TcMode curveMode, const std::vector<double>& curve)
|
||||
@ -1027,11 +1028,12 @@ void ToneCurve::autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParam
|
||||
nextToneCurveMode = curveMode;
|
||||
nextToneCurve = curve;
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
static_cast<ToneCurve*>(data)->histmatchingComputed();
|
||||
const auto func =
|
||||
[](ToneCurve* self) -> bool
|
||||
{
|
||||
self->histmatchingComputed();
|
||||
return false;
|
||||
};
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
|
||||
idle_register.add(func, this);
|
||||
idle_register.add<ToneCurve>(func, this, false);
|
||||
}
|
||||
|
@ -263,74 +263,74 @@ void ToolPanelCoordinator::imageTypeChanged (bool isRaw, bool isBayer, bool isXt
|
||||
{
|
||||
if (isRaw) {
|
||||
if (isBayer) {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
ToolPanelCoordinator* const self = static_cast<ToolPanelCoordinator*>(data);
|
||||
const auto func =
|
||||
[](ToolPanelCoordinator* self) -> bool
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
};
|
||||
idle_register.add<ToolPanelCoordinator>(func, this, false);
|
||||
}
|
||||
else if (isXtrans) {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
ToolPanelCoordinator* const self = static_cast<ToolPanelCoordinator*>(data);
|
||||
const auto func =
|
||||
[](ToolPanelCoordinator* self) -> bool
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
};
|
||||
idle_register.add<ToolPanelCoordinator>(func, this, false);
|
||||
}
|
||||
else if (isMono) {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
ToolPanelCoordinator* const self = static_cast<ToolPanelCoordinator*>(data);
|
||||
const auto func =
|
||||
[](ToolPanelCoordinator* self) -> bool
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
};
|
||||
idle_register.add<ToolPanelCoordinator>(func, this, false);
|
||||
} else {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
ToolPanelCoordinator* const self = static_cast<ToolPanelCoordinator*>(data);
|
||||
const auto func =
|
||||
[](ToolPanelCoordinator* self) -> bool
|
||||
{
|
||||
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);
|
||||
|
||||
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;
|
||||
};
|
||||
idle_register.add<ToolPanelCoordinator>(func, this, false);
|
||||
}
|
||||
} else {
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
ToolPanelCoordinator* const self = static_cast<ToolPanelCoordinator*>(data);
|
||||
const auto func =
|
||||
[](ToolPanelCoordinator* self) -> bool
|
||||
{
|
||||
self->rawPanelSW->set_sensitive (false);
|
||||
self->retinex->FoldableToolPanel::setGrayedOut(true);
|
||||
|
||||
self->rawPanelSW->set_sensitive (false);
|
||||
self->retinex->FoldableToolPanel::setGrayedOut(true);
|
||||
|
||||
return FALSE;
|
||||
};
|
||||
idle_register.add(func, this);
|
||||
return false;
|
||||
};
|
||||
idle_register.add<ToolPanelCoordinator>(func, this, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -888,22 +888,22 @@ void Wavelet::wavChanged (double nlevel)
|
||||
{
|
||||
if (!batchMode) {
|
||||
struct Data {
|
||||
Wavelet *me;
|
||||
Wavelet *self;
|
||||
double nlevel;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(data);
|
||||
Wavelet *me = d->me;
|
||||
me->wavLabels->set_text(
|
||||
Glib::ustring::compose(M("TP_WAVELET_LEVLABEL"),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), d->nlevel))
|
||||
);
|
||||
delete d;
|
||||
return FALSE;
|
||||
};
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
Wavelet* self = data->self;
|
||||
self->wavLabels->set_text(
|
||||
Glib::ustring::compose(M("TP_WAVELET_LEVLABEL"),
|
||||
Glib::ustring::format(std::fixed, std::setprecision(0), data->nlevel))
|
||||
);
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data { this, nlevel });
|
||||
idle_register.add<Data>(func, new Data{this, nlevel}, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,7 +695,7 @@ void WhiteBalance::read (const ProcParams* pp, const ParamsEdited* pedited)
|
||||
}
|
||||
|
||||
green->setLogScale(10, green->getValue(), true);
|
||||
|
||||
|
||||
methconn.block (false);
|
||||
enableListener ();
|
||||
}
|
||||
@ -915,22 +915,23 @@ void WhiteBalance::WBChanged(double temperature, double greenVal)
|
||||
double green_val;
|
||||
};
|
||||
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
WhiteBalance* const self = static_cast<WhiteBalance*>(static_cast<Data*>(data)->self);
|
||||
const double temperature = static_cast<Data*>(data)->temperature;
|
||||
const double green_val = static_cast<Data*>(data)->green_val;
|
||||
delete static_cast<Data*>(data);
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
WhiteBalance* const self = static_cast<WhiteBalance*>(data->self);
|
||||
const double temperature = data->temperature;
|
||||
const double green_val = data->green_val;
|
||||
|
||||
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();
|
||||
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;
|
||||
};
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add(func, new Data{this, temperature, greenVal});
|
||||
idle_register.add<Data>(func, new Data{this, temperature, greenVal}, true);
|
||||
}
|
||||
|
@ -255,18 +255,19 @@ void XTransProcess::checkBoxToggled (CheckBox* c, CheckValue newval)
|
||||
void XTransProcess::autoContrastChanged (double autoContrast)
|
||||
{
|
||||
struct Data {
|
||||
XTransProcess *me;
|
||||
XTransProcess* self;
|
||||
double autoContrast;
|
||||
};
|
||||
const auto func = [](gpointer data) -> gboolean {
|
||||
Data *d = static_cast<Data *>(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 });
|
||||
const auto func =
|
||||
[](Data* data) -> bool
|
||||
{
|
||||
XTransProcess* self = data->self;
|
||||
self->disableListener();
|
||||
self->dualDemosaicContrast->setValue(data->autoContrast);
|
||||
self->enableListener();
|
||||
return false;
|
||||
};
|
||||
|
||||
idle_register.add<Data>(func, new Data{this, autoContrast}, true);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user