Gui Endprodukt

This commit is contained in:
AshBastian
2020-01-09 02:43:43 +01:00
parent a33041a076
commit 6fdda34d68
7 changed files with 65 additions and 24 deletions

View File

@@ -81,7 +81,7 @@ void IntelliPhotoGui::slotCreateNewLayer(){
if (ok1&&ok2) if (ok1&&ok2)
{ {
int layer = paintingArea->addLayer(width,height,0,0); int layer = paintingArea->addLayer(width,height,0,0);
paintingArea->slotActivateLayer(layer); UpdateGui();
} }
} }
@@ -95,12 +95,11 @@ void IntelliPhotoGui::slotDeleteLayer(){
// Define the standard Value, min, max, step and ok button // Define the standard Value, min, max, step and ok button
int layerNumber = QInputDialog::getInt(this, tr("delete Layer"), int layerNumber = QInputDialog::getInt(this, tr("delete Layer"),
tr("Number:"), tr("Number:"),
1,0, 500, 1, &ok); paintingArea->getNumberOfActiveLayer(),0, 500, 1, &ok);
// Create New Layer // Create New Layer
if (ok){ if (ok){
paintingArea->deleteLayer(layerNumber); paintingArea->deleteLayer(layerNumber);
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer()); UpdateGui();
ActiveLayerLine->setText(string);
} }
} }
@@ -121,6 +120,7 @@ void IntelliPhotoGui::slotSetActiveAlpha(){
if (ok1&&ok2) if (ok1&&ok2)
{ {
paintingArea->setLayerAlpha(layer,alpha); paintingArea->setLayerAlpha(layer,alpha);
UpdateGui();
} }
} }
@@ -179,6 +179,7 @@ void IntelliPhotoGui::slotClearActiveLayer(){
if (ok1&&ok2&&ok3&&ok4) if (ok1&&ok2&&ok3&&ok4)
{ {
paintingArea->floodFill(red, green, blue, alpha); paintingArea->floodFill(red, green, blue, alpha);
UpdateGui();
} }
} }
@@ -195,29 +196,23 @@ void IntelliPhotoGui::slotSetActiveLayer(){
if (ok1) if (ok1)
{ {
paintingArea->setLayerActive(layer); paintingArea->setLayerActive(layer);
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer()); UpdateGui();
ActiveLayerLine->setText(string);
} }
} }
void IntelliPhotoGui::slotSetFirstColor(){ void IntelliPhotoGui::slotSetFirstColor(){
paintingArea->colorPickerSetFirstColor(); paintingArea->colorPickerSetFirstColor();
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); UpdateGui();
FirstColorButton->setStyleSheet(string);
} }
void IntelliPhotoGui::slotSetSecondColor(){ void IntelliPhotoGui::slotSetSecondColor(){
paintingArea->colorPickerSetSecondColor(); paintingArea->colorPickerSetSecondColor();
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name()); UpdateGui();
SecondColorButton->setStyleSheet(string);
} }
void IntelliPhotoGui::slotSwapColor(){ void IntelliPhotoGui::slotSwapColor(){
paintingArea->colorPickerSwapColors(); paintingArea->colorPickerSwapColors();
QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); UpdateGui();
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
} }
void IntelliPhotoGui::slotCreatePenTool(){ void IntelliPhotoGui::slotCreatePenTool(){
@@ -511,6 +506,7 @@ void IntelliPhotoGui::createGui(){
// create Gui elements // create Gui elements
paintingArea = new PaintingArea(); paintingArea = new PaintingArea();
paintingArea->DumpyGui = this;
p = QPixmap(":/Icons/Buttons/icons/circle-tool.svg"); p = QPixmap(":/Icons/Buttons/icons/circle-tool.svg");
CircleButton = new QPushButton(); CircleButton = new QPushButton();
@@ -602,6 +598,13 @@ void IntelliPhotoGui::createGui(){
ActiveLayerLine->setText(string); ActiveLayerLine->setText(string);
ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3); ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3);
p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
ActiveLayerImageButton = new QPushButton();
ActiveLayerImageButton->setFixedSize(Buttonsize);
ActiveLayerImageButton->setIcon(p);
ActiveLayerImageButton->setIconSize(Buttonsize);
// set gui elements // set gui elements
mainLayout->addWidget(paintingArea,1,1,20,1); mainLayout->addWidget(paintingArea,1,1,20,1);
@@ -620,6 +623,7 @@ void IntelliPhotoGui::createGui(){
mainLayout->addWidget(SecondColorButton,12,3,1,1); mainLayout->addWidget(SecondColorButton,12,3,1,1);
mainLayout->addWidget(SwitchColorButton,13,2,1,2); mainLayout->addWidget(SwitchColorButton,13,2,1,2);
mainLayout->addWidget(ActiveLayerLine,14,2,1,2); mainLayout->addWidget(ActiveLayerLine,14,2,1,2);
mainLayout->addWidget(ActiveLayerImageButton,15,2,1,2);
} }
void IntelliPhotoGui::setIntelliStyle(){ void IntelliPhotoGui::setIntelliStyle(){
@@ -686,3 +690,16 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
void IntelliPhotoGui::setDefaultToolValue(){ void IntelliPhotoGui::setDefaultToolValue(){
slotEnterPressed(); slotEnterPressed();
} }
void IntelliPhotoGui::UpdateGui(){
QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer());
ActiveLayerLine->setText(string);
p = p.fromImage(paintingArea->getImageOfActiveLayer()->getImageData());
ActiveLayerImageButton->setIcon(p);
ActiveLayerImageButton->setIconSize(Buttonsize);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name());
FirstColorButton->setStyleSheet(string);
string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name());
SecondColorButton->setStyleSheet(string);
}

View File

@@ -32,6 +32,8 @@ public:
*/ */
IntelliPhotoGui(); IntelliPhotoGui();
void UpdateGui();
protected: protected:
// Function used to close an event // Function used to close an event
void closeEvent(QCloseEvent*event) override; void closeEvent(QCloseEvent*event) override;
@@ -115,6 +117,7 @@ QPushButton* SecondColorButton;
QPushButton* SwitchColorButton; QPushButton* SwitchColorButton;
QLabel* ActiveLayerLine; QLabel* ActiveLayerLine;
QPushButton* ActiveLayerImageButton;
// The menu widgets // The menu widgets
QMenu*saveAsMenu; QMenu*saveAsMenu;

View File

@@ -81,3 +81,7 @@ void IntelliImage::drawPlain(const QColor& color){
QColor IntelliImage::getPixelColor(QPoint& point){ QColor IntelliImage::getPixelColor(QPoint& point){
return imageData.pixelColor(point); return imageData.pixelColor(point);
} }
QImage IntelliImage::getImageData(){
return imageData;
}

View File

@@ -141,6 +141,8 @@ virtual bool loadImage(const QString &filePath);
* \return The color of the Pixel as QColor. * \return The color of the Pixel as QColor.
*/ */
virtual QColor getPixelColor(QPoint& point); virtual QColor getPixelColor(QPoint& point);
QImage getImageData();
}; };
#endif #endif

View File

