mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 12:20:32 +02:00
Merge branch 'experimental_layer' into dev
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// IntelliPhotoGui constructor
|
||||
IntelliPhotoGui::IntelliPhotoGui()
|
||||
{
|
||||
//create Gui elemnts and lay them out
|
||||
//create Gui elements and lay them out
|
||||
createGui();
|
||||
// Create actions
|
||||
createActions();
|
||||
@@ -101,6 +101,46 @@ void IntelliPhotoGui::penWidth()
|
||||
paintingArea->setPenWidth(newWidth);
|
||||
}
|
||||
|
||||
// Opens a dialog that allows the user to create a New Layer
|
||||
void IntelliPhotoGui::newLayer()
|
||||
{
|
||||
// Stores button value
|
||||
bool ok;
|
||||
|
||||
// tr("New Layer") is the title
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
int width = QInputDialog::getInt(this, tr("New Layer"),
|
||||
tr("Width:"),
|
||||
200,1, 500, 1, &ok);
|
||||
int height = QInputDialog::getInt(this, tr("New Layer"),
|
||||
tr("Height:"),
|
||||
200,1, 500, 1, &ok);
|
||||
// Create New Layer
|
||||
if (ok)
|
||||
{
|
||||
int layer = paintingArea->addLayer(width,height,100,100);
|
||||
paintingArea->activate(layer);
|
||||
}
|
||||
}
|
||||
|
||||
// Opens a dialog that allows the user to delete a Layer
|
||||
void IntelliPhotoGui::deleteLayer()
|
||||
{
|
||||
// Stores button value
|
||||
bool ok;
|
||||
|
||||
// tr("delete Layer") is the title
|
||||
// the next tr is the text to display
|
||||
// Define the standard Value, min, max, step and ok button
|
||||
int layerNumber = QInputDialog::getInt(this, tr("delete Layer"),
|
||||
tr("Number:"),
|
||||
1,1, 500, 1, &ok);
|
||||
// Create New Layer
|
||||
if (ok)
|
||||
paintingArea->deleteLayer(layerNumber-1);
|
||||
}
|
||||
|
||||
// Open an about dialog
|
||||
void IntelliPhotoGui::about()
|
||||
{
|
||||
@@ -111,7 +151,8 @@ void IntelliPhotoGui::about()
|
||||
|
||||
void IntelliPhotoGui::onSetAlpha(){
|
||||
int a = this->setAlphaEdit->text().toInt();
|
||||
emit this->sendAlpha(a);
|
||||
if (a >= 0 && a < 256)
|
||||
emit this->sendAlpha(a);
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::onMoveUp(){
|
||||
@@ -146,12 +187,13 @@ void IntelliPhotoGui::onClearedPressed(){
|
||||
int r = this->RedEdit->text().toInt();
|
||||
int g = this->GreenEdit->text().toInt();
|
||||
int b = this->BlueEdit->text().toInt();
|
||||
emit this->sendClearColor(r,g,b);
|
||||
if(r < 256 && r >= 0 && g < 256 && g >= 0 && b < 256 && b >= 0)
|
||||
emit this->sendClearColor(r,g,b);
|
||||
}
|
||||
|
||||
void IntelliPhotoGui::onActivePressed(){
|
||||
int a = this->selectActiveEdit->text().toInt();
|
||||
emit this->sendActiveLayer(a);
|
||||
emit this->sendActiveLayer(a-1);
|
||||
};
|
||||
|
||||
|
||||
@@ -247,6 +289,18 @@ void IntelliPhotoGui::createActions()
|
||||
connect(clearScreenAct, SIGNAL(triggered()),
|
||||
this, SLOT(onClearedPressed()));
|
||||
|
||||
// Create New Layer action and tie to IntelliPhotoGui::newLayer()
|
||||
newLayerAct = new QAction(tr("&New Layer..."), this);
|
||||
connect(newLayerAct, SIGNAL(triggered()), this, SLOT(newLayer()));
|
||||
|
||||
// Delete New Layer action and tie to IntelliPhotoGui::deleteLayer()
|
||||
deleteLayerAct = new QAction(tr("&Delete Layer..."), this);
|
||||
connect(deleteLayerAct, SIGNAL(triggered()), this, SLOT(deleteLayer()));
|
||||
|
||||
// Delete Active Layer action and tie to paintingArea::deleteActiveLayerLayer()
|
||||
deleteActiveLayerAct = new QAction(tr("&Delete active Layer"), this);
|
||||
connect(deleteActiveLayerAct, SIGNAL(triggered()), paintingArea, SLOT(deleteActiveLayer()));
|
||||
|
||||
// Create about action and tie to IntelliPhotoGui::about()
|
||||
aboutAct = new QAction(tr("&About"), this);
|
||||
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
|
||||
@@ -279,6 +333,12 @@ void IntelliPhotoGui::createMenus()
|
||||
optionMenu->addSeparator();
|
||||
optionMenu->addAction(clearScreenAct);
|
||||
|
||||
// Attach all actions to Layer
|
||||
layerMenu = new QMenu(tr("&Layer"), this);
|
||||
layerMenu->addAction(newLayerAct);
|
||||
layerMenu->addAction(deleteLayerAct);
|
||||
layerMenu->addAction(deleteActiveLayerAct);
|
||||
|
||||
// Attach all actions to Help
|
||||
helpMenu = new QMenu(tr("&Help"), this);
|
||||
helpMenu->addAction(aboutAct);
|
||||
@@ -287,6 +347,7 @@ void IntelliPhotoGui::createMenus()
|
||||
// Add menu items to the menubar
|
||||
menuBar()->addMenu(fileMenu);
|
||||
menuBar()->addMenu(optionMenu);
|
||||
menuBar()->addMenu(layerMenu);
|
||||
menuBar()->addMenu(helpMenu);
|
||||
}
|
||||
|
||||
@@ -316,7 +377,7 @@ void IntelliPhotoGui::createGui(){
|
||||
|
||||
selectActiveButton = new QPushButton("select Active");
|
||||
selectActiveLabel = new QLabel("Active:");
|
||||
selectActiveEdit = new QLineEdit("0");
|
||||
selectActiveEdit = new QLineEdit("1");
|
||||
selectActiveLabel->setMaximumSize(150,20);
|
||||
selectActiveEdit->setMaximumSize(150,20);
|
||||
|
||||
|
||||
@@ -41,6 +41,8 @@ private slots:
|
||||
void save();
|
||||
void penColor();
|
||||
void penWidth();
|
||||
void newLayer();
|
||||
void deleteLayer();
|
||||
void about();
|
||||
|
||||
void onClearedPressed();
|
||||
@@ -77,6 +79,7 @@ private:
|
||||
QMenu *saveAsMenu;
|
||||
QMenu *fileMenu;
|
||||
QMenu *optionMenu;
|
||||
QMenu *layerMenu;
|
||||
QMenu *helpMenu;
|
||||
|
||||
|
||||
@@ -89,6 +92,9 @@ private:
|
||||
QAction *penColorAct;
|
||||
QAction *penWidthAct;
|
||||
QAction *clearScreenAct;
|
||||
QAction *newLayerAct;
|
||||
QAction *deleteLayerAct;
|
||||
QAction *deleteActiveLayerAct;
|
||||
QAction *aboutAct;
|
||||
QAction *aboutQtAct;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/jonas/OneDrive/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -132,7 +132,7 @@
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/jonas/OneDrive/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -188,7 +188,7 @@
|
||||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/jonas/OneDrive/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
@@ -311,8 +311,8 @@
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">IntelliPhoto</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">IntelliPhoto2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/jonas/OneDrive/Documents/GitHub/intelliphoto/src/Painting/IntelliPhoto.pro</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Mienek/Documents/intelliphoto/src/Painting/IntelliPhoto.pro</value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
@@ -322,7 +322,7 @@
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/jonas/OneDrive/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Release</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
|
||||
@@ -35,6 +35,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
|
||||
this->addLayer(200,200,150,150);
|
||||
layerStructure[1].image->floodFill(QColor(0,255,0,255));
|
||||
layerStructure[1].alpha=200;
|
||||
|
||||
activeLayer=1;
|
||||
#endif
|
||||
}
|
||||
@@ -55,7 +56,7 @@ void PaintingArea::setUp(int maxWidth, int maxHeight){
|
||||
myPenColor = Qt::blue;
|
||||
}
|
||||
|
||||
void PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){
|
||||
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){
|
||||
LayerObject newLayer;
|
||||
newLayer.width = width;
|
||||
newLayer.height = height;
|
||||
@@ -68,7 +69,7 @@ void PaintingArea::addLayer(int width, int height, int widthOffset, int heightOf
|
||||
}
|
||||
newLayer.alpha = 255;
|
||||
this->layerStructure.push_back(newLayer);
|
||||
|
||||
return layerStructure.size()-1;
|
||||
}
|
||||
|
||||
void PaintingArea::deleteLayer(int index){
|
||||
@@ -80,6 +81,11 @@ void PaintingArea::deleteLayer(int index){
|
||||
}
|
||||
}
|
||||
|
||||
void PaintingArea::deleteActiveLayer(){
|
||||
this->layerStructure.erase(layerStructure.begin()+activeLayer);
|
||||
activeLayer--;
|
||||
}
|
||||
|
||||
void PaintingArea::setLayerToActive(int index) {
|
||||
if(index<layerStructure.size()){
|
||||
this->activeLayer=index;
|
||||
@@ -185,7 +191,7 @@ void PaintingArea::getMoveLeft(int a){
|
||||
}
|
||||
|
||||
void PaintingArea::getMoveLayerUp(){
|
||||
if(activeLayer<layerStructure.size() && activeLayer>=0){
|
||||
if(activeLayer<layerStructure.size()-1 && activeLayer>=0){
|
||||
std::swap(layerStructure[activeLayer], layerStructure[activeLayer+1]);
|
||||
activeLayer++;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
bool openImage(const QString &fileName);
|
||||
bool saveImage(const QString &fileName, const char *fileFormat);
|
||||
|
||||
void addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
|
||||
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
|
||||
void deleteLayer(int index);
|
||||
void setLayerToActive(int index);
|
||||
void setAlphaToLayer(int index, int alpha);
|
||||
@@ -44,6 +44,7 @@ public slots:
|
||||
// Events to handle
|
||||
void clearImage(int r, int g, int b);
|
||||
void activate(int a);
|
||||
void deleteActiveLayer();
|
||||
|
||||
void setAlpha(int a);
|
||||
void getMoveUp(int a);
|
||||
|
||||
Reference in New Issue
Block a user