diff --git a/rtgui/clipboard.h b/rtgui/clipboard.h index cce305e3d..0b3054bad 100644 --- a/rtgui/clipboard.h +++ b/rtgui/clipboard.h @@ -23,6 +23,7 @@ #include "../rtengine/rtengine.h" #include "../rtengine/procparams.h" #include "paramsedited.h" +#include "myflatcurve.h" #include "mydiagonalcurve.h" class Clipboard { @@ -30,8 +31,10 @@ class Clipboard { bool _hasIPTC; rtengine::procparams::IPTCPairs iptc; rtengine::procparams::PartialProfile partProfile; - DiagonalCurveType hasCurveDataType; - std::vector curve; + DiagonalCurveType hasDiagonalCurveDataType; + FlatCurveType hasFlatCurveDataType; + std::vector diagonalCurve; + std::vector flatCurve; public: @@ -46,9 +49,13 @@ class Clipboard { bool hasProcParams () { return partProfile.pparams; } bool hasPEdited () { return partProfile.pedited; } - void setCurveData (std::vector& p, DiagonalCurveType type ) { curve = p; hasCurveDataType = type; return; } - const std::vector & getCurveData () { return curve; } - DiagonalCurveType hasCurveData () { return hasCurveDataType; } + void setDiagonalCurveData (std::vector& p, DiagonalCurveType type ) { diagonalCurve = p; hasDiagonalCurveDataType = type; return; } + const std::vector & getDiagonalCurveData () { return diagonalCurve; } + DiagonalCurveType hasDiagonalCurveData () { return hasDiagonalCurveDataType; } + + void setFlatCurveData (std::vector& p, FlatCurveType type ) { flatCurve = p; hasFlatCurveDataType = type; return; } + const std::vector & getFlatCurveData () { return flatCurve; } + FlatCurveType hasFlatCurveData () { return hasFlatCurveDataType; } Clipboard (); ~Clipboard (); diff --git a/rtgui/diagonalcurveeditorsubgroup.cc b/rtgui/diagonalcurveeditorsubgroup.cc index 05676d566..d4193fdfa 100644 --- a/rtgui/diagonalcurveeditorsubgroup.cc +++ b/rtgui/diagonalcurveeditorsubgroup.cc @@ -483,16 +483,16 @@ void DiagonalCurveEditorSubGroup::copyPressed () { switch (parent->displayedCurve->selected) { case DCT_Spline: // custom curve = customCurve->getPoints (); - clipboard.setCurveData (curve,DCT_Spline); + clipboard.setDiagonalCurveData (curve,DCT_Spline); break; case DCT_Parametric: // parametric // ... do something, first add save/load functions curve = paramCurve->getPoints (); - clipboard.setCurveData (curve,DCT_Parametric); + clipboard.setDiagonalCurveData (curve,DCT_Parametric); break; case DCT_NURBS: // NURBS curve = NURBSCurve->getPoints (); - clipboard.setCurveData (curve,DCT_NURBS); + clipboard.setDiagonalCurveData (curve,DCT_NURBS); break; default: // (DCT_Linear, DCT_Unchanged) // ... do nothing @@ -506,13 +506,11 @@ void DiagonalCurveEditorSubGroup::pastePressed () { std::vector curve; DiagonalCurveType type; - type = clipboard.hasCurveData(); + type = clipboard.hasDiagonalCurveData(); if (type == (DiagonalCurveType)parent->displayedCurve->selected) { - curve = clipboard.getCurveData (); + curve = clipboard.getDiagonalCurveData (); switch (type) { - case DCT_Linear: // linear - break; case DCT_Spline: // custom customCurve->setPoints (curve); customCurve->queue_draw (); diff --git a/rtgui/flatcurveeditorsubgroup.cc b/rtgui/flatcurveeditorsubgroup.cc index b262d29e4..926d1ab8e 100644 --- a/rtgui/flatcurveeditorsubgroup.cc +++ b/rtgui/flatcurveeditorsubgroup.cc @@ -17,6 +17,7 @@ * along with RawTherapee. If not, see . */ +#include "clipboard.h" #include #include #include @@ -46,11 +47,18 @@ FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::u Gtk::HBox* CPointsbbox = Gtk::manage (new Gtk::HBox ()); CPointsbbox->set_spacing(4); + + pasteCPoints = Gtk::manage (new Gtk::Button ()); + pasteCPoints->add (*Gtk::manage (new RTImage ("edit-paste.png"))); + copyCPoints = Gtk::manage (new Gtk::Button ()); + copyCPoints->add (*Gtk::manage (new RTImage ("edit-copy.png"))); saveCPoints = Gtk::manage (new Gtk::Button ()); saveCPoints->add (*Gtk::manage (new RTImage ("gtk-save-large.png"))); loadCPoints = Gtk::manage (new Gtk::Button ()); loadCPoints->add (*Gtk::manage (new RTImage ("gtk-open.png"))); + CPointsbbox->pack_end (*pasteCPoints, Gtk::PACK_SHRINK, 0); + CPointsbbox->pack_end (*copyCPoints, Gtk::PACK_SHRINK, 0); CPointsbbox->pack_end (*saveCPoints, Gtk::PACK_SHRINK, 0); CPointsbbox->pack_end (*loadCPoints, Gtk::PACK_SHRINK, 0); @@ -59,8 +67,13 @@ FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt, Glib::u saveCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::savePressed) ); loadCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::loadPressed) ); + copyCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::copyPressed) ); + pasteCPoints->signal_clicked().connect( sigc::mem_fun(*this, &FlatCurveEditorSubGroup::pastePressed) ); + saveCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPSAVE")); loadCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPLOAD")); + copyCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPCOPY")); + pasteCPoints->set_tooltip_text (M("CURVEEDITOR_TOOLTIPPASTE")); CPointsCurve->setCurveListener (parent); // Send the message directly to the parent } @@ -238,6 +251,46 @@ void FlatCurveEditorSubGroup::loadPressed () { } } +void FlatCurveEditorSubGroup::copyPressed () { +// For compatibility use enum FlatCurveType here + + std::vector curve; + + switch (parent->displayedCurve->selected) { + case FCT_MinMaxCPoints: // custom + curve = CPointsCurve->getPoints (); + clipboard.setFlatCurveData (curve,FCT_MinMaxCPoints); + break; + default: // (DCT_Linear, DCT_Unchanged) + // ... do nothing + break; + } +} + +void FlatCurveEditorSubGroup::pastePressed () { +// For compatibility use enum FlatCurveType here + + std::vector curve; + FlatCurveType type; + + type = clipboard.hasFlatCurveData(); + + if (type == (FlatCurveType)parent->displayedCurve->selected) { + curve = clipboard.getFlatCurveData (); + switch (type) { + case FCT_MinMaxCPoints: // min/max control points + CPointsCurve->setPoints (curve); + CPointsCurve->queue_draw (); + CPointsCurve->notifyListener (); + break; + default: // (FCT_Linear, FCT_Unchanged) + // ... do nothing + break; + } + } + return; +} + /* * Store the curves of the currently displayed type from the widgets to the CurveEditor object */ diff --git a/rtgui/flatcurveeditorsubgroup.h b/rtgui/flatcurveeditorsubgroup.h index 630f4cd49..3a584006b 100644 --- a/rtgui/flatcurveeditorsubgroup.h +++ b/rtgui/flatcurveeditorsubgroup.h @@ -35,6 +35,8 @@ protected: Gtk::Button* saveCPoints; Gtk::Button* loadCPoints; + Gtk::Button* copyCPoints; + Gtk::Button* pasteCPoints; public: FlatCurveEditorSubGroup(CurveEditorGroup* prt, Glib::ustring& curveDir); @@ -51,6 +53,8 @@ protected: void restoreDisplayedHistogram (); void savePressed (); void loadPressed (); + void copyPressed (); + void pastePressed (); bool curveReset (int cType); void removeEditor (); const std::vector getCurveFromGUI (int type);