Tool structure implemented

This commit is contained in:
Sonaion
2019-12-10 15:44:22 +01:00
parent 30d6781e7f
commit 10fba8c454
3 changed files with 8 additions and 9 deletions

View File

@@ -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);
}
}

View File

@@ -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){

View File

@@ -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){