diff --git a/rtgui/colortoning.cc b/rtgui/colortoning.cc index b6e001b70..3ec149a0a 100644 --- a/rtgui/colortoning.cc +++ b/rtgui/colortoning.cc @@ -339,20 +339,8 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR // LAB grid auto m = ProcEventMapper::getInstance(); 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"))); - labgridBox->pack_start(*labgrid, true, true); - 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); + pack_start(*labgrid, Gtk::PACK_EXPAND_WIDGET, 4); //------------------------------------------------------------------------ //------------------------------------------------------------------------ @@ -410,14 +398,7 @@ ColorToning::ColorToning () : FoldableToolPanel(this, "colortoning", M("TP_COLOR labRegionBox->pack_start(*hb, true, true); labRegionAB = Gtk::manage(new LabGrid(EvLabRegionAB, M("TP_COLORTONING_LABREGION_ABVALUES"), false)); - hb = Gtk::manage(new Gtk::HBox()); - 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); + labRegionBox->pack_start(*labRegionAB); labRegionSaturation = Gtk::manage(new Adjuster(M("TP_COLORTONING_LABREGION_SATURATION"), -100, 100, 1, 0)); labRegionSaturation->setAdjusterListener(this); @@ -985,7 +966,7 @@ void ColorToning::methodChanged () { if (!batchMode) { - labgridBox->hide(); + labgrid->hide(); labRegionBox->hide(); if (method->get_active_row_number() == 0) { // Lab @@ -1155,7 +1136,7 @@ void ColorToning::methodChanged () lumamode->hide(); if (method->get_active_row_number() == 5) { - labgridBox->show(); + labgrid->show(); } else { 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() { diff --git a/rtgui/colortoning.h b/rtgui/colortoning.h index eff26bd46..8fb640cba 100644 --- a/rtgui/colortoning.h +++ b/rtgui/colortoning.h @@ -62,8 +62,6 @@ public: float blendPipetteValues(CurveEditor *ce, float chan1, float chan2, float chan3); private: - bool resetPressed(GdkEventButton* event); - bool labRegionResetPressed(GdkEventButton *event); void onLabRegionSelectionChanged(); void labRegionAddPressed(); void labRegionRemovePressed(); @@ -126,9 +124,7 @@ private: sigc::connection lumamodeConn; rtengine::ProcEvent EvColorToningLabGridValue; - Gtk::Button *labgridReset; LabGrid *labgrid; - Gtk::HBox *labgridBox; rtengine::ProcEvent EvLabRegionList; rtengine::ProcEvent EvLabRegionAB; @@ -145,7 +141,6 @@ private: Gtk::Button *labRegionRemove; Gtk::Button *labRegionUp; Gtk::Button *labRegionDown; - Gtk::Button *labRegionABReset; LabGrid *labRegionAB; Adjuster *labRegionSaturation; Adjuster *labRegionLightness; diff --git a/rtgui/labgrid.cc b/rtgui/labgrid.cc index 5e0d571a5..f680c7322 100644 --- a/rtgui/labgrid.cc +++ b/rtgui/labgrid.cc @@ -41,7 +41,11 @@ using rtengine::Color; -bool LabGrid::notifyListener() +//----------------------------------------------------------------------------- +// LabGridArea +//----------------------------------------------------------------------------- + +bool LabGridArea::notifyListener() { if (listener) { 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(), evt(evt), evtMsg(msg), 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); } -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; 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 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_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) { 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; } -bool LabGrid::getEdited() const +bool LabGridArea::getEdited() const { return edited; } -void LabGrid::setListener(ToolPanelListener *l) +void LabGridArea::setListener(ToolPanelListener *l) { listener = l; } -void LabGrid::on_style_updated () +void LabGridArea::on_style_updated () { setDirty(true); queue_draw (); } -bool LabGrid::on_draw(const ::Cairo::RefPtr &crf) +bool LabGridArea::on_draw(const ::Cairo::RefPtr &crf) { Gtk::Allocation allocation = get_allocation(); allocation.set_x(0); @@ -232,7 +236,7 @@ bool LabGrid::on_draw(const ::Cairo::RefPtr &crf) } -bool LabGrid::on_button_press_event(GdkEventButton *event) +bool LabGridArea::on_button_press_event(GdkEventButton *event) { if (event->button == 1) { 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) { 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()) { delayconn.disconnect(); @@ -295,7 +299,7 @@ bool LabGrid::on_motion_notify_event(GdkEventMotion *event) if (options.adjusterMinDelay == 0) { notifyListener(); } 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(); } 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; } -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; 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; } -bool LabGrid::lowEnabled() const +bool LabGridArea::lowEnabled() const { return low_enabled; } -void LabGrid::setLowEnabled(bool yes) +void LabGridArea::setLowEnabled(bool yes) { if (low_enabled != yes) { low_enabled = yes; 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; +} diff --git a/rtgui/labgrid.h b/rtgui/labgrid.h index 715175f74..35e259996 100644 --- a/rtgui/labgrid.h +++ b/rtgui/labgrid.h @@ -43,7 +43,7 @@ #include "toolpanel.h" -class LabGrid: public Gtk::DrawingArea, public BackBuffer { +class LabGridArea: public Gtk::DrawingArea, public BackBuffer { private: rtengine::ProcEvent evt; Glib::ustring evtMsg; @@ -73,7 +73,7 @@ private: void getLitPoint(); 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 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; }; + +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); } +}; +