labgrid: code refactoring to avoid duplication for adding reset buttons
This commit is contained in:
parent
e9f0b6ac60
commit
a8bbc9cb8b
@ -339,20 +339,8 @@ 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");
|
||||||
labgridBox = Gtk::manage(new Gtk::HBox());
|
|
||||||
labgrid = Gtk::manage(new LabGrid(EvColorToningLabGridValue, M("TP_COLORTONING_LABGRID_VALUES")));
|
labgrid = Gtk::manage(new LabGrid(EvColorToningLabGridValue, M("TP_COLORTONING_LABGRID_VALUES")));
|
||||||
labgridBox->pack_start(*labgrid, true, true);
|
pack_start(*labgrid, Gtk::PACK_EXPAND_WIDGET, 4);
|
||||||
labgridReset = Gtk::manage(new Gtk::Button ());
|
|
||||||
labgridReset->add (*Gtk::manage(new RTImage ("undo-small.png", "redo-small.png")));
|
|
||||||
setExpandAlignProperties(labgridReset, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_START);
|
|
||||||
labgridReset->set_relief(Gtk::RELIEF_NONE);
|
|
||||||
labgridReset->set_tooltip_markup(M("ADJUSTER_RESET_TO_DEFAULT"));
|
|
||||||
labgridReset->get_style_context()->add_class(GTK_STYLE_CLASS_FLAT);
|
|
||||||
labgridReset->set_can_focus(false);
|
|
||||||
labgridReset->set_size_request(-1, 20);
|
|
||||||
labgridReset->signal_button_release_event().connect(sigc::mem_fun(*this, &ColorToning::resetPressed));
|
|
||||||
labgridBox->pack_start(*labgridReset, false, false);
|
|
||||||
pack_start(*labgridBox, Gtk::PACK_EXPAND_WIDGET, 4);
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -410,14 +398,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR
|
|||||||
labRegionBox->pack_start(*hb, true, true);
|
labRegionBox->pack_start(*hb, true, true);
|
||||||
|
|
||||||
labRegionAB = Gtk::manage(new LabGrid(EvLabRegionAB, M("TP_COLORTONING_LABREGION_ABVALUES"), false));
|
labRegionAB = Gtk::manage(new LabGrid(EvLabRegionAB, M("TP_COLORTONING_LABREGION_ABVALUES"), false));
|
||||||
hb = Gtk::manage(new Gtk::HBox());
|
labRegionBox->pack_start(*labRegionAB);
|
||||||
hb->pack_start(*labRegionAB, true, true);
|
|
||||||
labRegionABReset = Gtk::manage(new Gtk::Button());
|
|
||||||
labRegionABReset->set_tooltip_markup(M("ADJUSTER_RESET_TO_DEFAULT"));
|
|
||||||
labRegionABReset->add(*Gtk::manage(new RTImage("undo-small.png", "redo-small.png")));
|
|
||||||
labRegionABReset->signal_button_release_event().connect(sigc::mem_fun(*this, &ColorToning::labRegionResetPressed));
|
|
||||||
add_button(labRegionABReset, hb);
|
|
||||||
labRegionBox->pack_start(*hb);
|
|
||||||
|
|
||||||
labRegionSaturation = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_SATURATION"), -100, 100, 1, 0));
|
labRegionSaturation = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_SATURATION"), -100, 100, 1, 0));
|
||||||
labRegionSaturation->setAdjusterListener(this);
|
labRegionSaturation->setAdjusterListener(this);
|
||||||
@ -985,7 +966,7 @@ void ColorToning::methodChanged ()
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!batchMode) {
|
if (!batchMode) {
|
||||||
labgridBox->hide();
|
labgrid->hide();
|
||||||
labRegionBox->hide();
|
labRegionBox->hide();
|
||||||
|
|
||||||
if (method->get_active_row_number() == 0) { // Lab
|
if (method->get_active_row_number() == 0) { // Lab
|
||||||
@ -1155,7 +1136,7 @@ void ColorToning::methodChanged ()
|
|||||||
lumamode->hide();
|
lumamode->hide();
|
||||||
|
|
||||||
if (method->get_active_row_number() == 5) {
|
if (method->get_active_row_number() == 5) {
|
||||||
labgridBox->show();
|
labgrid->show();
|
||||||
} else {
|
} else {
|
||||||
labRegionBox->show();
|
labRegionBox->show();
|
||||||
}
|
}
|
||||||
@ -1388,19 +1369,6 @@ void ColorToning::setBatchMode (bool batchMode)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ColorToning::resetPressed(GdkEventButton* event)
|
|
||||||
{
|
|
||||||
labgrid->reset(event->state & GDK_CONTROL_MASK);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ColorToning::labRegionResetPressed(GdkEventButton *event)
|
|
||||||
{
|
|
||||||
labRegionAB->reset(event->state & GDK_CONTROL_MASK);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ColorToning::onLabRegionSelectionChanged()
|
void ColorToning::onLabRegionSelectionChanged()
|
||||||
{
|
{
|
||||||
|
@ -62,8 +62,6 @@ public:
|
|||||||
float blendPipetteValues(CurveEditor *ce, float chan1, float chan2, float chan3);
|
float blendPipetteValues(CurveEditor *ce, float chan1, float chan2, float chan3);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool resetPressed(GdkEventButton* event);
|
|
||||||
bool labRegionResetPressed(GdkEventButton *event);
|
|
||||||
void onLabRegionSelectionChanged();
|
void onLabRegionSelectionChanged();
|
||||||
void labRegionAddPressed();
|
void labRegionAddPressed();
|
||||||
void labRegionRemovePressed();
|
void labRegionRemovePressed();
|
||||||
@ -126,9 +124,7 @@ private:
|
|||||||
sigc::connection lumamodeConn;
|
sigc::connection lumamodeConn;
|
||||||
|
|
||||||
rtengine::ProcEvent EvColorToningLabGridValue;
|
rtengine::ProcEvent EvColorToningLabGridValue;
|
||||||
Gtk::Button *labgridReset;
|
|
||||||
LabGrid *labgrid;
|
LabGrid *labgrid;
|
||||||
Gtk::HBox *labgridBox;
|
|
||||||
|
|
||||||
rtengine::ProcEvent EvLabRegionList;
|
rtengine::ProcEvent EvLabRegionList;
|
||||||
rtengine::ProcEvent EvLabRegionAB;
|
rtengine::ProcEvent EvLabRegionAB;
|
||||||
@ -145,7 +141,6 @@ private:
|
|||||||
Gtk::Button *labRegionRemove;
|
Gtk::Button *labRegionRemove;
|
||||||
Gtk::Button *labRegionUp;
|
Gtk::Button *labRegionUp;
|
||||||
Gtk::Button *labRegionDown;
|
Gtk::Button *labRegionDown;
|
||||||
Gtk::Button *labRegionABReset;
|
|
||||||
LabGrid *labRegionAB;
|
LabGrid *labRegionAB;
|
||||||
Adjuster *labRegionSaturation;
|
Adjuster *labRegionSaturation;
|
||||||
Adjuster *labRegionLightness;
|
Adjuster *labRegionLightness;
|
||||||
|
@ -41,7 +41,11 @@
|
|||||||
using rtengine::Color;
|
using rtengine::Color;
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::notifyListener()
|
//-----------------------------------------------------------------------------
|
||||||
|
// LabGridArea
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool LabGridArea::notifyListener()
|
||||||
{
|
{
|
||||||
if (listener) {
|
if (listener) {
|
||||||
const auto round =
|
const auto round =
|
||||||
@ -55,7 +59,7 @@ bool LabGrid::notifyListener()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LabGrid::LabGrid(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_low):
|
LabGridArea::LabGridArea(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_low):
|
||||||
Gtk::DrawingArea(),
|
Gtk::DrawingArea(),
|
||||||
evt(evt), evtMsg(msg),
|
evt(evt), evtMsg(msg),
|
||||||
litPoint(NONE),
|
litPoint(NONE),
|
||||||
@ -70,7 +74,7 @@ LabGrid::LabGrid(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_
|
|||||||
add_events(Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_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
|
void LabGridArea::getParams(double &la, double &lb, double &ha, double &hb) const
|
||||||
{
|
{
|
||||||
la = low_a;
|
la = low_a;
|
||||||
ha = high_a;
|
ha = high_a;
|
||||||
@ -79,7 +83,7 @@ void LabGrid::getParams(double &la, double &lb, double &ha, double &hb) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::setParams(double la, double lb, double ha, double hb, bool notify)
|
void LabGridArea::setParams(double la, double lb, double ha, double hb, bool notify)
|
||||||
{
|
{
|
||||||
const double lo = -1.0;
|
const double lo = -1.0;
|
||||||
const double hi = 1.0;
|
const double hi = 1.0;
|
||||||
@ -93,7 +97,7 @@ void LabGrid::setParams(double la, double lb, double ha, double hb, bool notify)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabGrid::setDefault (double la, double lb, double ha, double hb)
|
void LabGridArea::setDefault (double la, double lb, double ha, double hb)
|
||||||
{
|
{
|
||||||
defaultLow_a = la;
|
defaultLow_a = la;
|
||||||
defaultLow_b = lb;
|
defaultLow_b = lb;
|
||||||
@ -102,7 +106,7 @@ void LabGrid::setDefault (double la, double lb, double ha, double hb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::reset(bool toInitial)
|
void LabGridArea::reset(bool toInitial)
|
||||||
{
|
{
|
||||||
if (toInitial) {
|
if (toInitial) {
|
||||||
setParams(defaultLow_a, defaultLow_b, defaultHigh_a, defaultHigh_b, true);
|
setParams(defaultLow_a, defaultLow_b, defaultHigh_a, defaultHigh_b, true);
|
||||||
@ -112,32 +116,32 @@ void LabGrid::reset(bool toInitial)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::setEdited(bool yes)
|
void LabGridArea::setEdited(bool yes)
|
||||||
{
|
{
|
||||||
edited = yes;
|
edited = yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::getEdited() const
|
bool LabGridArea::getEdited() const
|
||||||
{
|
{
|
||||||
return edited;
|
return edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::setListener(ToolPanelListener *l)
|
void LabGridArea::setListener(ToolPanelListener *l)
|
||||||
{
|
{
|
||||||
listener = l;
|
listener = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::on_style_updated ()
|
void LabGridArea::on_style_updated ()
|
||||||
{
|
{
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
queue_draw ();
|
queue_draw ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
bool LabGridArea::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
||||||
{
|
{
|
||||||
Gtk::Allocation allocation = get_allocation();
|
Gtk::Allocation allocation = get_allocation();
|
||||||
allocation.set_x(0);
|
allocation.set_x(0);
|
||||||
@ -232,7 +236,7 @@ bool LabGrid::on_draw(const ::Cairo::RefPtr<Cairo::Context> &crf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_button_press_event(GdkEventButton *event)
|
bool LabGridArea::on_button_press_event(GdkEventButton *event)
|
||||||
{
|
{
|
||||||
if (event->button == 1) {
|
if (event->button == 1) {
|
||||||
if (event->type == GDK_2BUTTON_PRESS) {
|
if (event->type == GDK_2BUTTON_PRESS) {
|
||||||
@ -259,7 +263,7 @@ bool LabGrid::on_button_press_event(GdkEventButton *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_button_release_event(GdkEventButton *event)
|
bool LabGridArea::on_button_release_event(GdkEventButton *event)
|
||||||
{
|
{
|
||||||
if (event->button == 1) {
|
if (event->button == 1) {
|
||||||
isDragged = false;
|
isDragged = false;
|
||||||
@ -269,7 +273,7 @@ bool LabGrid::on_button_release_event(GdkEventButton *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
bool LabGridArea::on_motion_notify_event(GdkEventMotion *event)
|
||||||
{
|
{
|
||||||
if (isDragged && delayconn.connected()) {
|
if (isDragged && delayconn.connected()) {
|
||||||
delayconn.disconnect();
|
delayconn.disconnect();
|
||||||
@ -295,7 +299,7 @@ bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
|||||||
if (options.adjusterMinDelay == 0) {
|
if (options.adjusterMinDelay == 0) {
|
||||||
notifyListener();
|
notifyListener();
|
||||||
} else {
|
} else {
|
||||||
delayconn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &LabGrid::notifyListener), options.adjusterMinDelay);
|
delayconn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &LabGridArea::notifyListener), options.adjusterMinDelay);
|
||||||
}
|
}
|
||||||
queue_draw();
|
queue_draw();
|
||||||
} else {
|
} else {
|
||||||
@ -320,35 +324,66 @@ bool LabGrid::on_motion_notify_event(GdkEventMotion *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Gtk::SizeRequestMode LabGrid::get_request_mode_vfunc() const
|
Gtk::SizeRequestMode LabGridArea::get_request_mode_vfunc() const
|
||||||
{
|
{
|
||||||
return Gtk::SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
return Gtk::SIZE_REQUEST_HEIGHT_FOR_WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
|
void LabGridArea::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const
|
||||||
{
|
{
|
||||||
minimum_width = 50;
|
minimum_width = 50;
|
||||||
natural_width = 150; // same as GRAPH_SIZE from mycurve.h
|
natural_width = 150; // same as GRAPH_SIZE from mycurve.h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const
|
void LabGridArea::get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const
|
||||||
{
|
{
|
||||||
minimum_height = natural_height = width;
|
minimum_height = natural_height = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool LabGrid::lowEnabled() const
|
bool LabGridArea::lowEnabled() const
|
||||||
{
|
{
|
||||||
return low_enabled;
|
return low_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LabGrid::setLowEnabled(bool yes)
|
void LabGridArea::setLowEnabled(bool yes)
|
||||||
{
|
{
|
||||||
if (low_enabled != yes) {
|
if (low_enabled != yes) {
|
||||||
low_enabled = yes;
|
low_enabled = yes;
|
||||||
queue_draw();
|
queue_draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// LabGrid
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
LabGrid::LabGrid(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_low):
|
||||||
|
grid(evt, msg, enable_low)
|
||||||
|
{
|
||||||
|
Gtk::Button *reset = Gtk::manage(new Gtk::Button());
|
||||||
|
reset->set_tooltip_markup(M("ADJUSTER_RESET_TO_DEFAULT"));
|
||||||
|
reset->add(*Gtk::manage(new RTImage("undo-small.png", "redo-small.png")));
|
||||||
|
reset->signal_button_release_event().connect(sigc::mem_fun(*this, &LabGrid::resetPressed));
|
||||||
|
|
||||||
|
setExpandAlignProperties(reset, false, false, Gtk::ALIGN_CENTER, Gtk::ALIGN_START);
|
||||||
|
reset->set_relief(Gtk::RELIEF_NONE);
|
||||||
|
reset->get_style_context()->add_class(GTK_STYLE_CLASS_FLAT);
|
||||||
|
reset->set_can_focus(false);
|
||||||
|
reset->set_size_request(-1, 20);
|
||||||
|
|
||||||
|
pack_start(grid, true, true);
|
||||||
|
pack_start(*reset, false, false);
|
||||||
|
show_all_children();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool LabGrid::resetPressed(GdkEventButton *event)
|
||||||
|
{
|
||||||
|
grid.reset(event->state & GDK_CONTROL_MASK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
#include "toolpanel.h"
|
#include "toolpanel.h"
|
||||||
|
|
||||||
|
|
||||||
class LabGrid: public Gtk::DrawingArea, public BackBuffer {
|
class LabGridArea: public Gtk::DrawingArea, public BackBuffer {
|
||||||
private:
|
private:
|
||||||
rtengine::ProcEvent evt;
|
rtengine::ProcEvent evt;
|
||||||
Glib::ustring evtMsg;
|
Glib::ustring evtMsg;
|
||||||
@ -73,7 +73,7 @@ private:
|
|||||||
void getLitPoint();
|
void getLitPoint();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LabGrid(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_low=true);
|
LabGridArea(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_low=true);
|
||||||
|
|
||||||
void getParams(double &la, double &lb, double &ha, double &hb) const;
|
void getParams(double &la, double &lb, double &ha, double &hb) const;
|
||||||
void setParams(double la, double lb, double ha, double hb, bool notify);
|
void setParams(double la, double lb, double ha, double hb, bool notify);
|
||||||
@ -96,3 +96,24 @@ public:
|
|||||||
void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const;
|
void get_preferred_height_for_width_vfunc (int width, int &minimum_height, int &natural_height) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class LabGrid: public Gtk::HBox {
|
||||||
|
private:
|
||||||
|
LabGridArea grid;
|
||||||
|
|
||||||
|
bool resetPressed(GdkEventButton *event);
|
||||||
|
|
||||||
|
public:
|
||||||
|
LabGrid(rtengine::ProcEvent evt, const Glib::ustring &msg, bool enable_low=true);
|
||||||
|
|
||||||
|
void getParams(double &la, double &lb, double &ha, double &hb) const { return grid.getParams(la, lb, ha, hb); }
|
||||||
|
void setParams(double la, double lb, double ha, double hb, bool notify) { grid.setParams(la, lb, ha, hb, notify); }
|
||||||
|
void setDefault (double la, double lb, double ha, double hb) { grid.setDefault(la, lb, ha, hb); }
|
||||||
|
void setEdited(bool yes) { grid.setEdited(yes); }
|
||||||
|
bool getEdited() const { return grid.getEdited(); }
|
||||||
|
void reset(bool toInitial) { grid.reset(toInitial); }
|
||||||
|
void setListener(ToolPanelListener *l) { grid.setListener(l); }
|
||||||
|
bool lowEnabled() const { return grid.lowEnabled(); }
|
||||||
|
void setLowEnabled(bool yes) { grid.setLowEnabled(yes); }
|
||||||
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user