Solving issue 2341: "Pipette and flat curves - no line colors"

This commit is contained in:
Hombre
2014-04-23 22:22:34 +02:00
parent 0fde2ec06d
commit 402c5a6af9
7 changed files with 89 additions and 40 deletions

View File

@@ -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 : * Call back method when the reset button is pressed :
* reset the currently toggled on curve editor * reset the currently toggled on curve editor

View File

@@ -89,6 +89,7 @@ protected:
void updateGUI (CurveEditor* ce); void updateGUI (CurveEditor* ce);
void curveResetPressed (); void curveResetPressed ();
void curveChanged (); void curveChanged ();
float blendPipetteValues(float chan1, float chan2, float chan3);
void setUnChanged (bool uc, CurveEditor* ce); void setUnChanged (bool uc, CurveEditor* ce);
}; };

View File

@@ -23,14 +23,43 @@ class CurveEditor;
class CurveListener { class CurveListener {
private: private:
bool multi; bool multi;
public: public:
CurveListener() : multi(false) {}
virtual ~CurveListener() {}
virtual void curveChanged () {} virtual void curveChanged () {}
virtual void curveChanged (CurveEditor* ce) {} virtual void curveChanged (CurveEditor* ce) {}
void setMulti(bool value) { multi = value; } void setMulti(bool value) { multi = value; }
bool isMulti() { return multi; } 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 #endif

View File

@@ -40,7 +40,7 @@ Gradient::Gradient () : FoldableToolPanel(this), EditSubscriber(ET_OBJECTS), las
centerY->set_tooltip_text (M("TP_GRADIENT_CENTER_Y_TOOLTIP")); centerY->set_tooltip_text (M("TP_GRADIENT_CENTER_Y_TOOLTIP"));
centerY->setAdjusterListener (this); centerY->setAdjusterListener (this);
Gtk::HBox* enaBox = Gtk::manage (new Gtk::HBox()); enaBox = Gtk::manage (new Gtk::HBox());
enaBox->pack_start(*enabled); enaBox->pack_start(*enabled);
enaBox->pack_end(*edit, false, false, 0); enaBox->pack_end(*edit, false, false, 0);
pack_start(*enaBox); pack_start(*enaBox);
@@ -289,6 +289,7 @@ void Gradient::trimValues (rtengine::procparams::ProcParams* pp)
void Gradient::setBatchMode (bool batchMode) void Gradient::setBatchMode (bool batchMode)
{ {
removeIfThere(enaBox, edit, false);
ToolPanel::setBatchMode (batchMode); ToolPanel::setBatchMode (batchMode);
degree->showEditedCB (); degree->showEditedCB ();
feather->showEditedCB (); feather->showEditedCB ();

View File

@@ -13,6 +13,7 @@ class Gradient : public ToolParamBlock, public AdjusterListener, public Foldable
private: private:
int lastObject; int lastObject;
Gtk::HBox* enaBox;
protected: protected:
Gtk::CheckButton* enabled; Gtk::CheckButton* enabled;

View File

@@ -681,25 +681,27 @@ void MyDiagonalCurve::pipetteMouseOver (EditDataProvider *provider, int modifier
pipetteG = provider->pipetteVal[1]; pipetteG = provider->pipetteVal[1];
pipetteB = provider->pipetteVal[2]; pipetteB = provider->pipetteVal[2];
pipetteVal = 0.f; pipetteVal = 0.f;
int n = 0; if (listener)
if (pipetteR != -1.f) { pipetteVal = listener->blendPipetteValues(pipetteR, pipetteG, pipetteB);
pipetteVal += pipetteR; else {
++n; 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 */ /* graphW and graphH are the size of the graph */
calcDimensions(); calcDimensions();
@@ -708,7 +710,6 @@ void MyDiagonalCurve::pipetteMouseOver (EditDataProvider *provider, int modifier
return; return;
double minDistanceX = double(MIN_DISTANCE) / double(graphW-1); 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) { if (curve.type == DCT_Linear || curve.type == DCT_Spline || curve.type == DCT_NURBS) {
// get the pointer position // get the pointer position

View File

@@ -205,8 +205,9 @@ void MyFlatCurve::draw () {
cr->set_line_width (1.); cr->set_line_width (1.);
} }
} }
// draw the color feedback of the control points // draw the color feedback of the control points
else if (colorProvider) { if (colorProvider) {
//if (curve.type!=FCT_Parametric) //if (curve.type!=FCT_Parametric)
for (int i=0; i<(int)curve.x.size(); ++i) { 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]; pipetteG = provider->pipetteVal[1];
pipetteB = provider->pipetteVal[2]; pipetteB = provider->pipetteVal[2];
pipetteVal = 0.f; pipetteVal = 0.f;
int n = 0; if (listener)
if (pipetteR != -1.f) { pipetteVal = listener->blendPipetteValues(pipetteR, pipetteG, pipetteB);
pipetteVal += pipetteR; else {
++n; 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; snapToElmt = -100;