Speed up playlist paintEvent.
This commit is contained in:
parent
d57ebf91a0
commit
c4affb2619
1 changed files with 71 additions and 56 deletions
127
Playlist.cpp
127
Playlist.cpp
|
@ -289,92 +289,107 @@ void
|
||||||
PlaylistWidget::paintEvent (QPaintEvent *event)
|
PlaylistWidget::paintEvent (QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter paint;
|
QPainter paint;
|
||||||
|
QRect r;
|
||||||
|
QRect er = event->rect ();
|
||||||
|
|
||||||
paint.begin (this);
|
paint.begin (this);
|
||||||
paint.drawPixmap (QRect (0, 0,
|
|
||||||
m_corner1.size ().width (),
|
/* drawing the upper left corner */
|
||||||
m_corner1.size ().height ()),
|
r.setRect (0, 0,
|
||||||
m_corner1,
|
m_corner1.width(),
|
||||||
m_corner1.rect ());
|
m_corner1.height());
|
||||||
|
if (er.contains (r))
|
||||||
|
paint.drawPixmap (r, m_corner1, m_corner1.rect ());
|
||||||
|
|
||||||
paint.drawPixmap (QRect (size().width()-m_corner2.width(),
|
/* drawing the upper right corner */
|
||||||
0, m_corner2.width(),
|
r.setRect (width()-m_corner2.width(), 0, m_corner2.width(), m_corner2.height());
|
||||||
m_corner2.height()),
|
if (er.contains (r))
|
||||||
m_corner2,
|
paint.drawPixmap (r, m_corner2, m_corner2.rect());
|
||||||
m_corner2.rect());
|
|
||||||
|
|
||||||
paint.drawPixmap (QRect (0, size().height()-m_corner3.height(),
|
/* Drawing the lower left corner */
|
||||||
m_corner3.width(),
|
r.setRect (0, size().height()-m_corner3.height(),
|
||||||
m_corner3.height()),
|
m_corner3.width(), m_corner3.height());
|
||||||
m_corner3,
|
if (er.contains (r))
|
||||||
m_corner3.rect());
|
paint.drawPixmap (r, m_corner3, m_corner3.rect());
|
||||||
|
|
||||||
paint.drawPixmap (QRect (size().width()-m_corner4.width(),
|
/* drawing the lower right corner */
|
||||||
size().height()-m_corner4.height(),
|
r.setRect (size().width()-m_corner4.width(),
|
||||||
m_corner4.width(),
|
size().height()-m_corner4.height(),
|
||||||
m_corner4.height()),
|
m_corner4.width(),
|
||||||
m_corner4,
|
m_corner4.height());
|
||||||
m_corner4.rect());
|
if (er.contains (r))
|
||||||
|
paint.drawPixmap (r, m_corner4, m_corner4.rect());
|
||||||
|
|
||||||
|
/* calculate middle of the bar */
|
||||||
int midx = (size().width()/2) - (m_titlebar.width()/2);
|
int midx = (size().width()/2) - (m_titlebar.width()/2);
|
||||||
paint.drawPixmap (QRect(midx, 0, m_titlebar.width(), m_titlebar.height()),
|
|
||||||
m_titlebar, m_titlebar.rect());
|
/* Add the titlebar */
|
||||||
|
r.setRect (midx, 0, m_titlebar.width(), m_titlebar.height());
|
||||||
|
if (er.contains (r))
|
||||||
|
paint.drawPixmap (r, m_titlebar, m_titlebar.rect());
|
||||||
|
|
||||||
/* left fill */
|
/* left fill */
|
||||||
paint.drawPixmap (QRect(m_corner1.width(),
|
r.setRect (m_corner1.width(), 0, midx - m_corner1.width(), m_tfill.height());
|
||||||
0, midx - m_corner1.width(),
|
if (er.contains (r))
|
||||||
m_tfill.height()),
|
paint.drawPixmap (r, m_tfill, m_tfill.rect());
|
||||||
m_tfill,
|
|
||||||
m_tfill.rect());
|
|
||||||
|
|
||||||
|
/* Calculate middle pixel to the right side of the titlebar */
|
||||||
int midx2 = midx + m_titlebar.width();
|
int midx2 = midx + m_titlebar.width();
|
||||||
|
|
||||||
paint.drawPixmap (QRect (midx2, 0, size().width()-midx2-m_corner2.width(),
|
/* right fill */
|
||||||
m_tfill.height()),
|
r.setRect (midx2, 0, width()-midx2-m_corner2.width(), m_tfill.height());
|
||||||
m_tfill,
|
if (er.contains (r))
|
||||||
m_tfill.rect());
|
paint.drawPixmap (r, m_tfill, m_tfill.rect());
|
||||||
|
|
||||||
|
/* calculate the size of the bottom side */
|
||||||
int bsize = m_corner3.width()+m_corner4.width();
|
int bsize = m_corner3.width()+m_corner4.width();
|
||||||
|
|
||||||
|
/* if the width is bigger than bottom size we need to pad with
|
||||||
|
* a bit of generic bottom */
|
||||||
if (size().width() > bsize) {
|
if (size().width() > bsize) {
|
||||||
|
/* calculate padding width */
|
||||||
int pad_to = size().width() - bsize;
|
int pad_to = size().width() - bsize;
|
||||||
paint.drawPixmap (QRect (m_corner3.width(),
|
|
||||||
size().height()-m_bfill.height(),
|
/* Draw the bottom filling */
|
||||||
pad_to,
|
r.setRect (m_corner3.width(), size().height()-m_bfill.height(),
|
||||||
m_bfill.height()),
|
pad_to, m_bfill.height());
|
||||||
m_bfill,
|
if (er.contains (r))
|
||||||
m_bfill.rect());
|
paint.drawPixmap (r, m_bfill, m_bfill.rect());
|
||||||
}
|
}
|
||||||
|
|
||||||
paint.drawPixmap (QRect (0, m_corner1.height(), m_lfill.width(),
|
/* The slider bar consists of three elements L|S|R (left, slider, right)
|
||||||
size().height()-m_corner3.height()-m_corner1.height()),
|
* here we paint L and R and let the slider take care of the rest.
|
||||||
m_lfill,
|
*/
|
||||||
m_lfill.rect());
|
r.setRect (0, m_corner1.height(), m_lfill.width(),
|
||||||
paint.drawPixmap (QRect (size().width()-m_rfill3.width(),
|
size().height()-m_corner3.height()-m_corner1.height());
|
||||||
m_corner2.height(),
|
if (er.contains (r))
|
||||||
m_rfill3.width(),
|
paint.drawPixmap (r,m_lfill, m_lfill.rect());
|
||||||
size().height()-m_corner2.height()-m_corner3.height()),
|
|
||||||
m_rfill3,
|
|
||||||
m_rfill3.rect());
|
|
||||||
|
|
||||||
|
r.setRect (size().width()-m_rfill3.width(), m_corner2.height(), m_rfill3.width(),
|
||||||
|
size().height()-m_corner2.height()-m_corner3.height());
|
||||||
|
if (er.contains (r))
|
||||||
|
paint.drawPixmap (r, m_rfill3, m_rfill3.rect());
|
||||||
|
|
||||||
|
/* figure out where to place the last padding */
|
||||||
int x = size().width();
|
int x = size().width();
|
||||||
x -= m_rfill3.width();
|
x -= m_rfill3.width(); /* minus R */
|
||||||
x -= m_rfill2.width();
|
x -= m_rfill2.width(); /* minus slider */
|
||||||
x -= m_rfill.width();
|
x -= m_rfill.width(); /* minus L */
|
||||||
|
|
||||||
paint.drawPixmap (QRect (x, m_corner2.height(),
|
r.setRect (x, m_corner2.height(), m_rfill.width(),
|
||||||
m_rfill.width(),
|
size().height()-m_corner2.height()-m_corner3.height());
|
||||||
size().height()-m_corner2.height()-m_corner3.height()),
|
if (er.contains (r))
|
||||||
m_rfill,
|
paint.drawPixmap (r, m_rfill, m_rfill.rect());
|
||||||
m_rfill.rect());
|
|
||||||
|
|
||||||
paint.end ();
|
paint.end ();
|
||||||
|
|
||||||
|
/* since the sizes has changed we need to move the buttons */
|
||||||
m_scroller->move (size().width()-m_rfill3.width()-m_rfill2.width(),
|
m_scroller->move (size().width()-m_rfill3.width()-m_rfill2.width(),
|
||||||
m_corner2.height());
|
m_corner2.height());
|
||||||
m_scroller->resize (m_rfill2.width(),
|
m_scroller->resize (m_rfill2.width(),
|
||||||
size().height()-m_corner2.height()-m_corner4.height());
|
size().height()-m_corner2.height()-m_corner4.height());
|
||||||
|
|
||||||
|
/* drag corner */
|
||||||
m_drag->move (size().width()-30,
|
m_drag->move (size().width()-30,
|
||||||
size().height()-30);
|
size().height()-30);
|
||||||
m_drag->resize (30, 30);
|
m_drag->resize (30, 30);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue