diff --git a/src/Painting/GUI/IntelliPhotoGui.h b/src/Painting/GUI/IntelliPhotoGui.h index 7639383..5559f71 100644 --- a/src/Painting/GUI/IntelliPhotoGui.h +++ b/src/Painting/GUI/IntelliPhotoGui.h @@ -14,6 +14,8 @@ class PaintingArea; class IntelliTool; +class IntelliColorPicker; + class IntelliPhotoGui : public QMainWindow { // Declares our class as a QObject which is the base class @@ -66,7 +68,6 @@ private: // What we'll draw on PaintingArea* paintingArea; - IntelliTool* Tool; // The menu widgets QMenu *saveAsMenu; diff --git a/src/Painting/IntelliHelper/IntelliColorPicker.cpp b/src/Painting/IntelliHelper/IntelliColorPicker.cpp new file mode 100644 index 0000000..cfd951f --- /dev/null +++ b/src/Painting/IntelliHelper/IntelliColorPicker.cpp @@ -0,0 +1,47 @@ +#include "IntelliColorPicker.h" + +IntelliColorPicker::IntelliColorPicker(PaintingArea* Area){ + firstColor = {255,0,0,255}; + secondColor = {0,0,255,255}; +} + +IntelliColorPicker::~IntelliColorPicker(){ + +} + +void IntelliColorPicker::getColorbar(int firstOrSecondColor = 1){ + QString Titel; + QColor newColor; + if(firstOrSecondColor == 1){ + Titel = "Choose first Color"; + newColor = QColorDialog::getColor(this->firstColor,nullptr,Titel); + setFirstColor(newColor); + } + else{ + Titel = "Choose second Color"; + newColor = QColorDialog::getColor(this->secondColor,nullptr,Titel); + setFirstColor(newColor); + } +} + +void IntelliColorPicker::switchColors(){ + QColor temp = this->firstColor; + this->firstColor = this->secondColor; + this->secondColor = temp; +} + +QColor IntelliColorPicker::getFirstColor(){ + return this->firstColor; +} + +QColor IntelliColorPicker::getSecondColor(){ + return this->secondColor; +} + +void IntelliColorPicker::setFirstColor(QColor Color){ + this->firstColor = Color; +} + +void IntelliColorPicker::setSecondColor(QColor Color){ + this->secondColor = Color; +} diff --git a/src/Painting/IntelliHelper/IntelliColorPicker.h b/src/Painting/IntelliHelper/IntelliColorPicker.h new file mode 100644 index 0000000..1eeb28e --- /dev/null +++ b/src/Painting/IntelliHelper/IntelliColorPicker.h @@ -0,0 +1,28 @@ +#ifndef INTELLITOOLSETCOLORTOOL_H +#define INTELLITOOLSETCOLORTOOL_H + +#include"Layer/PaintingArea.h" +#include"QColor" +#include"QPoint" +#include"QColorDialog" + +class IntelliColorPicker{ +public: + IntelliColorPicker(PaintingArea *Area); + virtual ~IntelliColorPicker(); + + void getColorbar(int firstOrSecondColor); + void switchColors(); + + QColor getFirstColor(); + QColor getSecondColor(); + + void setFirstColor(QColor Color); + void setSecondColor(QColor Color); + +private: + QColor firstColor; + QColor secondColor; +}; + +#endif // INTELLITOOLSETCOLORTOOL_H diff --git a/src/Painting/IntelliPhoto.pro b/src/Painting/IntelliPhoto.pro index e4c4ce5..7d3580d 100644 --- a/src/Painting/IntelliPhoto.pro +++ b/src/Painting/IntelliPhoto.pro @@ -20,6 +20,7 @@ SOURCES += \ Image/IntelliImage.cpp \ Image/IntelliRasterImage.cpp \ Image/IntelliShapedImage.cpp \ + IntelliHelper/IntelliColorPicker.cpp \ IntelliHelper/IntelliHelper.cpp \ Layer/PaintingArea.cpp \ Tool/IntelliTool.cpp \ @@ -33,6 +34,7 @@ HEADERS += \ Image/IntelliImage.h \ Image/IntelliRasterImage.h \ Image/IntelliShapedImage.h \ + IntelliHelper/IntelliColorPicker.h \ IntelliHelper/IntelliHelper.h \ Layer/PaintingArea.h \ Tool/IntelliTool.h \ diff --git a/src/Painting/Layer/PaintingArea.cpp b/src/Painting/Layer/PaintingArea.cpp index 2650aaa..704b676 100644 --- a/src/Painting/Layer/PaintingArea.cpp +++ b/src/Painting/Layer/PaintingArea.cpp @@ -37,6 +37,22 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) } +void PaintingArea::switchColors(){ + ColorTool->switchColors(); +} + +void PaintingArea::createPenTool(){ + IntelliTool *temp = this->Tool; + this->Tool = new IntelliToolPen(this); + delete temp; +} + +void PaintingArea::createFloodFillTool(){ + IntelliTool *temp = this->Tool; + this->Tool = new IntelliToolFloodFillTool(this); + delete temp; +} + void PaintingArea::setUp(int maxWidth, int maxHeight){ //set standart parameter this->maxWidth = maxWidth; diff --git a/src/Painting/Layer/PaintingArea.h b/src/Painting/Layer/PaintingArea.h index 2a0ab76..a1571f6 100644 --- a/src/Painting/Layer/PaintingArea.h +++ b/src/Painting/Layer/PaintingArea.h @@ -8,6 +8,8 @@ #include #include #include "Image/IntelliImage.h" +#include "Image/IntelliRasterImage.h" +#include "Image/IntelliShapedImage.h" #include "Tool/IntelliTool.h" @@ -22,6 +24,8 @@ struct LayerObject{ }; +class IntelliColorPicker; + class PaintingArea : public QWidget { // Declares our class as a QObject which is the base class diff --git a/src/Painting/Tool/IntelliColorPicker.cpp b/src/Painting/Tool/IntelliColorPicker.cpp new file mode 100644 index 0000000..55af5b9 --- /dev/null +++ b/src/Painting/Tool/IntelliColorPicker.cpp @@ -0,0 +1,36 @@ +#include "IntelliColorPicker.h" +#include "QDebug" + +IntelliColorPicker::IntelliColorPicker(PaintingArea* Area) + :IntelliTool(Area){ + firstColor = {255,0,0,255}; + secondColor = {0,0,255,255}; +} + +IntelliColorPicker::~IntelliColorPicker(){ + +} + +void IntelliColorPicker::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 IntelliColorPicker::getFirstColor(){ + return firstColor; +} + +QColor IntelliColorPicker::getSecondColor(){ + return secondColor; +} diff --git a/src/Painting/Tool/IntelliTool.h b/src/Painting/Tool/IntelliTool.h index 466e03c..a519616 100644 --- a/src/Painting/Tool/IntelliTool.h +++ b/src/Painting/Tool/IntelliTool.h @@ -21,7 +21,6 @@ public: IntelliTool(PaintingArea* Area); virtual ~IntelliTool() = 0; - virtual void onMouseRightPressed(int x, int y); virtual void onMouseRightReleased(int x, int y); virtual void onMouseLeftPressed(int x, int y);