Skip to content

Commit

Permalink
fix zoom buttons in picedit
Browse files Browse the repository at this point in the history
  • Loading branch information
cromerc committed Apr 19, 2020
1 parent 52a4b3f commit 3db0d2f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/picedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ void PicEdit::zoom_minus()
h = canvas->cur_h+4;
canvas->resizeContents(w,h);
}
canvas->update();

}

Expand All @@ -620,6 +621,7 @@ void PicEdit::zoom_plus()
h = canvas->cur_h+4;
canvas->resizeContents(w,h);
}
canvas->update();

}

Expand Down Expand Up @@ -902,7 +904,7 @@ void PCanvas::setPixsize(int s)
pixmap.resize(cur_w,cur_h);
QPainter p(&pixmap);
p.eraseRect(0,0,cur_w,cur_h);
update();
updatePainter(&p);

}
//*********************************************
Expand Down Expand Up @@ -984,11 +986,17 @@ void PCanvas::drawContents(QPainter* p,int ,int ,int ,int )

}

//*********************************************
void PCanvas::update()
{

QPainter p(&pixmap);
updatePainter(&p);
}

//*********************************************
void PCanvas::updatePainter(QPainter *p)
{

//QPainter p(&pixmap);
int x,y;
byte c;
byte *data;
Expand All @@ -1000,19 +1008,19 @@ void PCanvas::update()
for(x=0;x<MAX_W;x+=2){
c=data[y*MAX_W+x];
if((pic&&c==15)||(!pic&&c==4)){ //draw background instead of "empty" areas
p.fillRect(x*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x,y)));
p.fillRect((x+1)*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x+1,y)));
p->fillRect(x*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x,y)));
p->fillRect((x+1)*pixsize,y*pixsize,pixsize,pixsize,QColor(bgpix.pixel(x+1,y)));
}
else{
p.fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[c]);
p->fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[c]);
}
}
}
}
else{
for(y=0;y<MAX_HH;y++){
for(x=0;x<MAX_W;x+=2){
p.fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[data[y*MAX_W+x]]);
p->fillRect(x*pixsize,y*pixsize,pixsize*2,pixsize,egacolor[data[y*MAX_W+x]]);
}
}
}
Expand All @@ -1030,11 +1038,11 @@ void PCanvas::update()
for(y=step*3;y<MAX_HH*pixsize;y+=step){
//pen.setBrush(QColor(255, 0, 0, 127));
pen.setBrush(egacolor[i++]);
p.setPen(pen);
p.drawLine(0,y,MAX_W*pixsize,y);
p->setPen(pen);
p->drawLine(0,y,MAX_W*pixsize,y);
pen.setBrush(QColor(0, 0, 0, 127));
p.setPen(pen);
p.drawLine(0,y+1,MAX_W*pixsize,y+1);
p->setPen(pen);
p->drawLine(0,y+1,MAX_W*pixsize,y+1);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/picedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class PCanvas : public Q3ScrollView
void load_bg(char *filename);
void draw(int ResNum);
void update();
void updatePainter(QPainter *p);
void setSize(int w,int h);
void setPixsize(int pixsize);
protected:
Expand Down

0 comments on commit 3db0d2f

Please sign in to comment.