Better handling of the autoresize feature of the curve editors. Not ideal yet, but way better.
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
#include <version.h>
|
#include <version.h>
|
||||||
#include <ppversion.h>
|
#include <ppversion.h>
|
||||||
#include <myflatcurve.h>
|
#include <myflatcurve.h>
|
||||||
|
#include <mydiagonalcurve.h>
|
||||||
|
|
||||||
#include <safekeyfile.h>
|
#include <safekeyfile.h>
|
||||||
|
|
||||||
@@ -63,6 +64,7 @@ void ProcParams::setDefaults () {
|
|||||||
toneCurve.hlcomprthresh = 0;
|
toneCurve.hlcomprthresh = 0;
|
||||||
toneCurve.shcompr = 25;
|
toneCurve.shcompr = 25;
|
||||||
toneCurve.curve.clear ();
|
toneCurve.curve.clear ();
|
||||||
|
toneCurve.curve.push_back(DCT_Linear);
|
||||||
|
|
||||||
labCurve.brightness = 0;
|
labCurve.brightness = 0;
|
||||||
labCurve.contrast = 0;
|
labCurve.contrast = 0;
|
||||||
@@ -71,8 +73,11 @@ void ProcParams::setDefaults () {
|
|||||||
labCurve.enable_saturationlimiter = false;
|
labCurve.enable_saturationlimiter = false;
|
||||||
labCurve.saturationlimit = 40;
|
labCurve.saturationlimit = 40;
|
||||||
labCurve.lcurve.clear ();
|
labCurve.lcurve.clear ();
|
||||||
|
labCurve.lcurve.push_back(DCT_Linear);
|
||||||
labCurve.acurve.clear ();
|
labCurve.acurve.clear ();
|
||||||
|
labCurve.acurve.push_back(DCT_Linear);
|
||||||
labCurve.bcurve.clear ();
|
labCurve.bcurve.clear ();
|
||||||
|
labCurve.bcurve.push_back(DCT_Linear);
|
||||||
|
|
||||||
sharpening.enabled = true;
|
sharpening.enabled = true;
|
||||||
sharpening.radius = 1.0;
|
sharpening.radius = 1.0;
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ protected:
|
|||||||
virtual void switchGUI() = 0;
|
virtual void switchGUI() = 0;
|
||||||
virtual void removeEditor () = 0;
|
virtual void removeEditor () = 0;
|
||||||
virtual const std::vector<double> getCurveFromGUI (int type) = 0;
|
virtual const std::vector<double> getCurveFromGUI (int type) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -40,23 +40,22 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
|||||||
|
|
||||||
// custom curve
|
// custom curve
|
||||||
customCurveBox = new Gtk::HBox ();
|
customCurveBox = new Gtk::HBox ();
|
||||||
Gtk::HBox* tmpa = Gtk::manage (new Gtk::HBox ());
|
customCurveBox->set_spacing(4);
|
||||||
customCurve = Gtk::manage (new MyDiagonalCurve ());
|
customCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||||
//Gtk::AspectFrame* af = Gtk::manage (new Gtk::AspectFrame ("",Gtk::ALIGN_CENTER,Gtk::ALIGN_CENTER,1,false));
|
|
||||||
customCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
customCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
||||||
customCurve->setType (DCT_Spline);
|
customCurve->setType (DCT_Spline);
|
||||||
//customCurve->set_tooltip_text (M("CURVEEDITOR_TOOLTIPMOVESPEED"));
|
//customCurve->set_tooltip_text (M("CURVEEDITOR_TOOLTIPMOVESPEED"));
|
||||||
tmpa->pack_start (*customCurve, true, false, 4);
|
customCurveBox->pack_start (*customCurve, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||||
customCurveBox->pack_start (*tmpa, true, true,4);
|
|
||||||
|
|
||||||
Gtk::VBox* custombbox = Gtk::manage (new Gtk::VBox ());
|
Gtk::VBox* custombbox = Gtk::manage (new Gtk::VBox ());
|
||||||
|
custombbox->set_spacing(4);
|
||||||
saveCustom = Gtk::manage (new Gtk::Button ());
|
saveCustom = Gtk::manage (new Gtk::Button ());
|
||||||
saveCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
saveCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
||||||
loadCustom = Gtk::manage (new Gtk::Button ());
|
loadCustom = Gtk::manage (new Gtk::Button ());
|
||||||
loadCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
loadCustom->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
||||||
|
|
||||||
custombbox->pack_end (*saveCustom, Gtk::PACK_SHRINK, 4);
|
custombbox->pack_end (*saveCustom, Gtk::PACK_SHRINK, 0);
|
||||||
custombbox->pack_end (*loadCustom, Gtk::PACK_SHRINK, 4);
|
custombbox->pack_end (*loadCustom, Gtk::PACK_SHRINK, 0);
|
||||||
|
|
||||||
customCurveBox->pack_end (*custombbox, Gtk::PACK_SHRINK, 0);
|
customCurveBox->pack_end (*custombbox, Gtk::PACK_SHRINK, 0);
|
||||||
customCurveBox->show_all ();
|
customCurveBox->show_all ();
|
||||||
@@ -68,24 +67,22 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
|||||||
|
|
||||||
// NURBS curve
|
// NURBS curve
|
||||||
NURBSCurveBox = new Gtk::HBox ();
|
NURBSCurveBox = new Gtk::HBox ();
|
||||||
Gtk::HBox* tmpb = Gtk::manage (new Gtk::HBox ());
|
NURBSCurveBox->set_spacing(4);
|
||||||
NURBSCurve = Gtk::manage (new MyDiagonalCurve ());
|
NURBSCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||||
//Gtk::AspectFrame* af = Gtk::manage (new Gtk::AspectFrame ("",Gtk::ALIGN_CENTER,Gtk::ALIGN_CENTER,1,false));
|
|
||||||
//af->add (*customCurve);
|
|
||||||
NURBSCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
NURBSCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
||||||
NURBSCurve->setType (DCT_NURBS);
|
NURBSCurve->setType (DCT_NURBS);
|
||||||
//customCurve->set_tooltip_text (M("CURVEEDITOR_TOOLTIPMOVESPEED"));
|
//customCurve->set_tooltip_text (M("CURVEEDITOR_TOOLTIPMOVESPEED"));
|
||||||
tmpb->pack_start (*NURBSCurve, true, false, 4);
|
NURBSCurveBox->pack_start (*NURBSCurve, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||||
NURBSCurveBox->pack_start (*tmpb, true, true,4);
|
|
||||||
|
|
||||||
Gtk::VBox* NURBSbbox = Gtk::manage (new Gtk::VBox ());
|
Gtk::VBox* NURBSbbox = Gtk::manage (new Gtk::VBox ());
|
||||||
|
NURBSbbox->set_spacing(4);
|
||||||
saveNURBS = Gtk::manage (new Gtk::Button ());
|
saveNURBS = Gtk::manage (new Gtk::Button ());
|
||||||
saveNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
saveNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
||||||
loadNURBS = Gtk::manage (new Gtk::Button ());
|
loadNURBS = Gtk::manage (new Gtk::Button ());
|
||||||
loadNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
loadNURBS->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
||||||
|
|
||||||
NURBSbbox->pack_end (*saveNURBS, Gtk::PACK_SHRINK, 4);
|
NURBSbbox->pack_end (*saveNURBS, Gtk::PACK_SHRINK, 0);
|
||||||
NURBSbbox->pack_end (*loadNURBS, Gtk::PACK_SHRINK, 4);
|
NURBSbbox->pack_end (*loadNURBS, Gtk::PACK_SHRINK, 0);
|
||||||
|
|
||||||
NURBSCurveBox->pack_end (*NURBSbbox, Gtk::PACK_SHRINK, 0);
|
NURBSCurveBox->pack_end (*NURBSbbox, Gtk::PACK_SHRINK, 0);
|
||||||
NURBSCurveBox->show_all ();
|
NURBSCurveBox->show_all ();
|
||||||
@@ -97,21 +94,18 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt)
|
|||||||
|
|
||||||
// parametric curve
|
// parametric curve
|
||||||
paramCurveBox = new Gtk::VBox ();
|
paramCurveBox = new Gtk::VBox ();
|
||||||
|
paramCurveBox->set_spacing(4);
|
||||||
paramCurve = Gtk::manage (new MyDiagonalCurve ());
|
paramCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||||
Gtk::Table* paramctab = Gtk::manage (new Gtk::Table (2,1));
|
Gtk::Table* paramctab = Gtk::manage (new Gtk::Table (2,1));
|
||||||
//Gtk::AspectFrame* afp = Gtk::manage (new Gtk::AspectFrame ("",Gtk::ALIGN_CENTER,Gtk::ALIGN_CENTER,1,false));
|
|
||||||
paramCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
paramCurve->set_size_request (GRAPH_SIZE+2*RADIUS, GRAPH_SIZE+2*RADIUS);
|
||||||
paramCurve->setType (DCT_Parametric);
|
paramCurve->setType (DCT_Parametric);
|
||||||
shcSelector = Gtk::manage (new SHCSelector ());
|
shcSelector = Gtk::manage (new SHCSelector ());
|
||||||
shcSelector->set_size_request (GRAPH_SIZE, 20);
|
shcSelector->set_size_request (GRAPH_SIZE, 20);
|
||||||
|
|
||||||
paramctab->attach (*paramCurve, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 4, 4);
|
paramctab->attach (*paramCurve, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK, 0, 0);
|
||||||
paramctab->attach (*shcSelector, 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK, RADIUS+4, 0);
|
paramctab->attach (*shcSelector, 0, 1, 1, 2, Gtk::FILL, Gtk::SHRINK, RADIUS, 0);
|
||||||
|
|
||||||
Gtk::HBox* tmpc = Gtk::manage (new Gtk::HBox ());
|
paramCurveBox->pack_start (*paramctab, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||||
tmpc->pack_start (*paramctab, true, false);
|
|
||||||
|
|
||||||
paramCurveBox->pack_start (*tmpc, true, true);
|
|
||||||
|
|
||||||
highlights = Gtk::manage (new Adjuster (M("CURVEEDITOR_HIGHLIGHTS"), -100, 100, 1, 0));
|
highlights = Gtk::manage (new Adjuster (M("CURVEEDITOR_HIGHLIGHTS"), -100, 100, 1, 0));
|
||||||
lights = Gtk::manage (new Adjuster (M("CURVEEDITOR_LIGHTS"), -100, 100, 1, 0));
|
lights = Gtk::manage (new Adjuster (M("CURVEEDITOR_LIGHTS"), -100, 100, 1, 0));
|
||||||
@@ -203,6 +197,8 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
|
|||||||
case (DCT_Spline):
|
case (DCT_Spline):
|
||||||
customCurve->setPoints (dCurve->customCurveEd);
|
customCurve->setPoints (dCurve->customCurveEd);
|
||||||
parent->pack_start (*customCurveBox);
|
parent->pack_start (*customCurveBox);
|
||||||
|
customCurveBox->check_resize();
|
||||||
|
customCurve->forceResize();
|
||||||
break;
|
break;
|
||||||
case (DCT_Parametric):
|
case (DCT_Parametric):
|
||||||
paramCurve->setPoints (dCurve->paramCurveEd);
|
paramCurve->setPoints (dCurve->paramCurveEd);
|
||||||
@@ -216,10 +212,13 @@ void DiagonalCurveEditorSubGroup::switchGUI() {
|
|||||||
darks->setValue (dCurve->paramCurveEd.at(6));
|
darks->setValue (dCurve->paramCurveEd.at(6));
|
||||||
shadows->setValue (dCurve->paramCurveEd.at(7));
|
shadows->setValue (dCurve->paramCurveEd.at(7));
|
||||||
parent->pack_start (*paramCurveBox);
|
parent->pack_start (*paramCurveBox);
|
||||||
|
paramCurve->forceResize();
|
||||||
break;
|
break;
|
||||||
case (DCT_NURBS):
|
case (DCT_NURBS):
|
||||||
NURBSCurve->setPoints (dCurve->NURBSCurveEd);
|
NURBSCurve->setPoints (dCurve->NURBSCurveEd);
|
||||||
parent->pack_start (*NURBSCurveBox);
|
parent->pack_start (*NURBSCurveBox);
|
||||||
|
NURBSCurveBox->check_resize();
|
||||||
|
NURBSCurve->forceResize();
|
||||||
break;
|
break;
|
||||||
default: // (DCT_Linear, DCT_Unchanged)
|
default: // (DCT_Linear, DCT_Unchanged)
|
||||||
// ... do nothing
|
// ... do nothing
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class DiagonalCurveEditorSubGroup : public CurveEditorSubGroup, public SHCListen
|
|||||||
|
|
||||||
friend class DiagonalCurveEditor;
|
friend class DiagonalCurveEditor;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Gtk::HBox* customCurveBox;
|
Gtk::HBox* customCurveBox;
|
||||||
Gtk::VBox* paramCurveBox;
|
Gtk::VBox* paramCurveBox;
|
||||||
Gtk::HBox* NURBSCurveBox;
|
Gtk::HBox* NURBSCurveBox;
|
||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
virtual void updateBackgroundHistogram (CurveEditor* ce);
|
virtual void updateBackgroundHistogram (CurveEditor* ce);
|
||||||
virtual void setColorProvider (ColorProvider* p);
|
virtual void setColorProvider (ColorProvider* p);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void storeCurveValues (CurveEditor* ce, const std::vector<double>& p);
|
void storeCurveValues (CurveEditor* ce, const std::vector<double>& p);
|
||||||
void storeDisplayedCurve ();
|
void storeDisplayedCurve ();
|
||||||
void restoreDisplayedHistogram ();
|
void restoreDisplayedHistogram ();
|
||||||
|
|||||||
@@ -38,23 +38,21 @@ FlatCurveEditorSubGroup::FlatCurveEditorSubGroup (CurveEditorGroup* prt) {
|
|||||||
|
|
||||||
// ControlPoints curve
|
// ControlPoints curve
|
||||||
CPointsCurveBox = new Gtk::HBox ();
|
CPointsCurveBox = new Gtk::HBox ();
|
||||||
//Gtk::HBox* tmpb = Gtk::manage (new Gtk::HBox ());
|
CPointsCurveBox->set_spacing(4);
|
||||||
CPointsCurve = Gtk::manage (new MyFlatCurve ());
|
CPointsCurve = Gtk::manage (new MyFlatCurve ());
|
||||||
//Gtk::AspectFrame* af = Gtk::manage (new Gtk::AspectFrame ("",Gtk::ALIGN_CENTER,Gtk::ALIGN_CENTER,1,false));
|
|
||||||
//CPointsCurve->set_size_request (GRAPH_SIZE+2*RADIUS+1, GRAPH_SIZE+2*RADIUS+1);
|
//CPointsCurve->set_size_request (GRAPH_SIZE+2*RADIUS+1, GRAPH_SIZE+2*RADIUS+1);
|
||||||
CPointsCurve->setType (FCT_MinMaxCPoints);
|
CPointsCurve->setType (FCT_MinMaxCPoints);
|
||||||
//tmpb->pack_start (*CPointsCurve, Gtk::PACK_EXPAND_WIDGET, 4);
|
CPointsCurveBox->pack_start (*CPointsCurve, Gtk::PACK_EXPAND_WIDGET, 0);
|
||||||
CPointsCurveBox->pack_start (*CPointsCurve, Gtk::PACK_EXPAND_WIDGET,4);
|
|
||||||
//CPointsCurveBox->pack_start (*tmpb, Gtk::PACK_EXPAND_WIDGET,4);
|
|
||||||
|
|
||||||
Gtk::VBox* CPointsbbox = Gtk::manage (new Gtk::VBox ());
|
Gtk::VBox* CPointsbbox = Gtk::manage (new Gtk::VBox ());
|
||||||
|
CPointsbbox->set_spacing(4);
|
||||||
saveCPoints = Gtk::manage (new Gtk::Button ());
|
saveCPoints = Gtk::manage (new Gtk::Button ());
|
||||||
saveCPoints->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
saveCPoints->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-save"), Gtk::ICON_SIZE_BUTTON)));
|
||||||
loadCPoints = Gtk::manage (new Gtk::Button ());
|
loadCPoints = Gtk::manage (new Gtk::Button ());
|
||||||
loadCPoints->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
loadCPoints->add (*Gtk::manage (new Gtk::Image (Gtk::StockID("gtk-open"), Gtk::ICON_SIZE_BUTTON)));
|
||||||
|
|
||||||
CPointsbbox->pack_end (*saveCPoints, Gtk::PACK_SHRINK, 4);
|
CPointsbbox->pack_end (*saveCPoints, Gtk::PACK_SHRINK, 0);
|
||||||
CPointsbbox->pack_end (*loadCPoints, Gtk::PACK_SHRINK, 4);
|
CPointsbbox->pack_end (*loadCPoints, Gtk::PACK_SHRINK, 0);
|
||||||
|
|
||||||
CPointsCurveBox->pack_end (*CPointsbbox, Gtk::PACK_SHRINK, 0);
|
CPointsCurveBox->pack_end (*CPointsbbox, Gtk::PACK_SHRINK, 0);
|
||||||
CPointsCurveBox->show_all ();
|
CPointsCurveBox->show_all ();
|
||||||
@@ -103,6 +101,8 @@ void FlatCurveEditorSubGroup::switchGUI() {
|
|||||||
case (FCT_MinMaxCPoints):
|
case (FCT_MinMaxCPoints):
|
||||||
CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
|
CPointsCurve->setPoints (dCurve->controlPointsCurveEd);
|
||||||
parent->pack_start (*CPointsCurveBox);
|
parent->pack_start (*CPointsCurveBox);
|
||||||
|
CPointsCurveBox->check_resize();
|
||||||
|
CPointsCurve->forceResize();
|
||||||
break;
|
break;
|
||||||
default: // (DCT_Linear, DCT_Unchanged)
|
default: // (DCT_Linear, DCT_Unchanged)
|
||||||
// ... do nothing
|
// ... do nothing
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class FlatCurveEditorSubGroup: public CurveEditorSubGroup {
|
|||||||
|
|
||||||
friend class FlatCurveEditor;
|
friend class FlatCurveEditor;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
Gtk::HBox* CPointsCurveBox;
|
Gtk::HBox* CPointsCurveBox;
|
||||||
|
|
||||||
MyFlatCurve* CPointsCurve;
|
MyFlatCurve* CPointsCurve;
|
||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
//virtual void updateBackgroundHistogram (CurveEditor* ce);
|
//virtual void updateBackgroundHistogram (CurveEditor* ce);
|
||||||
virtual void setColorProvider (ColorProvider* p);
|
virtual void setColorProvider (ColorProvider* p);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void storeCurveValues (CurveEditor* ce, const std::vector<double>& p);
|
void storeCurveValues (CurveEditor* ce, const std::vector<double>& p);
|
||||||
void storeDisplayedCurve ();
|
void storeDisplayedCurve ();
|
||||||
void restoreDisplayedHistogram ();
|
void restoreDisplayedHistogram ();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ MyCurve::MyCurve () : listener(NULL) {
|
|||||||
buttonPressed = false;
|
buttonPressed = false;
|
||||||
snapTo = ST_None;
|
snapTo = ST_None;
|
||||||
colorProvider = NULL;
|
colorProvider = NULL;
|
||||||
sized = false;
|
sized = RS_Pending;
|
||||||
|
|
||||||
set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
|
set_extension_events(Gdk::EXTENSION_EVENTS_ALL);
|
||||||
add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK);
|
add_events(Gdk::EXPOSURE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::POINTER_MOTION_HINT_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::BUTTON1_MOTION_MASK);
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ enum SnapToType {
|
|||||||
ST_Identity, // Point snapped to the identity curve
|
ST_Identity, // Point snapped to the identity curve
|
||||||
ST_Neighbors // Point snapped to the neighbor points
|
ST_Neighbors // Point snapped to the neighbor points
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ResizeState {
|
||||||
|
RS_Pending = 1, // Resize has to occure
|
||||||
|
RS_Done = 2, // Resize has been done
|
||||||
|
RS_Force = 4 // Resize has to occure even without CONFIGURE event
|
||||||
|
};
|
||||||
|
|
||||||
class MyCurveIdleHelper;
|
class MyCurveIdleHelper;
|
||||||
|
|
||||||
class MyCurve : public Gtk::DrawingArea {
|
class MyCurve : public Gtk::DrawingArea {
|
||||||
@@ -64,7 +71,10 @@ class MyCurve : public Gtk::DrawingArea {
|
|||||||
bool buttonPressed;
|
bool buttonPressed;
|
||||||
enum SnapToType snapTo;
|
enum SnapToType snapTo;
|
||||||
MyCurveIdleHelper* mcih;
|
MyCurveIdleHelper* mcih;
|
||||||
bool sized;
|
enum ResizeState sized;
|
||||||
|
|
||||||
|
virtual std::vector<double> get_vector (int veclen) = 0;
|
||||||
|
int getGraphMinSize() { return GRAPH_SIZE + RADIUS + 1; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MyCurve ();
|
MyCurve ();
|
||||||
@@ -74,12 +84,11 @@ class MyCurve : public Gtk::DrawingArea {
|
|||||||
void setColorProvider (ColorProvider* cp) { colorProvider = cp; }
|
void setColorProvider (ColorProvider* cp) { colorProvider = cp; }
|
||||||
void notifyListener ();
|
void notifyListener ();
|
||||||
void updateBackgroundHistogram (unsigned int* hist) {return;} ;
|
void updateBackgroundHistogram (unsigned int* hist) {return;} ;
|
||||||
|
void forceResize() { sized = RS_Force; }
|
||||||
virtual std::vector<double> getPoints () = 0;
|
virtual std::vector<double> getPoints () = 0;
|
||||||
virtual void setPoints (const std::vector<double>& p) = 0;
|
virtual void setPoints (const std::vector<double>& p) = 0;
|
||||||
virtual bool handleEvents (GdkEvent* event) = 0;
|
virtual bool handleEvents (GdkEvent* event) = 0;
|
||||||
virtual void reset () = 0;
|
virtual void reset () = 0;
|
||||||
protected:
|
|
||||||
virtual std::vector<double> get_vector (int veclen) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyCurveIdleHelper {
|
class MyCurveIdleHelper {
|
||||||
|
|||||||
@@ -243,6 +243,13 @@ void MyDiagonalCurve::draw (int handle) {
|
|||||||
get_window()->draw_drawable (style->get_fg_gc (state), pixmap, 0, 0, 0, 0, innerWidth + RADIUS * 2, innerHeight + RADIUS * 2);
|
get_window()->draw_drawable (style->get_fg_gc (state), pixmap, 0, 0, 0, 0, innerWidth + RADIUS * 2, innerHeight + RADIUS * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*void MyDiagonalCurve::graphSizeRequest (Gtk::Requisition* req) {
|
||||||
|
req->width = getGraphMinSize();
|
||||||
|
// The real height request should take care of the presence of the vertical
|
||||||
|
// scroll bar and its width
|
||||||
|
req->height = sized ? getGraphMinSize() : get_allocation().get_width();
|
||||||
|
}*/
|
||||||
|
|
||||||
bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
||||||
|
|
||||||
CursorShape new_type = cursor_type;
|
CursorShape new_type = cursor_type;
|
||||||
@@ -263,13 +270,24 @@ bool MyDiagonalCurve::handleEvents (GdkEvent* event) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case Gdk::CONFIGURE:
|
case Gdk::CONFIGURE: {
|
||||||
|
// Happen when the the window is resized
|
||||||
|
if (sized & (RS_Pending | RS_Force)) {
|
||||||
|
int size = get_allocation().get_width();
|
||||||
|
set_size_request(-1, size);
|
||||||
|
sized = RS_Done;
|
||||||
|
}
|
||||||
if (pixmap)
|
if (pixmap)
|
||||||
pixmap.clear ();
|
pixmap.clear ();
|
||||||
retval = true;
|
retval = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Gdk::EXPOSE:
|
case Gdk::EXPOSE:
|
||||||
|
if (sized & (RS_Pending | RS_Force)) {
|
||||||
|
int size = get_allocation().get_width();
|
||||||
|
set_size_request(-1, size);
|
||||||
|
}
|
||||||
|
sized = RS_Pending;
|
||||||
if (!pixmap) {
|
if (!pixmap) {
|
||||||
pixmap = Gdk::Pixmap::create (get_window(), get_allocation().get_width(), get_allocation().get_height());
|
pixmap = Gdk::Pixmap::create (get_window(), get_allocation().get_width(), get_allocation().get_height());
|
||||||
interpolate ();
|
interpolate ();
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ class MyDiagonalCurve : public MyCurve {
|
|||||||
void setActiveParam (int ac);
|
void setActiveParam (int ac);
|
||||||
void reset ();
|
void reset ();
|
||||||
void updateBackgroundHistogram (unsigned int* hist);
|
void updateBackgroundHistogram (unsigned int* hist);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ void MyFlatCurve::draw () {
|
|||||||
double x = (double)RADIUS+0.5 + innerWidth*curve.x[i];
|
double x = (double)RADIUS+0.5 + innerWidth*curve.x[i];
|
||||||
|
|
||||||
if (i == lit_point && editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointX)) {
|
if (i == lit_point && editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointX)) {
|
||||||
cr->set_line_width (2.0);
|
cr->set_line_width (4.0);
|
||||||
}
|
}
|
||||||
cr->move_to (x, (double)RADIUS+0.5);
|
cr->move_to (x, (double)RADIUS+0.5);
|
||||||
cr->line_to (x, (double)RADIUS+0.5 + innerHeight);
|
cr->line_to (x, (double)RADIUS+0.5 + innerHeight);
|
||||||
@@ -208,7 +208,7 @@ void MyFlatCurve::draw () {
|
|||||||
if (area&(FCT_Area_H|FCT_Area_V|FCT_Area_Point) || editedHandle==FCT_EditedHandle_CPointUD) {
|
if (area&(FCT_Area_H|FCT_Area_V|FCT_Area_Point) || editedHandle==FCT_EditedHandle_CPointUD) {
|
||||||
|
|
||||||
if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) {
|
if (editedHandle&(FCT_EditedHandle_CPointUD|FCT_EditedHandle_CPoint|FCT_EditedHandle_CPointY)) {
|
||||||
cr->set_line_width (2.0);
|
cr->set_line_width (4.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
colorProvider->colorForValue(curve.x[i], curve.y[i]);
|
colorProvider->colorForValue(curve.x[i], curve.y[i]);
|
||||||
@@ -467,7 +467,6 @@ bool MyFlatCurve::getHandles(int n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
||||||
|
|
||||||
CursorShape new_type = cursor_type;
|
CursorShape new_type = cursor_type;
|
||||||
@@ -489,11 +488,11 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case Gdk::CONFIGURE: {
|
case Gdk::CONFIGURE: {
|
||||||
GdkEventConfigure* cEvent = (GdkEventConfigure*)event;
|
// Happen when the the window is resized
|
||||||
if (!sized) {
|
if (sized & (RS_Pending | RS_Force)) {
|
||||||
int size = get_allocation().get_width();
|
int size = get_allocation().get_width();
|
||||||
set_size_request(size, size);
|
set_size_request(-1, size);
|
||||||
sized = true;
|
sized = RS_Done;
|
||||||
}
|
}
|
||||||
if (pixmap)
|
if (pixmap)
|
||||||
pixmap.clear ();
|
pixmap.clear ();
|
||||||
@@ -501,10 +500,11 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Gdk::EXPOSE:
|
case Gdk::EXPOSE:
|
||||||
if (!sized) {
|
if (sized & (RS_Pending | RS_Force)) {
|
||||||
set_size_request(GRAPH_SIZE + RADIUS + 1, GRAPH_SIZE + RADIUS + 1);
|
int size = get_allocation().get_width();
|
||||||
|
set_size_request(-1, size);
|
||||||
}
|
}
|
||||||
sized = false;
|
sized = RS_Pending;
|
||||||
if (!pixmap) {
|
if (!pixmap) {
|
||||||
pixmap = Gdk::Pixmap::create (get_window(), get_allocation().get_width(), get_allocation().get_height());
|
pixmap = Gdk::Pixmap::create (get_window(), get_allocation().get_width(), get_allocation().get_height());
|
||||||
interpolate ();
|
interpolate ();
|
||||||
@@ -694,8 +694,15 @@ bool MyFlatCurve::handleEvents (GdkEvent* event) {
|
|||||||
|
|
||||||
case Gdk::MOTION_NOTIFY:
|
case Gdk::MOTION_NOTIFY:
|
||||||
if (curve.type == FCT_Linear || curve.type == FCT_MinMaxCPoints) {
|
if (curve.type == FCT_Linear || curve.type == FCT_MinMaxCPoints) {
|
||||||
|
|
||||||
|
int leftNeigborPoint = -1;
|
||||||
|
int rightNeigborPoint = -1;
|
||||||
|
double leftNeigborY = -1.;
|
||||||
|
double rightNeigborY = -1.;
|
||||||
|
|
||||||
int previous_lit_point = lit_point;
|
int previous_lit_point = lit_point;
|
||||||
enum MouseOverAreas prevArea = area;
|
enum MouseOverAreas prevArea = area;
|
||||||
|
|
||||||
// get the pointer position
|
// get the pointer position
|
||||||
getCursorPosition(event);
|
getCursorPosition(event);
|
||||||
getMouseOverArea();
|
getMouseOverArea();
|
||||||
@@ -1092,7 +1099,7 @@ void MyFlatCurve::getCursorPosition(GdkEvent* event) {
|
|||||||
void MyFlatCurve::getMouseOverArea () {
|
void MyFlatCurve::getMouseOverArea () {
|
||||||
|
|
||||||
// When dragging an element, editedHandle keep its value
|
// When dragging an element, editedHandle keep its value
|
||||||
if (editedHandle == FCT_EditedHandle_None) {
|
if (editedHandle == FCT_EditedHandle_None) { // && curve.type!=Parametric
|
||||||
|
|
||||||
double minDist = 1000; // used to find out the point pointed by the cursor (over it)
|
double minDist = 1000; // used to find out the point pointed by the cursor (over it)
|
||||||
double minDistX = 1000; // used to find out the closest point
|
double minDistX = 1000; // used to find out the closest point
|
||||||
@@ -1103,17 +1110,6 @@ void MyFlatCurve::getMouseOverArea () {
|
|||||||
|
|
||||||
// NB: this function assume that the graph's shape is a square
|
// NB: this function assume that the graph's shape is a square
|
||||||
|
|
||||||
//if (curve.type!=Parametric) {
|
|
||||||
|
|
||||||
// we first check first if the cursor is still over a tangent handle
|
|
||||||
/*if (area = (FCT_Area_LeftTan|FCT_Area_RightTan)) {
|
|
||||||
if (still over a tangent handle) {
|
|
||||||
|
|
||||||
}
|
|
||||||
area = FCT_Area_None;
|
|
||||||
return;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Check if the cursor is over a tangent handle
|
// Check if the cursor is over a tangent handle
|
||||||
if (tanHandlesDisplayed) {
|
if (tanHandlesDisplayed) {
|
||||||
|
|
||||||
|
|||||||
@@ -65,15 +65,6 @@ class FlatCurveDescr {
|
|||||||
rightTangent; // Range: [0.0 - 1.0], where 1.0 = distance from this to next point
|
rightTangent; // Range: [0.0 - 1.0], where 1.0 = distance from this to next point
|
||||||
};
|
};
|
||||||
|
|
||||||
class RectArea {
|
|
||||||
|
|
||||||
public:
|
|
||||||
double top;
|
|
||||||
double left;
|
|
||||||
double bottom;
|
|
||||||
double right;
|
|
||||||
};
|
|
||||||
|
|
||||||
class HandlePosition {
|
class HandlePosition {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -102,8 +93,6 @@ class MyFlatCurve : public MyCurve {
|
|||||||
double minDistanceX; // X minimal distance before point suppression
|
double minDistanceX; // X minimal distance before point suppression
|
||||||
double minDistanceY; // Y minimal distance before point suppression
|
double minDistanceY; // Y minimal distance before point suppression
|
||||||
double deletedPointX; // Backup of the X value of the edited point, when deleted while being dragged
|
double deletedPointX; // Backup of the X value of the edited point, when deleted while being dragged
|
||||||
//RectArea leftTanHandle; // XY coordinate if the upper left and bottom right corner of the left tangent handle
|
|
||||||
//RectArea rightTanHandle; // XY coordinate if the upper left and bottom right corner of the right tangent handle
|
|
||||||
HandlePosition leftTanHandle; // XY coordinate if the upper left and bottom right corner of the left tangent handle
|
HandlePosition leftTanHandle; // XY coordinate if the upper left and bottom right corner of the left tangent handle
|
||||||
HandlePosition rightTanHandle; // XY coordinate if the upper left and bottom right corner of the right tangent handle
|
HandlePosition rightTanHandle; // XY coordinate if the upper left and bottom right corner of the right tangent handle
|
||||||
bool tanHandlesDisplayed; // True if the tangent handles are displayed
|
bool tanHandlesDisplayed; // True if the tangent handles are displayed
|
||||||
|
|||||||
Reference in New Issue
Block a user