Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/waveform/waveformrenderbackground.cpp

Go to the documentation of this file.
00001 
00002 #include <QDebug>
00003 #include <QColor>
00004 #include <QDomNode>
00005 #include <QPaintEvent>
00006 #include <QPainter>
00007 #include <QObject>
00008 #include <QVector>
00009 #include <QLine>
00010 #include <QPixmap>
00011 
00012 #include "waveformrenderbackground.h"
00013 #include "waveformrenderer.h"
00014 #include "controlobjectthreadmain.h"
00015 #include "controlobject.h"
00016 #include "widget/wskincolor.h"
00017 #include "widget/wwidget.h"
00018 #include "trackinfoobject.h"
00019 
00020 WaveformRenderBackground::WaveformRenderBackground(const char* group, WaveformRenderer *parent)
00021         : m_iWidth(0),
00022           m_iHeight(0),
00023           m_backgroundPixmap(),
00024           m_bRepaintBackground(true),
00025           bgColor(0,0,0) {
00026 }
00027 
00028 WaveformRenderBackground::~WaveformRenderBackground() {
00029     qDebug() << this << "~WaveformRenderBackground()";
00030 }
00031 
00032 void WaveformRenderBackground::resize(int w, int h) {
00033     m_iWidth = w;
00034     m_iHeight = h;
00035     // Need to repaint the background if we've been resized.
00036     m_bRepaintBackground = true;
00037 }
00038 
00039 void WaveformRenderBackground::newTrack(TrackPointer pTrack) {
00040 }
00041 
00042 void WaveformRenderBackground::setup(QDomNode node) {
00043     bgColor.setNamedColor(WWidget::selectNodeQString(node, "BgColor"));
00044     bgColor = WSkinColor::getCorrectColor(bgColor);
00045     m_backgroundPixmapPath = WWidget::selectNodeQString(node, "BgPixmap");
00046     m_bRepaintBackground = true;
00047 }
00048 
00049 void WaveformRenderBackground::draw(QPainter *pPainter, QPaintEvent *pEvent,
00050                                     QVector<float> *buffer, double dPlayPos, double rateAdjust) {
00051     if(m_bRepaintBackground) {
00052         generatePixmap();
00053     }
00054 
00055     pPainter->fillRect(pEvent->rect(), bgColor);
00056 
00057     // Paint the background pixmap if it exists.
00058     if (!m_backgroundPixmap.isNull()) {
00059         pPainter->drawTiledPixmap(pEvent->rect(), m_backgroundPixmap, QPoint(0,0));
00060     }
00061 }
00062 
00063 void WaveformRenderBackground::generatePixmap() {
00064     if (m_backgroundPixmapPath != "") {
00065         m_backgroundPixmap = QPixmap(WWidget::getPath(m_backgroundPixmapPath));
00066     } else {
00067         m_backgroundPixmap = QPixmap();
00068     }
00069     m_bRepaintBackground = false;
00070 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines