Bugfix in LabGrid class + code refactoring
- suppressed trailing `_` char for class' parameters - renamed function name (those not related to Gtk) to lowerCamelCase - changed the mecanism of dragging point, to avoid throwing unecessary `panelChange` event - added a `reset` function, with support of `toInitial` to get back the values at load time (CTRL+click on reset button) - `on_draw` optimisation: now LabGrid IS A BackBuffer
This commit is contained in:
@@ -1381,6 +1381,7 @@ TP_COLORTONING_HIGHLIGHT;Hautes lumières
|
|||||||
TP_COLORTONING_HUE;Teinte
|
TP_COLORTONING_HUE;Teinte
|
||||||
TP_COLORTONING_LAB;Mixage Lab
|
TP_COLORTONING_LAB;Mixage Lab
|
||||||
TP_COLORTONING_LABEL;Virage Partiel
|
TP_COLORTONING_LABEL;Virage Partiel
|
||||||
|
TP_COLORTONING_LABGRID_VALUES;HL: a=%1 b=%2\nO: a=%3 b=%4
|
||||||
TP_COLORTONING_LUMA;Luminance
|
TP_COLORTONING_LUMA;Luminance
|
||||||
TP_COLORTONING_LUMAMODE;Préserver la luminance
|
TP_COLORTONING_LUMAMODE;Préserver la luminance
|
||||||
TP_COLORTONING_LUMAMODE_TOOLTIP;Si activé, lorsque vous changez la couleur (rouge, vert, cyan, bleu, etc.), la luminance de chaque pixel est préservé
|
TP_COLORTONING_LUMAMODE_TOOLTIP;Si activé, lorsque vous changez la couleur (rouge, vert, cyan, bleu, etc.), la luminance de chaque pixel est préservé
|
||||||
|
@@ -1407,6 +1407,7 @@ TP_COLORTONING_HUE;Hue
|
|||||||
TP_COLORTONING_LAB;L*a*b* blending
|
TP_COLORTONING_LAB;L*a*b* blending
|
||||||
TP_COLORTONING_LABEL;Color Toning
|
TP_COLORTONING_LABEL;Color Toning
|
||||||
TP_COLORTONING_LABGRID;L*a*b* color correction grid
|
TP_COLORTONING_LABGRID;L*a*b* color correction grid
|
||||||
|
TP_COLORTONING_LABGRID_VALUES;HL: a=%1 b=%2\nS: a=%3 b=%4
|
||||||
TP_COLORTONING_LUMA;Luminance
|
TP_COLORTONING_LUMA;Luminance
|
||||||
TP_COLORTONING_LUMAMODE;Preserve luminance
|
TP_COLORTONING_LUMAMODE;Preserve luminance
|
||||||
TP_COLORTONING_LUMAMODE_TOOLTIP;If enabled, when you change color (red, green, cyan, blue, etc.) the luminance of each pixel is preserved.
|
TP_COLORTONING_LUMAMODE_TOOLTIP;If enabled, when you change color (red, green, cyan, blue, etc.) the luminance of each pixel is preserved.
|
||||||
|
@@ -1003,7 +1003,7 @@ void BlackWhite::autoch_toggled ()
|
|||||||
bool wasEnabled = disableListener();
|
bool wasEnabled = disableListener();
|
||||||
|
|
||||||
if (mixerRed->getAddMode()) {
|
if (mixerRed->getAddMode()) {
|
||||||
mixerRed->resetValue(false);
|
mixerRed->resetValue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mixerGreen->getAddMode()) {
|
if (mixerGreen->getAddMode()) {
|
||||||
@@ -1053,14 +1053,14 @@ void BlackWhite::autoch_toggled ()
|
|||||||
} else {
|
} else {
|
||||||
if (autoch->get_active()) {
|
if (autoch->get_active()) {
|
||||||
bool wasEnabled = disableListener();
|
bool wasEnabled = disableListener();
|
||||||
mixerRed->setValue(33);
|
mixerRed->resetValue(false);
|
||||||
mixerGreen->setValue(33);
|
mixerGreen->resetValue(false);
|
||||||
mixerBlue->setValue(33);
|
mixerBlue->resetValue(false);
|
||||||
mixerOrange->setValue(33);
|
mixerOrange->resetValue(false);
|
||||||
mixerYellow->setValue(33);
|
mixerYellow->resetValue(false);
|
||||||
mixerMagenta->setValue(33);
|
mixerMagenta->resetValue(false);
|
||||||
mixerPurple->setValue(33);
|
mixerPurple->resetValue(false);
|
||||||
mixerCyan->setValue(33);
|
mixerCyan->resetValue(false);
|
||||||
setting->set_active (11);
|
setting->set_active (11);
|
||||||
filter->set_active (0);
|
filter->set_active (0);
|
||||||
|
|
||||||
|
@@ -320,9 +320,9 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
|||||||
// LAB grid
|
// LAB grid
|
||||||
auto m = ProcEventMapper::getInstance();
|
auto m = ProcEventMapper::getInstance();
|
||||||
EvColorToningLabGridValue = m->newEvent(RGBCURVE, "HISTORY_MSG_COLORTONING_LABGRID_VALUE");
|
EvColorToningLabGridValue = m->newEvent(RGBCURVE, "HISTORY_MSG_COLORTONING_LABGRID_VALUE");
|
||||||
Gtk::HBox *labgridBox = Gtk::manage(new Gtk::HBox());
|
labgridBox = Gtk::manage(new Gtk::HBox());
|
||||||
labgridArea = Gtk::manage(new LabGrid(EvColorToningLabGridValue));
|
labgrid = Gtk::manage(new LabGrid(EvColorToningLabGridValue));
|
||||||
labgridBox->pack_start(*labgridArea, true, true);
|
labgridBox->pack_start(*labgrid, true, true);
|
||||||
labgridReset = Gtk::manage(new Gtk::Button ());
|
labgridReset = Gtk::manage(new Gtk::Button ());
|
||||||
labgridReset->add (*Gtk::manage(new RTImage ("gtk-undo-ltr-small.png", "gtk-undo-rtl-small.png")));
|
labgridReset->add (*Gtk::manage(new RTImage ("gtk-undo-ltr-small.png", "gtk-undo-rtl-small.png")));
|
||||||
setExpandAlignProperties(labgridReset, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_START);
|
setExpandAlignProperties(labgridReset, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_START);
|
||||||
@@ -331,11 +331,11 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
|||||||
labgridReset->get_style_context()->add_class(GTK_STYLE_CLASS_FLAT);
|
labgridReset->get_style_context()->add_class(GTK_STYLE_CLASS_FLAT);
|
||||||
labgridReset->set_can_focus(false);
|
labgridReset->set_can_focus(false);
|
||||||
labgridReset->set_size_request(-1, 20);
|
labgridReset->set_size_request(-1, 20);
|
||||||
labgridReset->signal_pressed().connect([=]() { static_cast<LabGrid *>(labgridArea)->set_params(0.0, 0.0, 0.0, 0.0, true); });
|
labgridReset->signal_button_release_event().connect([=](GdkEventButton* release_event) { labgrid->reset(release_event->state & GDK_CONTROL_MASK ? true : false); return false; });
|
||||||
labgridBox->pack_start(*labgridReset, false, false);
|
labgridBox->pack_start(*labgridReset, false, false);
|
||||||
pack_start(*labgridBox, Gtk::PACK_EXPAND_WIDGET, 4);
|
pack_start(*labgridBox, Gtk::PACK_EXPAND_WIDGET, 4);
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
show_all();
|
show_all();
|
||||||
|
|
||||||
disableListener();
|
disableListener();
|
||||||
@@ -357,7 +357,7 @@ ColorToning::~ColorToning()
|
|||||||
void ColorToning::setListener(ToolPanelListener *tpl)
|
void ColorToning::setListener(ToolPanelListener *tpl)
|
||||||
{
|
{
|
||||||
ToolPanel::setListener(tpl);
|
ToolPanel::setListener(tpl);
|
||||||
static_cast<LabGrid *>(labgridArea)->set_listener(tpl);
|
labgrid->setListener(tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -432,7 +432,7 @@ void ColorToning::read (const ProcParams* pp, const ParamsEdited* pedited)
|
|||||||
cl2shape->setUnChanged (!pedited->colorToning.cl2curve);
|
cl2shape->setUnChanged (!pedited->colorToning.cl2curve);
|
||||||
lumamode->set_inconsistent (!pedited->colorToning.lumamode);
|
lumamode->set_inconsistent (!pedited->colorToning.lumamode);
|
||||||
|
|
||||||
static_cast<LabGrid *>(labgridArea)->set_edited(pedited->colorToning.labgridALow || pedited->colorToning.labgridBLow || pedited->colorToning.labgridAHigh || pedited->colorToning.labgridBHigh);
|
labgrid->setEdited(pedited->colorToning.labgridALow || pedited->colorToning.labgridBLow || pedited->colorToning.labgridAHigh || pedited->colorToning.labgridBHigh);
|
||||||
}
|
}
|
||||||
|
|
||||||
redlow->setValue (pp->colorToning.redlow);
|
redlow->setValue (pp->colorToning.redlow);
|
||||||
@@ -464,7 +464,7 @@ void ColorToning::read (const ProcParams* pp, const ParamsEdited* pedited)
|
|||||||
|
|
||||||
lastLumamode = pp->colorToning.lumamode;
|
lastLumamode = pp->colorToning.lumamode;
|
||||||
|
|
||||||
static_cast<LabGrid *>(labgridArea)->set_params(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh, false);
|
labgrid->setParams(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh, false);
|
||||||
|
|
||||||
if (pedited && !pedited->colorToning.method) {
|
if (pedited && !pedited->colorToning.method) {
|
||||||
method->set_active (5);
|
method->set_active (5);
|
||||||
@@ -532,7 +532,7 @@ void ColorToning::write (ProcParams* pp, ParamsEdited* pedited)
|
|||||||
pp->colorToning.saturatedOpacity = saturatedOpacity->getIntValue();
|
pp->colorToning.saturatedOpacity = saturatedOpacity->getIntValue();
|
||||||
pp->colorToning.strength = strength->getIntValue();
|
pp->colorToning.strength = strength->getIntValue();
|
||||||
|
|
||||||
static_cast<LabGrid *>(labgridArea)->get_params(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh);
|
labgrid->getParams(pp->colorToning.labgridALow, pp->colorToning.labgridBLow, pp->colorToning.labgridAHigh, pp->colorToning.labgridBHigh);
|
||||||
|
|
||||||
if (pedited) {
|
if (pedited) {
|
||||||
pedited->colorToning.redlow = redlow->getEditedState ();
|
pedited->colorToning.redlow = redlow->getEditedState ();
|
||||||
@@ -559,7 +559,7 @@ void ColorToning::write (ProcParams* pp, ParamsEdited* pedited)
|
|||||||
pedited->colorToning.hlColSat = hlColSat->getEditedState ();
|
pedited->colorToning.hlColSat = hlColSat->getEditedState ();
|
||||||
pedited->colorToning.shadowsColSat = shadowsColSat->getEditedState ();
|
pedited->colorToning.shadowsColSat = shadowsColSat->getEditedState ();
|
||||||
|
|
||||||
pedited->colorToning.labgridALow = pedited->colorToning.labgridBLow = pedited->colorToning.labgridAHigh = pedited->colorToning.labgridBHigh = static_cast<LabGrid *>(labgridArea)->get_edited();
|
pedited->colorToning.labgridALow = pedited->colorToning.labgridBLow = pedited->colorToning.labgridAHigh = pedited->colorToning.labgridBHigh = labgrid->getEdited();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method->get_active_row_number() == 0) {
|
if (method->get_active_row_number() == 0) {
|
||||||
@@ -630,6 +630,7 @@ void ColorToning::setDefaults (const ProcParams* defParams, const ParamsEdited*
|
|||||||
hlColSat->setDefault<int> (defParams->colorToning.hlColSat);
|
hlColSat->setDefault<int> (defParams->colorToning.hlColSat);
|
||||||
shadowsColSat->setDefault<int> (defParams->colorToning.shadowsColSat);
|
shadowsColSat->setDefault<int> (defParams->colorToning.shadowsColSat);
|
||||||
strength->setDefault (defParams->colorToning.strength);
|
strength->setDefault (defParams->colorToning.strength);
|
||||||
|
labgrid->setDefault(defParams->colorToning.labgridALow, defParams->colorToning.labgridBLow, defParams->colorToning.labgridAHigh, defParams->colorToning.labgridBHigh);
|
||||||
|
|
||||||
if (pedited) {
|
if (pedited) {
|
||||||
redlow->setDefaultEditedState (pedited->colorToning.redlow ? Edited : UnEdited);
|
redlow->setDefaultEditedState (pedited->colorToning.redlow ? Edited : UnEdited);
|
||||||
@@ -647,6 +648,7 @@ void ColorToning::setDefaults (const ProcParams* defParams, const ParamsEdited*
|
|||||||
hlColSat->setDefaultEditedState (pedited->colorToning.hlColSat ? Edited : UnEdited);
|
hlColSat->setDefaultEditedState (pedited->colorToning.hlColSat ? Edited : UnEdited);
|
||||||
shadowsColSat->setDefaultEditedState (pedited->colorToning.shadowsColSat ? Edited : UnEdited);
|
shadowsColSat->setDefaultEditedState (pedited->colorToning.shadowsColSat ? Edited : UnEdited);
|
||||||
strength->setDefaultEditedState (pedited->colorToning.strength ? Edited : UnEdited);
|
strength->setDefaultEditedState (pedited->colorToning.strength ? Edited : UnEdited);
|
||||||
|
labgrid->setEdited((pedited->colorToning.labgridALow || pedited->colorToning.labgridBLow || pedited->colorToning.labgridAHigh || pedited->colorToning.labgridBHigh) ? Edited : UnEdited);
|
||||||
} else {
|
} else {
|
||||||
redlow->setDefaultEditedState (Irrelevant);
|
redlow->setDefaultEditedState (Irrelevant);
|
||||||
greenlow->setDefaultEditedState (Irrelevant);
|
greenlow->setDefaultEditedState (Irrelevant);
|
||||||
@@ -663,6 +665,7 @@ void ColorToning::setDefaults (const ProcParams* defParams, const ParamsEdited*
|
|||||||
hlColSat->setDefaultEditedState (Irrelevant);
|
hlColSat->setDefaultEditedState (Irrelevant);
|
||||||
shadowsColSat->setDefaultEditedState (Irrelevant);
|
shadowsColSat->setDefaultEditedState (Irrelevant);
|
||||||
strength->setDefaultEditedState (Irrelevant);
|
strength->setDefaultEditedState (Irrelevant);
|
||||||
|
labgrid->setEdited(Edited);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,8 +828,7 @@ void ColorToning::methodChanged ()
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!batchMode) {
|
if (!batchMode) {
|
||||||
labgridReset->hide();
|
labgridBox->hide();
|
||||||
labgridArea->hide();
|
|
||||||
|
|
||||||
if (method->get_active_row_number() == 0) { // Lab
|
if (method->get_active_row_number() == 0) { // Lab
|
||||||
colorSep->show();
|
colorSep->show();
|
||||||
@@ -994,8 +996,7 @@ void ColorToning::methodChanged ()
|
|||||||
neutrHBox->hide();
|
neutrHBox->hide();
|
||||||
lumamode->hide();
|
lumamode->hide();
|
||||||
|
|
||||||
labgridReset->show();
|
labgridBox->show();
|
||||||
labgridArea->show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "curveeditorgroup.h"
|
#include "curveeditorgroup.h"
|
||||||
#include "thresholdadjuster.h"
|
#include "thresholdadjuster.h"
|
||||||
#include "colorprovider.h"
|
#include "colorprovider.h"
|
||||||
|
#include "labgrid.h"
|
||||||
|
|
||||||
class ColorToning final :
|
class ColorToning final :
|
||||||
public ToolParamBlock,
|
public ToolParamBlock,
|
||||||
@@ -105,7 +106,8 @@ private:
|
|||||||
|
|
||||||
rtengine::ProcEvent EvColorToningLabGridValue;
|
rtengine::ProcEvent EvColorToningLabGridValue;
|
||||||
Gtk::Button *labgridReset;
|
Gtk::Button *labgridReset;
|
||||||
Gtk::DrawingArea *labgridArea;
|
LabGrid *labgrid;
|
||||||
|
Gtk::HBox *labgridBox;
|
||||||
|
|
||||||
IdleRegister idle_register;
|
IdleRegister idle_register;
|
||||||
};
|
};
|
||||||
|
334
rtgui/labgrid.cc
334
rtgui/labgrid.cc
@@ -41,208 +41,270 @@
|
|||||||
using rtengine::Color;
|
using rtengine::Color;
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::notify_listener()
|
bool LabGrid::notifyListener()
|
||||||
{
|
{
|
||||||
if (listener_) {
|
if (listener) {
|
||||||
listener_->panelChanged(evt_, Glib::ustring::compose("%1 %2 %3 %4", int(low_a_), int(low_b_), int(high_a_), int(high_b_)));
|
listener->panelChanged(evt, Glib::ustring::compose(M("TP_COLORTONING_LABGRID_VALUES"), int(low_a), int(low_b), int(high_a), int(high_b)));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LabGrid::LabGrid(rtengine::ProcEvent evt):
|
LabGrid::LabGrid(rtengine::ProcEvent evt):
|
||||||
Gtk::DrawingArea(),
|
Gtk::DrawingArea(),
|
||||||
evt_(evt), selected_(OFF),
|
evt(evt), litPoint(NONE),
|
||||||
low_a_(0.f), high_a_(0.f), low_b_(0.f), high_b_(0.f),
|
low_a(0.f), high_a(0.f), low_b(0.f), high_b(0.f),
|
||||||
listener_(nullptr),
|
defaultLow_a(0.f), defaultHigh_a(0.f), defaultLow_b(0.f), defaultHigh_b(0.f),
|
||||||
edited_(false)
|
listener(nullptr),
|
||||||
|
edited(false),
|
||||||
|
isDragged(false)
|
||||||
{
|
{
|
||||||
set_can_focus(true);
|
set_can_focus(true);
|
||||||
add_events(Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK);
|
add_events(Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LabGrid::getParams(double &la, double &lb, double &ha, double &hb) const
|
||||||
|
{
|
||||||
|
la = low_a;
|
||||||
|
ha = high_a;
|
||||||
|
lb = low_b;
|
||||||
|
hb = high_b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::get_params(double &la, double &lb, double &ha, double &hb) const
|
void LabGrid::setParams(double la, double lb, double ha, double hb, bool notify)
|
||||||
{
|
{
|
||||||
la = low_a_;
|
low_a = la;
|
||||||
ha = high_a_;
|
low_b = lb;
|
||||||
lb = low_b_;
|
high_a = ha;
|
||||||
hb = high_b_;
|
high_b = hb;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::set_params(double la, double lb, double ha, double hb, bool notify)
|
|
||||||
{
|
|
||||||
low_a_ = la;
|
|
||||||
low_b_ = lb;
|
|
||||||
high_a_ = ha;
|
|
||||||
high_b_ = hb;
|
|
||||||
queue_draw();
|
queue_draw();
|
||||||
if (notify) {
|
if (notify) {
|
||||||
notify_listener();
|
notifyListener();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LabGrid::setDefault (double la, double lb, double ha, double hb)
|
||||||
|
{
|
||||||
|
defaultLow_a = la;
|
||||||
|
defaultLow_b = lb;
|
||||||
|
defaultHigh_a = ha;
|
||||||
|
defaultHigh_b = hb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LabGrid::reset(bool toInitial)
|
||||||
|
{
|
||||||
|
if (toInitial) {
|
||||||
|
setParams(defaultLow_a, defaultLow_b, defaultHigh_a, defaultHigh_b, true);
|
||||||
|
} else {
|
||||||
|
setParams(0., 0., 0., 0., true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::set_edited(bool yes)
|
void LabGrid::setEdited(bool yes)
|
||||||
{
|
{
|
||||||
edited_ = yes;
|
edited = yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::get_edited() const
|
bool LabGrid::getEdited() const
|
||||||
{
|
{
|
||||||
return edited_;
|
return edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::set_listener(ToolPanelListener *l)
|
void LabGrid::setListener(ToolPanelListener *l)
|
||||||
{
|
{
|
||||||
listener_ = l;
|
listener = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LabGrid::on_style_updated ()
|
||||||
|
{
|
||||||
|
setDirty(true);
|
||||||
|
queue_draw ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
bool LabGrid::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
||||||
{
|
{
|
||||||
int width = get_allocated_width();
|
Gtk::Allocation allocation = get_allocation();
|
||||||
int height = get_allocated_height();
|
allocation.set_x(0);
|
||||||
Cairo::RefPtr<Cairo::ImageSurface> cst =
|
allocation.set_y(0);
|
||||||
Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
|
|
||||||
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(cst);
|
// setDrawRectangle will allocate the backbuffer Surface
|
||||||
// clear bg
|
if (setDrawRectangle(Cairo::FORMAT_ARGB32, allocation)) {
|
||||||
cr->set_source_rgb(.2, .2, .2);
|
setDirty(true);
|
||||||
cr->paint();
|
}
|
||||||
|
|
||||||
cr->translate(inset, inset);
|
if (!isDirty() || !surfaceCreated()) {
|
||||||
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
return true;
|
||||||
width -= 2 * inset;
|
}
|
||||||
height -= 2 * inset;
|
|
||||||
// flip y:
|
Glib::RefPtr<Gtk::StyleContext> style = get_style_context();
|
||||||
cr->translate(0, height);
|
Cairo::RefPtr<Cairo::Context> cr = getContext();
|
||||||
cr->scale(1., -1.);
|
|
||||||
const int cells = 8;
|
if (isDirty()) {
|
||||||
float step = rtengine::ColorToningParams::LABGRID_CORR_MAX / float(cells/2);
|
int width = allocation.get_width();
|
||||||
for (int j = 0; j < cells; j++) {
|
int height = allocation.get_height();
|
||||||
for (int i = 0; i < cells; i++) {
|
|
||||||
float R, G, B;
|
cr->set_line_cap(Cairo::LINE_CAP_SQUARE);
|
||||||
float x, y, z;
|
|
||||||
int ii = i - cells/2;
|
// clear background
|
||||||
int jj = j - cells/2;
|
cr->set_source_rgba (0., 0., 0., 0.);
|
||||||
float a = step * (ii + 0.5);
|
cr->set_operator (Cairo::OPERATOR_CLEAR);
|
||||||
float b = step * (jj + 0.5);
|
cr->paint ();
|
||||||
Color::Lab2XYZ(25000.f, a, b, x, y, z);
|
cr->set_operator (Cairo::OPERATOR_OVER);
|
||||||
Color::xyz2srgb(x, y, z, R, G, B);
|
style->render_background(cr, 0, 0, width, height);
|
||||||
cr->set_source_rgb(R / 65535.f, G / 65535.f, B / 65535.f);
|
|
||||||
cr->rectangle(width * i / float(cells), height * j / float(cells), width / float(cells) - 1, height / float(cells) - 1);
|
// drawing the cells
|
||||||
cr->fill();
|
cr->translate(inset, inset);
|
||||||
|
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
||||||
|
width -= 2 * inset;
|
||||||
|
height -= 2 * inset;
|
||||||
|
// flip y:
|
||||||
|
cr->translate(0, height);
|
||||||
|
cr->scale(1., -1.);
|
||||||
|
const int cells = 8;
|
||||||
|
float step = rtengine::ColorToningParams::LABGRID_CORR_MAX / float(cells/2);
|
||||||
|
for (int j = 0; j < cells; j++) {
|
||||||
|
for (int i = 0; i < cells; i++) {
|
||||||
|
float R, G, B;
|
||||||
|
float x, y, z;
|
||||||
|
int ii = i - cells/2;
|
||||||
|
int jj = j - cells/2;
|
||||||
|
float a = step * (ii + 0.5);
|
||||||
|
float b = step * (jj + 0.5);
|
||||||
|
Color::Lab2XYZ(25000.f, a, b, x, y, z);
|
||||||
|
Color::xyz2srgb(x, y, z, R, G, B);
|
||||||
|
cr->set_source_rgb(R / 65535.f, G / 65535.f, B / 65535.f);
|
||||||
|
cr->rectangle(width * i / float(cells), height * j / float(cells), width / float(cells) - 1, height / float(cells) - 1);
|
||||||
|
cr->fill();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
|
|
||||||
float loa, hia, lob, hib;
|
|
||||||
loa = .5f * (width + width * low_a_ / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
|
||||||
hia = .5f * (width + width * high_a_ / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
|
||||||
lob = .5f * (height + height * low_b_ / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
|
||||||
hib = .5f * (height + height * high_b_ / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
|
||||||
cr->set_line_width(2.);
|
|
||||||
cr->set_source_rgb(0.6, 0.6, 0.6);
|
|
||||||
cr->move_to(loa, lob);
|
|
||||||
cr->line_to(hia, hib);
|
|
||||||
cr->stroke();
|
|
||||||
|
|
||||||
cr->set_source_rgb(0.1, 0.1, 0.1);
|
// drawing the connection line
|
||||||
if (selected_ == LOW) {
|
cr->set_antialias(Cairo::ANTIALIAS_DEFAULT);
|
||||||
cr->arc(loa, lob, 5, 0, 2. * rtengine::RT_PI);
|
float loa, hia, lob, hib;
|
||||||
} else {
|
loa = .5f * (width + width * low_a / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
||||||
cr->arc(loa, lob, 3, 0, 2. * rtengine::RT_PI);
|
hia = .5f * (width + width * high_a / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
||||||
}
|
lob = .5f * (height + height * low_b / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
||||||
cr->fill();
|
hib = .5f * (height + height * high_b / rtengine::ColorToningParams::LABGRID_CORR_MAX);
|
||||||
|
cr->set_line_width(2.);
|
||||||
|
cr->set_source_rgb(0.6, 0.6, 0.6);
|
||||||
|
cr->move_to(loa, lob);
|
||||||
|
cr->line_to(hia, hib);
|
||||||
|
cr->stroke();
|
||||||
|
|
||||||
cr->set_source_rgb(0.9, 0.9, 0.9);
|
// drawing points
|
||||||
if (selected_ == HIGH) {
|
cr->set_source_rgb(0.1, 0.1, 0.1);
|
||||||
cr->arc(hia, hib, 5, 0, 2. * rtengine::RT_PI);
|
if (litPoint == LOW) {
|
||||||
} else {
|
cr->arc(loa, lob, 5, 0, 2. * rtengine::RT_PI);
|
||||||
cr->arc(hia, hib, 3, 0, 2. * rtengine::RT_PI);
|
} else {
|
||||||
}
|
cr->arc(loa, lob, 3, 0, 2. * rtengine::RT_PI);
|
||||||
cr->fill();
|
}
|
||||||
|
cr->fill();
|
||||||
|
|
||||||
crf->set_source(cst, 0, 0);
|
cr->set_source_rgb(0.9, 0.9, 0.9);
|
||||||
crf->paint();
|
if (litPoint == HIGH) {
|
||||||
|
cr->arc(hia, hib, 5, 0, 2. * rtengine::RT_PI);
|
||||||
return true;
|
} else {
|
||||||
|
cr->arc(hia, hib, 3, 0, 2. * rtengine::RT_PI);
|
||||||
|
}
|
||||||
|
cr->fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
copySurface(crf);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_button_press_event(GdkEventButton *event)
|
bool LabGrid::on_button_press_event(GdkEventButton *event)
|
||||||
{
|
{
|
||||||
if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) {
|
if (event->button == 1) {
|
||||||
switch (selected_) {
|
if (event->type == GDK_2BUTTON_PRESS) {
|
||||||
case OFF:
|
switch (litPoint) {
|
||||||
low_a_ = low_b_ = high_a_ = high_b_ = 0.f;
|
case NONE:
|
||||||
break;
|
low_a = low_b = high_a = high_b = 0.f;
|
||||||
case LOW:
|
break;
|
||||||
low_a_ = low_b_ = 0.f;
|
case LOW:
|
||||||
break;
|
low_a = low_b = 0.f;
|
||||||
case HIGH:
|
break;
|
||||||
high_a_ = high_b_ = 0.f;
|
case HIGH:
|
||||||
break;
|
high_a = high_b = 0.f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
edited = true;
|
||||||
|
} else if (event->type == GDK_BUTTON_PRESS && litPoint != NONE) {
|
||||||
|
isDragged = true;
|
||||||
}
|
}
|
||||||
edited_ = true;
|
return false;
|
||||||
queue_draw();
|
|
||||||
notify_listener();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LabGrid::on_button_release_event(GdkEventButton *event)
|
||||||
|
{
|
||||||
|
if (event->button == 1) {
|
||||||
|
isDragged = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
||||||
{
|
{
|
||||||
if (delay_conn_.connected()) {
|
if (isDragged && delayconn.connected()) {
|
||||||
delay_conn_.disconnect();
|
delayconn.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
State oldLitPoint = litPoint;
|
||||||
|
|
||||||
int width = get_allocated_width() - 2 * inset, height = get_allocated_height() - 2 * inset;
|
int width = get_allocated_width() - 2 * inset, height = get_allocated_height() - 2 * inset;
|
||||||
const float mouse_x = std::min(std::max(event->x - inset, 0.), double(width));
|
const float mouse_x = std::min(std::max(event->x - inset, 0.), double(width));
|
||||||
const float mouse_y = std::min(std::max(height - 1 - event->y + inset, 0.), double(height));
|
const float mouse_y = std::min(std::max(height - 1 - event->y + inset, 0.), double(height));
|
||||||
const float ma = (2.0 * mouse_x - width) / (float)width;
|
const float ma = (2.0 * mouse_x - width) / (float)width;
|
||||||
const float mb = (2.0 * mouse_y - height) / (float)height;
|
const float mb = (2.0 * mouse_y - height) / (float)height;
|
||||||
bool refresh = selected_ != OFF;
|
if (isDragged) {
|
||||||
if (event->state & GDK_BUTTON1_MASK) {
|
if (litPoint == LOW) {
|
||||||
if (selected_ == LOW) {
|
low_a = ma * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
low_a_ = ma * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
low_b = mb * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
low_b_ = mb * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
} else if (litPoint == HIGH) {
|
||||||
} else if (selected_ == HIGH) {
|
high_a = ma * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
high_a_ = ma * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
high_b = mb * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
high_b_ = mb * rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
|
||||||
}
|
}
|
||||||
|
grab_focus();
|
||||||
|
if (options.adjusterMinDelay == 0) {
|
||||||
|
notifyListener();
|
||||||
|
} else {
|
||||||
|
delayconn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &LabGrid::notifyListener), options.adjusterMinDelay);
|
||||||
|
}
|
||||||
|
queue_draw();
|
||||||
} else {
|
} else {
|
||||||
selected_ = OFF;
|
litPoint = NONE;
|
||||||
float la = low_a_ / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float la = low_a / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
float lb = low_b_ / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float lb = low_b / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
float ha = high_a_ / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float ha = high_a / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
float hb = high_b_ / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
float hb = high_b / rtengine::ColorToningParams::LABGRID_CORR_MAX;
|
||||||
const float thrs = 0.05f;
|
const float thrs = 0.05f;
|
||||||
const float distlo = (la - ma) * (la - ma) + (lb - mb) * (lb - mb);
|
const float distlo = (la - ma) * (la - ma) + (lb - mb) * (lb - mb);
|
||||||
const float disthi = (ha - ma) * (ha - ma) + (hb - mb) * (hb - mb);
|
const float disthi = (ha - ma) * (ha - ma) + (hb - mb) * (hb - mb);
|
||||||
if (distlo < thrs * thrs && distlo < disthi) {
|
if (distlo < thrs * thrs && distlo < disthi) {
|
||||||
selected_ = LOW;
|
litPoint = LOW;
|
||||||
} else if (disthi < thrs * thrs && disthi <= distlo) {
|
} else if (disthi < thrs * thrs && disthi <= distlo) {
|
||||||
selected_ = HIGH;
|
litPoint = HIGH;
|
||||||
}
|
}
|
||||||
}
|
if ((oldLitPoint == NONE && litPoint != NONE) || (oldLitPoint != NONE && litPoint == NONE)) {
|
||||||
if (selected_ != OFF) {
|
queue_draw();
|
||||||
grab_focus();
|
|
||||||
if (options.adjusterMinDelay == 0) {
|
|
||||||
notify_listener();
|
|
||||||
} else {
|
|
||||||
delay_conn_ = Glib::signal_timeout().connect(sigc::mem_fun(*this, &LabGrid::notify_listener), options.adjusterMinDelay);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (refresh) {
|
|
||||||
queue_draw();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Gtk::SizeRequestMode LabGrid::get_request_mode_vfunc() const
|
Gtk::SizeRequestMode LabGrid::get_request_mode_vfunc() const
|
||||||
{
|
{
|
||||||
@@ -253,7 +315,7 @@ Gtk::SizeRequestMode LabGrid::get_request_mode_vfunc() const
|
|||||||
void LabGrid::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
|
void LabGrid::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
|
||||||
{
|
{
|
||||||
minimum_width = 50;
|
minimum_width = 50;
|
||||||
natural_width = 200;
|
natural_width = 150; // same as GRAPH_SIZE from mycurve.h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -43,33 +43,45 @@
|
|||||||
#include "toolpanel.h"
|
#include "toolpanel.h"
|
||||||
|
|
||||||
|
|
||||||
class LabGrid: public Gtk::DrawingArea {
|
class LabGrid: public Gtk::DrawingArea, public BackBuffer {
|
||||||
private:
|
private:
|
||||||
rtengine::ProcEvent evt_;
|
rtengine::ProcEvent evt;
|
||||||
enum State { OFF, HIGH, LOW };
|
enum State { NONE, HIGH, LOW };
|
||||||
State selected_;
|
State litPoint;
|
||||||
float low_a_;
|
float low_a;
|
||||||
float high_a_;
|
float high_a;
|
||||||
float low_b_;
|
float low_b;
|
||||||
float high_b_;
|
float high_b;
|
||||||
ToolPanelListener *listener_;
|
|
||||||
bool edited_;
|
float defaultLow_a;
|
||||||
sigc::connection delay_conn_;
|
float defaultHigh_a;
|
||||||
|
float defaultLow_b;
|
||||||
|
float defaultHigh_b;
|
||||||
|
|
||||||
|
ToolPanelListener *listener;
|
||||||
|
bool edited;
|
||||||
|
bool isDragged;
|
||||||
|
sigc::connection delayconn;
|
||||||
static const int inset = 2;
|
static const int inset = 2;
|
||||||
|
|
||||||
bool notify_listener();
|
bool notifyListener();
|
||||||
|
void getLitPoint();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LabGrid(rtengine::ProcEvent evt);
|
LabGrid(rtengine::ProcEvent evt);
|
||||||
|
|
||||||
void get_params(double &la, double &lb, double &ha, double &hb) const;
|
void getParams(double &la, double &lb, double &ha, double &hb) const;
|
||||||
void set_params(double la, double lb, double ha, double hb, bool notify);
|
void setParams(double la, double lb, double ha, double hb, bool notify);
|
||||||
void set_edited(bool yes);
|
void setDefault (double la, double lb, double ha, double hb);
|
||||||
bool get_edited() const;
|
void setEdited(bool yes);
|
||||||
void set_listener(ToolPanelListener *l);
|
bool getEdited() const;
|
||||||
|
void reset(bool toInitial);
|
||||||
|
void setListener(ToolPanelListener *l);
|
||||||
|
|
||||||
bool on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf);
|
bool on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf);
|
||||||
|
void on_style_updated ();
|
||||||
bool on_button_press_event(GdkEventButton *event);
|
bool on_button_press_event(GdkEventButton *event);
|
||||||
|
bool on_button_release_event(GdkEventButton *event);
|
||||||
bool on_motion_notify_event(GdkEventMotion *event);
|
bool on_motion_notify_event(GdkEventMotion *event);
|
||||||
Gtk::SizeRequestMode get_request_mode_vfunc() const;
|
Gtk::SizeRequestMode get_request_mode_vfunc() const;
|
||||||
void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const;
|
void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const;
|
||||||
|
@@ -1540,9 +1540,6 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
|
|||||||
toEdit.colorToning.bluehigh = dontforceSet && options.baBehav[ADDSET_COLORTONING_SPLIT] ? toEdit.colorToning.bluehigh + mods.colorToning.bluehigh : mods.colorToning.bluehigh;
|
toEdit.colorToning.bluehigh = dontforceSet && options.baBehav[ADDSET_COLORTONING_SPLIT] ? toEdit.colorToning.bluehigh + mods.colorToning.bluehigh : mods.colorToning.bluehigh;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colorToning.labgridALow) {
|
|
||||||
toEdit.colorToning.labgridALow = mods.colorToning.labgridALow;
|
|
||||||
}
|
|
||||||
if (colorToning.labgridALow) {
|
if (colorToning.labgridALow) {
|
||||||
toEdit.colorToning.labgridALow = mods.colorToning.labgridALow;
|
toEdit.colorToning.labgridALow = mods.colorToning.labgridALow;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user