Adding Pipette feature for the Parametric curve + bugfix of the SnapTo feature
This commit is contained in:
@@ -471,21 +471,21 @@ void Adjuster::editedToggled () {
|
||||
eventPending = false;
|
||||
}
|
||||
|
||||
double Adjuster::trimValue (double& val) {
|
||||
double Adjuster::trimValue (double val) {
|
||||
|
||||
if (val > vMax) val = vMax; // shapeValue(vMax) ?
|
||||
else if (val < vMin) val = vMin; // shapeValue(vMin) ?
|
||||
return val;
|
||||
}
|
||||
|
||||
int Adjuster::trimValue (int& val) {
|
||||
int Adjuster::trimValue (int val) {
|
||||
|
||||
if (val > (int)vMax) val = (int)vMax; // shapeValue(vMax) ?
|
||||
else if (val < (int)vMin) val = (int)vMin; // shapeValue(vMin) ?
|
||||
return val;
|
||||
}
|
||||
|
||||
float Adjuster::trimValue (float& val) {
|
||||
float Adjuster::trimValue (float val) {
|
||||
|
||||
if (val > (float)vMax) val = (float)vMax; // shapeValue(vMax) ?
|
||||
else if (val < (float)vMin) val = (float)vMin; // shapeValue(vMin) ?
|
||||
|
||||
@@ -126,9 +126,9 @@ class Adjuster : public Gtk::VBox {
|
||||
void resetValue (bool toInitial);
|
||||
void resetPressed (GdkEventButton* event);
|
||||
void editedToggled ();
|
||||
double trimValue (double& val);
|
||||
float trimValue (float& val);
|
||||
int trimValue (int& val);
|
||||
double trimValue (double val);
|
||||
float trimValue (float val);
|
||||
int trimValue (int val);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -612,7 +612,7 @@ void CropWindow::pointerMoved (int bstate, int x, int y) {
|
||||
|
||||
Coord oldPosScreen = iarea->posScreen+iarea->deltaScreen;
|
||||
//printf(">>> SCR / ScrPrev(%d x %d) = (%d x %d) + (%d x %d)\n", oldPosScreen.x, oldPosScreen.y, iarea->posScreen.x, iarea->posScreen.y, iarea->deltaScreen.x, iarea->deltaScreen.y);
|
||||
screenCoordToPreview(x, y, currPos.x, currPos.y);
|
||||
currPos.set(x, y);
|
||||
iarea->deltaScreen = currPos - iarea->posScreen;
|
||||
iarea->deltaPrevScreen = currPos - oldPosScreen;
|
||||
//printf(" action_ & xy (%d x %d) -> (%d x %d) = (%d x %d) + (%d x %d) / deltaPrev(%d x %d)\n", action_x, action_y, currPos.x, currPos.y, iarea->posScreen.x, iarea->posScreen.y, iarea->deltaScreen.x, iarea->deltaScreen.y, iarea->deltaPrevScreen.x, iarea->deltaPrevScreen.y);
|
||||
@@ -1474,7 +1474,6 @@ void CropWindow::screenCoordToPreview (int phyx, int phyy, int& prevx, int& prev
|
||||
void CropWindow::imageCoordToScreen (int imgx, int imgy, int& phyx, int& phyy) {
|
||||
|
||||
int cropX, cropY;
|
||||
rtengine::Crop* crop = static_cast<rtengine::Crop*>(cropHandler.getCrop());
|
||||
cropHandler.getPosition (cropX, cropY);
|
||||
phyx = (imgx - cropX)*zoomSteps[cropZoom].zoom + xpos + imgX;
|
||||
phyy = (imgy - cropY)*zoomSteps[cropZoom].zoom + ypos + imgY;
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
|
||||
DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt, Glib::ustring& curveDir) : CurveEditorSubGroup(curveDir) {
|
||||
|
||||
editedAdjuster = NULL;
|
||||
editedAdjusterValue = 0;
|
||||
|
||||
valLinear = (int)DCT_Linear;
|
||||
valUnchanged = (int)DCT_Unchanged;
|
||||
parent = prt;
|
||||
@@ -277,8 +280,53 @@ void DiagonalCurveEditorSubGroup::pipetteMouseOver(EditDataProvider *provider, i
|
||||
customCurve->setDirty(true);
|
||||
break;
|
||||
case (DCT_Parametric):
|
||||
{
|
||||
paramCurve->pipetteMouseOver(provider, modifierKey);
|
||||
paramCurve->setDirty(true);
|
||||
float pipetteVal = 0.f;
|
||||
editedAdjuster = NULL;
|
||||
int n = 0;
|
||||
if (provider->pipetteVal[0] != -1.f) {
|
||||
pipetteVal += provider->pipetteVal[0];
|
||||
++n;
|
||||
}
|
||||
if (provider->pipetteVal[1] != -1.f) {
|
||||
pipetteVal += provider->pipetteVal[1];
|
||||
++n;
|
||||
}
|
||||
if (provider->pipetteVal[2] != -1.f) {
|
||||
pipetteVal += provider->pipetteVal[2];
|
||||
++n;
|
||||
}
|
||||
if (n>1) {
|
||||
pipetteVal /= n;
|
||||
}
|
||||
else if (!n)
|
||||
pipetteVal = -1.f;
|
||||
|
||||
if (pipetteVal != -1.f) {
|
||||
double pos[3];
|
||||
shcSelector->getPositions(pos[0], pos[1], pos[2]);
|
||||
if (pipetteVal>=pos[2]) {
|
||||
editedAdjuster = highlights;
|
||||
paramCurve->setActiveParam(4);
|
||||
}
|
||||
else if(pipetteVal>=pos[1]) {
|
||||
editedAdjuster = lights;
|
||||
paramCurve->setActiveParam(5);
|
||||
}
|
||||
else if(pipetteVal>=pos[0]) {
|
||||
editedAdjuster = darks;
|
||||
paramCurve->setActiveParam(6);
|
||||
}
|
||||
else {
|
||||
editedAdjuster = shadows;
|
||||
paramCurve->setActiveParam(7);
|
||||
}
|
||||
}
|
||||
else
|
||||
paramCurve->setActiveParam(-1);
|
||||
}
|
||||
break;
|
||||
case (DCT_NURBS):
|
||||
NURBSCurve->pipetteMouseOver(provider, modifierKey);
|
||||
@@ -297,7 +345,8 @@ void DiagonalCurveEditorSubGroup::pipetteButton1Pressed(EditDataProvider *provid
|
||||
customCurve->pipetteButton1Pressed(provider, modifierKey);
|
||||
break;
|
||||
case (DCT_Parametric):
|
||||
paramCurve->pipetteButton1Pressed(provider, modifierKey);
|
||||
if (editedAdjuster)
|
||||
editedAdjusterValue = editedAdjuster->getIntValue();
|
||||
break;
|
||||
case (DCT_NURBS):
|
||||
NURBSCurve->pipetteButton1Pressed(provider, modifierKey);
|
||||
@@ -315,7 +364,7 @@ void DiagonalCurveEditorSubGroup::pipetteButton1Released(EditDataProvider *provi
|
||||
customCurve->pipetteButton1Released(provider);
|
||||
break;
|
||||
case (DCT_Parametric):
|
||||
paramCurve->pipetteButton1Released(provider);
|
||||
editedAdjuster = NULL;
|
||||
break;
|
||||
case (DCT_NURBS):
|
||||
NURBSCurve->pipetteButton1Released(provider);
|
||||
@@ -333,7 +382,13 @@ void DiagonalCurveEditorSubGroup::pipetteDrag(EditDataProvider *provider, int mo
|
||||
customCurve->pipetteDrag(provider, modifierKey);
|
||||
break;
|
||||
case (DCT_Parametric):
|
||||
paramCurve->pipetteDrag(provider, modifierKey);
|
||||
if (editedAdjuster) {
|
||||
int trimmedValue = editedAdjuster->trimValue(editedAdjusterValue-(provider->deltaScreen.y/2));
|
||||
if (trimmedValue != editedAdjuster->getIntValue()) {
|
||||
editedAdjuster->setValue(trimmedValue);
|
||||
adjusterChanged(editedAdjuster, trimmedValue);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case (DCT_NURBS):
|
||||
NURBSCurve->pipetteDrag(provider, modifierKey);
|
||||
|
||||
@@ -43,6 +43,9 @@ protected:
|
||||
Adjuster* darks;
|
||||
Adjuster* shadows;
|
||||
|
||||
Adjuster *editedAdjuster;
|
||||
int editedAdjusterValue;
|
||||
|
||||
Gtk::Button* saveCustom;
|
||||
Gtk::Button* loadCustom;
|
||||
Gtk::Button* copyCustom;
|
||||
|
||||
@@ -854,23 +854,27 @@ void MyDiagonalCurve::pipetteButton1Released(EditDataProvider *provider) {
|
||||
}
|
||||
|
||||
void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
||||
if (curve.type==DCT_Parametric || graphW<0 || graphH<0)
|
||||
return;
|
||||
|
||||
snapToMinDistY = snapToMinDistX = 10.;
|
||||
snapToValY = snapToValX = 0.;
|
||||
snapToElmt = -100;
|
||||
|
||||
/* graphW and graphH are the size of the graph */
|
||||
calcDimensions();
|
||||
|
||||
double minDistanceX = double(MIN_DISTANCE) / double(graphW-1);
|
||||
double minDistanceY = double(MIN_DISTANCE) / double(graphH-1);
|
||||
|
||||
if ((graphW < 0) || (graphH < 0))
|
||||
return;
|
||||
//double minDistanceX = double(MIN_DISTANCE) / double(graphW-1);
|
||||
//double minDistanceY = double(MIN_DISTANCE) / double(graphH-1);
|
||||
|
||||
getCursorPosition(Gdk::MOTION_NOTIFY, false, cursorX+graphX, graphY+provider->deltaScreen.y, Gdk::ModifierType(modifierKey));
|
||||
|
||||
// bounds of the grabbed point
|
||||
double const bottomBound = 0.;
|
||||
double const topBound = 1.;
|
||||
//double const bottomBound = 0.;
|
||||
//double const topBound = 1.;
|
||||
|
||||
double bottomDeletionBound = bottomBound - minDistanceY;
|
||||
double topDeletionBound = topBound + minDistanceY;
|
||||
//double bottomDeletionBound = bottomBound - minDistanceY;
|
||||
//double topDeletionBound = topBound + minDistanceY;
|
||||
|
||||
// we memorize the previous position of the point, for optimization purpose
|
||||
double prevPosX = curve.x[grab_point];
|
||||
@@ -912,7 +916,7 @@ void MyDiagonalCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
||||
}
|
||||
else {
|
||||
// nextPosY is in the bounds
|
||||
curve.y[grab_point] = CLAMP(ugpY, 0.0, 1.0);
|
||||
curve.y[grab_point] = ugpY;
|
||||
}
|
||||
|
||||
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
|
||||
|
||||
@@ -1062,11 +1062,11 @@ void MyFlatCurve::pipetteDrag(EditDataProvider *provider, int modifierKey) {
|
||||
getMouseOverArea();
|
||||
|
||||
if (editedHandle == FCT_EditedHandle_CPointY) {
|
||||
movePoint(false, true);
|
||||
movePoint(false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
void MyFlatCurve::movePoint(bool moveX, bool moveY) {
|
||||
void MyFlatCurve::movePoint(bool moveX, bool moveY, bool pipetteDrag) {
|
||||
|
||||
// bounds of the grabbed point
|
||||
double leftBound;
|
||||
@@ -1187,6 +1187,10 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY) {
|
||||
// we memorize the previous position of the point, for optimization purpose
|
||||
ugpY += deltaY;
|
||||
|
||||
// the points stay in the bounds (and can't be deleted) in pipette drag mode
|
||||
if (pipetteDrag)
|
||||
ugpY = CLAMP(ugpY, 0.0, 1.0);
|
||||
|
||||
// snapping point to specific values
|
||||
if (snapTo && curve.x[lit_point] != -1) {
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class MyFlatCurve : public MyCurve {
|
||||
enum MouseOverAreas area;
|
||||
|
||||
void draw ();
|
||||
void movePoint(bool moveX, bool moveY);
|
||||
void movePoint(bool moveX, bool moveY, bool pipetteDrag=false);
|
||||
void defaultCurve (double iVal=0.5);
|
||||
void interpolate ();
|
||||
void getCursorPosition(Gdk::EventType evType, bool isHint, int evX, int evY, Gdk::ModifierType modifier);
|
||||
|
||||
Reference in New Issue
Block a user