Review idle_register.add() calls: wavelets, ciecam02, colortoning

This commit is contained in:
heckflosse 2018-10-24 17:12:11 +02:00
parent eee6837385
commit ccc882dbcf
8 changed files with 75 additions and 124 deletions

View File

@ -611,7 +611,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
if (actListener && params.colorToning.enabled) {
if (params.blackwhite.enabled && params.colorToning.autosat) {
actListener->autoColorTonChanged(0, satTH, satPR); //hide sliders only if autosat
actListener->autoColorTonChanged(satTH, satPR); //hide sliders only if autosat
indi = 0;
} else {
if (params.colorToning.autosat) {
@ -656,7 +656,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, bool panningRelatedChange)
printf("ImProcCoordinator / Auto CT: indi=%d satH=%d satPR=%d\n", indi, (int)colourToningSatLimit, (int) colourToningSatLimitOpacity);
}
actListener->autoColorTonChanged(indi, (int) colourToningSatLimit, (int)colourToningSatLimitOpacity); //change sliders autosat
actListener->autoColorTonChanged((int) colourToningSatLimit, (int)colourToningSatLimitOpacity); //change sliders autosat
}
// correct GUI black and white with value

View File

@ -347,7 +347,7 @@ class AutoColorTonListener
{
public:
virtual ~AutoColorTonListener() = default;
virtual void autoColorTonChanged(int bwct, int satthres, int satprot) = 0;
virtual void autoColorTonChanged(int satthres, int satprot) = 0;
};
class AutoBWListener

View File

@ -1451,75 +1451,64 @@ void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdit
void ColorAppearance::autoCamChanged (double ccam, double ccamout)
{
nextCcam = ccam;
nextCcamout = ccamout;
struct Data {
ColorAppearance *me;
double ccam;
double ccamout;
};
const auto func = [] (gpointer data) -> gboolean {
static_cast<ColorAppearance*> (data)->autoCamComputed_();
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;
};
idle_register.add (func, this);
}
bool ColorAppearance::autoCamComputed_ ()
{
disableListener ();
// degree->setEnabled (true);
degree->setValue (nextCcam);
degreeout->setValue (nextCcamout);
enableListener ();
return false;
idle_register.add(func, new Data { this, ccam, ccamout });
}
void ColorAppearance::adapCamChanged (double cadap)
{
nextCadap = cadap;
struct Data {
ColorAppearance *me;
double cadap;
};
const auto func = [] (gpointer data) -> gboolean {
static_cast<ColorAppearance*> (data)->adapCamComputed_();
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;
};
idle_register.add (func, this);
}
bool ColorAppearance::adapCamComputed_ ()
{
disableListener ();
// degree->setEnabled (true);
adapscen->setValue (nextCadap);
// ybscen->setValue (nextYbscn);
enableListener ();
return false;
idle_register.add(func, new Data { this, cadap });
}
void ColorAppearance::ybCamChanged (int ybsc)
{
nextYbscn = ybsc;
struct Data {
ColorAppearance *me;
int ybsc;
};
const auto func = [] (gpointer data) -> gboolean {
static_cast<ColorAppearance*> (data)->ybCamComputed_();
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;
};
idle_register.add (func, this);
}
bool ColorAppearance::ybCamComputed_ ()
{
disableListener ();
// degree->setEnabled (true);
// adapscen->setValue (nextCadap);
ybscen->setValue (nextYbscn);
enableListener ();
return false;
idle_register.add(func, new Data { this, ybsc });
}
void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller)

View File

@ -59,11 +59,8 @@ public:
void tonecie_toggled ();
// void sharpcie_toggled ();
void autoCamChanged (double ccam, double ccamout);
bool autoCamComputed_ ();
void adapCamChanged (double cadap);
bool adapCamComputed_ ();
void ybCamChanged (int yb);
bool ybCamComputed_ ();
void curveChanged (CurveEditor* ce);
void curveMode1Changed ();
@ -160,8 +157,6 @@ private:
DiagonalCurveEditor* shape;
DiagonalCurveEditor* shape2;
DiagonalCurveEditor* shape3;
double nextCcam, nextCcamout, nextCadap;
int nextYbscn;
bool lastAutoDegree;
bool lastAutoAdapscen;
bool lastAutoDegreeout;

View File

