Tool structure- input bug

This commit is contained in:
Sonaion
2019-12-10 15:32:22 +01:00
parent 0aa3b17b8a
commit 30d6781e7f
10 changed files with 118 additions and 41 deletions

View File

@@ -12,12 +12,24 @@ IntelliTool::~IntelliTool(){
void IntelliTool::onMouseRightPressed(int x, int y){
this->drawing=true;
//create drawing layer
this->createToolLayer();
if(drawing){
drawing=false;
this->deleteToolLayer();
}
}
void IntelliTool::onMouseRightReleased(int x, int y){
//optional for tool
}
void IntelliTool::onMouseLeftPressed(int x, int y){
this->drawing=true;
//create drawing layer
this->createToolLayer();
}
void IntelliTool::onMouseLeftReleased(int x, int y){
if(drawing){
drawing=false;
this->mergeToolLayer();
@@ -25,17 +37,6 @@ void IntelliTool::onMouseRightReleased(int x, int y){
}
}
void IntelliTool::onMouseLeftPressed(int x, int y){
if(drawing){
drawing=false;
this->deleteToolLayer();
}
}
void IntelliTool::onMouseLeftReleased(int x, int y){
//optional for tool
}
void IntelliTool::onMouseMoved(int x, int y){
//optional for tool
}

View File

@@ -0,0 +1,42 @@
#include"IntelliToolPen.h"
#include"Layer/PaintingArea.h"
#include"QDebug"
IntelliToolPen::IntelliToolPen(PaintingArea* Area)
:IntelliTool(Area){
}
IntelliToolPen::~IntelliToolPen(){
}
void IntelliToolPen::onMouseRightPressed(int x, int y){
IntelliTool::onMouseRightPressed(x,y);
//implement in here
this->point=QPoint(x,y);
this->Canvas->image->drawPixel(point, QColor(255,0,0,255));
}
void IntelliToolPen::onMouseRightReleased(int x, int y){
IntelliTool::onMouseRightReleased(x,y);
//implemnt in here
}
void IntelliToolPen::onMouseLeftPressed(int x, int y){
//implement in here
IntelliTool::onMouseLeftPressed(x,y);
}
void IntelliToolPen::onMouseLeftReleased(int x, int y){
//implement in here
IntelliTool::onMouseLeftReleased(x,y);
}
void IntelliToolPen::onMouseMoved(int x, int y){
if(this->drawing){
QPoint newPoint(x,y);
this->Canvas->image->drawLine(this->point, newPoint, QColor(255,0,0,255), 2);
this->point=newPoint;
}
}

View File

@@ -0,0 +1,23 @@
#ifndef INTELLITOOLPEN_H
#define INTELLITOOLPEN_H
#include"IntelliTool.h"
#include"QColor"
#include"QPoint"
class IntelliToolPen : public IntelliTool{
QColor clr;
QPoint point;
public:
IntelliToolPen(PaintingArea* Area);
virtual ~IntelliToolPen() override;
virtual void onMouseRightPressed(int x, int y) override;
virtual void onMouseRightReleased(int x, int y) override;
virtual void onMouseLeftPressed(int x, int y) override;
virtual void onMouseLeftReleased(int x, int y) override;
virtual void onMouseMoved(int x, int y) override;
};
#endif // INTELLITOOLPEN_H