Refactor the oscilloscope (#5488)
* Rename files * Update code * Remove unused code * Make background a member variable
This commit is contained in:
@@ -159,7 +159,7 @@ GroupBox {
|
||||
|
||||
/* main toolbar oscilloscope - can have transparent bg now */
|
||||
|
||||
VisualizationWidget {
|
||||
Oscilloscope {
|
||||
background: none;
|
||||
border: none;
|
||||
qproperty-normalColor: rgb(71, 253, 133);
|
||||
|
||||
@@ -191,7 +191,7 @@ GroupBox {
|
||||
|
||||
/* main toolbar oscilloscope - can have transparent bg now */
|
||||
|
||||
VisualizationWidget {
|
||||
Oscilloscope {
|
||||
background: none;
|
||||
border: none;
|
||||
qproperty-normalColor: rgb(71, 253, 133);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* VisualizationWidget.h - widget for visualization of sound-data
|
||||
* Oscilloscope.h
|
||||
*
|
||||
* Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
@@ -23,8 +23,8 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _VISUALIZATION_WIDGET
|
||||
#define _VISUALIZATION_WIDGET
|
||||
#ifndef _OSCILLOSCOPE
|
||||
#define _OSCILLOSCOPE
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPixmap>
|
||||
@@ -32,21 +32,16 @@
|
||||
#include "lmms_basics.h"
|
||||
|
||||
|
||||
class VisualizationWidget : public QWidget
|
||||
class Oscilloscope : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Q_PROPERTY( QColor normalColor READ normalColor WRITE setNormalColor )
|
||||
Q_PROPERTY( QColor warningColor READ warningColor WRITE setWarningColor )
|
||||
Q_PROPERTY( QColor clippingColor READ clippingColor WRITE setClippingColor )
|
||||
enum visualizationTypes
|
||||
{
|
||||
Simple // add more here
|
||||
} ;
|
||||
|
||||
VisualizationWidget( const QPixmap & _bg, QWidget * _parent,
|
||||
visualizationTypes _vtype = Simple );
|
||||
virtual ~VisualizationWidget();
|
||||
Oscilloscope( QWidget * _parent );
|
||||
virtual ~Oscilloscope();
|
||||
|
||||
void setActive( bool _active );
|
||||
|
||||
@@ -72,7 +67,7 @@ private:
|
||||
QColor const & determineLineColor(float level) const;
|
||||
|
||||
private:
|
||||
QPixmap s_background;
|
||||
QPixmap m_background;
|
||||
QPointF * m_points;
|
||||
|
||||
sampleFrame * m_buffer;
|
||||
@@ -77,6 +77,7 @@ SET(LMMS_SRCS
|
||||
gui/widgets/MeterDialog.cpp
|
||||
gui/widgets/MidiPortMenu.cpp
|
||||
gui/widgets/NStateButton.cpp
|
||||
gui/widgets/Oscilloscope.cpp
|
||||
gui/widgets/PixmapButton.cpp
|
||||
gui/widgets/ProjectNotes.cpp
|
||||
gui/widgets/RenameDialog.cpp
|
||||
@@ -93,7 +94,6 @@ SET(LMMS_SRCS
|
||||
gui/widgets/ToolTip.cpp
|
||||
gui/widgets/TrackLabelButton.cpp
|
||||
gui/widgets/TrackRenameLineEdit.cpp
|
||||
gui/widgets/VisualizationWidget.cpp
|
||||
gui/widgets/StepRecorderWidget.cpp
|
||||
|
||||
PARENT_SCOPE
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "TextFloat.h"
|
||||
#include "TimeLineWidget.h"
|
||||
#include "ToolTip.h"
|
||||
#include "VisualizationWidget.h"
|
||||
#include "Oscilloscope.h"
|
||||
#include "TimeDisplayWidget.h"
|
||||
#include "AudioDevice.h"
|
||||
#include "PianoRoll.h"
|
||||
@@ -210,15 +210,14 @@ SongEditor::SongEditor( Song * song ) :
|
||||
|
||||
gui->mainWindow()->addSpacingToToolBar( 10 );
|
||||
|
||||
// create widget for visualization- and cpu-load-widget
|
||||
// create widget for oscilloscope- and cpu-load-widget
|
||||
QWidget * vc_w = new QWidget( tb );
|
||||
QVBoxLayout * vcw_layout = new QVBoxLayout( vc_w );
|
||||
vcw_layout->setMargin( 0 );
|
||||
vcw_layout->setSpacing( 0 );
|
||||
|
||||
//vcw_layout->addStretch();
|
||||
vcw_layout->addWidget( new VisualizationWidget(
|
||||
embed::getIconPixmap( "output_graph" ), vc_w ) );
|
||||
vcw_layout->addWidget( new Oscilloscope( vc_w ) );
|
||||
|
||||
vcw_layout->addWidget( new CPULoadWidget( vc_w ) );
|
||||
vcw_layout->addStretch();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* VisualizationWidget.cpp - widget for visualization of sound-data
|
||||
* Oscilloscope.cpp
|
||||
*
|
||||
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
|
||||
#include "VisualizationWidget.h"
|
||||
#include "Oscilloscope.h"
|
||||
#include "GuiApplication.h"
|
||||
#include "gui_templates.h"
|
||||
#include "MainWindow.h"
|
||||
@@ -34,21 +34,20 @@
|
||||
#include "Engine.h"
|
||||
#include "ToolTip.h"
|
||||
#include "Song.h"
|
||||
|
||||
#include "embed.h"
|
||||
#include "BufferManager.h"
|
||||
|
||||
|
||||
VisualizationWidget::VisualizationWidget( const QPixmap & _bg, QWidget * _p,
|
||||
visualizationTypes _vtype ) :
|
||||
Oscilloscope::Oscilloscope( QWidget * _p ) :
|
||||
QWidget( _p ),
|
||||
s_background( _bg ),
|
||||
m_background( embed::getIconPixmap( "output_graph" ) ),
|
||||
m_points( new QPointF[Engine::mixer()->framesPerPeriod()] ),
|
||||
m_active( false ),
|
||||
m_normalColor(71, 253, 133),
|
||||
m_warningColor(255, 192, 64),
|
||||
m_clippingColor(255, 64, 64)
|
||||
{
|
||||
setFixedSize( s_background.width(), s_background.height() );
|
||||
setFixedSize( m_background.width(), m_background.height() );
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, true );
|
||||
setActive( ConfigManager::inst()->value( "ui", "displaywaveform").toInt() );
|
||||
|
||||
@@ -64,7 +63,7 @@ VisualizationWidget::VisualizationWidget( const QPixmap & _bg, QWidget * _p,
|
||||
|
||||
|
||||
|
||||
VisualizationWidget::~VisualizationWidget()
|
||||
Oscilloscope::~Oscilloscope()
|
||||
{
|
||||
delete[] m_buffer;
|
||||
delete[] m_points;
|
||||
@@ -73,7 +72,7 @@ VisualizationWidget::~VisualizationWidget()
|
||||
|
||||
|
||||
|
||||
void VisualizationWidget::updateAudioBuffer( const surroundSampleFrame * buffer )
|
||||
void Oscilloscope::updateAudioBuffer( const surroundSampleFrame * buffer )
|
||||
{
|
||||
if( !Engine::getSong()->isExporting() )
|
||||
{
|
||||
@@ -85,7 +84,7 @@ void VisualizationWidget::updateAudioBuffer( const surroundSampleFrame * buffer
|
||||
|
||||
|
||||
|
||||
void VisualizationWidget::setActive( bool _active )
|
||||
void Oscilloscope::setActive( bool _active )
|
||||
{
|
||||
m_active = _active;
|
||||
if( m_active )
|
||||
@@ -112,42 +111,42 @@ void VisualizationWidget::setActive( bool _active )
|
||||
}
|
||||
|
||||
|
||||
QColor const & VisualizationWidget::normalColor() const
|
||||
QColor const & Oscilloscope::normalColor() const
|
||||
{
|
||||
return m_normalColor;
|
||||
}
|
||||
|
||||
void VisualizationWidget::setNormalColor(QColor const & normalColor)
|
||||
void Oscilloscope::setNormalColor(QColor const & normalColor)
|
||||
{
|
||||
m_normalColor = normalColor;
|
||||
}
|
||||
|
||||
QColor const & VisualizationWidget::warningColor() const
|
||||
QColor const & Oscilloscope::warningColor() const
|
||||
{
|
||||
return m_warningColor;
|
||||
}
|
||||
|
||||
void VisualizationWidget::setWarningColor(QColor const & warningColor)
|
||||
void Oscilloscope::setWarningColor(QColor const & warningColor)
|
||||
{
|
||||
m_warningColor = warningColor;
|
||||
}
|
||||
|
||||
QColor const & VisualizationWidget::clippingColor() const
|
||||
QColor const & Oscilloscope::clippingColor() const
|
||||
{
|
||||
return m_clippingColor;
|
||||
}
|
||||
|
||||
void VisualizationWidget::setClippingColor(QColor const & clippingColor)
|
||||
void Oscilloscope::setClippingColor(QColor const & clippingColor)
|
||||
{
|
||||
m_clippingColor = clippingColor;
|
||||
}
|
||||
|
||||
|
||||
void VisualizationWidget::paintEvent( QPaintEvent * )
|
||||
void Oscilloscope::paintEvent( QPaintEvent * )
|
||||
{
|
||||
QPainter p( this );
|
||||
|
||||
p.drawPixmap( 0, 0, s_background );
|
||||
p.drawPixmap( 0, 0, m_background );
|
||||
|
||||
if( m_active && !Engine::getSong()->isExporting() )
|
||||
{
|
||||
@@ -195,7 +194,7 @@ void VisualizationWidget::paintEvent( QPaintEvent * )
|
||||
|
||||
|
||||
|
||||
void VisualizationWidget::mousePressEvent( QMouseEvent * _me )
|
||||
void Oscilloscope::mousePressEvent( QMouseEvent * _me )
|
||||
{
|
||||
if( _me->button() == Qt::LeftButton )
|
||||
{
|
||||
@@ -204,7 +203,7 @@ void VisualizationWidget::mousePressEvent( QMouseEvent * _me )
|
||||
}
|
||||
|
||||
|
||||
QColor const & VisualizationWidget::determineLineColor(float level) const
|
||||
QColor const & Oscilloscope::determineLineColor(float level) const
|
||||
{
|
||||
if( level < 0.9f )
|
||||
{
|
||||
Reference in New Issue
Block a user