Replace all add_idle()s with IdleRegister

This commit is contained in:
Flössie 2017-02-10 21:22:42 +01:00
parent 824ecaed41
commit 79ff7f5997
21 changed files with 691 additions and 637 deletions

View File

@ -85,6 +85,8 @@ BatchQueue::BatchQueue (FileCatalog* aFileCatalog) : processing(nullptr), fileCa
BatchQueue::~BatchQueue () BatchQueue::~BatchQueue ()
{ {
idle_register.destroy();
MYWRITERLOCK(l, entryRW); MYWRITERLOCK(l, entryRW);
// The listener merges parameters with old values, so delete afterwards // The listener merges parameters with old values, so delete afterwards
@ -937,7 +939,7 @@ void BatchQueue::notifyListener (bool queueEmptied)
} }
params->queueEmptied = queueEmptied; params->queueEmptied = queueEmptied;
params->queueError = false; params->queueError = false;
add_idle (bqnotifylistenerUI, params); idle_register.add(bqnotifylistenerUI, params);
} }
} }
@ -967,6 +969,6 @@ void BatchQueue::error (Glib::ustring msg)
params->queueEmptied = false; params->queueEmptied = false;
params->queueError = true; params->queueError = true;
params->queueErrorMessage = msg; params->queueErrorMessage = msg;
add_idle (bqnotifylistenerUI, params); idle_register.add(bqnotifylistenerUI, params);
} }
} }

View File

@ -36,37 +36,12 @@ public:
}; };
class FileCatalog; class FileCatalog;
class BatchQueue : public ThumbBrowserBase,
class BatchQueue final :
public ThumbBrowserBase,
public rtengine::BatchProcessingListener, public rtengine::BatchProcessingListener,
public LWButtonListener public LWButtonListener
{ {
protected:
int getMaxThumbnailHeight() const;
void saveThumbnailHeight (int height);
int getThumbnailHeight ();
BatchQueueEntry* processing; // holds the currently processed image
FileCatalog* fileCatalog;
int sequence; // holds the current sequence index
Glib::ustring nameTemplate;
MyImageMenuItem* cancel;
MyImageMenuItem* head;
MyImageMenuItem* tail;
Gtk::MenuItem* selall;
Gtk::MenuItem* open;
Glib::RefPtr<Gtk::AccelGroup> pmaccelgroup;
Gtk::Menu pmenu;
BatchQueueListener* listener;
Glib::ustring autoCompleteFileName (const Glib::ustring& fileName, const Glib::ustring& format);
Glib::ustring getTempFilenameForParams( const Glib::ustring &filename );
bool saveBatchQueue ();
void notifyListener (bool queueEmptied);
public: public:
explicit BatchQueue (FileCatalog* aFileCatalog); explicit BatchQueue (FileCatalog* aFileCatalog);
~BatchQueue (); ~BatchQueue ();
@ -106,6 +81,34 @@ public:
static Glib::ustring calcAutoFileNameBase (const Glib::ustring& origFileName, int sequence = 0); static Glib::ustring calcAutoFileNameBase (const Glib::ustring& origFileName, int sequence = 0);
static int calcMaxThumbnailHeight(); static int calcMaxThumbnailHeight();
protected:
int getMaxThumbnailHeight() const;
void saveThumbnailHeight (int height);
int getThumbnailHeight ();
Glib::ustring autoCompleteFileName (const Glib::ustring& fileName, const Glib::ustring& format);
Glib::ustring getTempFilenameForParams( const Glib::ustring &filename );
bool saveBatchQueue ();
void notifyListener (bool queueEmptied);
BatchQueueEntry* processing; // holds the currently processed image
FileCatalog* fileCatalog;
int sequence; // holds the current sequence index
Glib::ustring nameTemplate;
MyImageMenuItem* cancel;
MyImageMenuItem* head;
MyImageMenuItem* tail;
Gtk::MenuItem* selall;
Gtk::MenuItem* open;
Glib::RefPtr<Gtk::AccelGroup> pmaccelgroup;
Gtk::Menu pmenu;
BatchQueueListener* listener;
IdleRegister idle_register;
}; };
#endif #endif

View File

@ -364,23 +364,25 @@ BlackWhite::BlackWhite (): FoldableToolPanel(this, "blackwhite", M("TP_BWMIX_LAB
} }
BlackWhite::~BlackWhite () BlackWhite::~BlackWhite ()
{ {
idle_register.destroy();
delete luminanceCEG; delete luminanceCEG;
delete beforeCurveCEG; delete beforeCurveCEG;
delete afterCurveCEG; delete afterCurveCEG;
} }
int BWChangedUI (void* data)
{
(static_cast<BlackWhite*>(data))->BWComputed_ ();
return 0;
}
void BlackWhite::BWChanged (double redbw, double greenbw, double bluebw) void BlackWhite::BWChanged (double redbw, double greenbw, double bluebw)
{ {
nextredbw = redbw; nextredbw = redbw;
nextgreenbw = greenbw; nextgreenbw = greenbw;
nextbluebw = bluebw; nextbluebw = bluebw;
add_idle (BWChangedUI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<BlackWhite*>(data)->BWComputed_();
return FALSE;
};
idle_register.add(func, this);
} }
bool BlackWhite::BWComputed_ () bool BlackWhite::BWComputed_ ()

View File

@ -28,10 +28,64 @@
#include "mycurve.h" #include "mycurve.h"
#include "colorprovider.h" #include "colorprovider.h"
class BlackWhite : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::AutoBWListener, public CurveListener, public ColorProvider class BlackWhite final :
public ToolParamBlock,
public AdjusterListener,
public FoldableToolPanel,
public rtengine::AutoBWListener,
public CurveListener,
public ColorProvider
{ {
public:
BlackWhite ();
~BlackWhite ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void autoOpenCurve ();
void setEditProvider (EditDataProvider *provider);
void autoch_toggled ();
void neutral_pressed ();
void updateRGBLabel ();
void adjusterChanged (Adjuster* a, double newval);
void setAdjusterBehavior (bool bwadd, bool bwgadd);
void trimValues (rtengine::procparams::ProcParams* pp);
void enabledcc_toggled ();
void enabledChanged ();
void methodChanged ();
void filterChanged ();
void settingChanged ();
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
void BWChanged (double redbw, double greenbw, double bluebw);
bool BWComputed_ ();
void curveChanged (CurveEditor* ce);
void curveMode1Changed ();
bool curveMode1Changed_ ();
void curveMode1Changed2 ();
bool curveMode1Changed2_ ();
void algoChanged ();
Glib::ustring getSettingString ();
Glib::ustring getFilterString ();
Glib::ustring getalgoString ();
private:
void showLuminance();
void hideLuminance();
void showFilter();
void hideFilter();
void showEnabledCC();
void hideEnabledCC();
void showMixer(int nChannels, bool RGBIsSensitive = true);
void hideMixer();
void showGamma();
void hideGamma();
protected:
FlatCurveEditor* luminanceCurve; FlatCurveEditor* luminanceCurve;
Gtk::HSeparator* luminanceSep; Gtk::HSeparator* luminanceSep;
CurveEditorGroup* luminanceCEG; CurveEditorGroup* luminanceCEG;
@ -85,55 +139,7 @@ protected:
double nextgreenbw; double nextgreenbw;
double nextbluebw; double nextbluebw;
void showLuminance(); IdleRegister idle_register;
void hideLuminance();
void showFilter();
void hideFilter();
void showEnabledCC();
void hideEnabledCC();
void showMixer(int nChannels, bool RGBIsSensitive = true);
void hideMixer();
void showGamma();
void hideGamma();
public:
BlackWhite ();
~BlackWhite ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void autoOpenCurve ();
void setEditProvider (EditDataProvider *provider);
void autoch_toggled ();
void neutral_pressed ();
void updateRGBLabel ();
void adjusterChanged (Adjuster* a, double newval);
void setAdjusterBehavior (bool bwadd, bool bwgadd);
void trimValues (rtengine::procparams::ProcParams* pp);
void enabledcc_toggled ();
void enabledChanged ();
void methodChanged ();
void filterChanged ();
void settingChanged ();
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
void BWChanged (double redbw, double greenbw, double bluebw);
bool BWComputed_ ();
void curveChanged (CurveEditor* ce);
void curveMode1Changed ();
bool curveMode1Changed_ ();
void curveMode1Changed2 ();
bool curveMode1Changed2_ ();
void algoChanged ();
Glib::ustring getSettingString ();
Glib::ustring getFilterString ();
Glib::ustring getalgoString ();
}; };
#endif #endif

