Solving issue 1528: "HSV equalizer channels sometimes can't be switched properly"
This commit is contained in:
@@ -332,9 +332,9 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
|
||||
customCurve->setPoints (dCurve->customCurveEd);
|
||||
customCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
||||
customCurve->setColoredBar(leftBar, bottomBar);
|
||||
customCurve->forceResize();
|
||||
parent->pack_start (*customCurveBox);
|
||||
customCurveBox->check_resize();
|
||||
customCurve->forceResize();
|
||||
break;
|
||||
case (DCT_Parametric):
|
||||
{
|
||||
@@ -362,17 +362,17 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
|
||||
shcSelector->setBgGradient(bgGradient);
|
||||
shcSelector->setMargins( (leftBar ? MyCurve::getBarWidth()+CBAR_MARGIN : RADIUS), RADIUS );
|
||||
paramCurve->setColoredBar(leftBar, NULL);
|
||||
parent->pack_start (*paramCurveBox);
|
||||
paramCurve->forceResize();
|
||||
parent->pack_start (*paramCurveBox);
|
||||
break;
|
||||
}
|
||||
case (DCT_NURBS):
|
||||
NURBSCurve->setPoints (dCurve->NURBSCurveEd);
|
||||
NURBSCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
||||
NURBSCurve->setColoredBar(leftBar, bottomBar);
|
||||
NURBSCurve->forceResize();
|
||||
parent->pack_start (*NURBSCurveBox);
|
||||
NURBSCurveBox->check_resize();
|
||||
NURBSCurve->forceResize();
|
||||
break;
|
||||
default: // (DCT_Linear, DCT_Unchanged)
|
||||
// ... do nothing
|
||||
@@ -407,13 +407,13 @@ void DiagonalCurveEditorSubGroup::savePressed () {
|
||||
|
||||
int ix = 0;
|
||||
if (p[ix]==(double)(DCT_Linear))
|
||||
f << "Linear\n";
|
||||
f << "Linear" << std::endl;
|
||||
else if (p[ix]==(double)(DCT_Spline))
|
||||
f << "Spline\n";
|
||||
f << "Spline" << std::endl;
|
||||
else if (p[ix]==(double)(DCT_NURBS))
|
||||
f << "NURBS\n";
|
||||
f << "NURBS" << std::endl;
|
||||
else if (p[ix]==(double)(DCT_Parametric))
|
||||
f << "Parametric\n";
|
||||
f << "Parametric" << std::endl;
|
||||
if (p[ix]==(double)(DCT_Parametric)) {
|
||||
ix++;
|
||||
for (unsigned int i=0; i<p.size()-1; i++, ix++)
|
||||
|
@@ -171,9 +171,9 @@ void FlatCurveEditorSubGroup::switchGUI() {
|
||||
CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
|
||||
CPointsCurve->setColorProvider(dCurve->getCurveColorProvider(), dCurve->getCurveCallerId());
|
||||
CPointsCurve->setColoredBar(leftBar, bottomBar);
|
||||
CPointsCurve->forceResize();
|
||||
parent->pack_start (*CPointsCurveBox);
|
||||
CPointsCurveBox->check_resize();
|
||||
CPointsCurve->forceResize();
|
||||
break;
|
||||
default: // (DCT_Linear, DCT_Unchanged)
|
||||
// ... do nothing
|
||||
@@ -202,9 +202,9 @@ void FlatCurveEditorSubGroup::savePressed () {
|
||||
|
||||
int ix = 0;
|
||||
if (p[ix]==(double)(FCT_Linear))
|
||||
f << "Linear\n";
|
||||
f << "Linear" << std::endl;
|
||||
else if (p[ix]==(double)(FCT_MinMaxCPoints))
|
||||
f << "ControlPoints\n";
|
||||
f << "ControlPoints" << std::endl;
|
||||
ix++;
|
||||
for (unsigned int i=0; i<p.size()/2; i++, ix+=2)
|
||||
f << p[ix] << ' ' << p[ix+1] << std::endl;
|
||||
@@ -291,7 +291,7 @@ void FlatCurveEditorSubGroup::storeCurveValues (CurveEditor* ce, const std::vect
|
||||
const std::vector<double> FlatCurveEditorSubGroup::getCurveFromGUI (int type) {
|
||||
switch ((FlatCurveType)type) {
|
||||
case (FCT_MinMaxCPoints):
|
||||
return CPointsCurve->getPoints ();
|
||||
return CPointsCurve->getPoints ();
|
||||
default: {
|
||||
// linear and other solutions
|
||||
std::vector<double> lcurve (1);
|
||||
|
@@ -35,6 +35,7 @@ MyCurve::MyCurve () : listener(NULL) {
|
||||
colorProvider = NULL;
|
||||
sized = RS_Pending;
|
||||
snapToElmt = -100;
|
||||
curveIsDirty = true;
|
||||
|
||||
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);
|
||||
|
@@ -81,7 +81,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
|
||||
* -2 : identity value
|
||||
* -1 : minimum value
|
||||
* [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;
|
||||
bool snapTo;
|
||||
@@ -89,6 +89,7 @@ class MyCurve : public Gtk::DrawingArea, public BackBuffer, public ColorCaller {
|
||||
double snapToVal;
|
||||
MyCurveIdleHelper* mcih;
|
||||
enum ResizeState sized;
|
||||
bool curveIsDirty;
|
||||
|
||||
virtual std::vector<double> get_vector (int veclen) = 0;
|
||||
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 forceResize() { sized = RS_Force; }
|
||||
void refresh();
|
||||
void setCurveDirty () { curveIsDirty = true; }
|
||||
void styleChanged (const Glib::RefPtr<Gtk::Style>& style);
|
||||
virtual std::vector<double> getPoints () = 0;
|
||||
virtual void setPoints (const std::vector<double>& p) = 0;
|
||||
|
@@ -100,7 +100,7 @@ void MyDiagonalCurve::interpolate () {
|
||||
point.resize (nbPoints);
|
||||
std::vector<double> vector = get_vector (nbPoints);
|
||||
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)));
|
||||
}
|
||||
upoint.clear ();
|
||||
@@ -114,31 +114,33 @@ void MyDiagonalCurve::interpolate () {
|
||||
curve.x.at(activeParam-1) = 100;
|
||||
vector = get_vector (nbPoints);
|
||||
for (int i = 0; i < nbPoints; ++i) {
|
||||
float currX = float(i)/float(nbPoints-1);
|
||||
upoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||
float currX = float(i)/float(nbPoints-1);
|
||||
upoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||
}
|
||||
curve.x.at(activeParam-1) = -100;
|
||||
vector = get_vector (nbPoints);
|
||||
for (int i = 0; i < nbPoints; ++i) {
|
||||
float currX = float(i)/float(nbPoints-1);
|
||||
lpoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||
float currX = float(i)/float(nbPoints-1);
|
||||
lpoint.at(i).setCoords(float(graphX)+1.5f+float(graphW-3)*currX, float(graphY)-1.5f-float(graphH-3)*float(vector.at(i)));
|
||||
}
|
||||
curve.x.at(activeParam-1) = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
curveIsDirty = false;
|
||||
}
|
||||
|
||||
void MyDiagonalCurve::draw (int handle) {
|
||||
if (!isDirty()) {
|
||||
return;
|
||||
}
|
||||
if (!isDirty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Window > win = get_window();
|
||||
Glib::RefPtr<Gdk::Window > win = get_window();
|
||||
if (!surfaceCreated() || !win)
|
||||
return;
|
||||
|
||||
// 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 ();
|
||||
|
||||
Gtk::StateType state = !is_sensitive() ? Gtk::STATE_INSENSITIVE : Gtk::STATE_NORMAL;
|
||||
@@ -159,7 +161,7 @@ void MyDiagonalCurve::draw (int handle) {
|
||||
unsigned int valMax = 0;
|
||||
for (int i=0; i<256; i++)
|
||||
if (bghist[i]>valMax)
|
||||
valMax = bghist[i];
|
||||
valMax = bghist[i];
|
||||
// draw histogram
|
||||
cr->set_line_width (1.0);
|
||||
double stepSize = (graphW-3) / 255.0;
|
||||
@@ -175,7 +177,7 @@ void MyDiagonalCurve::draw (int handle) {
|
||||
//if (i>0)
|
||||
cr->line_to (double(graphX)+1.5+double(i)*stepSize, double(graphY-1)-val);
|
||||
}
|
||||
cr->line_to (double(graphX)+1.5+255.*stepSize, double(graphY-1));
|
||||
cr->line_to (double(graphX)+1.5+255.*stepSize, double(graphY-1));
|
||||
cr->close_path();
|
||||
cr->fill ();
|
||||
}
|
||||
@@ -268,7 +270,7 @@ void MyDiagonalCurve::draw (int handle) {
|
||||
// draw the left colored bar
|
||||
if (leftBar) {
|
||||
// first the background
|
||||
int bWidth = getBarWidth();
|
||||
int bWidth = getBarWidth();
|
||||
BackBuffer *bb = this;
|
||||
leftBar->setDrawRectangle(win, 1, graphY-graphH+1, bWidth-2, graphH-2);
|
||||
leftBar->expose(bb);
|
||||
@@ -283,8 +285,8 @@ void MyDiagonalCurve::draw (int handle) {
|
||||
// draw the bottom colored bar
|
||||
if (bottomBar) {
|
||||
// first the background
|
||||
int bWidth = getBarWidth();
|
||||
BackBuffer *bb = this;
|
||||
int bWidth = getBarWidth();
|
||||
BackBuffer *bb = this;
|
||||
bottomBar->setDrawRectangle(win, graphX+1, graphY+CBAR_MARGIN+1, graphW-2, bWidth-2);
|
||||
bottomBar->expose(bb);
|
||||
|
||||
@@ -368,11 +370,13 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
||||
}
|
||||
sized = RS_Pending;
|
||||
// setDrawRectangle will allocate the backbuffer Surface
|
||||
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height()))
|
||||
interpolate ();
|
||||
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) {
|
||||
setDirty(true);
|
||||
curveIsDirty = true;
|
||||
}
|
||||
draw (lit_point);
|
||||
GdkRectangle *rectangle = &(event->expose.area);
|
||||
copySurface(win, rectangle);
|
||||
copySurface(win, rectangle);
|
||||
|
||||
retval = true;
|
||||
break;
|
||||
@@ -407,7 +411,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
||||
curve.x[closest_point] = clampedX;
|
||||
curve.y[closest_point] = clampedY;
|
||||
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw (closest_point);
|
||||
notifyListener ();
|
||||
@@ -449,7 +453,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
||||
if (curve.x.empty()) {
|
||||
curve.x.push_back (0);
|
||||
curve.y.push_back (0);
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw (lit_point);
|
||||
}
|
||||
@@ -598,7 +602,7 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
||||
|
||||
if (curve.x[grab_point] != prevPosX || curve.y[grab_point] != prevPosY) {
|
||||
// we recalculate the curve only if we have to
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw (lit_point);
|
||||
notifyListener ();
|
||||
@@ -751,6 +755,7 @@ void MyDiagonalCurve::setPoints (const std::vector<double>& p) {
|
||||
}
|
||||
activeParam = -1;
|
||||
}
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
queue_draw ();
|
||||
}
|
||||
@@ -818,7 +823,7 @@ void MyDiagonalCurve::reset() {
|
||||
curve.y.at(1) = 1.;
|
||||
grab_point = -1;
|
||||
lit_point = -1;
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
break;
|
||||
case DCT_Parametric :
|
||||
curve.x.resize(7);
|
||||
@@ -833,11 +838,11 @@ void MyDiagonalCurve::reset() {
|
||||
curve.x.at(6) = 0.00;
|
||||
grab_point = -1; // not sure that it's necessary
|
||||
lit_point = -1; // not sure that it's necessary
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
setDirty(true);
|
||||
setDirty(true);
|
||||
draw(-1);
|
||||
}
|
||||
|
@@ -25,8 +25,8 @@ MyFlatCurve::MyFlatCurve () {
|
||||
|
||||
graphW = get_allocation().get_width() - RADIUS * 2;
|
||||
graphH = get_allocation().get_height() - RADIUS * 2;
|
||||
prevGraphW = 0;
|
||||
prevGraphH = 0;
|
||||
prevGraphW = graphW;
|
||||
prevGraphH = graphH;
|
||||
lit_point = -1;
|
||||
closest_point = 0;
|
||||
buttonPressed = false;
|
||||
@@ -78,25 +78,27 @@ void MyFlatCurve::interpolate () {
|
||||
int nbPoints = graphW-2;
|
||||
point.resize (nbPoints);
|
||||
std::vector<double> vector = get_vector (nbPoints);
|
||||
for (int i = 0; i < int(point.size()); ++i) {
|
||||
float currX = float(i)/float(nbPoints-1);
|
||||
for (int i = 0; i < nbPoints; ++i) {
|
||||
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)));
|
||||
}
|
||||
upoint.clear ();
|
||||
lpoint.clear ();
|
||||
|
||||
curveIsDirty = false;
|
||||
}
|
||||
|
||||
void MyFlatCurve::draw () {
|
||||
if (!isDirty()) {
|
||||
return;
|
||||
}
|
||||
if (!isDirty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Glib::RefPtr<Gdk::Window> win = get_window();
|
||||
if (!surfaceCreated() || !win)
|
||||
return;
|
||||
|
||||
// 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 ();
|
||||
|
||||
double innerW = double(graphW-2);
|
||||
@@ -135,7 +137,7 @@ void MyFlatCurve::draw () {
|
||||
// draw the left colored bar
|
||||
if (leftBar) {
|
||||
// first the background
|
||||
int bWidth = getBarWidth();
|
||||
int bWidth = getBarWidth();
|
||||
BackBuffer *bb = this;
|
||||
leftBar->setDrawRectangle(win, 1, graphY-graphH+1, bWidth-2, graphH-2);
|
||||
leftBar->expose(bb);
|
||||
@@ -150,7 +152,7 @@ void MyFlatCurve::draw () {
|
||||
// draw the bottom colored bar
|
||||
if (bottomBar) {
|
||||
// first the background
|
||||
int bWidth = getBarWidth();
|
||||
int bWidth = getBarWidth();
|
||||
BackBuffer *bb = this;
|
||||
bottomBar->setDrawRectangle(win, graphX+1, graphY+CBAR_MARGIN+1, graphW-2, bWidth-2);
|
||||
bottomBar->expose(bb);
|
||||
@@ -371,7 +373,7 @@ void MyFlatCurve::draw () {
|
||||
}
|
||||
|
||||
setDirty(false);
|
||||
queue_draw();
|
||||
queue_draw();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -455,13 +457,15 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
||||
}
|
||||
sized = RS_Pending;
|
||||
// setDrawRectangle will allocate the backbuffer Surface
|
||||
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height()))
|
||||
interpolate ();
|
||||
if (setDrawRectangle(win, 0, 0, get_allocation().get_width(), get_allocation().get_height())) {
|
||||
setDirty(true);
|
||||
curveIsDirty = true;
|
||||
}
|
||||
draw ();
|
||||
GdkRectangle *rectangle = &(event->expose.area);
|
||||
copySurface(win, rectangle);
|
||||
copySurface(win, rectangle);
|
||||
|
||||
retval = true;
|
||||
retval = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -506,7 +510,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
||||
curve.leftTangent[closest_point] = 0.35;
|
||||
curve.rightTangent[closest_point] = 0.35;
|
||||
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw ();
|
||||
notifyListener ();
|
||||
@@ -595,7 +599,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
||||
curve.y.push_back (0.5);
|
||||
curve.leftTangent.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) {
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw ();
|
||||
notifyListener ();
|
||||
@@ -823,7 +827,7 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
||||
}
|
||||
|
||||
if (curve.rightTangent[lit_point] != prevValue) {
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw ();
|
||||
notifyListener ();
|
||||
@@ -1034,7 +1038,7 @@ void MyFlatCurve::movePoint(bool moveX, bool moveY) {
|
||||
|
||||
if (curve.x[lit_point] != prevPosX || curve.y[lit_point] != prevPosY) {
|
||||
// we recompute the curve only if we have to
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
draw ();
|
||||
notifyListener ();
|
||||
@@ -1216,6 +1220,7 @@ void MyFlatCurve::setPoints (const std::vector<double>& p) {
|
||||
curve.rightTangent.push_back (p[ix++]);
|
||||
}
|
||||
}
|
||||
curveIsDirty = true;
|
||||
setDirty(true);
|
||||
queue_draw ();
|
||||
}
|
||||
@@ -1233,30 +1238,29 @@ void MyFlatCurve::reset() {
|
||||
case FCT_MinMaxCPoints :
|
||||
defaultCurve();
|
||||
lit_point = -1;
|
||||
interpolate ();
|
||||
curveIsDirty = true;
|
||||
break;
|
||||
//case Parametric :
|
||||
// Nothing to do (?)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
setDirty(true);
|
||||
setDirty(true);
|
||||
draw();
|
||||
}
|
||||
|
||||
void MyFlatCurve::defaultCurve () {
|
||||
|
||||
curve.x.clear();
|
||||
curve.y.clear();
|
||||
curve.leftTangent.clear();
|
||||
curve.rightTangent.clear();
|
||||
curve.x.resize(6);
|
||||
curve.y.resize(6);
|
||||
curve.leftTangent.resize(6);
|
||||
curve.rightTangent.resize(6);
|
||||
|
||||
// Point for RGBCMY colors
|
||||
for (int i=0; i<6; i++) {
|
||||
curve.x.push_back((1./6.)*i);
|
||||
curve.y.push_back(0.5);
|
||||
curve.leftTangent.push_back(0.35);
|
||||
curve.rightTangent.push_back(0.35);
|
||||
curve.x.at(i) = (1./6.)*i;
|
||||
curve.y.at(i) = 0.5;
|
||||
curve.leftTangent.at(i) = 0.35;
|
||||
curve.rightTangent.at(i) = 0.35;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user