The Same timer widget, this time with Git patches.
/* * timer_widget.cpp - widget for visualization of elapsed time * Based on visualization widget * Uploaded by Ruben Ibarra * TODO: Add glow effect and make it look more digital * Licensed by GPLv2 */
#include <QtGui/QMouseEvent> #include <QtGui/QPainter> #include "timer_widget.h" #include "gui_templates.h" #include "MainWindow.h" #include "embed.h" #include "engine.h" #include "tooltip.h" #include "song.h" timerWidget::timerWidget( const QPixmap & _bg, QWidget * _p ) : QWidget( _p ), s_background( _bg ), mode( 0 ) { setFixedSize( s_background.width(), s_background.height() ); setAttribute( Qt::WA_OpaquePaintEvent, true ); const fpp_t frames = engine::getMixer()->framesPerPeriod(); m_buffer = new sampleFrame[frames]; engine::getMixer()->clearAudioBuffer( m_buffer, frames ); toolTip::add( this, tr( "click to enable/disable visualization of " "time" ) ); } timerWidget::~timerWidget() { delete[] m_buffer; } void timerWidget::updateAudioBuffer() { if( !engine::getSong()->isExporting() ) { engine::getMixer()->lock(); const surroundSampleFrame * c = engine::getMixer()-> currentReadBuffer(); const fpp_t fpp = engine::getMixer()->framesPerPeriod(); memcpy( m_buffer, c, sizeof( surroundSampleFrame ) * fpp ); engine::getMixer()->unlock(); } } void timerWidget::setActive( bool _active ) { if( mode != 2 ) { connect( engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); connect( engine::getMixer(), SIGNAL( nextAudioBuffer() ), this, SLOT( updateAudioBuffer() ) ); } else { disconnect( engine::mainWindow(), SIGNAL( periodicUpdate() ), this, SLOT( update() ) ); disconnect( engine::getMixer(), SIGNAL( nextAudioBuffer() ), this, SLOT( updateAudioBuffer() ) ); // we have to update (remove last waves), // because timer doesn't do that anymore update(); } } void timerWidget::paintEvent( QPaintEvent * ) { QPainter p( this ); p.drawPixmap( 0, 0, s_background ); //if( m_active && !engine::getSong()->isExporting() ) if( (mode == 1) && !engine::getSong()->isExporting() ) { p.setPen( QColor( 64, 224, 255 ) ); p.setRenderHint( QPainter::Antialiasing ); // now draw all that stuff milliseconds = milliseconds.setNum(engine::getSong()->getMilliseconds()%100); seconds = seconds.setNum((engine::getSong()->getMilliseconds()/100)%60); minutes = minutes.setNum((engine::getSong()->getMilliseconds()/6000)); p.setFont( pointSize<16>( p.font() ) ); if((engine::getSong()->getMilliseconds()/6000) < 10)//Minutes time1 = "0"; else time1 = ""; if((engine::getSong()->getMilliseconds()/100)%60 < 10)//Seconds time2 = ":0"; else time2 = ":"; if(engine::getSong()->getMilliseconds()%100 < 10)//Milliseconds time3 = ":0"; else time3 = ":"; total = minutes + ":" + seconds + ":" + milliseconds; total = time1 + minutes + time2 + seconds + time3 + milliseconds; p.drawText( 10, 30,total); } else if(mode == 2) { p.setPen( QColor( 64, 224, 255 ) ); p.setRenderHint( QPainter::Antialiasing ); tacts = seconds.setNum(engine::getSong()->getTacts()); ticks = minutes.setNum(engine::getSong()->getTicks()); milliseconds = milliseconds.setNum(engine::getSong()->getMilliseconds()%100); p.setFont( pointSize<16>( p.font() ) ); if(engine::getSong()->getTacts() < 10)//Tacts time1 = "0"; else time1 = ""; if(engine::getSong()->getTicks() < 10)//Ticks time2 = ":0"; else time2 = ":"; if(engine::getSong()->getMilliseconds()%100 < 10)//Milliseconds time3 = ":0"; else time3 = ":"; total = time1 + tacts + time2 + ticks + time3 + milliseconds; p.drawText( 10, 30,total); } else { p.setPen( QColor( 192, 192, 192 ) ); p.setFont( pointSize<7>( p.font() ) ); p.drawText( 6, height()-5, tr( "Click to enable" ) ); } } void timerWidget::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton ) { if(mode == 0) setActive( true ); else if(mode == 2) setActive( false); mode++; mode = mode%3; } } #include "moc_timer_widget.cxx"
/* * timer_widget.cpp - widget for visualization of ellapsed time * Based on visualization widget * Uploaded by Ruben Ibarra * TODO: Add glow effect * Licensed by GPLv2 */ #ifndef _TIMER_WIDGET #define _TIMER_WIDGET #include <QtGui/QWidget> #include <QtGui/QPixmap> #include <QtGui/QGraphicsDropShadowEffect> #include "Mixer.h" class timerWidget : public QWidget { Q_OBJECT public: timerWidget( const QPixmap & _bg, QWidget * _parent); virtual ~timerWidget(); void setActive( bool _active ); protected: virtual void paintEvent( QPaintEvent * _pe ); virtual void mousePressEvent( QMouseEvent * _me ); protected slots: void updateAudioBuffer(); private: QPixmap s_background; QPointF * m_points; QString seconds; QString minutes; QString milliseconds; QString tacts; QString ticks; QString time1,time2,time3; QString total; QGraphicsDropShadowEffect * dse; sampleFrame * m_buffer; int mode; } ; #endif
MainWindow.patch
Description: Binary data
timeline.patch
Description: Binary data
song.patch
Description: Binary data
------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev
_______________________________________________ LMMS-devel mailing list LMMS-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lmms-devel