Convert almost all IdleRegister::add() calls to add(std::function<>)

This commit is contained in:
Flössie
2019-01-01 15:53:39 +01:00
parent 5af3f64a9d
commit b08fb04dae
22 changed files with 574 additions and 610 deletions

View File

@@ -832,41 +832,6 @@ void ToneCurve::enableAll ()
histmatching->set_sensitive(true);
}
bool ToneCurve::autoExpComputed_ ()
{
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected
disableListener ();
enableAll ();
expcomp->setValue (nextExpcomp);
brightness->setValue (nextBrightness);
contrast->setValue (nextContrast);
black->setValue (nextBlack);
hlcompr->setValue (nextHlcompr);
hlcomprthresh->setValue (nextHlcomprthresh);
enaconn.block (true);
hrenabled->set_active (nextHLRecons);
enaconn.block (false);
if (nextHLRecons) {
hlrbox->show();
} else if (!batchMode) {
hlrbox->hide();
}
if (!black->getAddMode() && !batchMode) {
shcompr->set_sensitive(!((int)black->getValue () == 0)); //at black=0 shcompr value has no effect
}
if (!hlcompr->getAddMode() && !batchMode) {
hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect
}
enableListener ();
return false;
}
void ToneCurve::setBatchMode (bool batchMode)
{
ToolPanel::setBatchMode (batchMode);
@@ -967,42 +932,6 @@ void ToneCurve::histmatchingToggled()
}
}
bool ToneCurve::histmatchingComputed()
{
GThreadLock lock;
disableListener();
enableAll();
brightness->setValue(0);
contrast->setValue(0);
black->setValue(0);
if (!black->getAddMode() && !batchMode) {
shcompr->set_sensitive(!((int)black->getValue() == 0));
}
if (!hlcompr->getAddMode() && !batchMode) {
hlcomprthresh->set_sensitive(!((int)hlcompr->getValue () == 0)); //at hlcompr=0 hlcomprthresh value has no effect
}
if (autolevels->get_active() ) {
expcomp->setValue(0);
autoconn.block(true);
autolevels->set_active(false);
autoconn.block(false);
autolevels->set_inconsistent(false);
}
toneCurveMode->set_active(rtengine::toUnderlying(nextToneCurveMode));
shape->setCurve(nextToneCurve);
shape2->setCurve({ DCT_Linear });
shape->openIfNonlinear();
enableListener();
fromHistMatching = true;
return false;
}
void ToneCurve::autoExpChanged(double expcomp, int bright, int contr, int black, int hlcompr, int hlcomprthresh, bool hlrecons)
{
nextBlack = black;
@@ -1013,14 +942,41 @@ void ToneCurve::autoExpChanged(double expcomp, int bright, int contr, int black,
nextHlcomprthresh = hlcomprthresh;
nextHLRecons = hlrecons;
const auto func =
[](ToneCurve* self) -> bool
idle_register.add(
[this]() -> bool
{
self->autoExpComputed_();
return false;
};
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected
// FIXME: We don't need the GThreadLock, don't we?
disableListener();
enableAll();
this->expcomp->setValue(nextExpcomp);
brightness->setValue(nextBrightness);
contrast->setValue(nextContrast);
this->black->setValue(nextBlack);
this->hlcompr->setValue(nextHlcompr);
this->hlcomprthresh->setValue(nextHlcomprthresh);
enaconn.block(true);
hrenabled->set_active(nextHLRecons);
enaconn.block(false);
idle_register.add<ToneCurve>(func, this, false);
if (nextHLRecons) {
hlrbox->show();
} else if (!batchMode) {
hlrbox->hide();
}
if (!this->black->getAddMode() && !batchMode) {
shcompr->set_sensitive(static_cast<int>(this->black->getValue())); //at black=0 shcompr value has no effect
}
if (!this->hlcompr->getAddMode() && !batchMode) {
this->hlcomprthresh->set_sensitive(static_cast<int>(this->hlcompr->getValue())); //at hlcompr=0 hlcomprthresh value has no effect
}
enableListener();
return false;
}
);
}
void ToneCurve::autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParams::TcMode curveMode, const std::vector<double>& curve)
@@ -1028,12 +984,41 @@ void ToneCurve::autoMatchedToneCurveChanged(rtengine::procparams::ToneCurveParam
nextToneCurveMode = curveMode;
nextToneCurve = curve;
const auto func =
[](ToneCurve* self) -> bool
idle_register.add(
[this]() -> bool
{
self->histmatchingComputed();
return false;
};
GThreadLock lock; // FIXME: Obsolete
disableListener();
enableAll();
brightness->setValue(0);
contrast->setValue(0);
black->setValue(0);
idle_register.add<ToneCurve>(func, this, false);
if (!black->getAddMode() && !batchMode) {
shcompr->set_sensitive(static_cast<int>(black->getValue()));
}
if (!hlcompr->getAddMode() && !batchMode) {
hlcomprthresh->set_sensitive(static_cast<int>(hlcompr->getValue())); //at hlcompr=0 hlcomprthresh value has no effect
}
if (autolevels->get_active() ) {
expcomp->setValue(0);
autoconn.block(true);
autolevels->set_active(false);
autoconn.block(false);
autolevels->set_inconsistent(false);
}
toneCurveMode->set_active(rtengine::toUnderlying(nextToneCurveMode));
shape->setCurve(nextToneCurve);
shape2->setCurve({DCT_Linear});
shape->openIfNonlinear();
enableListener();
fromHistMatching = true;
return false;
}
);
}