@ -13,7 +13,6 @@ using namespace rtengine::procparams;
ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLORTONING_LABEL"), false, true)
{
nextbw = 0;
CurveListener::setMulti(true);
//---------------method
@ -688,40 +687,26 @@ void ColorToning::setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool
}
void ColorToning::autoColorTonChanged(int bwct, int satthres, int satprot)
void ColorToning::autoColorTonChanged(int satthres, int satprot)
{
nextbw = bwct;
nextsatth = satthres;
nextsatpr = satprot;
struct Data {
ColorToning *me;
int satthres;
int satprot;
};
const auto func = [](gpointer data) -> gboolean {
static_cast<ColorToning*>(data)->CTComp_();
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, this);
}
bool ColorToning::CTComp_ ()
{
disableListener ();
saturatedOpacity->setValue (nextsatpr);
satProtectionThreshold->setValue (nextsatth);
/* if(nextbw==1) {
saturatedOpacity->show();
satProtectionThreshold->show();
autosat->show();
}
else {
saturatedOpacity->hide();
satProtectionThreshold->hide();
autosat->hide();
}
*/
enableListener ();
return false;
idle_register.add(func, new Data { this, satthres, satprot });
}
void ColorToning::adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop)

View File

@ -36,8 +36,7 @@ public:
void setAdjusterBehavior (bool splitAdd, bool satThresholdAdd, bool satOpacityAdd, bool strprotectAdd, bool balanceAdd);
void neutral_pressed ();
//void neutralCurves_pressed ();
void autoColorTonChanged (int bwct, int satthres, int satprot);
bool CTComp_ ();
void autoColorTonChanged (int satthres, int satprot);
void adjusterChanged(ThresholdAdjuster* a, double newBottom, double newTop);
void adjusterChanged(ThresholdAdjuster* a, double newBottomLeft, double newTopLeft, double newBottomRight, double newTopRight);
@ -99,9 +98,6 @@ private:
Gtk::Button* neutral;
Gtk::HBox* neutrHBox;
int nextbw;
int nextsatth;
int nextsatpr;
Glib::ustring nextbalcolor;
Glib::ustring balcolor;
sigc::connection neutralconn, twocconn; //, neutralcurvesconn;

View File

@ -144,7 +144,6 @@ Wavelet::Wavelet() :
neutrHBox(Gtk::manage(new Gtk::HBox()))
{
CurveListener::setMulti(true);
nextnlevel = 7.;
expsettings->signal_button_release_event().connect_notify( sigc::bind( sigc::mem_fun(this, &Wavelet::foldAllButMe), expsettings) );
@ -886,36 +885,25 @@ Wavelet::~Wavelet ()
}
void Wavelet::wavChanged (double nlevel)
{
nextnlevel = nlevel;
const auto func = [](gpointer data) -> gboolean {
GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected
static_cast<Wavelet*>(data)->wavComputed_();
return FALSE;
};
idle_register.add(func, this);
}
bool Wavelet::wavComputed_ ()
{
disableListener ();
enableListener ();
updatewavLabel ();
return false;
}
void Wavelet::updatewavLabel ()
{
if (!batchMode) {
float lv;
lv = nextnlevel;
wavLabels->set_text(
struct Data {
Wavelet *me;
double nlevel;
};
const auto func = [](gpointer data) -> gboolean {
Data *d = static_cast<Data *>(data);
Wavelet *me = d->me;
me->wavLabels->set_text(
Glib::ustring::compose(M("TP_WAVELET_LEVLABEL"),
Glib::ustring::format(std::fixed, std::setprecision(0), lv))
);
Glib::ustring::format(std::fixed, std::setprecision(0), d->nlevel))
);
delete d;
return FALSE;
};
idle_register.add(func, new Data { this, nlevel });
}
}

View File

@ -93,7 +93,6 @@ private:
void neutral_pressed ();
void neutralchPressed ();
void tmrToggled ();
void updatewavLabel ();
void wavChanged (double nlevel);
void HSmethodUpdateUI();
@ -252,7 +251,6 @@ private:
sigc::connection neutralchPressedConn;
bool lastmedian, lastmedianlev, lastlinkedg, lastavoid, lastlipst, lasttmr, lastcbenab;
int nextnlevel;
IdleRegister idle_register;
};