diff --git a/rtgui/curveeditorgroup.cc b/rtgui/curveeditorgroup.cc index 6e006141a..d0fe49e44 100644 --- a/rtgui/curveeditorgroup.cc +++ b/rtgui/curveeditorgroup.cc @@ -277,6 +277,17 @@ void CurveEditorGroup::curveChanged () { } } +/* + * Listener called when the user has modified the curve + */ +float CurveEditorGroup::blendPipetteValues (float chan1, float chan2, float chan3) { + + if (cl) + return cl->blendPipetteValues(chan1, chan2, chan3); + + return -1.f; +} + /* * Call back method when the reset button is pressed : * reset the currently toggled on curve editor diff --git a/rtgui/curveeditorgroup.h b/rtgui/curveeditorgroup.h index 182a0ef7a..84a3ec79e 100644 --- a/rtgui/curveeditorgroup.h +++ b/rtgui/curveeditorgroup.h @@ -89,6 +89,7 @@ protected: void updateGUI (CurveEditor* ce); void curveResetPressed (); void curveChanged (); + float blendPipetteValues(float chan1, float chan2, float chan3); void setUnChanged (bool uc, CurveEditor* ce); }; diff --git a/rtgui/curvelistener.h b/rtgui/curvelistener.h index 72980c5d2..c1119703d 100644 --- a/rtgui/curvelistener.h +++ b/rtgui/curvelistener.h @@ -23,14 +23,43 @@ class CurveEditor; class CurveListener { - private: - bool multi; + private: + bool multi; public: + CurveListener() : multi(false) {} + virtual ~CurveListener() {} virtual void curveChanged () {} virtual void curveChanged (CurveEditor* ce) {} void setMulti(bool value) { multi = value; } bool isMulti() { return multi; } - CurveListener() : multi(false) {} + + /** @brief Blend pipette values from its different channels into a single value + If the buffer has more than one channel and one channel, this method will blend them together. + @param chan1 first channel's value + @param chan2 second channel's value + @param chan3 third channel's value + @return the blended value */ + virtual float blendPipetteValues(float chan1, float chan2, float chan3) { + float retVal = 0.f; + int n = 0; + if (chan1 != -1.f) { + retVal += chan1; + ++n; + } + if (chan2 != -1.f) { + retVal += chan2; + ++n; + } + if (chan3 != -1.f) { + retVal += chan3; + ++n; + } + if (n>1) + retVal /= n; + else if (!n) + retVal = -1.f; + return retVal; + } }; #endif diff --git a/rtgui/gradient.cc b/rtgui/gradient.cc index aa4a7cf9c..7d282af94 100644 --- a/rtgui/gradient.cc +++ b/rtgui/gradient.cc @@ -40,7 +40,7 @@ Gradient::Gradient () : FoldableToolPanel(this), EditSubscriber(ET_OBJECTS), las centerY->set_tooltip_text (M("TP_GRADIENT_CENTER_Y_TOOLTIP")); centerY->setAdjusterListener (this); - Gtk::HBox* enaBox = Gtk::manage (new Gtk::HBox()); + enaBox = Gtk::manage (new Gtk::HBox()); enaBox->pack_start(*enabled); enaBox->pack_end(*edit, false, false, 0); pack_start(*enaBox); @@ -289,6 +289,7 @@ void Gradient::trimValues (rtengine::procparams::ProcParams* pp) void Gradient::setBatchMode (bool batchMode) { + removeIfThere(enaBox, edit, false); ToolPanel::setBatchMode (batchMode); degree->showEditedCB (); feather->showEditedCB (); diff --git a/rtgui/gradient.h b/rtgui/gradient.h index 0a7b8660a..26c9824bb 100644 --- a/rtgui/gradient.h +++ b/rtgui/gradient.h @@ -13,6 +13,7 @@ class Gradient : public ToolParamBlock, public AdjusterListener, public Foldable private: int lastObject; + Gtk::HBox* enaBox; protected: Gtk::CheckButton* enabled; diff --git a/rtgui/mydiagonalcurve.cc b/rtgui/mydiagonalcurve.cc index 6d4cec7b6..1f04a1f02 100644 --- a/rtgui/mydiagonalcurve.cc +++ b/rtgui/mydiagonalcurve.cc @@ -681,25 +681,27 @@ void MyDiagonalCurve::pipetteMouseOver (EditDataProvider *provider, int modifier pipetteG = provider->pipetteVal[1]; pipetteB = provider->pipetteVal[2]; pipetteVal = 0.f; - int n = 0; - if (pipetteR != -1.f) { - pipetteVal += pipetteR; - ++n; + if (listener) + pipetteVal = listener->blendPipetteValues(pipetteR, pipetteG, pipetteB); + else { + int n = 0; + if (pipetteR != -1.f) { + pipetteVal += pipetteR; + ++n; + } + if (pipetteG != -1.f) { + pipetteVal += pipetteG; + ++n; + } + if (pipetteB != -1.f) { + pipetteVal += pipetteB; + ++n; + } + if (n>1) + pipetteVal /= n; + else if (!n) + pipetteVal = -1.f; } - if (pipetteG != -1.f) { - pipetteVal += pipetteG; - ++n; - } - if (pipetteB != -1.f) { - pipetteVal += pipetteB; - ++n; - } - if (n>1) - pipetteVal /= n; - else if (!n) - pipetteVal = -1.f; - - int num = (int)curve.x.size(); /* graphW and graphH are the size of the graph */ calcDimensions(); @@ -708,7 +710,6 @@ void MyDiagonalCurve::pipetteMouseOver (EditDataProvider *provider, int modifier return; double minDistanceX = double(MIN_DISTANCE) / double(graphW-1); - double minDistanceY = double(MIN_DISTANCE) / double(graphH-1); if (curve.type == DCT_Linear || curve.type == DCT_Spline || curve.type == DCT_NURBS) { // get the pointer position diff --git a/rtgui/myflatcurve.cc b/rtgui/myflatcurve.cc index 3a0cbfc2c..23bf72451 100644 --- a/rtgui/myflatcurve.cc +++ b/rtgui/myflatcurve.cc @@ -205,8 +205,9 @@ void MyFlatCurve::draw () { cr->set_line_width (1.); } } + // draw the color feedback of the control points - else if (colorProvider) { + if (colorProvider) { //if (curve.type!=FCT_Parametric) for (int i=0; i<(int)curve.x.size(); ++i) { @@ -919,23 +920,27 @@ void MyFlatCurve::pipetteMouseOver (EditDataProvider *provider, int modifierKey) pipetteG = provider->pipetteVal[1]; pipetteB = provider->pipetteVal[2]; pipetteVal = 0.f; - int n = 0; - if (pipetteR != -1.f) { - pipetteVal += pipetteR; - ++n; + if (listener) + pipetteVal = listener->blendPipetteValues(pipetteR, pipetteG, pipetteB); + else { + int n = 0; + if (pipetteR != -1.f) { + pipetteVal += pipetteR; + ++n; + } + if (pipetteG != -1.f) { + pipetteVal += pipetteG; + ++n; + } + if (pipetteB != -1.f) { + pipetteVal += pipetteB; + ++n; + } + if (n>1) + pipetteVal /= n; + else if (!n) + pipetteVal = -1.f; } - if (pipetteG != -1.f) { - pipetteVal += pipetteG; - ++n; - } - if (pipetteB != -1.f) { - pipetteVal += pipetteB; - ++n; - } - if (n>1) - pipetteVal /= n; - else if (!n) - pipetteVal = -1.f; snapToElmt = -100;