Refractoring Update 2

- Adjusted variable names to naming conventions
- Concluded header files
This commit is contained in:
2019-12-20 10:05:57 +01:00
parent 52292ebfe7
commit d81afbb8ee
17 changed files with 93 additions and 157 deletions

View File

@@ -12,8 +12,8 @@ IntelliTool::~IntelliTool(){
}
void IntelliTool::onMouseRightPressed(int x, int y){
if(drawing) {
drawing=false;
if(isDrawing) {
isDrawing=false;
this->deleteToolLayer();
}
}
@@ -23,23 +23,23 @@ void IntelliTool::onMouseRightReleased(int x, int y){
}
void IntelliTool::onMouseLeftPressed(int x, int y){
this->drawing=true;
this->isDrawing=true;
//create drawing layer
this->createToolLayer();
Canvas->image->calculateVisiblity();
}
void IntelliTool::onMouseLeftReleased(int x, int y){
if(drawing) {
drawing=false;
if(isDrawing) {
isDrawing=false;
this->mergeToolLayer();
this->deleteToolLayer();
Active->image->calculateVisiblity();
activeLayer->image->calculateVisiblity();
}
}
void IntelliTool::onMouseMoved(int x, int y){
if(drawing)
if(isDrawing)
Canvas->image->calculateVisiblity();
}
@@ -49,16 +49,16 @@ void IntelliTool::onWheelScrolled(int value){
void IntelliTool::createToolLayer(){
Area->createTempTopLayer(Area->activeLayer);
this->Active=&Area->layerBundle[Area->activeLayer];
this->activeLayer=&Area->layerBundle[Area->activeLayer];
this->Canvas=&Area->layerBundle[Area->activeLayer+1];
}
void IntelliTool::mergeToolLayer(){
QColor clr_0;
QColor clr_1;
for(int y=0; y<Active->height; y++) {
for(int x=0; x<Active->width; x++) {
clr_0=Active->image->imageData.pixelColor(x,y);
for(int y=0; y<activeLayer->height; y++) {
for(int x=0; x<activeLayer->width; x++) {
clr_0=activeLayer->image->imageData.pixelColor(x,y);
clr_1=Canvas->image->imageData.pixelColor(x,y);
float t = static_cast<float>(clr_1.alpha())/255.f;
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
@@ -70,7 +70,7 @@ void IntelliTool::mergeToolLayer(){
clr_0.setBlue(b);
clr_0.setAlpha(a);
Active->image->imageData.setPixelColor(x, y, clr_0);
activeLayer->image->imageData.setPixelColor(x, y, clr_0);
}
}
}