fixed history tool

This commit is contained in:
Sonaion
2020-02-07 10:22:18 +01:00
parent 5787b065c5
commit 7e93e69a53
9 changed files with 23 additions and 74 deletions

View File

@@ -26,9 +26,9 @@ LayerObject::LayerObject(){
LayerObject::LayerObject(const LayerObject& layer){
if(layer.image->getTypeOfImage()==ImageType::RASTERIMAGE) {
this->image = new IntelliRasterImage(*dynamic_cast<IntelliRasterImage*>(layer.image));
this->image = new IntelliRasterImage(*dynamic_cast<IntelliRasterImage*>(layer.image));
}else if(layer.image->getTypeOfImage()==ImageType::SHAPEDIMAGE) {
this->image = new IntelliShapedImage(*dynamic_cast<IntelliShapedImage*>(layer.image));
this->image = new IntelliShapedImage(*dynamic_cast<IntelliShapedImage*>(layer.image));
}
this->width = layer.width;
this->height = layer.height;
@@ -130,7 +130,7 @@ void PaintingArea::slotDeleteActiveLayer(){
this->layerBundle.erase(layerBundle.begin() + activeLayer);
activeLayer--;
}
historyadd();
historyadd();
}
void PaintingArea::setLayerActive(int idx){
@@ -205,7 +205,7 @@ void PaintingArea::movePositionActive(int x, int y){
updateTools();
layerBundle[static_cast<size_t>(activeLayer)].widthOffset += x;
layerBundle[static_cast<size_t>(activeLayer)].heightOffset += y;
historyadd();
historyadd();
}
void PaintingArea::moveActiveLayer(int idx){
@@ -216,7 +216,7 @@ void PaintingArea::moveActiveLayer(int idx){
this->selectLayerDown();
}
guiReference->UpdateGui();
historyadd();
historyadd();
}
void PaintingArea::slotActivateLayer(int a){
@@ -509,46 +509,25 @@ void PaintingArea::updateTools(){
void PaintingArea::historyadd(){
historyPresent++;
if (historyPresent == 100) {
historyPresent = 0;
}
historyMaxFuture = historyPresent;
if (historyPresent == historyMaxPast) {
historyMaxPast++;
if (historyMaxPast == 100) {
historyMaxPast = 0;
}
}
history[static_cast<size_t>(historyPresent)] = layerBundle;
history.erase(history.begin()+historyPresent+1,history.end());
historyPresent++;
history.push_back(layerBundle);
}
void PaintingArea::historyGoBack(){
if (historyPresent != historyMaxPast) {
if (--historyPresent == -1)
historyPresent = 99;
if (activeLayer == -1)
activeLayer = 0;
if (layerBundle.size() > history[static_cast<size_t>(historyPresent)].size())
activeLayer = static_cast<int>(history[static_cast<size_t>(historyPresent)].size()) - 1;
if (history[static_cast<size_t>(historyPresent)].size() == 0)
activeLayer = -1;
layerBundle = history[static_cast<size_t>(historyPresent)];
}
this->guiReference->UpdateGui();
historyPresent--;
if( historyPresent<0){
historyPresent=0;
}
layerBundle = history[static_cast<size_t>(historyPresent)];
this->guiReference->UpdateGui();
}
void PaintingArea::historyGoForward(){
if (historyPresent != historyMaxFuture) {
if (++historyPresent == 100)
historyPresent = 0;
if (activeLayer == -1)
activeLayer = 0;
if (layerBundle.size() > history[static_cast<size_t>(historyPresent)].size())
activeLayer = static_cast<int>(history[static_cast<size_t>(historyPresent)].size()) - 1;
if (history[static_cast<size_t>(historyPresent)].size() == 0)
activeLayer = -1;
layerBundle = history[static_cast<size_t>(historyPresent)];
}
historyPresent++;
if(historyPresent>=static_cast<int>(history.size())){
historyPresent=history.size()-1;
}
layerBundle = history[static_cast<size_t>(historyPresent)];
this->guiReference->UpdateGui();
}