mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 20:30:32 +02:00
Bug free tool strucute - try me bitch
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#include"IntelliTool.h"
|
||||
#include"Layer/PaintingArea.h"
|
||||
|
||||
IntelliTool::IntelliTool(PaintingArea* Area){
|
||||
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){
|
||||
this->Area=Area;
|
||||
this->colorPicker=colorPicker;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +26,7 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
|
||||
this->drawing=true;
|
||||
//create drawing layer
|
||||
this->createToolLayer();
|
||||
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||
@@ -33,11 +34,13 @@ void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||
drawing=false;
|
||||
this->mergeToolLayer();
|
||||
this->deleteToolLayer();
|
||||
Active->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliTool::onMouseMoved(int x, int y){
|
||||
//optional for tool
|
||||
if(drawing)
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliTool::createToolLayer(){
|
||||
@@ -65,7 +68,6 @@ void IntelliTool::mergeToolLayer(){
|
||||
|
||||
Active->image->imageData.setPixelColor(x, y, clr_0);
|
||||
}
|
||||
Active->image->calculateVisiblity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef Intelli_Tool_H
|
||||
#define Intelli_Tool_H
|
||||
|
||||
#include "IntelliHelper/IntelliColorPicker.h"
|
||||
#include <vector>
|
||||
|
||||
class LayerObject;
|
||||
@@ -13,12 +14,14 @@ private:
|
||||
void deleteToolLayer();
|
||||
protected:
|
||||
PaintingArea* Area;
|
||||
IntelliColorPicker* colorPicker;
|
||||
|
||||
LayerObject* Active;
|
||||
LayerObject* Canvas;
|
||||
bool drawing = false;
|
||||
|
||||
public:
|
||||
IntelliTool(PaintingArea* Area);
|
||||
IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||
virtual ~IntelliTool() = 0;
|
||||
|
||||
virtual void onMouseRightPressed(int x, int y);
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
#include "QColorDialog"
|
||||
#include "QInputDialog"
|
||||
|
||||
IntelliToolLine::IntelliToolLine(PaintingArea* Area)
|
||||
:IntelliTool(Area){
|
||||
this->color = QColorDialog::getColor(Qt::blue, nullptr, "Line Color");
|
||||
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||
:IntelliTool(Area, colorPicker){
|
||||
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
|
||||
//create checkbox or scroll dialog to get line style
|
||||
this->lineStyle = LineStyle::SOLID_LINE;
|
||||
@@ -27,7 +26,8 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){
|
||||
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->start=QPoint(x,y);
|
||||
this->Canvas->image->drawLine(start, start, this->color, this->lineWidth);
|
||||
this->Canvas->image->drawLine(start, start, colorPicker->getFirstColor(),lineWidth);
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliToolLine::onMouseLeftReleased(int x, int y){
|
||||
@@ -41,9 +41,9 @@ void IntelliToolLine::onMouseMoved(int x, int y){
|
||||
QPoint next(x,y);
|
||||
switch(lineStyle){
|
||||
case LineStyle::SOLID_LINE :
|
||||
this->Canvas->image->drawLine(start,next,color,lineWidth);
|
||||
this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@ enum class LineStyle{
|
||||
class IntelliToolLine : public IntelliTool
|
||||
{
|
||||
QPoint start;
|
||||
QColor color;
|
||||
int lineWidth;
|
||||
LineStyle lineStyle;
|
||||
public:
|
||||
IntelliToolLine(PaintingArea* Area);
|
||||
IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||
virtual ~IntelliToolLine() override;
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
#include "QColorDialog"
|
||||
#include "QInputDialog"
|
||||
|
||||
IntelliToolPen::IntelliToolPen(PaintingArea* Area)
|
||||
:IntelliTool(Area){
|
||||
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
|
||||
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Number:", 1,0, 50, 1);
|
||||
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||
:IntelliTool(Area, colorPicker){
|
||||
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1);
|
||||
}
|
||||
|
||||
IntelliToolPen::~IntelliToolPen(){
|
||||
@@ -25,6 +24,8 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){
|
||||
void IntelliToolPen::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->point=QPoint(x,y);
|
||||
this->Canvas->image->drawPixel(point, colorPicker->getFirstColor());
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliToolPen::onMouseLeftReleased(int x, int y){
|
||||
@@ -34,7 +35,8 @@ void IntelliToolPen::onMouseLeftReleased(int x, int y){
|
||||
void IntelliToolPen::onMouseMoved(int x, int y){
|
||||
if(this->drawing){
|
||||
QPoint newPoint(x,y);
|
||||
this->Canvas->image->drawLine(this->point, newPoint, color, penWidth);
|
||||
this->Canvas->image->drawLine(this->point, newPoint, colorPicker->getFirstColor(), penWidth);
|
||||
this->point=newPoint;
|
||||
}
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
#include"QPoint"
|
||||
|
||||
class IntelliToolPen : public IntelliTool{
|
||||
QColor color;
|
||||
int penWidth;
|
||||
QPoint point;
|
||||
public:
|
||||
IntelliToolPen(PaintingArea* Area);
|
||||
IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||
virtual ~IntelliToolPen() override;
|
||||
|
||||
virtual void onMouseRightPressed(int x, int y) override;
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
#include "Layer/PaintingArea.h"
|
||||
#include "QColorDialog"
|
||||
|
||||
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area)
|
||||
:IntelliTool(Area){
|
||||
|
||||
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
|
||||
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||
:IntelliTool(Area, colorPicker){
|
||||
}
|
||||
|
||||
void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){
|
||||
IntelliTool::onMouseLeftPressed(x,y);
|
||||
this->Canvas->image->floodFill(color);
|
||||
this->Canvas->image->floodFill(colorPicker->getFirstColor());
|
||||
Canvas->image->calculateVisiblity();
|
||||
}
|
||||
|
||||
void IntelliToolPlainTool::onMouseLeftReleased(int x, int y){
|
||||
@@ -28,5 +27,4 @@ void IntelliToolPlainTool::onMouseRightReleased(int x, int y){
|
||||
|
||||
void IntelliToolPlainTool::onMouseMoved(int x, int y){
|
||||
IntelliTool::onMouseMoved(x,y);
|
||||
|
||||
}
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
class IntelliToolPlainTool : public IntelliTool
|
||||
{
|
||||
QColor color;
|
||||
public:
|
||||
IntelliToolPlainTool(PaintingArea *Area);
|
||||
IntelliToolPlainTool(PaintingArea *Area, IntelliColorPicker* colorPicker);
|
||||
|
||||
void onMouseLeftPressed(int x, int y) override;
|
||||
void onMouseLeftReleased(int x, int y) override;
|
||||
|
||||
Reference in New Issue
Block a user