Solving issue 1528: "HSV equalizer channels sometimes can't be switched properly"

This commit is contained in:
natureh
2012-08-19 20:53:58 +02:00
parent fe9d266cae
commit 8ac87562e7
6 changed files with 79 additions and 67 deletions

View File

@@ -332,9 +332,9 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
customCurve->setPoints (dCurve->customCurveEd); customCurve->setPoints (dCurve->customCurveEd);
customCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId()); customCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
customCurve->setColoredBar(leftBar, bottomBar); customCurve->setColoredBar(leftBar, bottomBar);
customCurve->forceResize();
parent->pack_start (*customCurveBox); parent->pack_start (*customCurveBox);
customCurveBox->check_resize(); customCurveBox->check_resize();
customCurve->forceResize();
break; break;
case (DCT_Parametric): case (DCT_Parametric):
{ {
@@ -362,17 +362,17 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
shcSelector->setBgGradient(bgGradient); shcSelector->setBgGradient(bgGradient);
shcSelector->setMargins( (leftBar ? MyCurve::getBarWidth()+CBAR_MARGIN : RADIUS), RADIUS ); shcSelector->setMargins( (leftBar ? MyCurve::getBarWidth()+CBAR_MARGIN : RADIUS), RADIUS );
paramCurve->setColoredBar(leftBar, NULL); paramCurve->setColoredBar(leftBar, NULL);
parent->pack_start (*paramCurveBox);
paramCurve->forceResize(); paramCurve->forceResize();
parent->pack_start (*paramCurveBox);
break; break;
} }
case (DCT_NURBS): case (DCT_NURBS):
NURBSCurve->setPoints (dCurve->NURBSCurveEd); NURBSCurve->setPoints (dCurve->NURBSCurveEd);
NURBSCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId()); NURBSCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
NURBSCurve->setColoredBar(leftBar, bottomBar); NURBSCurve->setColoredBar(leftBar, bottomBar);
NURBSCurve->forceResize();
parent->pack_start (*NURBSCurveBox); parent->pack_start (*NURBSCurveBox);
NURBSCurveBox->check_resize(); NURBSCurveBox->check_resize();
NURBSCurve->forceResize();
break; break;
default: // (DCT_Linear, DCT_Unchanged) default: // (DCT_Linear, DCT_Unchanged)
// ... do nothing // ... do nothing
@@ -407,13 +407,13 @@ void DiagonalCurveEditorSubGroup::savePressed () {
int ix = 0; int ix = 0;
if (p[ix]==(double)(DCT_Linear)) if (p[ix]==(double)(DCT_Linear))
f << "Linear\n"; f << "Linear" << std::endl;
else if (p[ix]==(double)(DCT_Spline)) else if (p[ix]==(double)(DCT_Spline))
f << "Spline\n"; f << "Spline" << std::endl;
else if (p[ix]==(double)(DCT_NURBS)) else if (p[ix]==(double)(DCT_NURBS))
f << "NURBS\n"; f << "NURBS" << std::endl;
else if (p[ix]==(double)(DCT_Parametric)) else if (p[ix]==(double)(DCT_Parametric))
f << "Parametric\n"; f << "Parametric" << std::endl;
if (p[ix]==(double)(DCT_Parametric)) { if (p[ix]==(double)(DCT_Parametric)) {
ix++; ix++;
for (unsigned int i=0; i<p.size()-1; i++, ix++) for (unsigned int i=0; i<p.size()-1; i++, ix++)

View File

@@ -171,9 +171,9 @@ void FlatCurveEditorSubGroup::switchGUI() {
CPointsCurve->setPoints (dCurve->controlPointsCurveEd); CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
CPointsCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId()); CPointsCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
CPointsCurve->setColoredBar(leftBar, bottomBar); CPointsCurve->setColoredBar(leftBar, bottomBar);
CPointsCurve->forceResize();
parent->pack_start (*CPointsCurveBox); parent->pack_start (*CPointsCurveBox);
CPointsCurveBox->check_resize(); CPointsCurveBox->check_resize();
CPointsCurve->forceResize();
break; break;
default: // (DCT_Linear, DCT_Unchanged) default: // (DCT_Linear, DCT_Unchanged)
// ... do nothing // ... do nothing
@@ -202,9 +202,9 @@ void FlatCurveEditorSubGroup::savePressed () {
int ix = 0; int ix = 0;
if (p[ix]==(double)(FCT_Linear)) if (p[ix]==(double)(FCT_Linear))
f << "Linear\n"; f << "Linear" << std::endl;
else if (p[ix]==(double)(FCT_MinMaxCPoints)) else if (p[ix]==(double)(FCT_MinMaxCPoints))
f << "ControlPoints\n"; f << "ControlPoints" << std::endl;
ix++; ix++;
for (unsigned int i=0; i<p.size()/2; i++, ix+=2) for (unsigned int i=0; i<p.size()/2; i++, ix+=2)
f << p[ix] << ' ' << p[ix+1] << std::endl; f << p[ix] << ' ' << p[ix+1] << std::endl;

View File

@@ -35,6 +35,7 @@ MyCurve::MyCurve () : listener(NULL) {
colorProvider = NULL; colorProvider = NULL;
sized = RS_Pending; sized = RS_Pending;
snapToElmt = -100; snapToElmt = -100;
curveIsDirty = true;
set_extension_events(Gdk::EXTENSION_EVENTS_ALL); set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK); add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK);

View File

@@ -81,7 +81,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
* -2 : identity value * -2 : identity value
* -1 : minimum value * -1 : minimum value
* [0;1000[ : control point that it's snapped to * [0;1000[ : control point that it's snapped to
* >=1000 : moved control point which is snapped to to the line made by it neighbors * >=1000 : moved control point which snaps to the line made by its previous and next point
*/ */
int snapToElmt; int snapToElmt;
bool snapTo; bool snapTo;
@@ -89,6 +89,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
double snapToVal; double snapToVal;
MyCurveIdleHelper* mcih; MyCurveIdleHelper* mcih;
enum ResizeState sized; enum ResizeState sized;
bool curveIsDirty;
virtual std::vector<double> get_vector (int veclen) = 0; virtual std::vector<double> get_vector (int veclen) = 0;
int getGraphMinSize() { return GRAPH_SIZE + RADIUS + 1; } int getGraphMinSize() { return GRAPH_SIZE + RADIUS + 1; }
@@ -107,6 +108,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
void updateBackgroundHistogram (LUTu & hist) {return;} ; void updateBackgroundHistogram (LUTu & hist) {return;} ;
void forceResize() { sized = RS_Force; } void forceResize() { sized = RS_Force; }
void refresh(); void refresh();
void setCurveDirty () { curveIsDirty = true; }
void styleChanged (const Glib::RefPtr<Gtk::Style>& style); void styleChanged (const Glib::RefPtr<Gtk::Style>& style);
virtual std::vector<double> getPoints () = 0; virtual std::vector<double> getPoints () = 0;
virtual void setPoints (const std::vector<double>& p) = 0; virtual void setPoints (const std::vector<double>& p) = 0;

View File

@@ -126,6 +126,8 @@ void MyDiagonalCurve::interpolate () {
curve.x.at(activeParam-1) = tmp; curve.x.at(activeParam-1) = tmp;
} }
} }
curveIsDirty = false;
} }
void MyDiagonalCurve::draw (int handle) { void MyDiagonalCurve::draw (int handle) {
@@ -138,7 +140,7 @@ void MyDiagonalCurve::draw (int handle) {
return; return;
// re-calculate curve if dimensions changed // re-calculate curve if dimensions changed
if (prevGraphW != graphW || prevGraphH != graphH || int(point.size()) != graphW-2) if (curveIsDirty || prevGraphW != graphW || prevGraphH != graphH || int(point.size()) != graphW-2)
interpolate (); interpolate ();
Gtk::StateType state = !is_sensitive() ? Gtk::STATE_INSENSITIVE : Gtk::STATE_NORMAL; Gtk::StateType state = !is_sensitive() ? Gtk::STATE_INSENSITIVE : Gtk::STATE_NORMAL;
@@ -368,8 +370,10 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
} }
sized = RS_Pending; sized = RS_Pending;
// setDrawRectangle will allocate the backbuffer Surface // setDrawRectangle will allocate the backbuffer Surface
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) {
interpolate (); setDirty(true);
curveIsDirty = true;
}
draw (lit_point); draw (lit_point);
GdkRectangle *rectangle = &(event->expose.area); GdkRectangle *rectangle = &(event->expose.area);
copySurface(win, rectangle); copySurface(win, rectangle);
@@ -407,7 +411,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
curve.x[closest_point] = clampedX; curve.x[closest_point] = clampedX;
curve.y[closest_point] = clampedY; curve.y[closest_point] = clampedY;
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (closest_point); draw (closest_point);
notifyListener (); notifyListener ();
@@ -449,7 +453,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
if (curve.x.empty()) { if (curve.x.empty()) {
curve.x.push_back (0); curve.x.push_back (0);
curve.y.push_back (0); curve.y.push_back (0);
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (lit_point); draw (lit_point);
} }
@@ -598,7 +602,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) { if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
// we recalculate the curve only if we have to // we recalculate the curve only if we have to
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (lit_point); draw (lit_point);
notifyListener (); notifyListener ();
@@ -751,6 +755,7 @@ void MyDiagonalCurve::setPoints (const std::vector<double>& p) {
} }
activeParam = -1; activeParam = -1;
} }
curveIsDirty = true;
setDirty(true); setDirty(true);
queue_draw (); queue_draw ();
} }
@@ -818,7 +823,7 @@ void MyDiagonalCurve::reset() {
curve.y.at(1) = 1.; curve.y.at(1) = 1.;
grab_point = -1; grab_point = -1;
lit_point = -1; lit_point = -1;
interpolate (); curveIsDirty = true;
break; break;
case DCT_Parametric : case DCT_Parametric :
curve.x.resize(7); curve.x.resize(7);
@@ -833,7 +838,7 @@ void MyDiagonalCurve::reset() {
curve.x.at(6) = 0.00; curve.x.at(6) = 0.00;
grab_point = -1; // not sure that it's necessary grab_point = -1; // not sure that it's necessary
lit_point = -1; // not sure that it's necessary lit_point = -1; // not sure that it's necessary
interpolate (); curveIsDirty = true;
break; break;
default: default:
break; break;

View File

@@ -25,8 +25,8 @@ MyFlatCurve::MyFlatCurve () {
graphW = get_allocation().get_width() - RADIUS * 2; graphW = get_allocation().get_width() - RADIUS * 2;
graphH = get_allocation().get_height() - RADIUS * 2; graphH = get_allocation().get_height() - RADIUS * 2;
prevGraphW = 0; prevGraphW = graphW;
prevGraphH = 0; prevGraphH = graphH;
lit_point = -1; lit_point = -1;
closest_point = 0; closest_point = 0;
buttonPressed = false; buttonPressed = false;
@@ -78,12 +78,14 @@ void MyFlatCurve::interpolate () {
int nbPoints = graphW-2; int nbPoints = graphW-2;
point.resize (nbPoints); point.resize (nbPoints);
std::vector<double> vector = get_vector (nbPoints); std::vector<double> vector = get_vector (nbPoints);
for (int i = 0; i < int(point.size()); ++i) { for (int i = 0; i < nbPoints; ++i) {
float currX = float(i)/float(nbPoints-1); float currX = float(i)/float(nbPoints-1);
point.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i))); point.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
} }
upoint.clear (); upoint.clear ();
lpoint.clear (); lpoint.clear ();
curveIsDirty = false;
} }
void MyFlatCurve::draw () { void MyFlatCurve::draw () {
@@ -96,7 +98,7 @@ void MyFlatCurve::draw () {
return; return;
// re-calculate curve if dimensions changed // re-calculate curve if dimensions changed
if (prevGraphW != graphW || prevGraphH != graphH || (int)point.size() != graphW-2) if (curveIsDirty || prevGraphW != graphW || prevGraphH != graphH || (int)point.size() != graphW-2)
interpolate (); interpolate ();
double innerW = double(graphW-2); double innerW = double(graphW-2);
@@ -455,8 +457,10 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
} }
sized = RS_Pending; sized = RS_Pending;
// setDrawRectangle will allocate the backbuffer Surface // setDrawRectangle will allocate the backbuffer Surface
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) {
interpolate (); setDirty(true);
curveIsDirty = true;
}
draw (); draw ();
GdkRectangle *rectangle = &(event->expose.area); GdkRectangle *rectangle = &(event->expose.area);
copySurface(win, rectangle); copySurface(win, rectangle);
@@ -506,7 +510,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
curve.leftTangent[closest_point] = 0.35; curve.leftTangent[closest_point] = 0.35;
curve.rightTangent[closest_point] = 0.35; curve.rightTangent[closest_point] = 0.35;
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (); draw ();
notifyListener (); notifyListener ();
@@ -595,7 +599,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
curve.y.push_back (0.5); curve.y.push_back (0.5);
curve.leftTangent.push_back (0.3); curve.leftTangent.push_back (0.3);
curve.rightTangent.push_back (0.3); curve.rightTangent.push_back (0.3);
interpolate (); curveIsDirty = true;
} }
} }
} }
@@ -798,7 +802,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
} }
if (curve.leftTangent[lit_point] != prevValue) { if (curve.leftTangent[lit_point] != prevValue) {
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (); draw ();
notifyListener (); notifyListener ();
@@ -823,7 +827,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
} }
if (curve.rightTangent[lit_point] != prevValue) { if (curve.rightTangent[lit_point] != prevValue) {
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (); draw ();
notifyListener (); notifyListener ();
@@ -1034,7 +1038,7 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY) {
if (curve.x[lit_point] != prevPosX || curve.y[lit_point] != prevPosY) { if (curve.x[lit_point] != prevPosX || curve.y[lit_point] != prevPosY) {
// we recompute the curve only if we have to // we recompute the curve only if we have to
interpolate (); curveIsDirty = true;
setDirty(true); setDirty(true);
draw (); draw ();
notifyListener (); notifyListener ();
@@ -1216,6 +1220,7 @@ void MyFlatCurve::setPoints (const std::vector<double>& p) {
curve.rightTangent.push_back (p[ix++]); curve.rightTangent.push_back (p[ix++]);
} }
} }
curveIsDirty = true;
setDirty(true); setDirty(true);
queue_draw (); queue_draw ();
} }
@@ -1233,7 +1238,7 @@ void MyFlatCurve::reset() {
case FCT_MinMaxCPoints : case FCT_MinMaxCPoints :
defaultCurve(); defaultCurve();
lit_point = -1; lit_point = -1;
interpolate (); curveIsDirty = true;
break; break;
//case Parametric : //case Parametric :
// Nothing to do (?) // Nothing to do (?)
@@ -1246,17 +1251,16 @@ void MyFlatCurve::reset() {
void MyFlatCurve::defaultCurve () { void MyFlatCurve::defaultCurve () {
curve.x.clear(); curve.x.resize(6);
curve.y.clear(); curve.y.resize(6);
curve.leftTangent.clear(); curve.leftTangent.resize(6);
curve.rightTangent.clear(); curve.rightTangent.resize(6);
// Point for RGBCMY colors // Point for RGBCMY colors
for (int i=0; i<6; i++) { for (int i=0; i<6; i++) {
curve.x.push_back((1./6.)*i); curve.x.at(i) = (1./6.)*i;
curve.y.push_back(0.5); curve.y.at(i) = 0.5;
curve.leftTangent.push_back(0.35); curve.leftTangent.at(i) = 0.35;
curve.rightTangent.push_back(0.35); curve.rightTangent.at(i) = 0.35;
} }
} }