From 10fba8c454af2b18dc72074fc3d41effb5591794 Mon Sep 17 00:00:00 2001 From: Sonaion Date: Tue, 10 Dec 2019 15:44:22 +0100 Subject: [PATCH] Tool structure implemented --- src/Painting/GUI/IntelliPhotoGui.cpp | 2 +- src/Painting/Layer/PaintingArea.cpp | 12 ++++++------ src/Painting/Tool/IntelliToolPen.cpp | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Painting/GUI/IntelliPhotoGui.cpp b/src/Painting/GUI/IntelliPhotoGui.cpp index 4a96e0e..d51a8bb 100644 --- a/src/Painting/GUI/IntelliPhotoGui.cpp +++ b/src/Painting/GUI/IntelliPhotoGui.cpp @@ -89,7 +89,7 @@ void IntelliPhotoGui::slotCreateNewLayer() // Create New Layer if (ok1&&ok2) { - int layer = paintingArea->addLayer(width,height,100,100); + int layer = paintingArea->addLayer(width,height,0,0); paintingArea->slotActivateLayer(layer); } } diff --git a/src/Painting/Layer/PaintingArea.cpp b/src/Painting/Layer/PaintingArea.cpp index eb23d1d..6177989 100644 --- a/src/Painting/Layer/PaintingArea.cpp +++ b/src/Painting/Layer/PaintingArea.cpp @@ -163,8 +163,8 @@ void PaintingArea::slotActivateLayer(int a){ // Set that we are currently drawing void PaintingArea::mousePressEvent(QMouseEvent *event) { - int x = (float)layerBundle[activeLayer].width/(float)width()*event->x()+layerBundle[activeLayer].widthOffset; - int y = (float)layerBundle[activeLayer].hight/(float)height()*event->y()+layerBundle[activeLayer].hightOffset; + int x = event->x()-layerBundle[activeLayer].widthOffset; + int y = event->y()-layerBundle[activeLayer].hightOffset; if(event->button() == Qt::LeftButton){ Tool->onMouseLeftPressed(x, y); }else if(event->button() == Qt::RightButton){ @@ -178,16 +178,16 @@ void PaintingArea::mousePressEvent(QMouseEvent *event) // from the last position to the current void PaintingArea::mouseMoveEvent(QMouseEvent *event) { - int x = (float)layerBundle[activeLayer].width/(float)width()*event->x()+layerBundle[activeLayer].widthOffset; - int y = (float)layerBundle[activeLayer].hight/(float)height()*event->y()+layerBundle[activeLayer].hightOffset; + int x = event->x()-layerBundle[activeLayer].widthOffset; + int y = event->y()-layerBundle[activeLayer].hightOffset; Tool->onMouseMoved(x, y); } // If the button is released we set variables to stop drawing void PaintingArea::mouseReleaseEvent(QMouseEvent *event) { - int x = (float)layerBundle[activeLayer].width/(float)width()*event->x()+layerBundle[activeLayer].widthOffset; - int y = (float)layerBundle[activeLayer].hight/(float)height()*event->y()+layerBundle[activeLayer].hightOffset; + int x = event->x()-layerBundle[activeLayer].widthOffset; + int y = event->y()-layerBundle[activeLayer].hightOffset; if(event->button() == Qt::LeftButton){ Tool->onMouseLeftReleased(x, y); }else if(event->button() == Qt::RightButton){ diff --git a/src/Painting/Tool/IntelliToolPen.cpp b/src/Painting/Tool/IntelliToolPen.cpp index ca66584..36ae08d 100644 --- a/src/Painting/Tool/IntelliToolPen.cpp +++ b/src/Painting/Tool/IntelliToolPen.cpp @@ -14,8 +14,6 @@ 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){ @@ -26,6 +24,7 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){ void IntelliToolPen::onMouseLeftPressed(int x, int y){ //implement in here IntelliTool::onMouseLeftPressed(x,y); + this->point=QPoint(x,y); } void IntelliToolPen::onMouseLeftReleased(int x, int y){