View File

@ -19,6 +19,7 @@
#include "cachemanager.h" #include "cachemanager.h"
#include <memory> #include <memory>
#include <iostream>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include <giomm.h> #include <giomm.h>

View File

@ -424,6 +424,8 @@ ColorAppearance::ColorAppearance () : FoldableToolPanel(this, "colorappearance",
ColorAppearance::~ColorAppearance () ColorAppearance::~ColorAppearance ()
{ {
idle_register.destroy();
delete curveEditorG; delete curveEditorG;
delete curveEditorG2; delete curveEditorG2;
delete curveEditorG3; delete curveEditorG3;
@ -1002,15 +1004,17 @@ void ColorAppearance::setDefaults (const ProcParams* defParams, const ParamsEdit
} }
} }
int autoCamChangedUI (void* data)
{
(static_cast<ColorAppearance*>(data))->autoCamComputed_ ();
return 0;
}
void ColorAppearance::autoCamChanged (double ccam) void ColorAppearance::autoCamChanged (double ccam)
{ {
nextCcam = ccam; nextCcam = ccam;
add_idle (autoCamChangedUI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<ColorAppearance*>(data)->autoCamComputed_();
return FALSE;
};
idle_register.add(func, this);
} }
bool ColorAppearance::autoCamComputed_ () bool ColorAppearance::autoCamComputed_ ()
@ -1023,15 +1027,17 @@ bool ColorAppearance::autoCamComputed_ ()
return false; return false;
} }
int adapCamChangedUI (void* data)
{
(static_cast<ColorAppearance*>(data))->adapCamComputed_ ();
return 0;
}
void ColorAppearance::adapCamChanged (double cadap) void ColorAppearance::adapCamChanged (double cadap)
{ {
nextCadap = cadap; nextCadap = cadap;
add_idle (adapCamChangedUI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<ColorAppearance*>(data)->adapCamComputed_();
return FALSE;
};
idle_register.add(func, this);
} }
bool ColorAppearance::adapCamComputed_ () bool ColorAppearance::adapCamComputed_ ()

View File

@ -28,10 +28,61 @@
#include "guiutils.h" #include "guiutils.h"
#include "colorprovider.h" #include "colorprovider.h"
class ColorAppearance : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::AutoCamListener, public CurveListener, public ColorProvider class ColorAppearance final :
public ToolParamBlock,
public AdjusterListener,
public FoldableToolPanel,
public rtengine::AutoCamListener,
public CurveListener,
public ColorProvider
{ {
public:
ColorAppearance ();
~ColorAppearance ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void adjusterChanged (Adjuster* a, double newval);
void adjusterAutoToggled (Adjuster* a, bool newval);
// void adjusterAdapToggled (Adjuster* a, bool newval);
void enabledChanged ();
void surroundChanged ();
void wbmodelChanged ();
void algoChanged ();
void surrsource_toggled ();
void gamut_toggled ();
// void badpix_toggled ();
void datacie_toggled ();
void tonecie_toggled ();
// void sharpcie_toggled ();
void autoCamChanged (double ccam);
bool autoCamComputed_ ();
void adapCamChanged (double cadap);
bool adapCamComputed_ ();
void curveChanged (CurveEditor* ce);
void curveMode1Changed ();
bool curveMode1Changed_ ();
void curveMode2Changed ();
bool curveMode2Changed_ ();
void curveMode3Changed ();
bool curveMode3Changed_ ();
void expandCurve (bool isExpanded);
bool isCurveExpanded ();
void autoOpenCurve ();
void setAdjusterBehavior (bool degreeadd, bool adapscenadd, bool adaplumadd, bool badpixsladd, bool jlightadd, bool chromaadd, bool contrastadd, bool rstprotectionadd, bool qbrightadd, bool qcontrastadd, bool schromaadd, bool mchromaadd, bool colorhadd);
void trimValues (rtengine::procparams::ProcParams* pp);
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve,/* LUTu & histCLurve, LUTu & histLLCurve,*/ LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma, LUTu & histLRETI);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller);
private:
bool bgTTipQuery(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
bool srTTipQuery(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
protected:
Glib::RefPtr<Gtk::Tooltip> bgTTips; Glib::RefPtr<Gtk::Tooltip> bgTTips;
Glib::RefPtr<Gtk::Tooltip> srTTips; Glib::RefPtr<Gtk::Tooltip> srTTips;
Glib::RefPtr<Gdk::Pixbuf> bgPixbuf; Glib::RefPtr<Gdk::Pixbuf> bgPixbuf;
@ -83,56 +134,10 @@ protected:
bool lastAutoAdapscen; bool lastAutoAdapscen;
bool lastsurr; bool lastsurr;
bool lastgamut; bool lastgamut;
// bool lastbadpix;
bool lastdatacie; bool lastdatacie;
bool lasttonecie; bool lasttonecie;
// bool lastsharpcie;
bool bgTTipQuery(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
bool srTTipQuery(int x, int y, bool keyboard_tooltip, const Glib::RefPtr<Gtk::Tooltip>& tooltip);
public: IdleRegister idle_register;
ColorAppearance ();
~ColorAppearance ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void adjusterChanged (Adjuster* a, double newval);
void adjusterAutoToggled (Adjuster* a, bool newval);
// void adjusterAdapToggled (Adjuster* a, bool newval);
void enabledChanged ();
void surroundChanged ();
void wbmodelChanged ();
void algoChanged ();
void surrsource_toggled ();
void gamut_toggled ();
// void badpix_toggled ();
void datacie_toggled ();
void tonecie_toggled ();
// void sharpcie_toggled ();
void autoCamChanged (double ccam);
bool autoCamComputed_ ();
void adapCamChanged (double cadap);
bool adapCamComputed_ ();
void curveChanged (CurveEditor* ce);
void curveMode1Changed ();
bool curveMode1Changed_ ();
void curveMode2Changed ();
bool curveMode2Changed_ ();
void curveMode3Changed ();
bool curveMode3Changed_ ();
void expandCurve (bool isExpanded);
bool isCurveExpanded ();
void autoOpenCurve ();
void setAdjusterBehavior (bool degreeadd, bool adapscenadd, bool adaplumadd, bool badpixsladd, bool jlightadd, bool chromaadd, bool contrastadd, bool rstprotectionadd, bool qbrightadd, bool qcontrastadd, bool schromaadd, bool mchromaadd, bool colorhadd);
void trimValues (rtengine::procparams::ProcParams* pp);
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve,/* LUTu & histCLurve, LUTu & histLLCurve,*/ LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma, LUTu & histLRETI);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller);
}; };
#endif #endif

