- use automation capabilities using helper knobs

- added context menu
- added save/load methods


git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@188 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Javier Serrano Polo
2006-07-02 21:34:49 +00:00
parent fa671c7d7e
commit 87e2cf6292
2 changed files with 139 additions and 4 deletions

View File

@@ -41,6 +41,7 @@
#endif
#include "knob.h"
#include "types.h"
#include "mixer.h"
#include "templates.h"
@@ -55,7 +56,8 @@ class surroundArea : public QWidget
{
Q_OBJECT
public:
surroundArea( QWidget * _parent = NULL );
surroundArea( QWidget * _parent, const QString & _name,
engine * _engine, track * _track );
virtual ~surroundArea();
volumeVector getVolumeVector( float _v_scale = 0.0f ) const;
inline const QPoint & value( void ) const
@@ -64,8 +66,14 @@ public:
}
void FASTCALL setValue( const QPoint & _p );
void FASTCALL saveSettings( QDomDocument & _doc, QDomElement & _this,
const QString & _name = "surpos" );
void FASTCALL loadSettings( const QDomElement & _this,
const QString & _name = "surpos" );
protected:
virtual void contextMenuEvent( QContextMenuEvent * _me );
virtual void paintEvent( QPaintEvent * _pe );
virtual void mousePressEvent( QMouseEvent * _me );
virtual void mouseMoveEvent( QMouseEvent * _me );
@@ -85,6 +93,14 @@ private:
static const QPoint s_defaultSpeakerPositions[SURROUND_CHANNELS];
static QPixmap * s_backgroundArtwork;
knob * m_position_x;
knob * m_position_y;
private slots:
void updatePositionX( void );
void updatePositionY( void );
} ;

View File

@@ -32,13 +32,17 @@
#include <QtGui/QApplication>
#include <QtGui/QCursor>
#include <QtGui/QLabel>
#include <QtGui/QMenu>
#include <QtGui/QMouseEvent>
#include <QtGui/QPainter>
#else
#include <qapplication.h>
#include <qlabel.h>
#include <qpainter.h>
#include <qpopupmenu.h>
#include <qcursor.h>
#include <qimage.h>
@@ -70,10 +74,30 @@ QPixmap * surroundArea::s_backgroundArtwork = NULL;
surroundArea::surroundArea( QWidget * _parent ) :
QWidget( _parent ),
surroundArea::surroundArea( QWidget * _parent, const QString & _name,
engine * _engine, track * _track ) :
QWidget( _parent
#ifndef QT4
, _name.ascii()
#endif
),
m_sndSrcPos( QPoint() )
{
m_position_x = new knob( knobDark_28, NULL, tr ( "Surround area X" ),
_engine, _track );
m_position_x->setRange( -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, 1.0f );
m_position_x->setInitValue( 0.0f );
m_position_y = new knob( knobDark_28, NULL, tr ( "Surround area Y" ),
_engine, _track );
m_position_y->setRange( -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE, 1.0f );
m_position_y->setInitValue( 0.0f );
connect( m_position_x, SIGNAL( valueChanged( float ) ), this,
SLOT( updatePositionX( void ) ) );
connect( m_position_y, SIGNAL( valueChanged( float ) ), this,
SLOT( updatePositionY( void ) ) );
if( s_backgroundArtwork == NULL )
{
s_backgroundArtwork = new QPixmap( embed::getIconPixmap(
@@ -82,7 +106,9 @@ surroundArea::surroundArea( QWidget * _parent ) :
setFixedSize( s_backgroundArtwork->width(),
s_backgroundArtwork->height() );
#ifndef QT4
#ifdef QT4
setAccessibleName( _name );
#else
setBackgroundMode( Qt::NoBackground );
#endif
toolTip::add( this,
@@ -94,6 +120,8 @@ surroundArea::surroundArea( QWidget * _parent ) :
surroundArea::~surroundArea()
{
delete m_position_x;
delete m_position_y;
}
@@ -146,6 +174,39 @@ FASTCALL float surroundArea::getVolume( const QPoint & _speaker_pos,
void surroundArea::contextMenuEvent( QContextMenuEvent * )
{
// for the case, the user clicked right while pressing left mouse-
// button, the context-menu appears while mouse-cursor is still hidden
// and it isn't shown again until user does something which causes
// an QApplication::restoreOverrideCursor()-call...
mouseReleaseEvent( NULL );
QMenu contextMenu( this );
#ifdef QT4
contextMenu.setTitle( accessibleName() );
#else
QLabel * caption = new QLabel( "<font color=white><b>" +
QString( accessibleName() ) + "</b></font>", this );
caption->setPaletteBackgroundColor( QColor( 0, 0, 192 ) );
caption->setAlignment( Qt::AlignCenter );
contextMenu.addAction( caption );
#endif
//TODO: Change icon
contextMenu.addAction( embed::getIconPixmap( "piano" ),
tr( "Open &X in automation editor" ),
m_position_x->getAutomationPattern(),
SLOT( openInAutomationEditor() ) );
contextMenu.addAction( embed::getIconPixmap( "piano" ),
tr( "Open &Y in automation editor" ),
m_position_y->getAutomationPattern(),
SLOT( openInAutomationEditor() ) );
contextMenu.exec( QCursor::pos() );
}
void surroundArea::paintEvent( QPaintEvent * )
{
#ifdef QT4
@@ -197,6 +258,11 @@ void surroundArea::paintEvent( QPaintEvent * )
void surroundArea::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::RightButton )
{
return;
}
const int w = width();//s_backgroundArtwork->width();
const int h = height();//s_backgroundArtwork->height();
if( _me->x() > 1 && _me->x() < w-1 && _me->y() > 1 && _me->y() < h-1 )
@@ -218,6 +284,9 @@ void surroundArea::mousePressEvent( QMouseEvent * _me )
QCursor::setPos( mapToGlobal( QPoint( x, y ) ) );
}
m_position_x->setValue( m_sndSrcPos.x() );
m_position_y->setValue( m_sndSrcPos.y() );
emit valueChanged( m_sndSrcPos );
}
@@ -240,6 +309,56 @@ void surroundArea::mouseReleaseEvent( QMouseEvent * )
void surroundArea::updatePositionX( void )
{
m_sndSrcPos.setX( (int)m_position_x->value() );
update();
}
void surroundArea::updatePositionY( void )
{
m_sndSrcPos.setY( (int)m_position_y->value() );
update();
}
void FASTCALL surroundArea::saveSettings( QDomDocument & _doc,
QDomElement & _this,
const QString & _name )
{
m_position_x->saveSettings( _doc, _this, _name + "-x" );
m_position_y->saveSettings( _doc, _this, _name + "-y" );
}
void FASTCALL surroundArea::loadSettings( const QDomElement & _this,
const QString & _name )
{
if( _this.hasAttribute( _name ) )
{
int i = _this.attribute( _name ).toInt();
setValue( QPoint( ( i & 0xFFFF ) - 2 * SURROUND_AREA_SIZE,
( i >> 16 ) - 2 * SURROUND_AREA_SIZE) );
m_position_x->setValue( m_sndSrcPos.x() );
m_position_y->setValue( m_sndSrcPos.y() );
}
else
{
m_position_x->loadSettings( _this, _name + "-x" );
m_position_y->loadSettings( _this, _name + "-y" );
}
}
#include "surround_area.moc"