Code cleanup of editcallbacks.h/.cc for more safety

This commit is contained in:
Hombre
2019-03-24 01:40:25 +01:00
parent 108b69ae22
commit f60711b65b
14 changed files with 262 additions and 176 deletions

View File

@@ -89,7 +89,7 @@ void Crop::setListener(DetailedCropListener* il)
EditUniqueID Crop::getCurrEditID()
{
EditSubscriber *subscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : nullptr;
const EditSubscriber *subscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : nullptr;
return subscriber ? subscriber->getEditID() : EUID_None;
}
@@ -102,7 +102,7 @@ void Crop::setEditSubscriber(EditSubscriber* newSubscriber)
MyMutex::MyLock lock(cropMutex);
// At this point, editCrop.dataProvider->currSubscriber is the old subscriber
EditSubscriber *oldSubscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : nullptr;
const EditSubscriber *oldSubscriber = PipetteBuffer::dataProvider ? PipetteBuffer::dataProvider->getCurrSubscriber() : nullptr;
if (newSubscriber == nullptr || (oldSubscriber != nullptr && oldSubscriber->getPipetteBufferType() != newSubscriber->getPipetteBufferType())) {
if (PipetteBuffer::imgFloatBuffer != nullptr) {

View File

@@ -1113,7 +1113,7 @@ public:
}
}
void getPipetteData (T &valueR, T &valueG, T &valueB, int posX, int posY, int squareSize, int tran) const
void getPipetteData (T &valueR, T &valueG, T &valueB, int posX, int posY, const int squareSize, int tran) const
{
int x;
int y;

View File

@@ -134,13 +134,17 @@ bool PipetteBuffer::bufferCreated()
return false;
}
void PipetteBuffer::getPipetteData(float* v, int x, int y, int squareSize)
void PipetteBuffer::getPipetteData(int x, int y, const int squareSize)
{
if (ready && dataProvider && dataProvider->getCurrSubscriber()) {
switch (dataProvider->getCurrSubscriber()->getPipetteBufferType()) {
case (BT_IMAGEFLOAT):
if (imgFloatBuffer) {
float v[3];
imgFloatBuffer->getPipetteData(v[0], v[1], v[2], x, y, squareSize, 0);
dataProvider->setPipetteVal1(v[0]);
dataProvider->setPipetteVal2(v[1]);
dataProvider->setPipetteVal3(v[2]);
return;
}
@@ -148,7 +152,11 @@ void PipetteBuffer::getPipetteData(float* v, int x, int y, int squareSize)
case (BT_LABIMAGE):
if (LabBuffer) {
float v[3];
LabBuffer->getPipetteData(v[0], v[1], v[2], x, y, squareSize);
dataProvider->setPipetteVal1(v[0]);
dataProvider->setPipetteVal2(v[1]);
dataProvider->setPipetteVal3(v[2]);
return;
}
@@ -156,14 +164,19 @@ void PipetteBuffer::getPipetteData(float* v, int x, int y, int squareSize)
case (BT_SINGLEPLANE_FLOAT):
if (singlePlaneBuffer.data != nullptr) {
singlePlaneBuffer.getPipetteData(v[0], x, y, squareSize, 0);
v[1] = v[2] = -1.f;
float v;
singlePlaneBuffer.getPipetteData(v, x, y, squareSize, 0);
dataProvider->setPipetteVal1(v);
dataProvider->setPipetteVal2(-1.f);
dataProvider->setPipetteVal3(-1.f);
return;
}
}
}
v[0] = v[1] = v[2] = -1.f;
dataProvider->setPipetteVal1(-1.f);
dataProvider->setPipetteVal2(-1.f);
dataProvider->setPipetteVal3(-1.f);
}
}

View File

@@ -90,7 +90,7 @@ public:
bool bufferCreated();
// get the pipette values
void getPipetteData(float* v, int x, int y, int squareSize);
void getPipetteData(int x, int y, const int squareSize);
};
}

View File

