mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-13 20:00:32 +02:00
Merge branch 'dev' into dev-colorpalette
This commit is contained in:
@@ -18,24 +18,13 @@
|
||||
#include "Tool/IntelliToolFloodFill.h"
|
||||
#include "Tool/IntelliToolPolygon.h"
|
||||
|
||||
|
||||
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
||||
: QWidget(parent){
|
||||
this->Tool = nullptr;
|
||||
this->setLayerDimensions(maxWidth, maxHeight);
|
||||
this->addLayer(200,200,0,0,IntelliImage::ImageType::SHAPEDIMAGE);
|
||||
layerBundle[0].image->drawPlain(QColor(0,0,255,255));
|
||||
std::vector<QPoint> polygon;
|
||||
polygon.push_back(QPoint(100,000));
|
||||
polygon.push_back(QPoint(200,100));
|
||||
polygon.push_back(QPoint(100,200));
|
||||
polygon.push_back(QPoint(000,100));
|
||||
layerBundle[0].image->setPolygon(polygon);
|
||||
|
||||
this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
|
||||
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
|
||||
layerBundle[1].alpha=200;
|
||||
|
||||
activeLayer=0;
|
||||
activeLayer=-1;
|
||||
}
|
||||
|
||||
PaintingArea::~PaintingArea(){
|
||||
@@ -64,6 +53,7 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
||||
|
||||
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, IntelliImage::ImageType type){
|
||||
LayerObject newLayer;
|
||||
updateTools();
|
||||
newLayer.width = width;
|
||||
newLayer.height = height;
|
||||
newLayer.widthOffset = widthOffset;
|
||||
@@ -80,7 +70,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
|
||||
}
|
||||
|
||||
|
||||
void PaintingArea::deleteLayer(int idx){
|
||||
void PaintingArea::deleteLayer(int idx, bool isTool){
|
||||
if(!isTool) {
|
||||
updateTools();
|
||||
}
|
||||
if(idx<static_cast<int>(layerBundle.size())) {
|
||||
this->layerBundle.erase(layerBundle.begin()+idx);
|
||||
if(activeLayer>=idx) {
|
||||
@@ -100,6 +93,7 @@ void PaintingArea::slotDeleteActiveLayer(){
|
||||
}
|
||||
|
||||
void PaintingArea::setLayerActive(int idx){
|
||||
updateTools();
|
||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
||||
this->activeLayer=idx;
|
||||
}
|
||||
@@ -110,6 +104,15 @@ void PaintingArea::setLayerAlpha(int idx, int alpha){
|
||||
layerBundle[static_cast<size_t>(idx)].alpha=alpha;
|
||||
}
|
||||
}
|
||||
void PaintingArea::setPolygon(int idx){
|
||||
if(idx>=0&&idx<static_cast<int>(layerBundle.size())) {
|
||||
if(layerBundle[static_cast<size_t>(idx)].image->getTypeOfImage()==IntelliImage::ImageType::SHAPEDIMAGE) {
|
||||
delete this->Tool;
|
||||
this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true);
|
||||
isSettingPolygon = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Used to load the image and place it in the widget
|
||||
bool PaintingArea::open(const QString &filePath){
|
||||
@@ -147,36 +150,14 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
|
||||
}
|
||||
}
|
||||
|
||||
// Color the image area with white
|
||||
void PaintingArea::floodFill(int r, int g, int b, int a){
|
||||
if(this->activeLayer==-1) {
|
||||
return;
|
||||
}
|
||||
IntelliImage* active = layerBundle[static_cast<size_t>(activeLayer)].image;
|
||||
active->drawPlain(QColor(r, g, b, a));
|
||||
update();
|
||||
}
|
||||
|
||||
void PaintingArea::movePositionActive(int x, int y){
|
||||
if(Tool!=nullptr) {
|
||||
if(Tool->getIsDrawing()) {
|
||||
IntelliTool* temp = copyActiveTool();
|
||||
delete this->Tool;
|
||||
this->Tool = temp;
|
||||
}
|
||||
}
|
||||
updateTools();
|
||||
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
|
||||
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
|
||||
}
|
||||
|
||||
void PaintingArea::moveActiveLayer(int idx){
|
||||
if(Tool != nullptr) {
|
||||
if(Tool->getIsDrawing()) {
|
||||
IntelliTool* temp = copyActiveTool();
|
||||
delete this->Tool;
|
||||
this->Tool = temp;
|
||||
}
|
||||
}
|
||||
updateTools();
|
||||
if(idx==1) {
|
||||
this->selectLayerUp();
|
||||
}else if(idx==-1) {
|
||||
@@ -186,13 +167,7 @@ void PaintingArea::moveActiveLayer(int idx){
|
||||
}
|
||||
|
||||
void PaintingArea::slotActivateLayer(int a){
|
||||
if(Tool != nullptr) {
|
||||
if(Tool->getIsDrawing()) {
|
||||
IntelliTool* temp = copyActiveTool();
|
||||
delete this->Tool;
|
||||
this->Tool = temp;
|
||||
}
|
||||
}
|
||||
updateTools();
|
||||
if(a>=0 && a < static_cast<int>(layerBundle.size())) {
|
||||
this->setLayerActive(a);
|
||||
}
|
||||
@@ -344,7 +319,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
||||
update();
|
||||
}
|
||||
|
||||
// Resize the image to slightly larger then the main window
|
||||
//TODOJ Resize the image to slightly larger then the main window
|
||||
// to cut down on the need to resize the image
|
||||
void PaintingArea::resizeEvent(QResizeEvent*event){
|
||||
//TODO wait till tool works
|
||||
@@ -356,6 +331,7 @@ void PaintingArea::resizeLayer(QImage*image_res, const QSize &newSize){
|
||||
}
|
||||
|
||||
void PaintingArea::selectLayerUp(){
|
||||
updateTools();
|
||||
if(activeLayer!=-1 && static_cast<unsigned long long>(activeLayer)<layerBundle.size()-1) {
|
||||
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer+1)]);
|
||||
activeLayer++;
|
||||
@@ -363,6 +339,7 @@ void PaintingArea::selectLayerUp(){
|
||||
}
|
||||
|
||||
void PaintingArea::selectLayerDown(){
|
||||
updateTools();
|
||||
if(activeLayer!=-1 && activeLayer>0) {
|
||||
std::swap(layerBundle[static_cast<unsigned long long>(activeLayer)], layerBundle[static_cast<unsigned long long>(activeLayer-1)]);
|
||||
activeLayer--;
|
||||
@@ -440,5 +417,35 @@ IntelliImage* PaintingArea::getImageOfActiveLayer(){
|
||||
if(activeLayer<0) {
|
||||
return nullptr;
|
||||
}
|
||||
return layerBundle[activeLayer].image;
|
||||
return layerBundle[static_cast<size_t>(activeLayer)].image;
|
||||
}
|
||||
|
||||
QImage PaintingArea::getImageDataOfActiveLayer(){
|
||||
QImage returnImage;
|
||||
if(activeLayer<0) {
|
||||
returnImage = QImage(QSize(10,10),QImage::Format_ARGB32);
|
||||
returnImage.fill(QColor(255,255,255,255));
|
||||
}
|
||||
else{
|
||||
returnImage = layerBundle[static_cast<size_t>(activeLayer)].image->getImageData();
|
||||
if(renderSettings.isFastRenderering()) {
|
||||
returnImage = returnImage.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
}
|
||||
return returnImage;
|
||||
}
|
||||
|
||||
void PaintingArea::updateTools(){
|
||||
if(Tool!=nullptr) {
|
||||
if(Tool->getIsDrawing()) {
|
||||
IntelliTool* temp = copyActiveTool();
|
||||
delete this->Tool;
|
||||
this->Tool = temp;
|
||||
}
|
||||
if(isSettingPolygon) {
|
||||
delete this->Tool;
|
||||
this->Tool = nullptr;
|
||||
isSettingPolygon = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user