@@ -66,14 +66,15 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
} }
newLayer.alpha = 255; newLayer.alpha = 255;
this->layerBundle.push_back(newLayer); this->layerBundle.push_back(newLayer);
return static_cast<int>(layerBundle.size())-1; activeLayer = static_cast<int>(layerBundle.size())-1;
return activeLayer;
} }
void PaintingArea::deleteLayer(int index){ void PaintingArea::deleteLayer(int index){
if(index<static_cast<int>(layerBundle.size())) { if(index<static_cast<int>(layerBundle.size())) {
this->layerBundle.erase(layerBundle.begin()+index); this->layerBundle.erase(layerBundle.begin()+index);
if(activeLayer>=index) { if(activeLayer>=index && activeLayer != 0) {
activeLayer--; activeLayer--;
} }
} }
@@ -145,10 +146,12 @@ void PaintingArea::floodFill(int r, int g, int b, int a){
} }
void PaintingArea::movePositionActive(int x, int y){ void PaintingArea::movePositionActive(int x, int y){
if(Tool->getIsDrawing()){ if(Tool!=nullptr){
IntelliTool* temp = copyActiveTool(); if(Tool->getIsDrawing()){
delete this->Tool; IntelliTool* temp = copyActiveTool();
this->Tool = temp; delete this->Tool;
this->Tool = temp;
}
} }
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x; layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y; layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
@@ -168,10 +171,12 @@ void PaintingArea::moveActiveLayer(int idx){
} }
void PaintingArea::slotActivateLayer(int a){ void PaintingArea::slotActivateLayer(int a){
if(Tool->getIsDrawing()){ if(Tool != nullptr){
IntelliTool* temp = copyActiveTool(); if(Tool->getIsDrawing()){
delete this->Tool; IntelliTool* temp = copyActiveTool();
this->Tool = temp; delete this->Tool;
this->Tool = temp;
}
} }
if(a>=0 && a < static_cast<int>(layerBundle.size())) { if(a>=0 && a < static_cast<int>(layerBundle.size())) {
this->setLayerActive(a); this->setLayerActive(a);
@@ -395,3 +400,7 @@ IntelliTool* PaintingArea::copyActiveTool(){
int PaintingArea::getNumberOfActiveLayer(){ int PaintingArea::getNumberOfActiveLayer(){
return activeLayer; return activeLayer;
} }
IntelliImage* PaintingArea::getImageOfActiveLayer(){
return layerBundle[activeLayer].image;
}

View File

@@ -7,6 +7,7 @@
#include <QPoint> #include <QPoint>
#include <QWidget> #include <QWidget>
#include <QList> #include <QList>
#include "GUI/IntelliPhotoGui.h"
#include "Image/IntelliImage.h" #include "Image/IntelliImage.h"
#include "Image/IntelliRasterImage.h" #include "Image/IntelliRasterImage.h"
#include "Image/IntelliShapedImage.h" #include "Image/IntelliShapedImage.h"
@@ -40,6 +41,7 @@ class PaintingArea : public QWidget
// QObjects handle events // QObjects handle events
Q_OBJECT Q_OBJECT
friend IntelliTool; friend IntelliTool;
friend IntelliPhotoGui;
public: public:
/*! /*!
* \brief PaintingArea is the constructor of the PaintingArea class, which initiates the working environment * \brief PaintingArea is the constructor of the PaintingArea class, which initiates the working environment
@@ -167,6 +169,8 @@ public:
int getNumberOfActiveLayer(); int getNumberOfActiveLayer();
IntelliImage* getImageOfActiveLayer();
IntelliToolsettings Toolsettings; IntelliToolsettings Toolsettings;
IntelliColorPicker colorPicker; IntelliColorPicker colorPicker;
@@ -207,6 +211,7 @@ private:
IntelliRenderSettings renderSettings; IntelliRenderSettings renderSettings;
IntelliTool* Tool; IntelliTool* Tool;
IntelliPhotoGui* DumpyGui;
std::vector<LayerObject> layerBundle; std::vector<LayerObject> layerBundle;
int activeLayer=-1; int activeLayer=-1;

View File

@@ -74,6 +74,7 @@ void IntelliTool::mergeToolLayer(){
activeLayer->image->imageData.setPixelColor(x, y, clr_0); activeLayer->image->imageData.setPixelColor(x, y, clr_0);
} }
} }
Area->DumpyGui->UpdateGui();
} }
void IntelliTool::deleteToolLayer(){ void IntelliTool::deleteToolLayer(){