@@ -258,7 +258,9 @@ void CropWindow::leaveNotify (GdkEventCrossing* event)
EditSubscriber* subscriber = iarea->getCurrSubscriber();
if (state == SNormal && subscriber && subscriber->getEditingType() == ET_PIPETTE) {
iarea->pipetteVal[0] = iarea->pipetteVal[1] = iarea->pipetteVal[2] = -1.f;
iarea->setPipetteVal1(-1.f);
iarea->setPipetteVal2(-1.f);
iarea->setPipetteVal3(-1.f);
if (subscriber->mouseOver(0)) {
iarea->redraw();
@@ -467,7 +469,7 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y)
state = SEditDrag1;
} else if (editSubscriber->isPicking()) {
state = SEditPick1;
pickedObject = iarea->object;
pickedObject = iarea->getObject();
pickModifierKey = bstate;
}
press_x = x;
@@ -501,7 +503,7 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y)
state = SEditDrag1;
} else if (editSubscriber->isPicking()) {
state = SEditPick1;
pickedObject = iarea->object;
pickedObject = iarea->getObject();
pickModifierKey = bstate;
}
@@ -535,7 +537,7 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y)
state = SEditDrag2;
} else if (editSubscriber->isPicking()) {
state = SEditPick2;
pickedObject = iarea->object;
pickedObject = iarea->getObject();
pickModifierKey = bstate;
}
@@ -555,7 +557,7 @@ void CropWindow::buttonPress (int button, int type, int bstate, int x, int y)
state = SEditDrag3;
} else if (editSubscriber->isPicking()) {
state = SEditPick3;
pickedObject = iarea->object;
pickedObject = iarea->getObject();
pickModifierKey = bstate;
}
@@ -678,23 +680,25 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y)
if (state == SEditDrag1 && editSubscriber->getEditingType() == ET_PIPETTE) {
screenCoordToCropBuffer (x, y, cropPos.x, cropPos.y);
iarea->object = onArea (CropImage, x, y) && !onArea (CropObserved, x, y) ? 1 : 0;
iarea->setObject(onArea (CropImage, x, y) && !onArea (CropObserved, x, y) ? 1 : 0);
//iarea->object = cropgl && cropgl->inImageArea(iarea->posImage.x, iarea->posImage.y) ? 1 : 0;
if (iarea->object) {
crop->getPipetteData(iarea->pipetteVal, cropPos.x, cropPos.y, iarea->getPipetteRectSize());
//iarea->setObject(cropgl && cropgl->inImageArea(iarea->posImage.x, iarea->posImage.y) ? 1 : 0);
if (iarea->getObject()) {
crop->getPipetteData(cropPos.x, cropPos.y, iarea->getPipetteRectSize());
//printf("PipetteData: %.3f %.3f %.3f\n", iarea->pipetteVal[0], iarea->pipetteVal[1], iarea->pipetteVal[2]);
} else {
iarea->pipetteVal[0] = iarea->pipetteVal[1] = iarea->pipetteVal[2] = -1.f;
iarea->setPipetteVal1(-1.f);
iarea->setPipetteVal2(-1.f);
iarea->setPipetteVal3(-1.f);
}
} else if (editSubscriber->getEditingType() == ET_OBJECTS) {
screenCoordToCropCanvas (x, y, cropPos.x, cropPos.y);
iarea->object = ObjectMOBuffer::getObjectID(cropPos);
iarea->setObject(ObjectMOBuffer::getObjectID(cropPos));
}
needRedraw |= editSubscriber->mouseOver(bstate);
} else {
iarea->object = 0;
iarea->setObject(0);
}
iarea->deltaImage.set(0, 0);
@@ -714,9 +718,9 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y)
Coord cropPos;
screenCoordToCropCanvas (x, y, cropPos.x, cropPos.y);
iarea->object = ObjectMOBuffer::getObjectID(cropPos);
iarea->setObject(ObjectMOBuffer::getObjectID(cropPos));
bool elemPicked = iarea->object == pickedObject && bstate == pickModifierKey;
bool elemPicked = iarea->getObject() == pickedObject && bstate == pickModifierKey;
if (state == SEditPick1) {
needRedraw = editSubscriber->pick1 (elemPicked);
@@ -726,12 +730,13 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y)
needRedraw = editSubscriber->pick3 (elemPicked);
}
iarea->object = pickedObject = -1;
pickedObject = -1;
iarea->setObject(-1);
pickModifierKey = 0;
needRedraw |= editSubscriber->mouseOver (bstate);
} else {
iarea->object = 0;
iarea->setObject(0);
}
} else if (state == SDeletePicker) {
needRedraw = true;
@@ -760,9 +765,11 @@ void CropWindow::buttonRelease (int button, int num, int bstate, int x, int y)
}
if (state != SDeletePicker && state != SEditDrag3 && state != SEditPick3 && button == 3 && !(bstate & (GDK_SHIFT_MASK|GDK_CONTROL_MASK))) {
iarea->pipetteVal[0] = iarea->pipetteVal[1] = iarea->pipetteVal[2] = -1.f;
iarea->setPipetteVal1(-1.f);
iarea->setPipetteVal2(-1.f);
iarea->setPipetteVal3(-1.f);
needRedraw = iarea->object == 1;
needRedraw = iarea->getObject() == 1;
if (editSubscriber && editSubscriber->getEditingType() == ET_PIPETTE) {
editSubscriber->mouseOver(0);
@@ -950,18 +957,20 @@ void CropWindow::pointerMoved (int bstate, int x, int y)
if (editSubscriber->getEditingType() == ET_PIPETTE) {
screenCoordToCropBuffer (x, y, cropPos.x, cropPos.y);
iarea->object = onArea (CropImage, x, y) && !onArea (CropObserved, x, y) ? 1 : 0;
iarea->setObject(onArea (CropImage, x, y) && !onArea (CropObserved, x, y) ? 1 : 0);
//iarea->object = cropgl && cropgl->inImageArea(iarea->posImage.x, iarea->posImage.y) ? 1 : 0;
if (iarea->object) {
crop->getPipetteData(iarea->pipetteVal, cropPos.x, cropPos.y, iarea->getPipetteRectSize());
//iarea->setObject(cropgl && cropgl->inImageArea(iarea->posImage.x, iarea->posImage.y) ? 1 : 0);
if (iarea->getObject()) {
crop->getPipetteData(cropPos.x, cropPos.y, iarea->getPipetteRectSize());
//printf("PipetteData: %.3f %.3f %.3f\n", iarea->pipetteVal[0], iarea->pipetteVal[1], iarea->pipetteVal[2]);
} else {
iarea->pipetteVal[0] = iarea->pipetteVal[1] = iarea->pipetteVal[2] = -1.f;
iarea->setPipetteVal1(-1.f);
iarea->setPipetteVal2(-1.f);
iarea->setPipetteVal3(-1.f);
}
} else if (editSubscriber->getEditingType() == ET_OBJECTS) {
screenCoordToCropCanvas (x, y, cropPos.x, cropPos.y);
iarea->object = ObjectMOBuffer::getObjectID(cropPos);
iarea->setObject(ObjectMOBuffer::getObjectID(cropPos));
}
if (editSubscriber->mouseOver(bstate)) {
@@ -1910,7 +1919,7 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr)
if (state == SNormal && isFlawnOver) {
EditSubscriber *editSubscriber = iarea->getCurrSubscriber();
if (iarea->getToolMode () == TMHand && editSubscriber && editSubscriber->getEditingType() == ET_PIPETTE && iarea->object) {
if (iarea->getToolMode () == TMHand && editSubscriber && editSubscriber->getEditingType() == ET_PIPETTE && iarea->getObject()) {
drawUnscaledSpotRectangle (cr, iarea->getPipetteRectSize ());
} else if (iarea->getToolMode () == TMSpotWB) {
drawScaledSpotRectangle (cr, iarea->getSpotWBRectSize ());

View File

@@ -449,7 +449,7 @@ void CurveEditor::switchOffEditMode ()
EditSubscriber::switchOffEditMode(); // disconnect
}
bool CurveEditor::mouseOver(const int modifierKey)
const bool CurveEditor::mouseOver(const int modifierKey)
{
EditDataProvider* provider = getEditProvider();
subGroup->pipetteMouseOver(provider, modifierKey);
@@ -461,12 +461,12 @@ bool CurveEditor::button1Pressed(const int modifierKey)
{
EditDataProvider* provider = getEditProvider();
if (provider->object) {
if (provider->getObject()) {
remoteDrag = subGroup->pipetteButton1Pressed(provider, modifierKey);
}
if (remoteDrag) {
action = ES_ACTION_DRAGGING;
action = EditSubscriber::Action::DRAGGING;
}
subGroup->refresh(this);
@@ -490,7 +490,7 @@ bool CurveEditor::drag1(const int modifierKey)
return false;
}
CursorShape CurveEditor::getCursor(const int objectID)
const CursorShape CurveEditor::getCursor(const int objectID) const
{
if (remoteDrag) {
return CSResizeHeight;

View File

@@ -128,11 +128,11 @@ public:
sigc::signal<void> signal_curvepoint_release();
void switchOffEditMode () override;
bool mouseOver(const int modifierKey) override;
const bool mouseOver(const int modifierKey) override;
bool button1Pressed(const int modifierKey) override;
bool button1Released() override;
bool drag1(const int modifierKey) override;
CursorShape getCursor(const int objectID) override;
const CursorShape getCursor(const int objectID) const override;
};

View File

@@ -450,18 +450,18 @@ void DiagonalCurveEditorSubGroup::pipetteMouseOver(EditDataProvider *provider, i
editedAdjuster = nullptr;
int n = 0;
if (provider->pipetteVal[0] != -1.f) {
pipetteVal += provider->pipetteVal[0];
if (provider->getPipetteVal1() != -1.f) {
pipetteVal += provider->getPipetteVal1();
++n;
}
if (provider->pipetteVal[1] != -1.f) {
pipetteVal += provider->pipetteVal[1];
if (provider->getPipetteVal2() != -1.f) {
pipetteVal += provider->getPipetteVal2();
++n;
}
if (provider->pipetteVal[2] != -1.f) {
pipetteVal += provider->pipetteVal[2];
if (provider->getPipetteVal3() != -1.f) {
pipetteVal += provider->getPipetteVal3();
++n;
}

View File

@@ -19,7 +19,13 @@
#include "editcallbacks.h"
EditSubscriber::EditSubscriber (EditType editType) : ID(EUID_None), editingType(editType), bufferType(BT_SINGLEPLANE_FLOAT), provider(nullptr), action(ES_ACTION_NONE) {}
EditSubscriber::EditSubscriber (EditType editType) :
ID(EUID_None),
editingType(editType),
bufferType(BT_SINGLEPLANE_FLOAT),
provider(nullptr),
action(EditSubscriber::Action::NONE)
{}
void EditSubscriber::setEditProvider(EditDataProvider *provider)
{
@@ -32,7 +38,7 @@ void EditSubscriber::setEditID(EditUniqueID ID, BufferType buffType)
bufferType = buffType;
}
bool EditSubscriber::isCurrentSubscriber()
const bool EditSubscriber::isCurrentSubscriber() const
{
//if (provider && provider->getCurrSubscriber())
// return provider->getCurrSubscriber()->getEditID() == ID;
@@ -63,39 +69,47 @@ void EditSubscriber::switchOffEditMode()
unsubscribe();
}
EditUniqueID EditSubscriber::getEditID()
const EditUniqueID EditSubscriber::getEditID() const
{
return ID;
}
EditType EditSubscriber::getEditingType()
const EditType EditSubscriber::getEditingType() const
{
return editingType;
}
BufferType EditSubscriber::getPipetteBufferType()
const BufferType EditSubscriber::getPipetteBufferType() const
{
return bufferType;
}
bool EditSubscriber::isDragging()
const bool EditSubscriber::isDragging() const
{
return action == ES_ACTION_DRAGGING;
return action == EditSubscriber::Action::DRAGGING;
}
bool EditSubscriber::isPicking()
const bool EditSubscriber::isPicking() const
{
return action == ES_ACTION_PICKING;
return action == EditSubscriber::Action::PICKING;
}
//--------------------------------------------------------------------------------------------------
EditDataProvider::EditDataProvider() : currSubscriber(nullptr), object(0), posScreen(-1, -1), posImage(-1, -1),
deltaScreen(0, 0), deltaImage(0, 0), deltaPrevScreen(0, 0), deltaPrevImage(0, 0)
{
pipetteVal[0] = pipetteVal[1] = pipetteVal[2] = 0.f;
}
EditDataProvider::EditDataProvider() :
currSubscriber(nullptr),
object(0),
pipetteVal1(0.f),
pipetteVal2(0.f),
pipetteVal3(0.f),
posScreen(-1, -1),
posImage(-1, -1),
deltaScreen(0, 0),
deltaImage(0, 0),
deltaPrevScreen(0, 0),
deltaPrevImage(0, 0)
{}
void EditDataProvider::subscribe(EditSubscriber *subscriber)
{
@@ -118,7 +132,47 @@ void EditDataProvider::switchOffEditMode()
}
}
CursorShape EditDataProvider::getCursor(int objectID)
int EditDataProvider::getObject()
{
return object;
}
void EditDataProvider::setObject(int newObject)
{
object = newObject;
}
float EditDataProvider::getPipetteVal1()
{
return pipetteVal1;
}
float EditDataProvider::getPipetteVal2()
{
return pipetteVal2;
}
float EditDataProvider::getPipetteVal3()
{
return pipetteVal3;
}
void EditDataProvider::setPipetteVal1(float newVal)
{
pipetteVal1 = newVal;
}
void EditDataProvider::setPipetteVal2(float newVal)
{
pipetteVal2 = newVal;
}
void EditDataProvider::setPipetteVal3(float newVal)
{
pipetteVal3 = newVal;
}
const CursorShape EditDataProvider::getCursor(int objectID) const
{
if (currSubscriber) {
currSubscriber->getCursor(objectID);
@@ -127,8 +181,79 @@ CursorShape EditDataProvider::getCursor(int objectID)
return CSHandOpen;
}
EditSubscriber* EditDataProvider::getCurrSubscriber()
EditSubscriber* EditDataProvider::getCurrSubscriber() const
{
return currSubscriber;
}
EditDataProvider* EditSubscriber::getEditProvider () {
return provider;
}
const CursorShape EditSubscriber::getCursor (int objectID) const {
return CSHandOpen;
}
const bool EditSubscriber::mouseOver (const int modifierKey) {
return false;
}
bool EditSubscriber::button1Pressed (const int modifierKey) {
return false;
}
bool EditSubscriber::button1Released () {
return false;
}
bool EditSubscriber::button2Pressed (const int modifierKey) {
return false;
}
bool EditSubscriber::button2Released () {
return false;
}
bool EditSubscriber::button3Pressed (const int modifierKey) {
return false;
}
bool EditSubscriber::button3Released () {
return false;
}
bool EditSubscriber::drag1 (const int modifierKey) {
return false;
}
bool EditSubscriber::drag2 (const int modifierKey) {
return false;
}
bool EditSubscriber::drag3 (const int modifierKey) {
return false;
}
bool EditSubscriber::pick1 (const bool picked) {
return false;
}
bool EditSubscriber::pick2 (const bool picked) {
return false;
}
bool EditSubscriber::pick3 (const bool picked) {
return false;
}
const std::vector<Geometry*>& EditSubscriber::getVisibleGeometry () {
return visibleGeometry;
}
const std::vector<Geometry*>& EditSubscriber::getMouseOverGeometry () {
return mouseOverGeometry;
}
const int EditDataProvider::getPipetteRectSize () const {
return 8; // TODO: make a GUI
}

View File

@@ -44,38 +44,40 @@ private:
protected:
std::vector<Geometry*> visibleGeometry; /// displayed geometry
std::vector<Geometry*> mouseOverGeometry; /// mouseOver geometry, drawn in a hidden buffer
enum {
ES_ACTION_NONE, ///
ES_ACTION_DRAGGING, /// set action to this value in the buttonPressed event to start dragging and ask for drag event
ES_ACTION_PICKING /// set action to this value in the buttonPressed event whenever the user is picking something through a single click. In this case, the pickX events will be called INSTEAD of buttonXReleased !
} action; /// object mode only, ignored in Pipette mode
enum class Action {
NONE, ///
DRAGGING, /// set action to this value in the buttonPressed event to start dragging and ask for drag event
PICKING /// set action to this value in the buttonPressed event whenever the user is picking something through a single click. In this case, the pickX events will be called INSTEAD of buttonXReleased !
};
Action action; /// object mode only, ignored in Pipette mode
public:
explicit EditSubscriber (EditType editType);
virtual ~EditSubscriber () {}
virtual ~EditSubscriber () = default;
void setEditProvider(EditDataProvider *provider);
EditDataProvider* getEditProvider ();
void setEditID(EditUniqueID ID, BufferType buffType);
bool isCurrentSubscriber();
const bool isCurrentSubscriber() const;
virtual void subscribe();
virtual void unsubscribe();
virtual void switchOffEditMode (); /// Occurs when the user want to stop the editing mode
EditUniqueID getEditID();
EditType getEditingType();
BufferType getPipetteBufferType();
bool isDragging(); /// Returns true if something is being dragged and drag events has to be sent (object mode only)
bool isPicking(); /// Returns true if something is being picked
virtual void switchOffEditMode(); /// Occurs when the user want to stop the editing mode
const EditUniqueID getEditID() const;
const EditType getEditingType() const;
const BufferType getPipetteBufferType() const;
const bool isDragging() const; /// Returns true if something is being dragged and drag events has to be sent (object mode only)
const bool isPicking() const; /// Returns true if something is being picked
/** @brief Get the cursor to be displayed when above handles
@param objectID object currently "hovered" */
virtual CursorShape getCursor (const int objectID);
virtual const CursorShape getCursor (int objectID) const;
/** @brief Triggered when the mouse is moving over an object
This method is also triggered when the cursor is moving over the image in ET_PIPETTE mode
@param modifierKey Gtk's event modifier key (GDK_CONTROL_MASK | GDK_SHIFT_MASK | ...)
@return true if the preview has to be redrawn, false otherwise */
virtual bool mouseOver (const int modifierKey);
virtual const bool mouseOver (const int modifierKey);
/** @brief Triggered when mouse button 1 is pressed, together with the CTRL modifier key if the subscriber is of type ET_PIPETTE
Once the key is pressed, RT will enter in drag1 mode on subsequent mouse movements
@@ -158,10 +160,12 @@ class EditDataProvider
private:
EditSubscriber *currSubscriber;
int object; /// ET_OBJECTS mode: Object detected under the cursor, 0 otherwise; ET_PIPETTE mode: 1 if above the image, 0 otherwise
float pipetteVal1; /// Current pipette values
float pipetteVal2; /// Current pipette values; if bufferType==BT_SINGLEPLANE_FLOAT, will be set to 0
float pipetteVal3; /// Current pipette values; if bufferType==BT_SINGLEPLANE_FLOAT, will be set to 0
public:
int object; /// ET_OBJECTS mode: Object detected under the cursor, 0 otherwise; ET_PIPETTE mode: 1 if above the image, 0 otherwise
float pipetteVal[3]; /// Current pipette values; if bufferType==BT_SINGLEPLANE_FLOAT, #2 & #3 will be set to 0
rtengine::Coord posScreen; /// Location of the mouse button press, in preview image space
rtengine::Coord posImage; /// Location of the mouse button press, in the full image space
@@ -171,86 +175,21 @@ public:
rtengine::Coord deltaPrevImage; /// Delta relative to the previous mouse location, in the full image space
EditDataProvider();
virtual ~EditDataProvider() {}
virtual ~EditDataProvider() = default;
virtual void subscribe(EditSubscriber *subscriber);
virtual void unsubscribe(); /// Occurs when the subscriber has been switched off first
virtual void switchOffEditMode (); /// Occurs when the user want to stop the editing mode
virtual CursorShape getCursor(int objectID);
int getPipetteRectSize ();
EditSubscriber* getCurrSubscriber();
virtual void getImageSize (int &w, int&h) = 0;
virtual void subscribe(EditSubscriber *subscriber);
virtual void unsubscribe(); /// Occurs when the subscriber has been switched off first
virtual void switchOffEditMode (); /// Occurs when the user want to stop the editing mode
int getObject();
void setObject(int newObject);
float getPipetteVal1();
float getPipetteVal2();
float getPipetteVal3();
void setPipetteVal1(float newVal);
void setPipetteVal2(float newVal);
void setPipetteVal3(float newVal);
virtual const CursorShape getCursor(int objectID) const;
const int getPipetteRectSize () const;
EditSubscriber* getCurrSubscriber() const;
virtual void getImageSize (int &w, int&h) = 0;
};
inline EditDataProvider* EditSubscriber::getEditProvider () {
return provider;
}
inline CursorShape EditSubscriber::getCursor (const int objectID) {
return CSHandOpen;
}
inline bool EditSubscriber::mouseOver (const int modifierKey) {
return false;
}
inline bool EditSubscriber::button1Pressed (const int modifierKey) {
return false;
}
inline bool EditSubscriber::button1Released () {
return false;
}
inline bool EditSubscriber::button2Pressed (const int modifierKey) {
return false;
}
inline bool EditSubscriber::button2Released () {
return false;
}
inline bool EditSubscriber::button3Pressed (const int modifierKey) {
return false;
}
inline bool EditSubscriber::button3Released () {
return false;
}
inline bool EditSubscriber::drag1 (const int modifierKey) {
return false;
}
inline bool EditSubscriber::drag2 (const int modifierKey) {
return false;
}
inline bool EditSubscriber::drag3 (const int modifierKey) {
return false;
}
inline bool EditSubscriber::pick1 (const bool picked) {
return false;
}
inline bool EditSubscriber::pick2 (const bool picked) {
return false;
}
inline bool EditSubscriber::pick3 (const bool picked) {
return false;
}
inline const std::vector<Geometry*>& EditSubscriber::getVisibleGeometry () {
return visibleGeometry;
}
inline const std::vector<Geometry*>& EditSubscriber::getMouseOverGeometry () {
return mouseOverGeometry;
}
inline int EditDataProvider::getPipetteRectSize () {
return 8; // TODO: make a GUI
}

View File

@@ -331,7 +331,7 @@ void Gradient::editToggled ()
}
}
CursorShape Gradient::getCursor(const int objectID)
const CursorShape Gradient::getCursor(const int objectID) const
{
switch (objectID) {
case (0):
@@ -357,11 +357,11 @@ CursorShape Gradient::getCursor(const int objectID)
}
}
bool Gradient::mouseOver(const int modifierKey)
const bool Gradient::mouseOver(const int modifierKey)
{
EditDataProvider* editProvider = getEditProvider();
if (editProvider && editProvider->object != lastObject) {
if (editProvider && editProvider->getObject() != lastObject) {
if (lastObject > -1) {
if (lastObject == 2 || lastObject == 3) {
EditSubscriber::visibleGeometry.at(2)->state = Geometry::NORMAL;
@@ -371,16 +371,16 @@ bool Gradient::mouseOver(const int modifierKey)
}
}
if (editProvider->object > -1) {
if (editProvider->object == 2 || editProvider->object == 3) {
if (editProvider->getObject() > -1) {
if (editProvider->getObject() == 2 || editProvider->getObject() == 3) {
EditSubscriber::visibleGeometry.at(2)->state = Geometry::PRELIGHT;
EditSubscriber::visibleGeometry.at(3)->state = Geometry::PRELIGHT;
} else {
EditSubscriber::visibleGeometry.at(editProvider->object)->state = Geometry::PRELIGHT;
EditSubscriber::visibleGeometry.at(editProvider->getObject())->state = Geometry::PRELIGHT;
}
}
lastObject = editProvider->object;
lastObject = editProvider->getObject();
return true;
}
@@ -441,7 +441,7 @@ bool Gradient::button1Pressed(const int modifierKey)
draggedFeatherOffset -= (feather->getValue() / 200. * diagonal);
}
EditSubscriber::action = ES_ACTION_DRAGGING;
EditSubscriber::action = EditSubscriber::Action::DRAGGING;
return false;
} else { // should theoretically always be true
// this will let this class ignore further drag events
@@ -462,7 +462,7 @@ bool Gradient::button1Pressed(const int modifierKey)
bool Gradient::button1Released()
{
draggedPointOldAngle = -1000.;
EditSubscriber::action = ES_ACTION_NONE;
EditSubscriber::action = EditSubscriber::Action::NONE;
return true;
}

View File

@@ -52,8 +52,8 @@ public:
void setEditProvider (EditDataProvider* provider) override;
// EditSubscriber interface
CursorShape getCursor(const int objectID) override;
bool mouseOver(const int modifierKey) override;
const CursorShape getCursor(const int objectID) const override;
const bool mouseOver(const int modifierKey) override;
bool button1Pressed(const int modifierKey) override;
bool button1Released() override;
bool drag1(const int modifierKey) override;

View File

@@ -989,9 +989,9 @@ void MyDiagonalCurve::pipetteMouseOver (CurveEditor *ce, EditDataProvider *provi
return;
}
pipetteR = provider->pipetteVal[0];
pipetteG = provider->pipetteVal[1];
pipetteB = provider->pipetteVal[2];
pipetteR = provider->getPipetteVal1();
pipetteG = provider->getPipetteVal2();
pipetteB = provider->getPipetteVal3();
pipetteVal = 0.f;
if (listener) {

View File

@@ -1209,9 +1209,9 @@ void MyFlatCurve::pipetteMouseOver (CurveEditor *ce, EditDataProvider *provider,
return;
}
pipetteR = provider->pipetteVal[0];
pipetteG = provider->pipetteVal[1];
pipetteB = provider->pipetteVal[2];
pipetteR = provider->getPipetteVal1();
pipetteG = provider->getPipetteVal2();
pipetteB = provider->getPipetteVal3();
pipetteVal = 0.f;
if (listener) {