mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-15 12:50:33 +02:00
Bug free tool strucute - try me bitch
This commit is contained in:
@@ -214,6 +214,17 @@ void IntelliPhotoGui::slotSetActiveLayer(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void IntelliPhotoGui::slotSetFirstColor(){
|
||||||
|
paintingArea->colorPickerSetFirstColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliPhotoGui::slotSetSecondColor(){
|
||||||
|
paintingArea->colorPickerSetSecondColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IntelliPhotoGui::slotSwitchColor(){
|
||||||
|
paintingArea->colorPickerSwitchColor();
|
||||||
|
}
|
||||||
|
|
||||||
void IntelliPhotoGui::slotCreatePenTool(){
|
void IntelliPhotoGui::slotCreatePenTool(){
|
||||||
paintingArea->createPenTool();
|
paintingArea->createPenTool();
|
||||||
@@ -318,6 +329,17 @@ void IntelliPhotoGui::createActions()
|
|||||||
actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
|
actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down));
|
||||||
connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown()));
|
connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown()));
|
||||||
|
|
||||||
|
//Create Color Actions here
|
||||||
|
actionColorPickerFirstColor = new QAction(tr("&Main"), this);
|
||||||
|
connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
|
||||||
|
|
||||||
|
actionColorPickerSecondColor = new QAction(tr("&Secondary"), this);
|
||||||
|
connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor()));
|
||||||
|
|
||||||
|
actionColorSwitch = new QAction(tr("&Switch"), this);
|
||||||
|
actionColorSwitch->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
|
||||||
|
connect(actionColorSwitch, SIGNAL(triggered()), this, SLOT(slotSwitchColor()));
|
||||||
|
|
||||||
//Create Tool actions down here
|
//Create Tool actions down here
|
||||||
actionCreatePlainTool = new QAction(tr("&Plain"), this);
|
actionCreatePlainTool = new QAction(tr("&Plain"), this);
|
||||||
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotCreatePlainTool()));
|
connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotCreatePlainTool()));
|
||||||
@@ -369,11 +391,19 @@ void IntelliPhotoGui::createMenus()
|
|||||||
layerMenu->addAction(actionCreateNewLayer);
|
layerMenu->addAction(actionCreateNewLayer);
|
||||||
layerMenu->addAction(actionDeleteLayer);
|
layerMenu->addAction(actionDeleteLayer);
|
||||||
|
|
||||||
|
//Attach all Color Options
|
||||||
|
colorMenu = new QMenu(tr("&Color"), this);
|
||||||
|
colorMenu->addAction(actionColorPickerFirstColor);
|
||||||
|
colorMenu->addAction(actionColorPickerSecondColor);
|
||||||
|
colorMenu->addAction(actionColorSwitch);
|
||||||
|
|
||||||
//Attach all Tool Options
|
//Attach all Tool Options
|
||||||
toolMenu = new QMenu(tr("&Tools"), this);
|
toolMenu = new QMenu(tr("&Tools"), this);
|
||||||
toolMenu->addAction(actionCreatePenTool);
|
toolMenu->addAction(actionCreatePenTool);
|
||||||
toolMenu->addAction(actionCreatePlainTool);
|
toolMenu->addAction(actionCreatePlainTool);
|
||||||
toolMenu->addAction(actionCreateLineTool);
|
toolMenu->addAction(actionCreateLineTool);
|
||||||
|
toolMenu->addSeparator();
|
||||||
|
toolMenu->addMenu(colorMenu);
|
||||||
|
|
||||||
// Attach all actions to Help
|
// Attach all actions to Help
|
||||||
helpMenu = new QMenu(tr("&Help"), this);
|
helpMenu = new QMenu(tr("&Help"), this);
|
||||||
|
|||||||
@@ -29,10 +29,12 @@ protected:
|
|||||||
// Function used to close an event
|
// Function used to close an event
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
// The events that can be triggered
|
|
||||||
private slots:
|
private slots:
|
||||||
|
//meta slots here (need further )
|
||||||
void slotOpen();
|
void slotOpen();
|
||||||
void slotSave();
|
void slotSave();
|
||||||
|
|
||||||
|
//layer slots here
|
||||||
void slotCreateNewLayer();
|
void slotCreateNewLayer();
|
||||||
void slotDeleteLayer();
|
void slotDeleteLayer();
|
||||||
void slotClearActiveLayer();
|
void slotClearActiveLayer();
|
||||||
@@ -45,10 +47,17 @@ private slots:
|
|||||||
void slotMoveLayerUp();
|
void slotMoveLayerUp();
|
||||||
void slotMoveLayerDown();
|
void slotMoveLayerDown();
|
||||||
|
|
||||||
|
//color Picker slots here
|
||||||
|
void slotSetFirstColor();
|
||||||
|
void slotSetSecondColor();
|
||||||
|
void slotSwitchColor();
|
||||||
|
|
||||||
|
//tool slots here
|
||||||
void slotCreatePenTool();
|
void slotCreatePenTool();
|
||||||
void slotCreatePlainTool();
|
void slotCreatePlainTool();
|
||||||
void slotCreateLineTool();
|
void slotCreateLineTool();
|
||||||
|
|
||||||
|
//slots for dialogs
|
||||||
void slotAboutDialog();
|
void slotAboutDialog();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -74,23 +83,33 @@ private:
|
|||||||
QMenu *fileMenu;
|
QMenu *fileMenu;
|
||||||
QMenu *optionMenu;
|
QMenu *optionMenu;
|
||||||
QMenu *layerMenu;
|
QMenu *layerMenu;
|
||||||
|
QMenu *colorMenu;
|
||||||
QMenu *toolMenu;
|
QMenu *toolMenu;
|
||||||
QMenu *helpMenu;
|
QMenu *helpMenu;
|
||||||
|
|
||||||
// All the actions that can occur
|
// All the actions that can occur
|
||||||
|
|
||||||
|
//meta image actions (need further modularisation)
|
||||||
QAction *actionOpen;
|
QAction *actionOpen;
|
||||||
QAction *actionExit;
|
QAction *actionExit;
|
||||||
|
|
||||||
QAction *actionCreateNewLayer;
|
//color Picker actions
|
||||||
QAction *actionDeleteLayer;
|
QAction *actionColorPickerFirstColor;
|
||||||
|
QAction *actionColorPickerSecondColor;
|
||||||
|
QAction *actionColorSwitch;
|
||||||
|
|
||||||
|
//tool actions
|
||||||
QAction *actionCreatePenTool;
|
QAction *actionCreatePenTool;
|
||||||
QAction *actionCreatePlainTool;
|
QAction *actionCreatePlainTool;
|
||||||
QAction *actionCreateLineTool;
|
QAction *actionCreateLineTool;
|
||||||
|
|
||||||
|
//dialog actions
|
||||||
QAction *actionAboutDialog;
|
QAction *actionAboutDialog;
|
||||||
QAction *actionAboutQtDialog;
|
QAction *actionAboutQtDialog;
|
||||||
|
|
||||||
|
//layer change actions
|
||||||
|
QAction *actionCreateNewLayer;
|
||||||
|
QAction *actionDeleteLayer;
|
||||||
QAction* actionSetActiveLayer;
|
QAction* actionSetActiveLayer;
|
||||||
QAction* actionSetActiveAlpha;
|
QAction* actionSetActiveAlpha;
|
||||||
QAction* actionMovePositionUp;
|
QAction* actionMovePositionUp;
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ QImage IntelliShapedImage::getDisplayable(int alpha){
|
|||||||
|
|
||||||
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height());
|
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height());
|
||||||
shaped->imageData.fill(Qt::transparent);
|
|
||||||
shaped->setPolygon(this->polygonData);
|
shaped->setPolygon(this->polygonData);
|
||||||
|
shaped->imageData.fill(Qt::transparent);
|
||||||
return shaped;
|
return shaped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ void IntelliShapedImage::calculateVisiblity(){
|
|||||||
imageData.setPixelColor(x,y,clr);
|
imageData.setPixelColor(x,y,clr);
|
||||||
}else{
|
}else{
|
||||||
clr = imageData.pixelColor(x,y);
|
clr = imageData.pixelColor(x,y);
|
||||||
clr.setAlpha(255);
|
clr.setAlpha(std::min(255, clr.alpha()));
|
||||||
imageData.setPixelColor(x,y,clr);
|
imageData.setPixelColor(x,y,clr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "IntelliColorPicker.h"
|
#include "IntelliColorPicker.h"
|
||||||
|
|
||||||
IntelliColorPicker::IntelliColorPicker(PaintingArea* Area){
|
IntelliColorPicker::IntelliColorPicker(){
|
||||||
firstColor = {255,0,0,255};
|
firstColor = {255,0,0,255};
|
||||||
secondColor = {0,0,255,255};
|
secondColor = {0,0,255,255};
|
||||||
}
|
}
|
||||||
@@ -9,25 +9,8 @@ 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(){
|
void IntelliColorPicker::switchColors(){
|
||||||
QColor temp = this->firstColor;
|
std::swap(firstColor, secondColor);
|
||||||
this->firstColor = this->secondColor;
|
|
||||||
this->secondColor = temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor IntelliColorPicker::getFirstColor(){
|
QColor IntelliColorPicker::getFirstColor(){
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
#ifndef INTELLITOOLSETCOLORTOOL_H
|
#ifndef INTELLITOOLSETCOLORTOOL_H
|
||||||
#define INTELLITOOLSETCOLORTOOL_H
|
#define INTELLITOOLSETCOLORTOOL_H
|
||||||
|
|
||||||
#include"Layer/PaintingArea.h"
|
|
||||||
#include"QColor"
|
#include"QColor"
|
||||||
#include"QPoint"
|
#include"QPoint"
|
||||||
#include"QColorDialog"
|
#include"QColorDialog"
|
||||||
|
|
||||||
class IntelliColorPicker{
|
class IntelliColorPicker{
|
||||||
public:
|
public:
|
||||||
IntelliColorPicker(PaintingArea *Area);
|
IntelliColorPicker();
|
||||||
virtual ~IntelliColorPicker();
|
virtual ~IntelliColorPicker();
|
||||||
|
|
||||||
void getColorbar(int firstOrSecondColor);
|
|
||||||
void switchColors();
|
void switchColors();
|
||||||
|
|
||||||
QColor getFirstColor();
|
QColor getFirstColor();
|
||||||
|
|||||||
@@ -37,22 +37,6 @@ 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){
|
void PaintingArea::setUp(int maxWidth, int maxHeight){
|
||||||
//set standart parameter
|
//set standart parameter
|
||||||
this->maxWidth = maxWidth;
|
this->maxWidth = maxWidth;
|
||||||
@@ -177,19 +161,33 @@ void PaintingArea::slotActivateLayer(int a){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PaintingArea::colorPickerSetFirstColor(){
|
||||||
|
QColor clr = QColorDialog::getColor(colorPicker.getFirstColor(), nullptr, "Main Color");
|
||||||
|
this->colorPicker.setFirstColor(clr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaintingArea::colorPickerSetSecondColor(){
|
||||||
|
QColor clr = QColorDialog::getColor(colorPicker.getSecondColor(), nullptr, "Secondary Color");
|
||||||
|
this->colorPicker.setSecondColor(clr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PaintingArea::colorPickerSwitchColor(){
|
||||||
|
this->colorPicker.switchColors();
|
||||||
|
}
|
||||||
|
|
||||||
void PaintingArea::createPenTool(){
|
void PaintingArea::createPenTool(){
|
||||||
delete this->Tool;
|
delete this->Tool;
|
||||||
Tool = new IntelliToolPen(this);
|
Tool = new IntelliToolPen(this, &colorPicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::createPlainTool(){
|
void PaintingArea::createPlainTool(){
|
||||||
delete this->Tool;
|
delete this->Tool;
|
||||||
Tool = new IntelliToolPlainTool(this);
|
Tool = new IntelliToolPlainTool(this, &colorPicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PaintingArea::createLineTool(){
|
void PaintingArea::createLineTool(){
|
||||||
delete this->Tool;
|
delete this->Tool;
|
||||||
Tool = new IntelliToolLine(this);
|
Tool = new IntelliToolLine(this, &colorPicker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a mouse button is pressed check if it was the
|
// If a mouse button is pressed check if it was the
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "Image/IntelliRasterImage.h"
|
#include "Image/IntelliRasterImage.h"
|
||||||
#include "Image/IntelliShapedImage.h"
|
#include "Image/IntelliShapedImage.h"
|
||||||
#include "Tool/IntelliTool.h"
|
#include "Tool/IntelliTool.h"
|
||||||
|
#include "IntelliHelper/IntelliColorPicker.h"
|
||||||
|
|
||||||
|
|
||||||
struct LayerObject{
|
struct LayerObject{
|
||||||
@@ -24,8 +25,6 @@ struct LayerObject{
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class IntelliColorPicker;
|
|
||||||
|
|
||||||
class PaintingArea : public QWidget
|
class PaintingArea : public QWidget
|
||||||
{
|
{
|
||||||
// Declares our class as a QObject which is the base class
|
// Declares our class as a QObject which is the base class
|
||||||
@@ -52,6 +51,11 @@ public:
|
|||||||
// Has the image been modified since last save
|
// Has the image been modified since last save
|
||||||
bool isModified() const { return modified; }
|
bool isModified() const { return modified; }
|
||||||
|
|
||||||
|
//change properties of colorPicker
|
||||||
|
void colorPickerSetFirstColor();
|
||||||
|
void colorPickerSetSecondColor();
|
||||||
|
void colorPickerSwitchColor();
|
||||||
|
|
||||||
//create tools
|
//create tools
|
||||||
void createPenTool();
|
void createPenTool();
|
||||||
void createPlainTool();
|
void createPlainTool();
|
||||||
@@ -86,6 +90,7 @@ private:
|
|||||||
int maxHeight;
|
int maxHeight;
|
||||||
|
|
||||||
IntelliTool* Tool;
|
IntelliTool* Tool;
|
||||||
|
IntelliColorPicker colorPicker;
|
||||||
|
|
||||||
std::vector<LayerObject> layerBundle;
|
std::vector<LayerObject> layerBundle;
|
||||||
int activeLayer=-1;
|
int activeLayer=-1;
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
#include"IntelliTool.h"
|
#include"IntelliTool.h"
|
||||||
#include"Layer/PaintingArea.h"
|
#include"Layer/PaintingArea.h"
|
||||||
|
|
||||||
IntelliTool::IntelliTool(PaintingArea* Area){
|
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker){
|
||||||
this->Area=Area;
|
this->Area=Area;
|
||||||
|
this->colorPicker=colorPicker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ void IntelliTool::onMouseLeftPressed(int x, int y){
|
|||||||
this->drawing=true;
|
this->drawing=true;
|
||||||
//create drawing layer
|
//create drawing layer
|
||||||
this->createToolLayer();
|
this->createToolLayer();
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliTool::onMouseLeftReleased(int x, int y){
|
void IntelliTool::onMouseLeftReleased(int x, int y){
|
||||||
@@ -33,11 +34,13 @@ void IntelliTool::onMouseLeftReleased(int x, int y){
|
|||||||
drawing=false;
|
drawing=false;
|
||||||
this->mergeToolLayer();
|
this->mergeToolLayer();
|
||||||
this->deleteToolLayer();
|
this->deleteToolLayer();
|
||||||
|
Active->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliTool::onMouseMoved(int x, int y){
|
void IntelliTool::onMouseMoved(int x, int y){
|
||||||
//optional for tool
|
if(drawing)
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliTool::createToolLayer(){
|
void IntelliTool::createToolLayer(){
|
||||||
@@ -65,7 +68,6 @@ void IntelliTool::mergeToolLayer(){
|
|||||||
|
|
||||||
Active->image->imageData.setPixelColor(x, y, clr_0);
|
Active->image->imageData.setPixelColor(x, y, clr_0);
|
||||||
}
|
}
|
||||||
Active->image->calculateVisiblity();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef Intelli_Tool_H
|
#ifndef Intelli_Tool_H
|
||||||
#define Intelli_Tool_H
|
#define Intelli_Tool_H
|
||||||
|
|
||||||
|
#include "IntelliHelper/IntelliColorPicker.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class LayerObject;
|
class LayerObject;
|
||||||
@@ -13,12 +14,14 @@ private:
|
|||||||
void deleteToolLayer();
|
void deleteToolLayer();
|
||||||
protected:
|
protected:
|
||||||
PaintingArea* Area;
|
PaintingArea* Area;
|
||||||
|
IntelliColorPicker* colorPicker;
|
||||||
|
|
||||||
LayerObject* Active;
|
LayerObject* Active;
|
||||||
LayerObject* Canvas;
|
LayerObject* Canvas;
|
||||||
bool drawing = false;
|
bool drawing = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IntelliTool(PaintingArea* Area);
|
IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
virtual ~IntelliTool() = 0;
|
virtual ~IntelliTool() = 0;
|
||||||
|
|
||||||
virtual void onMouseRightPressed(int x, int y);
|
virtual void onMouseRightPressed(int x, int y);
|
||||||
|
|||||||
@@ -3,9 +3,8 @@
|
|||||||
#include "QColorDialog"
|
#include "QColorDialog"
|
||||||
#include "QInputDialog"
|
#include "QInputDialog"
|
||||||
|
|
||||||
IntelliToolLine::IntelliToolLine(PaintingArea* Area)
|
IntelliToolLine::IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||||
:IntelliTool(Area){
|
:IntelliTool(Area, colorPicker){
|
||||||
this->color = QColorDialog::getColor(Qt::blue, nullptr, "Line Color");
|
|
||||||
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
|
this->lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
|
||||||
//create checkbox or scroll dialog to get line style
|
//create checkbox or scroll dialog to get line style
|
||||||
this->lineStyle = LineStyle::SOLID_LINE;
|
this->lineStyle = LineStyle::SOLID_LINE;
|
||||||
@@ -27,7 +26,8 @@ void IntelliToolLine::onMouseRightReleased(int x, int y){
|
|||||||
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
void IntelliToolLine::onMouseLeftPressed(int x, int y){
|
||||||
IntelliTool::onMouseLeftPressed(x,y);
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
this->start=QPoint(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){
|
void IntelliToolLine::onMouseLeftReleased(int x, int y){
|
||||||
@@ -41,9 +41,9 @@ void IntelliToolLine::onMouseMoved(int x, int y){
|
|||||||
QPoint next(x,y);
|
QPoint next(x,y);
|
||||||
switch(lineStyle){
|
switch(lineStyle){
|
||||||
case LineStyle::SOLID_LINE :
|
case LineStyle::SOLID_LINE :
|
||||||
this->Canvas->image->drawLine(start,next,color,lineWidth);
|
this->Canvas->image->drawLine(start,next,colorPicker->getFirstColor(),lineWidth);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,10 @@ enum class LineStyle{
|
|||||||
class IntelliToolLine : public IntelliTool
|
class IntelliToolLine : public IntelliTool
|
||||||
{
|
{
|
||||||
QPoint start;
|
QPoint start;
|
||||||
QColor color;
|
|
||||||
int lineWidth;
|
int lineWidth;
|
||||||
LineStyle lineStyle;
|
LineStyle lineStyle;
|
||||||
public:
|
public:
|
||||||
IntelliToolLine(PaintingArea* Area);
|
IntelliToolLine(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
virtual ~IntelliToolLine() override;
|
virtual ~IntelliToolLine() override;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,9 @@
|
|||||||
#include "QColorDialog"
|
#include "QColorDialog"
|
||||||
#include "QInputDialog"
|
#include "QInputDialog"
|
||||||
|
|
||||||
IntelliToolPen::IntelliToolPen(PaintingArea* Area)
|
IntelliToolPen::IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||||
:IntelliTool(Area){
|
:IntelliTool(Area, colorPicker){
|
||||||
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
|
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Width:", 1,0, 50, 1);
|
||||||
this->penWidth = QInputDialog::getInt(nullptr, "Pen width", "Number:", 1,0, 50, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IntelliToolPen::~IntelliToolPen(){
|
IntelliToolPen::~IntelliToolPen(){
|
||||||
@@ -25,6 +24,8 @@ void IntelliToolPen::onMouseRightReleased(int x, int y){
|
|||||||
void IntelliToolPen::onMouseLeftPressed(int x, int y){
|
void IntelliToolPen::onMouseLeftPressed(int x, int y){
|
||||||
IntelliTool::onMouseLeftPressed(x,y);
|
IntelliTool::onMouseLeftPressed(x,y);
|
||||||
this->point=QPoint(x,y);
|
this->point=QPoint(x,y);
|
||||||
|
this->Canvas->image->drawPixel(point, colorPicker->getFirstColor());
|
||||||
|
Canvas->image->calculateVisiblity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolPen::onMouseLeftReleased(int x, int y){
|
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){
|
void IntelliToolPen::onMouseMoved(int x, int y){
|
||||||
if(this->drawing){
|
if(this->drawing){
|
||||||
QPoint newPoint(x,y);
|
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;
|
this->point=newPoint;
|
||||||
}
|
}
|
||||||
|
IntelliTool::onMouseMoved(x,y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
#include"QPoint"
|
#include"QPoint"
|
||||||
|
|
||||||
class IntelliToolPen : public IntelliTool{
|
class IntelliToolPen : public IntelliTool{
|
||||||
QColor color;
|
|
||||||
int penWidth;
|
int penWidth;
|
||||||
QPoint point;
|
QPoint point;
|
||||||
public:
|
public:
|
||||||
IntelliToolPen(PaintingArea* Area);
|
IntelliToolPen(PaintingArea* Area, IntelliColorPicker* colorPicker);
|
||||||
virtual ~IntelliToolPen() override;
|
virtual ~IntelliToolPen() override;
|
||||||
|
|
||||||
virtual void onMouseRightPressed(int x, int y) override;
|
virtual void onMouseRightPressed(int x, int y) override;
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
#include "Layer/PaintingArea.h"
|
#include "Layer/PaintingArea.h"
|
||||||
#include "QColorDialog"
|
#include "QColorDialog"
|
||||||
|
|
||||||
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area)
|
IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicker* colorPicker)
|
||||||
:IntelliTool(Area){
|
:IntelliTool(Area, colorPicker){
|
||||||
|
|
||||||
this->color = QColorDialog::getColor(Qt::blue,nullptr,"Flood Fill Color");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){
|
void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){
|
||||||
IntelliTool::onMouseLeftPressed(x,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){
|
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){
|
void IntelliToolPlainTool::onMouseMoved(int x, int y){
|
||||||
IntelliTool::onMouseMoved(x,y);
|
IntelliTool::onMouseMoved(x,y);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,8 @@
|
|||||||
|
|
||||||
class IntelliToolPlainTool : public IntelliTool
|
class IntelliToolPlainTool : public IntelliTool
|
||||||
{
|
{
|
||||||
QColor color;
|
|
||||||
public:
|
public:
|
||||||
IntelliToolPlainTool(PaintingArea *Area);
|
IntelliToolPlainTool(PaintingArea *Area, IntelliColorPicker* colorPicker);
|
||||||
|
|
||||||
void onMouseLeftPressed(int x, int y) override;
|
void onMouseLeftPressed(int x, int y) override;
|
||||||
void onMouseLeftReleased(int x, int y) override;
|
void onMouseLeftReleased(int x, int y) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user