View File

@ -324,6 +324,8 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
ColorToning::~ColorToning() ColorToning::~ColorToning()
{ {
idle_register.destroy();
delete colorCurveEditorG; delete colorCurveEditorG;
delete opacityCurveEditorG; delete opacityCurveEditorG;
delete clCurveEditorG; delete clCurveEditorG;
@ -650,19 +652,18 @@ void ColorToning::adjusterChanged (ThresholdAdjuster* a, double newBottom, doubl
Glib::ustring::compose(Glib::ustring(M("TP_COLORTONING_HUE") + ": %1" + "\n" + M("TP_COLORTONING_STRENGTH") + ": %2"), int(newTop), int(newBottom))); Glib::ustring::compose(Glib::ustring(M("TP_COLORTONING_HUE") + ": %1" + "\n" + M("TP_COLORTONING_STRENGTH") + ": %2"), int(newTop), int(newBottom)));
} }
int CTChanged_UI (void* data)
{
(static_cast<ColorToning*>(data))->CTComp_ ();
return 0;
}
void ColorToning::autoColorTonChanged(int bwct, int satthres, int satprot) void ColorToning::autoColorTonChanged(int bwct, int satthres, int satprot)
{ {
nextbw = bwct; nextbw = bwct;
nextsatth = satthres; nextsatth = satthres;
nextsatpr = satprot; nextsatpr = satprot;
add_idle (CTChanged_UI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<ColorToning*>(data)->CTComp_();
return FALSE;
};
idle_register.add(func, this);
} }
bool ColorToning::CTComp_ () bool ColorToning::CTComp_ ()

View File

@ -13,12 +13,43 @@
#include "thresholdadjuster.h" #include "thresholdadjuster.h"
#include "colorprovider.h" #include "colorprovider.h"
class ColorToning : public ToolParamBlock, public FoldableToolPanel, public rtengine::AutoColorTonListener, public CurveListener, public ColorProvider, class ColorToning final :
public ThresholdAdjusterListener, public AdjusterListener public ToolParamBlock,
public FoldableToolPanel,
public rtengine::AutoColorTonListener,
public CurveListener,
public ColorProvider,
public ThresholdAdjusterListener,
public AdjusterListener
{ {
public:
ColorToning ();
~ColorToning();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void trimValues (rtengine::procparams::ProcParams* pp);
void adjusterChanged (Adjuster* a, double newval);
void adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop);
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_ ();
protected: void enabledChanged ();
//Gtk::HSeparator* splitSep; void curveChanged (CurveEditor* ce);
void autosatChanged ();
void autoOpenCurve ();
void methodChanged ();
void twocolorChanged (bool changedbymethod);
void twoColorChangedByGui ();
void lumamodeChanged ();
void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
private:
Gtk::HSeparator* satLimiterSep; Gtk::HSeparator* satLimiterSep;
Gtk::HSeparator* colorSep; Gtk::HSeparator* colorSep;
CurveEditorGroup* colorCurveEditorG; CurveEditorGroup* colorCurveEditorG;
@ -57,7 +88,6 @@ protected:
Gtk::Image* irg; Gtk::Image* irg;
Gtk::Button* neutral; Gtk::Button* neutral;
//Gtk::Button* neutralCurves;
Gtk::HBox* neutrHBox; Gtk::HBox* neutrHBox;
Gtk::HBox* chromaHbox; Gtk::HBox* chromaHbox;
Gtk::Label* chroLabel; Gtk::Label* chroLabel;
@ -75,32 +105,7 @@ protected:
bool lastLumamode; bool lastLumamode;
sigc::connection lumamodeConn; sigc::connection lumamodeConn;
public: IdleRegister idle_register;
ColorToning ();
~ColorToning();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void trimValues (rtengine::procparams::ProcParams* pp);
void adjusterChanged (Adjuster* a, double newval);
void adjusterChanged (ThresholdAdjuster* a, double newBottom, double newTop);
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 enabledChanged ();
void curveChanged (CurveEditor* ce);
void autosatChanged ();
void autoOpenCurve ();
void methodChanged ();
void twocolorChanged (bool changedbymethod);
void twoColorChangedByGui ();
void lumamodeChanged ();
void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
}; };
#endif #endif

View File

