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

@@ -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
}