Modularisation

This commit is contained in:
Sonaion
2019-12-11 18:54:04 +01:00
parent cb7ad31bd5
commit b1895b0c04
11 changed files with 81 additions and 137 deletions

View File

@@ -1,41 +1,30 @@
#include "IntelliToolFloodFillTool.h"
#include "Layer/PaintingArea.h"
#include "QColorDialog"
IntelliToolFloodFillTool::IntelliToolFloodFillTool(PaintingArea* Area)
:IntelliToolSetColorTool(Area)
{
Tool = Area->getTool();
isPressed = false;
:IntelliTool(Area){
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
}
void IntelliToolFloodFillTool::onMouseLeftPressed(int x, int y){
if(!isPressed){
isPressed = true;
IntelliTool::onMouseLeftPressed(x,y);
Tool = Area->getTool();
this->Canvas->image->floodFill(Tool->getFirstColor());
}
IntelliTool::onMouseLeftPressed(x,y);
this->Canvas->image->floodFill(color);
}
void IntelliToolFloodFillTool::onMouseRightPressed(int x, int y){
if(!isPressed){
isPressed = true;
IntelliTool::onMouseLeftPressed(x,y);
Tool = Area->getTool();
this->Canvas->image->floodFill(Tool->getSecondColor());
}
IntelliTool::onMouseRightPressed(x,y);
}
void IntelliToolFloodFillTool::onMouseRightReleased(int x, int y){
IntelliTool::onMouseLeftReleased(x,y);
if(isPressed) isPressed = false;
IntelliTool::onMouseRightReleased(x,y);
}
void IntelliToolFloodFillTool::onMouseLeftReleased(int x, int y){
IntelliTool::onMouseLeftReleased(x,y);
if(isPressed) isPressed = false;
}
void IntelliToolFloodFillTool::onMouseMoved(int x, int y){
IntelliTool::onMouseRightPressed(x,y);
IntelliTool::onMouseMoved(x,y);
}

View File

@@ -1,22 +1,21 @@
#ifndef INTELLITOOLFLOODFILLTOOL_H
#define INTELLITOOLFLOODFILLTOOL_H
#include "IntelliToolSetColorTool.h"
#include "IntelliTool.h"
#include "QColor"
class IntelliToolFloodFillTool : public IntelliToolSetColorTool
class IntelliToolFloodFillTool : public IntelliTool
{
QColor color;
public:
IntelliToolFloodFillTool(PaintingArea *Area);
void IntelliToolFloodFillTool::onMouseLeftPressed(int x, int y) override;
void IntelliToolFloodFillTool::onMouseLeftReleased(int x, int y) override;
void IntelliToolFloodFillTool::onMouseRightPressed(int x, int y) override;
void IntelliToolFloodFillTool::onMouseRightReleased(int x, int y) override;
void IntelliToolFloodFillTool::onMouseMoved(int x, int y) override;
void onMouseLeftPressed(int x, int y) override;
void onMouseLeftReleased(int x, int y) override;
void onMouseRightPressed(int x, int y) override;
void onMouseRightReleased(int x, int y) override;
void onMouseMoved(int x, int y) override;
private:
IntelliToolSetColorTool* Tool;
bool isPressed;
};
#endif // INTELLITOOLFLOODFILLTOOL_H

View File

@@ -1,10 +1,15 @@
#include "IntelliToolPen.h"
#include "Layer/PaintingArea.h"
#include "QDebug"
#include "QColorDialog"
#include "QInputDialog"
IntelliToolPen::IntelliToolPen(PaintingArea* Area)
:IntelliToolSetColorTool(Area){
:IntelliTool(Area){
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
bool ok;
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Number:", 1,0, 50, 1, &ok);
}
IntelliToolPen::~IntelliToolPen(){
@@ -35,9 +40,7 @@ void IntelliToolPen::onMouseLeftReleased(int x, int y){
void IntelliToolPen::onMouseMoved(int x, int y){
if(this->drawing){
QPoint newPoint(x,y);
Tool = Area->getTool();
qDebug() << Tool->getFirstColor();
this->Canvas->image->drawLine(this->point, newPoint, Tool->getFirstColor(), 2);
this->Canvas->image->drawLine(this->point, newPoint, color, penWidth);
this->point=newPoint;
}
}

View File

@@ -1,11 +1,13 @@
#ifndef INTELLITOOLPEN_H
#define INTELLITOOLPEN_H
#include"IntelliToolSetColorTool.h"
#include"IntelliTool.h"
#include"QColor"
#include"QPoint"
class IntelliToolPen : public IntelliToolSetColorTool{
class IntelliToolPen : public IntelliTool{
QColor color;
int penWidth;
QPoint point;
public:
IntelliToolPen(PaintingArea* Area);
@@ -17,9 +19,6 @@ public:
virtual void onMouseLeftReleased(int x, int y) override;
virtual void onMouseMoved(int x, int y) override;
private:
IntelliToolSetColorTool* Tool;
};
#endif // INTELLITOOLPEN_H

View File

@@ -1,36 +0,0 @@
#include "IntelliToolSetColorTool.h"
#include "QDebug"
IntelliToolSetColorTool::IntelliToolSetColorTool(PaintingArea* Area)
:IntelliTool(Area){
firstColor = {255,0,0,255};
secondColor = {0,0,255,255};
}
IntelliToolSetColorTool::~IntelliToolSetColorTool(){
}
void IntelliToolSetColorTool::getColorbar(int firstOrSecondColor = 1){
QString Titel;
QColor newColor;
if(firstOrSecondColor == 1){
Titel = "Choose first Color";
newColor = QColorDialog::getColor(this->firstColor,nullptr,Titel);
this->firstColor = newColor;
qDebug() << "Firstcolor" << this->firstColor;
}
else{
Titel = "Choose second Color";
newColor = QColorDialog::getColor(this->secondColor,nullptr,Titel);
this->secondColor = newColor;
}
}
QColor IntelliToolSetColorTool::getFirstColor(){
return firstColor;
}
QColor IntelliToolSetColorTool::getSecondColor(){
return secondColor;
}

View File

@@ -1,24 +0,0 @@
#ifndef INTELLITOOLSETCOLORTOOL_H
#define INTELLITOOLSETCOLORTOOL_H
#include"IntelliTool.h"
#include"QColor"
#include"QPoint"
#include"QColorDialog"
class IntelliToolSetColorTool: public IntelliTool{
public:
IntelliToolSetColorTool(PaintingArea *Area);
virtual ~IntelliToolSetColorTool() override;
void getColorbar(int firstOrSecondColor) override;
QColor IntelliToolSetColorTool::getFirstColor();
QColor IntelliToolSetColorTool::getSecondColor();
protected:
QColor firstColor;
QColor secondColor;
};
#endif // INTELLITOOLSETCOLORTOOL_H