Adding more possibilities to the ColorProvider class

This commit is contained in:
Hombre
2014-06-14 15:18:25 +02:00
parent 7d981c4a0a
commit 02240ae504
18 changed files with 88 additions and 26 deletions

View File

@@ -662,10 +662,13 @@ bool BlackWhite::curveMode1Changed2_ () {
return false;
}
*/
void BlackWhite::colorForValue (double valX, double valY, int callerId, ColorCaller* caller) {
void BlackWhite::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) {
float r, g, b;
if (elemType == ColorCaller::CCET_VERTICAL_BAR)
valY = 0.5f;
if (callerId == 1) { // Hue = f(Hue)
float h = float((valY - 0.5) * 2. + valX);

View File

@@ -122,7 +122,7 @@ class BlackWhite : public ToolParamBlock, public AdjusterListener, public Foldab
void methodChanged ();
void filterChanged ();
void settingChanged ();
virtual void colorForValue (double valX, double valY, int callerId, ColorCaller* caller);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
void BWChanged (double redbw, double greenbw, double bluebw);
bool BWComputed_ ();
void curveChanged (CurveEditor* ce);

View File

@@ -932,9 +932,13 @@ bool ColorAppearance::adapCamComputed_ () {
}
void ColorAppearance::colorForValue (double valX, double valY, int callerId, ColorCaller *caller) {
void ColorAppearance::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) {
float R, G, B;
if (elemType==ColorCaller::CCET_VERTICAL_BAR)
valY = 0.5;
if (callerId == 1) { // cc - bottom bar
float value = (1.f - 0.7f) * float(valX) + 0.7f;

View File

@@ -134,7 +134,7 @@ class ColorAppearance : public ToolParamBlock, public AdjusterListener, public F
void setAdjusterBehavior (bool degreeadd, bool adapscenadd, bool adaplumadd, bool badpixsladd, bool jlightadd, bool chromaadd, bool contrastadd, bool rstprotectionadd, bool qbrightadd, bool qcontrastadd, bool schromaadd, bool mchromaadd, bool colorhadd);
void trimValues (rtengine::procparams::ProcParams* pp);
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve,/* LUTu & histCLurve, LUTu & histLLCurve,*/ LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma);
virtual void colorForValue (double valX, double valY, int callerId, ColorCaller *caller);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller);
};
#endif

View File

@@ -104,7 +104,7 @@ void ColoredBar::draw() {
double y_ = double((h-1)-y);
double x01 = x_ /double(w-1);
double y01 = double(y)/double(h-1);
colorProvider->colorForValue (x01, y01, colorCallerId, this);
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
@@ -118,7 +118,7 @@ void ColoredBar::draw() {
double y_ = double((h-1)-y);
double x01 = double(x)/double(w-1);
double y01 = double(y)/double(h-1);
colorProvider->colorForValue (x01, y01, colorCallerId, this);
colorProvider->colorForValue (x01, y01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
@@ -132,7 +132,7 @@ void ColoredBar::draw() {
double y_ = double((h-1)-y);
double x01 = double(x)/double(w-1);
double y01 = double(y)/double(h-1);
colorProvider->colorForValue (y01, x01, colorCallerId, this);
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();
@@ -147,7 +147,7 @@ void ColoredBar::draw() {
double y_ = double( y);
double x01 = x_/double(w-1);
double y01 = y_/double(h-1);
colorProvider->colorForValue (y01, x01, colorCallerId, this);
colorProvider->colorForValue (y01, x01, CCET_BACKGROUND, colorCallerId, this);
cr->set_source_rgb(ccRed, ccGreen, ccBlue);
cr->rectangle(x_, y_, 1., 1.);
cr->fill();

View File

@@ -34,6 +34,12 @@ class ColorCaller {
ColorProvider* colorProvider;
public:
enum ElemType {
CCET_POINT,
CCET_VERTICAL_BAR,
CCET_HORIZONTAL_BAR,
CCET_BACKGROUND
};
double ccRed;
double ccGreen;
double ccBlue;
@@ -52,7 +58,7 @@ class ColorProvider {
public:
virtual ~ColorProvider() {};
virtual void colorForValue (double valX, double valY, int callerId, ColorCaller* caller) {};
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) {};
};
#endif

View File

@@ -73,9 +73,13 @@ Defringe::~Defringe () {
delete curveEditorPF;
}
void Defringe::colorForValue (double valX, double valY, int callerId, ColorCaller *caller) {
void Defringe::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) {
float R, G, B;
if (elemType==ColorCaller::CCET_VERTICAL_BAR)
valY = 0.5;
if (callerId == 1) { // ch
Color::hsv2rgb01(float(valX), float(valY), 0.5f, R, G, B);
}

View File

@@ -53,7 +53,7 @@ class Defringe : public ToolParamBlock, public AdjusterListener, public Foldable
void adjusterChanged (Adjuster* a, double newval);
void enabledChanged ();
virtual void colorForValue (double valX, double valY, int callerId, ColorCaller* caller);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
};

View File

@@ -177,6 +177,11 @@ private:
};
typedef enum RTUpdatePolicy {
RTUP_STATIC,
RTUP_DYNAMIC
} eUpdatePolicy;
typedef enum RTOrientation {
RTO_Left2Right,
RTO_Bottom2Top,

View File

@@ -134,10 +134,13 @@ void HSVEqualizer::curveChanged (CurveEditor* ce) {
}
}
void HSVEqualizer::colorForValue (double valX, double valY, int callerId, ColorCaller* caller) {
void HSVEqualizer::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller) {
float r, g, b;
if (elemType==ColorCaller::CCET_VERTICAL_BAR)
valY = 0.5;
if (callerId == 1) { // Hue = f(Hue)
float h = float((valY - 0.5) * 2. + valX);

View File

@@ -51,7 +51,7 @@ public:
void setBatchMode (bool batchMode);
void setEditProvider (EditDataProvider *provider);
void autoOpenCurve ();
virtual void colorForValue (double valX, double valY, int callerId, ColorCaller* caller);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
//void adjusterChanged (Adjuster* a, double newval);
};

View File

@@ -489,9 +489,13 @@ void LCurve::adjusterChanged (Adjuster* a, double newval) {
}
}
void LCurve::colorForValue (double valX, double valY, int callerId, ColorCaller *caller) {
void LCurve::colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller *caller) {
float R, G, B;
if (elemType==ColorCaller::CCET_VERTICAL_BAR)
valY = 0.5;
if (callerId == 1) { // ch - main curve
Color::hsv2rgb01(float(valX), float(valY), 0.5f, R, G, B);

View File

@@ -75,7 +75,7 @@ class LCurve : public ToolParamBlock, public AdjusterListener, public FoldableTo
void updateCurveBackgroundHistogram (LUTu & histToneCurve, LUTu & histLCurve, LUTu & histCCurve,/* LUTu & histCLurve, LUTu & histLLCurve,*/ LUTu & histLCAM, LUTu & histCCAM, LUTu & histRed, LUTu & histGreen, LUTu & histBlue, LUTu & histLuma);
virtual void colorForValue (double valX, double valY, int callerId, ColorCaller* caller);
virtual void colorForValue (double valX, double valY, enum ColorCaller::ElemType elemType, int callerId, ColorCaller* caller);
};
#endif

View File

@@ -216,7 +216,7 @@ void MyFlatCurve::draw () {
int coloredLineWidth = min( max(75,graphW)/75, 8 );
cr->set_line_width (coloredLineWidth);
colorProvider->colorForValue(curve.x.at(i), 0.5, colorCallerId, this);
colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), CCET_VERTICAL_BAR, colorCallerId, this);
cr->set_source_rgb (ccRed, ccGreen, ccBlue);
if ( i==lit_point && (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointX)) ) {
@@ -236,7 +236,7 @@ void MyFlatCurve::draw () {
cr->set_line_width (2*coloredLineWidth);
}
colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), colorCallerId, this);
colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), CCET_HORIZONTAL_BAR, colorCallerId, this);
cr->set_source_rgb (ccRed, ccGreen, ccBlue);
cr->move_to (double(graphX+1) , double(graphY-1) - innerH*curve.y.at(lit_point));
@@ -252,7 +252,7 @@ void MyFlatCurve::draw () {
else {
cr->set_source_rgb (0.5, 0.0, 0.0);
if ( (area&(FCT_Area_H|FCT_Area_V|FCT_Area_Point)) || editedHandle==FCT_EditedHandle_CPointUD ) {
if ((lit_point>-1) && ((area&(FCT_Area_H|FCT_Area_V|FCT_Area_Point)) || editedHandle==FCT_EditedHandle_CPointUD) ) {
// draw the lit_point's vertical line
if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) {
cr->set_line_width (2.0);
@@ -364,7 +364,7 @@ void MyFlatCurve::draw () {
if (curve.x.at(i) != -1.) {
if (i == lit_point) {
if (colorProvider) {
colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), colorCallerId, this);
colorProvider->colorForValue(curve.x.at(i), curve.y.at(i), CCET_POINT, colorCallerId, this);
cr->set_source_rgb (ccRed, ccGreen, ccBlue);
}
else

View File

@@ -211,11 +211,24 @@ void ThresholdAdjuster::setValue (double bottomLeft, double topLeft, double bott
afterReset = false;
}
inline void ThresholdAdjuster::getValue (Glib::ustring& bottom, Glib::ustring& top) {
void ThresholdAdjuster::getValue (double& bottom, double& top) {
tSelector.getPositions<double> (bottom, top);
}
void ThresholdAdjuster::getValue (double& bottomLeft, double& topLeft, double& bottomRight, double& topRight) {
tSelector.getPositions<double> (bottomLeft, topLeft, bottomRight, topRight);
}
void ThresholdAdjuster::getValue (int& bottom, int& top) {
tSelector.getPositions<int> (bottom, top);
}
void ThresholdAdjuster::getValue (int& bottomLeft, int& topLeft, int& bottomRight, int& topRight) {
tSelector.getPositions<int> (bottomLeft, topLeft, bottomRight, topRight);
}
void ThresholdAdjuster::getValue (Glib::ustring& bottom, Glib::ustring& top) {
tSelector.getPositions (bottom, top);
}
inline void ThresholdAdjuster::getValue (Glib::ustring& bottomLeft, Glib::ustring& topLeft, Glib::ustring& bottomRight, Glib::ustring& topRight) {
void ThresholdAdjuster::getValue (Glib::ustring& bottomLeft, Glib::ustring& topLeft, Glib::ustring& bottomRight, Glib::ustring& topRight) {
tSelector.getPositions (bottomLeft, topLeft, bottomRight, topRight);
}
@@ -228,7 +241,7 @@ bool ThresholdAdjuster::notifyListener () {
return false;
}
inline void ThresholdAdjuster::setBgCurveProvider (ThresholdCurveProvider* provider) {
void ThresholdAdjuster::setBgCurveProvider (ThresholdCurveProvider* provider) {
tSelector.setBgCurveProvider(provider);
}

View File

@@ -119,6 +119,8 @@ class ThresholdAdjuster : public Gtk::VBox {
void showEditedCB ();
void block(bool isBlocked) { blocked = isBlocked; }
void setBgGradient (const std::vector<GradientMilestone> &milestones) { tSelector.setBgGradient (milestones); }
void setBgColorProvider (ColorProvider *cp, int i) { tSelector.setColorProvider(cp, i); }
void setUpdatePolicy (eUpdatePolicy policy) { tSelector.setUpdatePolicy(policy); }
//void spinChanged ();
void selectorChanged ();

View File

@@ -132,6 +132,7 @@ ThresholdSelector::ThresholdSelector(double minValue, double maxValue, double de
void ThresholdSelector::initValues () {
updatePolicy = RTUP_STATIC;
additionalTTip = "";
oldLitCursor = litCursor = TS_UNDEFINED;
movedCursor = TS_UNDEFINED;
@@ -141,6 +142,7 @@ void ThresholdSelector::initValues () {
set_name("ThresholdSelector");
set_can_focus(false);
set_app_paintable(true);
setDirty(true);
updateTooltip();
}
@@ -150,6 +152,8 @@ void ThresholdSelector::initValues () {
void ThresholdSelector::setPositions (double bottom, double top) {
setPositions(bottom, top, maxValBottom, maxValTop);
if (updatePolicy==RTUP_DYNAMIC)
setDirty(true);
}
/*
@@ -165,6 +169,8 @@ void ThresholdSelector::setPositions (double bottomLeft, double topLeft, double
positions[TS_TOPRIGHT] = topRight;
if (different) {
if (updatePolicy==RTUP_DYNAMIC)
setDirty(true);
sig_val_changed.emit();
updateTooltip();
queue_draw ();
@@ -267,6 +273,7 @@ bool ThresholdSelector::on_expose_event(GdkEventExpose* event) {
}
else {
if (!separatedSliders) {
double yStart = initalEq1 ? double(int(float(h)*1.5f/7.f))+1.5 : double(int(float(h)*5.5f/7.f))-0.5;
double yEnd = initalEq1 ? double(int(float(h)*5.5f/7.f))-0.5 : double(int(float(h)*1.5f/7.f))+1.5;
ThreshCursorId p[4];
@@ -287,6 +294,7 @@ bool ThresholdSelector::on_expose_event(GdkEventExpose* event) {
cr->line_to (hb+hwslider+iw+0.5, yStart);
}
}
}
if (is_sensitive() && bgGradient.size()>1) {
// draw surrounding curve
c = style->get_bg (state);
@@ -444,6 +452,10 @@ bool ThresholdSelector::on_motion_notify_event (GdkEventMotion* event) {
// set the new reference value for the next move
tmpX = event->x;
// ask to redraw the background
if (updatePolicy==RTUP_DYNAMIC)
setDirty(true);
// update the tooltip
updateTooltip();
@@ -597,11 +609,15 @@ void ThresholdSelector::reset () {
positions[1] = defPos[1];
positions[2] = defPos[2];
positions[3] = defPos[3];
if (updatePolicy==RTUP_DYNAMIC)
setDirty(true);
updateTooltip();
queue_draw ();
}
inline double ThresholdSelector::to01(ThreshCursorId cursorId) {
double ThresholdSelector::to01(ThreshCursorId cursorId) {
double rVal;
if (cursorId==TS_BOTTOMLEFT || cursorId==TS_BOTTOMRIGHT)
@@ -613,15 +629,15 @@ inline double ThresholdSelector::to01(ThreshCursorId cursorId) {
return rVal;
}
inline void ThresholdSelector::setBgCurveProvider (ThresholdCurveProvider* provider) {
void ThresholdSelector::setBgCurveProvider (ThresholdCurveProvider* provider) {
bgCurveProvider = provider;
}
inline void ThresholdSelector::setSeparatedSliders(bool separated) {
void ThresholdSelector::setSeparatedSliders(bool separated) {
separatedSliders = separated;
}
inline bool ThresholdSelector::getSeparatedSliders() {
bool ThresholdSelector::getSeparatedSliders() {
return separatedSliders;
}

View File

@@ -97,6 +97,7 @@ class ThresholdSelector : public Gtk::DrawingArea, public ColoredBar {
double defPos[4];
double positions[4];
unsigned short wslider;
eUpdatePolicy updatePolicy;
const static int hb = 3; // horizontal border
const static int vb = 2; // vertical border
@@ -194,6 +195,7 @@ class ThresholdSelector : public Gtk::DrawingArea, public ColoredBar {
void styleChanged (const Glib::RefPtr<Gtk::Style>& style);
unsigned int getPrecision () { return precisionTop; }
void reset ();
void setUpdatePolicy (eUpdatePolicy policy) { updatePolicy = policy; }
void set_tooltip_markup(const Glib::ustring& markup);
// this set_tooltip_text method is to set_tooltip_markup, and text can contain markups
void set_tooltip_text(const Glib::ustring& text);