@ -25,6 +25,9 @@ using namespace rtengine::procparams;
extern Options options; extern Options options;
namespace
{
class RefreshSpinHelper class RefreshSpinHelper
{ {
@ -35,6 +38,22 @@ public:
: crop(_crop), notify(_notify) {} : crop(_crop), notify(_notify) {}
}; };
int refreshSpinsUI (void* data)
{
RefreshSpinHelper* rsh = static_cast<RefreshSpinHelper*>(data);
rsh->crop->refreshSpins (rsh->notify);
delete rsh;
return 0;
}
int notifyListenerUI (void* data)
{
static_cast<Crop*>(data)->notifyListener();
return 0;
}
}
Crop::Crop (): FoldableToolPanel(this, "crop", M("TP_CROP_LABEL"), false, true) Crop::Crop (): FoldableToolPanel(this, "crop", M("TP_CROP_LABEL"), false, true)
{ {
@ -252,6 +271,11 @@ Crop::Crop (): FoldableToolPanel(this, "crop", M("TP_CROP_LABEL"), false, true)
show_all (); show_all ();
} }
Crop::~Crop()
{
idle_register.destroy();
}
void Crop::writeOptions () void Crop::writeOptions ()
{ {
@ -508,32 +532,18 @@ void Crop::enabledChanged ()
} }
} }
int notifyListenerUI (void* data)
{
(static_cast<Crop*>(data))->notifyListener ();
return 0;
}
int refreshSpinsUI (void* data)
{
RefreshSpinHelper* rsh = static_cast<RefreshSpinHelper*>(data);
rsh->crop->refreshSpins (rsh->notify);
delete rsh;
return 0;
}
void Crop::hFlipCrop () void Crop::hFlipCrop ()
{ {
nx = maxw - nx - nw; nx = maxw - nx - nw;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::vFlipCrop () void Crop::vFlipCrop ()
{ {
ny = maxh - ny - nh; ny = maxh - ny - nh;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::rotateCrop (int deg, bool hflip, bool vflip) void Crop::rotateCrop (int deg, bool hflip, bool vflip)
@ -573,7 +583,7 @@ void Crop::rotateCrop (int deg, bool hflip, bool vflip)
} }
lastRotationDeg = deg; lastRotationDeg = deg;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::positionChanged () void Crop::positionChanged ()
@ -587,7 +597,7 @@ void Crop::positionChanged ()
int W = nw; int W = nw;
int H = nh; int H = nh;
cropMoved (X, Y, W, H); cropMoved (X, Y, W, H);
add_idle (notifyListenerUI, this); idle_register.add(notifyListenerUI, this);
} }
void Crop::widthChanged () void Crop::widthChanged ()
@ -600,7 +610,7 @@ void Crop::widthChanged ()
int W = (int)w->get_value (); int W = (int)w->get_value ();
int H = nh; int H = nh;
cropWidth2Resized (X, Y, W, H); cropWidth2Resized (X, Y, W, H);
add_idle (notifyListenerUI, this); idle_register.add(notifyListenerUI, this);
} }
void Crop::heightChanged () void Crop::heightChanged ()
@ -613,7 +623,7 @@ void Crop::heightChanged ()
int W = nw; int W = nw;
int H = (int)h->get_value (); int H = (int)h->get_value ();
cropHeight2Resized (X, Y, W, H); cropHeight2Resized (X, Y, W, H);
add_idle (notifyListenerUI, this); idle_register.add(notifyListenerUI, this);
} }
// Fixed ratio toggle button // Fixed ratio toggle button
@ -665,7 +675,7 @@ void Crop::adjustCropToRatio()
} }
// This will save the options // This will save the options
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, true)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, true));
} }
void Crop::refreshSize () void Crop::refreshSize ()
@ -737,28 +747,28 @@ void Crop::setDimensions (int mw, int mh)
refreshSize (); refreshSize ();
} }
struct setdimparams { void Crop::sizeChanged (int x, int y, int ow, int oh)
{
struct Params {
Crop* crop; Crop* crop;
int x; int x;
int y; int y;
}; };
int sizeChangedUI (void* data) Params* const params = new Params{
{ this,
setdimparams* params = static_cast<setdimparams*>(data); x,
y
};
const auto func = [](gpointer data) -> gboolean {
Params* const params = static_cast<Params*>(data);
params->crop->setDimensions(params->x, params->y); params->crop->setDimensions(params->x, params->y);
delete params; delete params;
return 0; return FALSE;
} };
void Crop::sizeChanged (int x, int y, int ow, int oh) idle_register.add(func, params);
{
setdimparams* params = new setdimparams;
params->x = x;
params->y = y;
params->crop = this;
add_idle (sizeChangedUI, params);
} }
bool Crop::refreshSpins (bool notify) bool Crop::refreshSpins (bool notify)
@ -822,7 +832,7 @@ void Crop::cropMoved (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
// Glib::signal_idle().connect (sigc::mem_fun(*this, &Crop::refreshSpins)); // Glib::signal_idle().connect (sigc::mem_fun(*this, &Crop::refreshSpins));
} }
@ -866,7 +876,7 @@ void Crop::cropWidth1Resized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H) void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H)
@ -906,7 +916,7 @@ void Crop::cropWidth2Resized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H) void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H)
@ -949,7 +959,7 @@ void Crop::cropHeight1Resized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H) void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H)
@ -989,7 +999,7 @@ void Crop::cropHeight2Resized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H) void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H)
@ -1031,7 +1041,7 @@ void Crop::cropTopLeftResized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H) void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H)
@ -1071,7 +1081,7 @@ void Crop::cropTopRightResized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H) void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H)
@ -1111,7 +1121,7 @@ void Crop::cropBottomLeftResized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H) void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H)
@ -1148,7 +1158,7 @@ void Crop::cropBottomRightResized (int &X, int &Y, int &W, int &H)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropInit (int &x, int &y, int &w, int &h) void Crop::cropInit (int &x, int &y, int &w, int &h)
@ -1266,13 +1276,12 @@ void Crop::cropResized (int &x, int &y, int& x2, int& y2)
nw = W; nw = W;
nh = H; nh = H;
add_idle (refreshSpinsUI, new RefreshSpinHelper (this, false)); idle_register.add(refreshSpinsUI, new RefreshSpinHelper(this, false));
} }
void Crop::cropManipReady () void Crop::cropManipReady ()
{ {
idle_register.add(notifyListenerUI, this);
add_idle (notifyListenerUI, this);
} }
double Crop::getRatio () double Crop::getRatio ()

View File

@ -33,44 +33,20 @@ public:
virtual void cropSelectRequested() = 0; virtual void cropSelectRequested() = 0;
}; };
class CropRatio struct CropRatio {
{
public:
Glib::ustring label; Glib::ustring label;
double value; double value;
}; };
class Crop : public ToolParamBlock, public CropGUIListener, public FoldableToolPanel, public rtengine::SizeListener class Crop final :
public ToolParamBlock,
public CropGUIListener,
public FoldableToolPanel,
public rtengine::SizeListener
{ {
protected:
Gtk::CheckButton* fixr;
MyComboBoxText* ratio;
MyComboBoxText* orientation;
MyComboBoxText* guide;
Gtk::Button* selectCrop;
CropPanelListener* clistener;
int opt;
MySpinButton* x;
MySpinButton* y;
MySpinButton* w;
MySpinButton* h;
MySpinButton* ppi;
Gtk::Label* sizecm;
Gtk::Label* sizein;
Gtk::VBox* ppibox;
Gtk::VBox* sizebox;
int maxw, maxh;
double nx, ny;
int nw, nh;
int lastRotationDeg;
sigc::connection xconn, yconn, wconn, hconn, fconn, rconn, oconn, gconn;
bool wDirty, hDirty, xDirty, yDirty, lastFixRatio;
void adjustCropToRatio();
std::vector<CropRatio> cropratio;
public: public:
Crop(); Crop();
~Crop();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr); void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr); void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
@ -116,6 +92,34 @@ public:
void hFlipCrop (); void hFlipCrop ();
void vFlipCrop (); void vFlipCrop ();
void rotateCrop (int deg, bool hflip, bool vflip); void rotateCrop (int deg, bool hflip, bool vflip);
private:
Gtk::CheckButton* fixr;
MyComboBoxText* ratio;
MyComboBoxText* orientation;
MyComboBoxText* guide;
Gtk::Button* selectCrop;
CropPanelListener* clistener;
int opt;
MySpinButton* x;
MySpinButton* y;
MySpinButton* w;
MySpinButton* h;
MySpinButton* ppi;
Gtk::Label* sizecm;
Gtk::Label* sizein;
Gtk::VBox* ppibox;
Gtk::VBox* sizebox;
int maxw, maxh;
double nx, ny;
int nw, nh;
int lastRotationDeg;
sigc::connection xconn, yconn, wconn, hconn, fconn, rconn, oconn, gconn;
bool wDirty, hDirty, xDirty, yDirty, lastFixRatio;
void adjustCropToRatio();
std::vector<CropRatio> cropratio;
IdleRegister idle_register;
}; };
#endif #endif

View File

@ -38,14 +38,15 @@ CropHandler::CropHandler ()
displayHandler(nullptr) displayHandler(nullptr)
{ {
chi = new CropHandlerIdleHelper; idle_helper = new IdleHelper;
chi->destroyed = false; idle_helper->destroyed = false;
chi->pending = 0; idle_helper->pending = 0;
chi->cropHandler = this; idle_helper->cropHandler = this;
} }
CropHandler::~CropHandler () CropHandler::~CropHandler ()
{ {
idle_register.destroy();
if (ipc) { if (ipc) {
ipc->delSizeListener (this); ipc->delSizeListener (this);
@ -61,10 +62,10 @@ CropHandler::~CropHandler ()
cimg.lock (); cimg.lock ();
if (chi->pending) { if (idle_helper->pending) {
chi->destroyed = true; idle_helper->destroyed = true;
} else { } else {
delete chi; delete idle_helper;
} }
cimg.unlock (); cimg.unlock ();
@ -292,22 +293,61 @@ void CropHandler::getPosition (int& x, int& y)
} }
int createpixbufs (void* data) void CropHandler::setDetailedCrop (IImage8* im, IImage8* imtrue, rtengine::procparams::ColorManagementParams cmp,
rtengine::procparams::CropParams cp, int ax, int ay, int aw, int ah, int askip)
{ {
CropHandlerIdleHelper* chi = static_cast<CropHandlerIdleHelper*>(data); if (!enabled) {
return;
}
if (chi->destroyed) { cimg.lock ();
if (chi->pending == 1) {
delete chi; cropParams = cp;
colorParams = cmp;
cropPixbuf.clear ();
if (cropimg) {
delete [] cropimg;
}
cropimg = nullptr;
if (cropimgtrue) {
delete [] cropimgtrue;
}
cropimgtrue = nullptr;
if (ax == cropX && ay == cropY && aw == cropW && ah == cropH && askip == (zoom >= 1000 ? 1 : zoom)) {
cropimg_width = im->getWidth ();
cropimg_height = im->getHeight ();
cropimg = new unsigned char [3 * cropimg_width * cropimg_height];
cropimgtrue = new unsigned char [3 * cropimg_width * cropimg_height];
memcpy (cropimg, im->getData(), 3 * cropimg_width * cropimg_height);
memcpy (cropimgtrue, imtrue->getData(), 3 * cropimg_width * cropimg_height);
cix = ax;
ciy = ay;
ciw = aw;
cih = ah;
cis = askip;
idle_helper->pending++;
const auto func = [](gpointer data) -> gboolean {
IdleHelper* const idle_helper = static_cast<IdleHelper*>(data);
if (idle_helper->destroyed) {
if (idle_helper->pending == 1) {
delete idle_helper;
} else { } else {
chi->pending--; idle_helper->pending--;
} }
return 0; return FALSE;
} }
CropHandler* ch = chi->cropHandler; CropHandler* ch = idle_helper->cropHandler;
ch->cimg.lock (); ch->cimg.lock ();
ch->cropPixbuf.clear (); ch->cropPixbuf.clear ();
@ -318,7 +358,7 @@ int createpixbufs (void* data)
delete [] ch->cropimgtrue; delete [] ch->cropimgtrue;
ch->cropimgtrue = nullptr; ch->cropimgtrue = nullptr;
ch->cimg.unlock (); ch->cimg.unlock ();
return 0; return FALSE;
} }
if (ch->cropimg) { if (ch->cropimg) {
@ -364,52 +404,12 @@ int createpixbufs (void* data)
} }
} }
chi->pending--; idle_helper->pending--;
return 0; return FALSE;
} };
void CropHandler::setDetailedCrop (IImage8* im, IImage8* imtrue, rtengine::procparams::ColorManagementParams cmp, idle_register.add(func, idle_helper);
rtengine::procparams::CropParams cp, int ax, int ay, int aw, int ah, int askip)
{
if (!enabled) {
return;
}
cimg.lock ();
cropParams = cp;
colorParams = cmp;
cropPixbuf.clear ();
if (cropimg) {
delete [] cropimg;
}
cropimg = nullptr;
if (cropimgtrue) {
delete [] cropimgtrue;
}
cropimgtrue = nullptr;
if (ax == cropX && ay == cropY && aw == cropW && ah == cropH && askip == (zoom >= 1000 ? 1 : zoom)) {
cropimg_width = im->getWidth ();
cropimg_height = im->getHeight ();
cropimg = new unsigned char [3 * cropimg_width * cropimg_height];
cropimgtrue = new unsigned char [3 * cropimg_width * cropimg_height];
memcpy (cropimg, im->getData(), 3 * cropimg_width * cropimg_height);
memcpy (cropimgtrue, imtrue->getData(), 3 * cropimg_width * cropimg_height);
cix = ax;
ciy = ay;
ciw = aw;
cih = ah;
cis = askip;
chi->pending++;
add_idle (createpixbufs, chi);
} }
cimg.unlock (); cimg.unlock ();

View File

@ -36,56 +36,15 @@ public:
virtual void setDisplayPosition (int x, int y) {} virtual void setDisplayPosition (int x, int y) {}
}; };
class CropHandler;
struct CropHandlerIdleHelper {
CropHandler* cropHandler;
bool destroyed;
int pending;
};
/** /**
* This class handle the displayed part of the image, ask for the initial data and process it so it can display it. * This class handle the displayed part of the image, ask for the initial data and process it so it can display it.
* Its position on the preview is handled not set by this class but by the CropHandlerListener (i.e. CropWindow) with which it works closely. * Its position on the preview is handled not set by this class but by the CropHandlerListener (i.e. CropWindow) with which it works closely.
*/ */
class CropHandler : public rtengine::DetailedCropListener, public rtengine::SizeListener class CropHandler final :
public rtengine::DetailedCropListener,
public rtengine::SizeListener
{ {
friend int createpixbufs (void* data);
protected:
int zoom; // scale factor (e.g. 5 if 1:5 scale) ; if 1:1 scale and bigger, factor is multiplied by 1000 (i.e. 1000 for 1:1 scale, 2000 for 2:1, etc...)
int ww, wh; // size of the crop's canvas on the screen ; might be bigger than the displayed image, but not smaller
int imx, imy, imw, imh; // this is a copy of the cropwindow's parameters
int cax, cay; // clamped crop anchor's coordinate, i.e. point of the image that coincide to the center of the display area, expressed in image coordinates; cannot be outside the image's bounds; but if cax==cay==-1, designate the center of the image
int cx, cy, cw, ch; // position and size of the requested crop ; position expressed in image coordinates, so cx and cy might be negative and cw and ch higher than the image's 1:1 size
int cropX, cropY, cropW, cropH; // cropPixbuf's displayed area (position and size), i.e. coordinates in 1:1 scale, i.e. cx, cy, cw & ch trimmed to the image's bounds
bool enabled;
unsigned char* cropimg;
unsigned char* cropimgtrue;
int cropimg_width, cropimg_height, cix, ciy, ciw, cih, cis;
bool initial;
bool isLowUpdatePriority;
rtengine::StagedImageProcessor* ipc;
rtengine::DetailedCrop* crop;
CropDisplayHandler* displayHandler;
CropHandlerIdleHelper* chi;
void compDim ();
public: public:
void update ();
rtengine::procparams::CropParams cropParams;
rtengine::procparams::ColorManagementParams colorParams;
Glib::RefPtr<Gdk::Pixbuf> cropPixbuf;
Glib::RefPtr<Gdk::Pixbuf> cropPixbuftrue;
MyMutex cimg;
CropHandler (); CropHandler ();
~CropHandler (); ~CropHandler ();
@ -127,6 +86,46 @@ public:
bool getWindow (int& cwx, int& cwy, int& cww, int& cwh, int& cskip); bool getWindow (int& cwx, int& cwy, int& cww, int& cwh, int& cskip);
// SizeListener interface // SizeListener interface
void sizeChanged (int w, int h, int ow, int oh); void sizeChanged (int w, int h, int ow, int oh);
void update ();
rtengine::procparams::CropParams cropParams;
rtengine::procparams::ColorManagementParams colorParams;
Glib::RefPtr<Gdk::Pixbuf> cropPixbuf;
Glib::RefPtr<Gdk::Pixbuf> cropPixbuftrue;
MyMutex cimg;
private:
struct IdleHelper {
CropHandler* cropHandler;
bool destroyed;
int pending;
};
void compDim ();
int zoom; // scale factor (e.g. 5 if 1:5 scale) ; if 1:1 scale and bigger, factor is multiplied by 1000 (i.e. 1000 for 1:1 scale, 2000 for 2:1, etc...)
int ww, wh; // size of the crop's canvas on the screen ; might be bigger than the displayed image, but not smaller
int imx, imy, imw, imh; // this is a copy of the cropwindow's parameters
int cax, cay; // clamped crop anchor's coordinate, i.e. point of the image that coincide to the center of the display area, expressed in image coordinates; cannot be outside the image's bounds; but if cax==cay==-1, designate the center of the image
int cx, cy, cw, ch; // position and size of the requested crop ; position expressed in image coordinates, so cx and cy might be negative and cw and ch higher than the image's 1:1 size
int cropX, cropY, cropW, cropH; // cropPixbuf's displayed area (position and size), i.e. coordinates in 1:1 scale, i.e. cx, cy, cw & ch trimmed to the image's bounds
bool enabled;
unsigned char* cropimg;
unsigned char* cropimgtrue;
int cropimg_width, cropimg_height, cix, ciy, ciw, cih, cis;
bool initial;
bool isLowUpdatePriority;
rtengine::StagedImageProcessor* ipc;
rtengine::DetailedCrop* crop;
CropDisplayHandler* displayHandler;
IdleHelper* idle_helper;
IdleRegister idle_register;
}; };
#endif #endif

View File

@ -18,6 +18,7 @@
*/ */
#include "dirbrowser.h" #include "dirbrowser.h"
#include <iostream>
#include <cstring> #include <cstring>
#ifdef WIN32 #ifdef WIN32

View File

@ -327,22 +327,24 @@ DirPyrDenoise::DirPyrDenoise () : FoldableToolPanel(this, "dirpyrdenoise", M("TP
DirPyrDenoise::~DirPyrDenoise () DirPyrDenoise::~DirPyrDenoise ()
{ {
idle_register.destroy();
delete NoiscurveEditorG; delete NoiscurveEditorG;
delete CCcurveEditorG; delete CCcurveEditorG;
}
}
int chromaChangedUI (void* data)
{
(static_cast<DirPyrDenoise*>(data))->chromaComputed_ ();
return 0;
}
void DirPyrDenoise::chromaChanged (double autchroma, double autred, double autblue) void DirPyrDenoise::chromaChanged (double autchroma, double autred, double autblue)
{ {
nextchroma = autchroma; nextchroma = autchroma;
// printf("CHROM=%f\n",nextchroma);
nextred = autred; nextred = autred;
nextblue = autblue; nextblue = autblue;
add_idle(chromaChangedUI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<DirPyrDenoise*>(data)->chromaComputed_();
return false;
};
idle_register.add(func, this);
} }
bool DirPyrDenoise::chromaComputed_ () bool DirPyrDenoise::chromaComputed_ ()
@ -356,12 +358,6 @@ bool DirPyrDenoise::chromaComputed_ ()
updateNoiseLabel (); updateNoiseLabel ();
return false; return false;
} }
int TilePrevChangedUI (void* data)
{
(static_cast<DirPyrDenoise*>(data))->TilePrevComputed_ ();
return 0;
}
void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP) void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP)
{ {
@ -372,10 +368,14 @@ void DirPyrDenoise::noiseTilePrev (int tileX, int tileY, int prevX, int prevY, i
nextsizeT = sizeT; nextsizeT = sizeT;
nextsizeP = sizeP; nextsizeP = sizeP;
add_idle(TilePrevChangedUI, this); const auto func = [](gpointer data) -> gboolean {
static_cast<DirPyrDenoise*>(data)->TilePrevComputed_();
return false;
};
idle_register.add(func, this);
} }
bool DirPyrDenoise::TilePrevComputed_ () bool DirPyrDenoise::TilePrevComputed_ ()
{ {
@ -385,6 +385,7 @@ bool DirPyrDenoise::TilePrevComputed_ ()
updatePrevLabel (); updatePrevLabel ();
return false; return false;
} }
void DirPyrDenoise::updateTileLabel () void DirPyrDenoise::updateTileLabel ()
{ {
if (!batchMode) { if (!batchMode) {
@ -422,19 +423,17 @@ void DirPyrDenoise::updatePrevLabel ()
} }
} }
int noiseChangedUI (void* data)
{
(static_cast<DirPyrDenoise*>(data))->noiseComputed_ ();
return 0;
}
void DirPyrDenoise::noiseChanged (double nresid, double highresid) void DirPyrDenoise::noiseChanged (double nresid, double highresid)
{ {
nextnresid = nresid; nextnresid = nresid;
nexthighresid = highresid; nexthighresid = highresid;
add_idle(noiseChangedUI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<DirPyrDenoise*>(data)->noiseComputed_();
return false;
};
idle_register.add(func, this);
} }
bool DirPyrDenoise::noiseComputed_ () bool DirPyrDenoise::noiseComputed_ ()

View File

@ -28,10 +28,58 @@
#include "guiutils.h" #include "guiutils.h"
#include "options.h" #include "options.h"
class DirPyrDenoise : public ToolParamBlock, public AdjusterListener, public FoldableToolPanel, public rtengine::AutoChromaListener, public CurveListener, public ColorProvider class DirPyrDenoise final :
public ToolParamBlock,
public AdjusterListener,
public FoldableToolPanel,
public rtengine::AutoChromaListener,
public CurveListener,
public ColorProvider
{ {
public:
DirPyrDenoise ();
~DirPyrDenoise ();
protected: void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void curveChanged (CurveEditor* ce);
void setEditProvider (EditDataProvider *provider);
void autoOpenCurve ();
void adjusterChanged (Adjuster* a, double newval);
void enabledChanged ();
void enhanceChanged ();
void medianChanged ();
void autochromaChanged ();
void chromaChanged (double autchroma, double autred, double autblue);
bool chromaComputed_ ();
void noiseChanged (double nresid, double highresid);
bool noiseComputed_ ();
void noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP);
bool TilePrevComputed_ ();
// void perform_toggled ();
void updateNoiseLabel ();
void LmethodChanged ();
void CmethodChanged ();
void C2methodChanged ();
void updateTileLabel ();
void updatePrevLabel ();
void dmethodChanged ();
void medmethodChanged ();
void methodmedChanged ();
void rgbmethodChanged ();
void smethodChanged ();
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
void setAdjusterBehavior (bool lumaadd, bool lumdetadd, bool chromaadd, bool chromaredadd, bool chromablueadd, bool gammaadd, bool passesadd);
void trimValues (rtengine::procparams::ProcParams* pp);
Glib::ustring getSettingString ();
private:
CurveEditorGroup* NoiscurveEditorG; CurveEditorGroup* NoiscurveEditorG;
CurveEditorGroup* CCcurveEditorG; CurveEditorGroup* CCcurveEditorG;
Adjuster* luma; Adjuster* luma;
@ -92,50 +140,7 @@ protected:
int nextsizeT; int nextsizeT;
int nextsizeP; int nextsizeP;
public: IdleRegister idle_register;
DirPyrDenoise ();
~DirPyrDenoise ();
void read (const rtengine::procparams::ProcParams* pp, const ParamsEdited* pedited = nullptr);
void write (rtengine::procparams::ProcParams* pp, ParamsEdited* pedited = nullptr);
void setDefaults (const rtengine::procparams::ProcParams* defParams, const ParamsEdited* pedited = nullptr);
void setBatchMode (bool batchMode);
void curveChanged (CurveEditor* ce);
void setEditProvider (EditDataProvider *provider);
void autoOpenCurve ();
void adjusterChanged (Adjuster* a, double newval);
void enabledChanged ();
void enhanceChanged ();
void medianChanged ();
void autochromaChanged ();
void chromaChanged (double autchroma, double autred, double autblue);
bool chromaComputed_ ();
void noiseChanged (double nresid, double highresid);
bool noiseComputed_ ();
void noiseTilePrev (int tileX, int tileY, int prevX, int prevY, int sizeT, int sizeP);
bool TilePrevComputed_ ();
// void perform_toggled ();
void updateNoiseLabel ();
void LmethodChanged ();
void CmethodChanged ();
void C2methodChanged ();
void updateTileLabel ();
void updatePrevLabel ();
void dmethodChanged ();
void medmethodChanged ();
void methodmedChanged ();
void rgbmethodChanged ();
void smethodChanged ();
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
void setAdjusterBehavior (bool lumaadd, bool lumdetadd, bool chromaadd, bool chromaredadd, bool chromablueadd, bool gammaadd, bool passesadd);
void trimValues (rtengine::procparams::ProcParams* pp);
Glib::ustring getSettingString ();
}; };
#endif #endif

View File

@ -35,6 +35,44 @@
using namespace rtengine::procparams; using namespace rtengine::procparams;
namespace
{
struct spparams {
double val;
Glib::ustring str;
MyProgressBar *pProgress;
Glib::RefPtr<Gtk::CssProvider> cssProvider;
};
int setprogressStrUI ( void *p )
{
spparams *s = static_cast<spparams*> (p);
if ( ! s->str.empty() ) {
s->pProgress->set_text ( M (s->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());
}
}
delete s;
return FALSE;
}
}
class EditorPanel::ColorManagementToolbar class EditorPanel::ColorManagementToolbar
{ {
private: private:
@ -683,6 +721,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel)
EditorPanel::~EditorPanel () EditorPanel::~EditorPanel ()
{ {
idle_register.destroy();
history->setHistoryBeforeLineListener (nullptr); history->setHistoryBeforeLineListener (nullptr);
// the order is important! // the order is important!
@ -1017,46 +1056,12 @@ void EditorPanel::setProgressState (bool inProcessing)
g_idle_add (setProgressStateUIThread, p); g_idle_add (setProgressStateUIThread, p);
} }
struct spparams {
double val;
Glib::ustring str;
MyProgressBar *pProgress;
Glib::RefPtr<Gtk::CssProvider> cssProvider;
};
int setprogressStrUI ( void *p )
{
spparams *s = static_cast<spparams*> (p);
if ( ! s->str.empty() ) {
s->pProgress->set_text ( M (s->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());
}
}
delete s;
return 0;
}
void EditorPanel::setProgress (double p) void EditorPanel::setProgress (double p)
{ {
spparams *s = new spparams; spparams *s = new spparams;
s->val = p; s->val = p;
s->pProgress = progressLabel; s->pProgress = progressLabel;
add_idle (setprogressStrUI, s); idle_register.add(setprogressStrUI, s);
} }
void EditorPanel::setProgressStr (Glib::ustring str) void EditorPanel::setProgressStr (Glib::ustring str)
@ -1065,7 +1070,7 @@ void EditorPanel::setProgressStr (Glib::ustring str)
s->str = str; s->str = str;
s->val = -1; s->val = -1;
s->pProgress = progressLabel; s->pProgress = progressLabel;
add_idle (setprogressStrUI, s); idle_register.add(setprogressStrUI, s);
} }
// This is only called from the ThreadUI, so within the gtk thread // This is only called from the ThreadUI, so within the gtk thread

View File

@ -45,102 +45,17 @@ struct EditorPanelIdleHelper {
}; };
class RTWindow; class RTWindow;
class EditorPanel : public Gtk::VBox, class EditorPanel final :
public Gtk::VBox,
public PParamsChangeListener, public PParamsChangeListener,
public rtengine::ProgressListener, public rtengine::ProgressListener,
public ThumbnailListener, public ThumbnailListener,
public HistoryBeforeLineListener, public HistoryBeforeLineListener,
public rtengine::HistogramListener public rtengine::HistogramListener
{ {
private:
Glib::ustring lastSaveAsFileName;
bool realized;
protected:
MyProgressBar *progressLabel;
Gtk::ToggleButton* info;
Gtk::ToggleButton* hidehp;
Gtk::ToggleButton* tbShowHideSidePanels;
Gtk::ToggleButton* tbTopPanel_1;
Gtk::ToggleButton* tbRightPanel_1;
Gtk::ToggleButton* tbBeforeLock;
//bool bAllSidePanelsVisible;
Gtk::ToggleButton* beforeAfter;
Gtk::Paned* hpanedl;
Gtk::Paned* hpanedr;
Gtk::Image *iHistoryShow, *iHistoryHide;
Gtk::Image *iTopPanel_1_Show, *iTopPanel_1_Hide;
Gtk::Image *iRightPanel_1_Show, *iRightPanel_1_Hide;
Gtk::Image *iShowHideSidePanels;
Gtk::Image *iShowHideSidePanels_exit;
Gtk::Image *iBeforeLockON, *iBeforeLockOFF;
Gtk::VBox *leftbox;
Gtk::VBox *vboxright;
Gtk::Button* queueimg;
Gtk::Button* saveimgas;
Gtk::Button* sendtogimp;
Gtk::Button* navSync;
Gtk::Button* navNext;
Gtk::Button* navPrev;
class ColorManagementToolbar;
std::unique_ptr<ColorManagementToolbar> colorMgmtToolBar;
ImageAreaPanel* iareapanel;
PreviewHandler* previewHandler;
PreviewHandler* beforePreviewHandler; // for the before-after view
Navigator* navigator;
ImageAreaPanel* beforeIarea; // for the before-after view
Gtk::VBox* beforeBox;
Gtk::VBox* afterBox;
Gtk::Label* beforeLabel;
Gtk::Label* afterLabel;
Gtk::HBox* beforeAfterBox;
Gtk::HBox* beforeHeaderBox;
Gtk::HBox* afterHeaderBox;
Gtk::Frame* ppframe;
ProfilePanel* profilep;
History* history;
HistogramPanel* histogramPanel;
ToolPanelCoordinator* tpc;
RTWindow* parent;
//SaveAsDialog* saveAsDialog;
BatchToolPanelCoordinator* btpCoordinator;
FilePanel* fPanel;
bool firstProcessingDone;
Thumbnail* openThm; // may get invalid on external delete event
Glib::ustring fname; // must be saved separately
rtengine::InitialImage* isrc;
rtengine::StagedImageProcessor* ipc;
rtengine::StagedImageProcessor* beforeIpc; // for the before-after view
EditorPanelIdleHelper* epih;
void close ();
BatchQueueEntry* createBatchQueueEntry ();
bool idle_imageSaved (ProgressConnector<int> *pc, rtengine::IImage16* img, Glib::ustring fname, SaveFormat sf);
bool idle_saveImage (ProgressConnector<rtengine::IImage16*> *pc, Glib::ustring fname, SaveFormat sf);
bool idle_sendToGimp ( ProgressConnector<rtengine::IImage16*> *pc, Glib::ustring fname);
bool idle_sentToGimp (ProgressConnector<int> *pc, rtengine::IImage16* img, Glib::ustring filename);
int err;
time_t processingStartedTime;
sigc::connection ShowHideSidePanelsconn;
bool isProcessing;
public: public:
explicit EditorPanel (FilePanel* filePanel = nullptr); explicit EditorPanel (FilePanel* filePanel = nullptr);
virtual ~EditorPanel (); ~EditorPanel ();
void open (Thumbnail* tmb, rtengine::InitialImage* isrc); void open (Thumbnail* tmb, rtengine::InitialImage* isrc);
void setAspect (); void setAspect ();
@ -215,6 +130,92 @@ public:
void updateHistogramPosition (int oldPosition, int newPosition); void updateHistogramPosition (int oldPosition, int newPosition);
Gtk::Paned* catalogPane; Gtk::Paned* catalogPane;
private:
void close ();
BatchQueueEntry* createBatchQueueEntry ();
bool idle_imageSaved (ProgressConnector<int> *pc, rtengine::IImage16* img, Glib::ustring fname, SaveFormat sf);
bool idle_saveImage (ProgressConnector<rtengine::IImage16*> *pc, Glib::ustring fname, SaveFormat sf);
bool idle_sendToGimp ( ProgressConnector<rtengine::IImage16*> *pc, Glib::ustring fname);
bool idle_sentToGimp (ProgressConnector<int> *pc, rtengine::IImage16* img, Glib::ustring filename);
Glib::ustring lastSaveAsFileName;
bool realized;
MyProgressBar *progressLabel;
Gtk::ToggleButton* info;
Gtk::ToggleButton* hidehp;
Gtk::ToggleButton* tbShowHideSidePanels;
Gtk::ToggleButton* tbTopPanel_1;
Gtk::ToggleButton* tbRightPanel_1;
Gtk::ToggleButton* tbBeforeLock;
//bool bAllSidePanelsVisible;
Gtk::ToggleButton* beforeAfter;
Gtk::Paned* hpanedl;
Gtk::Paned* hpanedr;
Gtk::Image *iHistoryShow, *iHistoryHide;
Gtk::Image *iTopPanel_1_Show, *iTopPanel_1_Hide;
Gtk::Image *iRightPanel_1_Show, *iRightPanel_1_Hide;
Gtk::Image *iShowHideSidePanels;
Gtk::Image *iShowHideSidePanels_exit;
Gtk::Image *iBeforeLockON, *iBeforeLockOFF;
Gtk::VBox *leftbox;
Gtk::VBox *vboxright;
Gtk::Button* queueimg;
Gtk::Button* saveimgas;
Gtk::Button* sendtogimp;
Gtk::Button* navSync;
Gtk::Button* navNext;
Gtk::Button* navPrev;
class ColorManagementToolbar;
std::unique_ptr<ColorManagementToolbar> colorMgmtToolBar;
ImageAreaPanel* iareapanel;
PreviewHandler* previewHandler;
PreviewHandler* beforePreviewHandler; // for the before-after view
Navigator* navigator;
ImageAreaPanel* beforeIarea; // for the before-after view
Gtk::VBox* beforeBox;
Gtk::VBox* afterBox;
Gtk::Label* beforeLabel;
Gtk::Label* afterLabel;
Gtk::HBox* beforeAfterBox;
Gtk::HBox* beforeHeaderBox;
Gtk::HBox* afterHeaderBox;
Gtk::Frame* ppframe;
ProfilePanel* profilep;
History* history;
HistogramPanel* histogramPanel;
ToolPanelCoordinator* tpc;
RTWindow* parent;
//SaveAsDialog* saveAsDialog;
BatchToolPanelCoordinator* btpCoordinator;
FilePanel* fPanel;
bool firstProcessingDone;
Thumbnail* openThm; // may get invalid on external delete event
Glib::ustring fname; // must be saved separately
rtengine::InitialImage* isrc;
rtengine::StagedImageProcessor* ipc;
rtengine::StagedImageProcessor* beforeIpc; // for the before-after view
EditorPanelIdleHelper* epih;
int err;
time_t processingStartedTime;
sigc::connection ShowHideSidePanelsconn;
bool isProcessing;
IdleRegister idle_register;
}; };
#endif #endif

View File

@ -22,12 +22,6 @@
#include "inspector.h" #include "inspector.h"
#include "placesbrowser.h" #include "placesbrowser.h"
int FilePanelInitUI (void* data)
{
(static_cast<FilePanel*>(data))->init ();
return 0;
}
FilePanel::FilePanel () : parent(nullptr) FilePanel::FilePanel () : parent(nullptr)
{ {
@ -143,13 +137,21 @@ FilePanel::FilePanel () : parent(nullptr)
fileCatalog->setFileSelectionChangeListener (tpc); fileCatalog->setFileSelectionChangeListener (tpc);
fileCatalog->setFileSelectionListener (this); fileCatalog->setFileSelectionListener (this);
add_idle (FilePanelInitUI, this);
const auto func = [](gpointer data) -> gboolean {
static_cast<FilePanel*>(data)->init();
return FALSE;
};
idle_register.add(func, this);
show_all (); show_all ();
} }
FilePanel::~FilePanel () FilePanel::~FilePanel ()
{ {
idle_register.destroy();
rightNotebookSwitchConn.disconnect(); rightNotebookSwitchConn.disconnect();
if (inspectorPanel) { if (inspectorPanel) {

View File

@ -33,38 +33,12 @@
#include "progressconnector.h" #include "progressconnector.h"
class RTWindow; class RTWindow;
class FilePanel : public Gtk::HPaned,
class FilePanel final :
public Gtk::HPaned,
public FileSelectionListener, public FileSelectionListener,
public PParamsChangeListener public PParamsChangeListener
{ {
protected:
//DirBrowser* dirBrowser;
PlacesBrowser* placesBrowser;
RecentBrowser* recentBrowser;
// FileCatalog* fileCatalog; // filecatalog is the file browser with the button bar above it
Inspector* inspectorPanel;
Gtk::VPaned* tpcPaned;
BatchToolPanelCoordinator* tpc;
History* history;
//FilterPanel* filterPanel;
RTWindow* parent;
Gtk::Notebook* rightNotebook;
sigc::connection rightNotebookSwitchConn;
struct pendingLoad {
bool complete;
ProgressConnector<rtengine::InitialImage*> *pc;
Thumbnail *thm;
};
MyMutex pendingLoadMutex;
std::vector<struct pendingLoad*> pendingLoads;
int error;
void on_NB_switch_page(Gtk::Widget* page, guint page_num);
public: public:
FilePanel (); FilePanel ();
~FilePanel (); ~FilePanel ();
@ -107,6 +81,32 @@ public:
bool handleShortcutKey (GdkEventKey* event); bool handleShortcutKey (GdkEventKey* event);
void updateTPVScrollbar (bool hide); void updateTPVScrollbar (bool hide);
void updateTabsUsesIcons (bool useIcons); void updateTabsUsesIcons (bool useIcons);
private:
void on_NB_switch_page(Gtk::Widget* page, guint page_num);
PlacesBrowser* placesBrowser;
RecentBrowser* recentBrowser;
Inspector* inspectorPanel;
Gtk::VPaned* tpcPaned;
BatchToolPanelCoordinator* tpc;
History* history;
RTWindow* parent;
Gtk::Notebook* rightNotebook;
sigc::connection rightNotebookSwitchConn;
struct pendingLoad {
bool complete;
ProgressConnector<rtengine::InitialImage*> *pc;
Thumbnail *thm;
};
MyMutex pendingLoadMutex;
std::vector<struct pendingLoad*> pendingLoads;
int error;
IdleRegister idle_register;
}; };
#endif #endif

View File

@ -19,9 +19,7 @@
#ifndef __GUI_UTILS_ #ifndef __GUI_UTILS_
#define __GUI_UTILS_ #define __GUI_UTILS_
#include <iostream> #include <map>
#include <set>
#include <sstream>
#include <gtkmm.h> #include <gtkmm.h>