lot of bugfixes, UI-improvements and more

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@56 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-01-23 09:25:49 +00:00
parent 7e6538d9b3
commit b762ad706f
101 changed files with 1789 additions and 536 deletions

View File

@@ -31,19 +31,14 @@
#include <Qt/QtXml>
#include <QButtonGroup>
#include <QLabel>
#include <QComboBox>
#else
#include <qbuttongroup.h>
#include <qdom.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qwhatsthis.h>
#define setCurrentIndex setCurrentItem
#define currentIndex currentItem
#endif
@@ -65,6 +60,7 @@
#include "channel_track.h"
#include "led_checkbox.h"
#include "preset_preview_play_handle.h"
#include "combobox.h"
@@ -197,7 +193,7 @@ const int CHORDS_GROUPBOX_HEIGHT = 65;
const int ARP_GROUPBOX_X = CHORDS_GROUPBOX_X;
const int ARP_GROUPBOX_Y = 10 + CHORDS_GROUPBOX_Y + CHORDS_GROUPBOX_HEIGHT;
const int ARP_GROUPBOX_WIDTH = CHORDS_GROUPBOX_WIDTH;
const int ARP_GROUPBOX_HEIGHT = 200 - ARP_GROUPBOX_Y;
const int ARP_GROUPBOX_HEIGHT = 240 - ARP_GROUPBOX_Y;
@@ -211,7 +207,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
CHORDS_GROUPBOX_WIDTH,
CHORDS_GROUPBOX_HEIGHT );
m_chordsComboBox = new QComboBox( m_chordsGroupBox );
m_chordsComboBox = new comboBox( m_chordsGroupBox );
m_chordsComboBox->setFont( pointSize<8>( m_chordsComboBox->font() ) );
m_chordsComboBox->setGeometry( 10, 25, 140, 22 );
@@ -262,7 +258,7 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
"not played at the same time. Typical arpeggios are "
"major or minor triads. But there're a lot of other "
"possible chords, you can select." ) );
m_arpComboBox = new QComboBox( m_arpGroupBox );
m_arpComboBox = new comboBox( m_arpGroupBox );
m_arpComboBox->setFont( pointSize<8>( m_arpComboBox->font() ) );
m_arpComboBox->setGeometry( 10, 25, 140, 22 );
@@ -334,15 +330,11 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
m_arpUpBtn = new pixmapButton( m_arpGroupBox );
m_arpUpBtn->move( 70, 60 );
m_arpUpBtn->move( 10, 74 );
m_arpUpBtn->setActiveGraphic( embed::getIconPixmap( "arp_up_on" ) );
m_arpUpBtn->setInactiveGraphic( embed::getIconPixmap( "arp_up_off" ) );
#ifdef QT4
m_arpUpBtn->setChecked( TRUE );
#else
m_arpUpBtn->setOn( TRUE );
#endif
#ifndef QT4
#ifdef QT3
m_arpUpBtn->setBackgroundMode( Qt::PaletteBackground );
#endif
toolTip::add( m_arpUpBtn, tr( "arpeggio direction = up" ) );
@@ -350,11 +342,11 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
SLOT( arpUpToggled( bool ) ) );
m_arpDownBtn = new pixmapButton( m_arpGroupBox );
m_arpDownBtn->move( 90, 60 );
m_arpDownBtn->move( 30, 74 );
m_arpDownBtn->setActiveGraphic( embed::getIconPixmap( "arp_down_on" ) );
m_arpDownBtn->setInactiveGraphic( embed::getIconPixmap(
"arp_down_off" ) );
#ifndef QT4
#ifdef QT3
m_arpDownBtn->setBackgroundMode( Qt::PaletteBackground );
#endif
toolTip::add( m_arpDownBtn, tr( "arpeggio direction = down" ) );
@@ -362,12 +354,12 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
SLOT( arpDownToggled( bool ) ) );
m_arpUpAndDownBtn = new pixmapButton( m_arpGroupBox );
m_arpUpAndDownBtn->move( 110, 60 );
m_arpUpAndDownBtn->move( 50, 74 );
m_arpUpAndDownBtn->setActiveGraphic( embed::getIconPixmap(
"arp_up_and_down_on" ) );
m_arpUpAndDownBtn->setInactiveGraphic( embed::getIconPixmap(
"arp_up_and_down_off" ) );
#ifndef QT4
#ifdef QT3
m_arpUpAndDownBtn->setBackgroundMode( Qt::PaletteBackground );
#endif
toolTip::add( m_arpUpAndDownBtn,
@@ -376,12 +368,12 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
SLOT( arpUpAndDownToggled( bool ) ) );
m_arpRandomBtn = new pixmapButton( m_arpGroupBox );
m_arpRandomBtn->move( 130, 60 );
m_arpRandomBtn->move( 70, 74 );
m_arpRandomBtn->setActiveGraphic( embed::getIconPixmap(
"arp_random_on" ) );
m_arpRandomBtn->setInactiveGraphic( embed::getIconPixmap(
"arp_random_off" ) );
#ifndef QT4
#ifdef QT3
m_arpRandomBtn->setBackgroundMode( Qt::PaletteBackground );
#endif
toolTip::add( m_arpRandomBtn, tr( "arpeggio direction = random" ) );
@@ -394,25 +386,25 @@ arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
m_arpDirections_group->addButton( m_arpUpAndDownBtn );
m_arpDirections_group->addButton( m_arpRandomBtn );
m_arpDirections_group->setExclusive( TRUE );
#ifndef QT4
#ifdef QT3
m_arpDirections_group->hide();
#endif
/* m_sortMode = new ledCheckBox( tr( "Sort-mode" ), m_arpGroupBox );
m_sortMode->move( 10, 90 );*/
QLabel * mode_lbl = new QLabel( tr( "Mode:" ), m_arpGroupBox );
mode_lbl->setGeometry( 10, 90, 64, 10 );
mode_lbl->setGeometry( 10, 104, 64, 10 );
mode_lbl->setFont( pointSize<7>( mode_lbl->font() ) );
m_arpModeComboBox = new QComboBox( m_arpGroupBox );
m_arpModeComboBox = new comboBox( m_arpGroupBox );
m_arpModeComboBox->setFont( pointSize<8>( m_arpModeComboBox->font() ) );
m_arpModeComboBox->setGeometry( 70, 87, 80, 22 );
m_arpModeComboBox->setGeometry( 10, 118, 128, 22 );
m_arpModeComboBox->addItem( tr( "Free" ) );
m_arpModeComboBox->addItem( tr( "Sort" ) );
m_arpModeComboBox->addItem( tr( "Sync" ) );
m_arpModeComboBox->setCurrentItem( 0 );
m_arpModeComboBox->addItem( tr( "Free" ),
embed::getIconPixmap( "arp_free" ) );
m_arpModeComboBox->addItem( tr( "Sort" ),
embed::getIconPixmap( "arp_sort" ) );
m_arpModeComboBox->addItem( tr( "Sync" ),
embed::getIconPixmap( "arp_sync" ) );
m_arpModeComboBox->setCurrentIndex( 0 );
}
@@ -771,9 +763,5 @@ void arpAndChordsTabWidget::arpRandomToggled( bool _on )
#undef setChecked
#undef currentIndex
#undef setCurrentIndex
#include "arp_and_chords_tab_widget.moc"

View File

@@ -1,7 +1,7 @@
/*
* bb_editor.cpp - basic main-window for editing of beats and basslines
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -50,6 +50,7 @@
#include "templates.h"
#include "debug.h"
#include "tooltip.h"
#include "combobox.h"
@@ -85,7 +86,8 @@ bbEditor::bbEditor() :
setWindowIcon( embed::getIconPixmap( "bb_track" ) );
setWindowTitle( tr( "Beat+Bassline Editor" ) );
setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH +
BBE_PPT + 2 * TCO_BORDER_WIDTH );
BBE_PPT + 2 * TCO_BORDER_WIDTH +
DEFAULT_SCROLLBAR_SIZE );
if( lmmsMainWin::inst()->workspace() != NULL )
{
setGeometry( 10, 340, minimumWidth(), 300 );
@@ -127,9 +129,16 @@ bbEditor::bbEditor() :
QLabel * l = new QLabel( m_toolBar );
l->setPixmap( embed::getIconPixmap( "drum" ) );
m_bbComboBox = new comboBox( m_toolBar );
m_bbComboBox->setFixedSize( 200, 22 );
connect( m_bbComboBox, SIGNAL( currentIndexChanged( int ) ),
this, SLOT( setCurrentBB( int ) ) );
tb_layout->addSpacing( 5 );
tb_layout->addWidget( m_playButton );
tb_layout->addWidget( m_stopButton );
tb_layout->addSpacing( 20 );
tb_layout->addWidget( m_bbComboBox );
tb_layout->addStretch();
tb_layout->addWidget( l );
tb_layout->addSpacing( 15 );
@@ -155,10 +164,15 @@ csize bbEditor::currentBB( void ) const
void bbEditor::setCurrentBB( csize _bb )
void bbEditor::setCurrentBB( int _bb )
{
if( m_bbComboBox->currentIndex() != _bb )
{
m_bbComboBox->setCurrentIndex( _bb );
}
// first make sure, all channels have a TCO at current BB
createTCOsForBB( _bb );
createTCOsForBB( static_cast<csize>( _bb ) );
realignTracks();
@@ -169,7 +183,8 @@ void bbEditor::setCurrentBB( csize _bb )
bbTrack::findBBTrack( i )->trackLabel()->update();
}
emit positionChanged( m_currentPosition = midiTime( _bb, 0 ) );
emit positionChanged( m_currentPosition = midiTime(
static_cast<csize>( _bb ), 0 ) );
}
@@ -270,6 +285,22 @@ void bbEditor::updateBBTrack( trackContentObject * _tco )
void bbEditor::updateComboBox( void )
{
m_bbComboBox->clear();
for( csize i = 0; i < numOfBBs(); ++i )
{
bbTrack * bbt = bbTrack::findBBTrack( i );
m_bbComboBox->addItem( bbt->trackLabel()->text(),
bbt->trackLabel()->pixmap() );
}
m_bbComboBox->setCurrentIndex( currentBB() );
}
// close-handler for bb-editor-window because closing of bb-editor isn't allowed
// instead of closing it's being hidden
void bbEditor::closeEvent( QCloseEvent * _ce )
@@ -323,7 +354,8 @@ void bbEditor::resizeEvent( QResizeEvent * _re )
{
setPixelsPerTact( width() - ( TRACK_OP_WIDTH +
DEFAULT_SETTINGS_WIDGET_WIDTH + 2 *
TCO_BORDER_WIDTH ) );
TCO_BORDER_WIDTH +
DEFAULT_SCROLLBAR_SIZE ) );
trackContainer::resizeEvent( _re );
m_toolBar->setFixedWidth( width() );
}
@@ -331,6 +363,15 @@ void bbEditor::resizeEvent( QResizeEvent * _re )
QRect bbEditor::scrollAreaRect( void ) const
{
return( QRect( 0, 0, (int) pixelsPerTact(),
height() - m_toolBar->height() ) );
}
void bbEditor::play( void )
{
if( songEditor::inst()->playing() )
@@ -431,6 +472,7 @@ void bbEditor::swapBB( csize _bb1, csize _bb2 )
{
( *it )->swapPositionOfTCOs( _bb1, _bb2 );
}
updateComboBox();
}

View File

@@ -2,7 +2,7 @@
* envelope_tab_widget.cpp - widget for use in envelope/lfo/filter-tab of
* channel-window
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -28,19 +28,14 @@
#ifdef QT4
#include <QComboBox>
#include <Qt/QtXml>
#include <QWhatsThis>
#else
#include <qcombobox.h>
#include <qdom.h>
#include <qwhatsthis.h>
#define isChecked isOn
#define setChecked setOn
#endif
@@ -54,6 +49,7 @@
#include "embed.h"
#include "gui_templates.h"
#include "channel_track.h"
#include "combobox.h"
@@ -142,19 +138,27 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
FILTER_GROUPBOX_WIDTH,
FILTER_GROUPBOX_HEIGHT );
m_filterComboBox = new QComboBox( m_filterGroupBox );
m_filterComboBox->setGeometry( 20, 20, 100, 22 );
m_filterComboBox = new comboBox( m_filterGroupBox );
m_filterComboBox->setGeometry( 14, 22, 120, 22 );
m_filterComboBox->setFont( pointSize<8>( m_filterComboBox->font() ) );
m_filterComboBox->addItem( tr( "LowPass" ) );
m_filterComboBox->addItem( tr( "HiPass" ) );
m_filterComboBox->addItem( tr( "BandPass csg" ) );
m_filterComboBox->addItem( tr( "BandPass czpg" ) );
m_filterComboBox->addItem( tr( "Notch" ) );
m_filterComboBox->addItem( tr( "Allpass" ) );
m_filterComboBox->addItem( tr( "Moog" ) );
m_filterComboBox->addItem( tr( "2x LowPass" ) );
m_filterComboBox->addItem( tr( "LowPass" ),
embed::getIconPixmap( "filter_lp" ) );
m_filterComboBox->addItem( tr( "HiPass" ),
embed::getIconPixmap( "filter_hp" ) );
m_filterComboBox->addItem( tr( "BandPass csg" ),
embed::getIconPixmap( "filter_bp" ) );
m_filterComboBox->addItem( tr( "BandPass czpg" ),
embed::getIconPixmap( "filter_bp" ) );
m_filterComboBox->addItem( tr( "Notch" ),
embed::getIconPixmap( "filter_notch" ) );
m_filterComboBox->addItem( tr( "Allpass" ),
embed::getIconPixmap( "filter_ap" ) );
m_filterComboBox->addItem( tr( "Moog" ),
embed::getIconPixmap( "filter_lp" ) );
m_filterComboBox->addItem( tr( "2x LowPass" ),
embed::getIconPixmap( "filter_2lp" ) );
#ifdef QT4
m_filterComboBox->setWhatsThis(
@@ -264,18 +268,14 @@ void envelopeTabWidget::processAudioBuffer( sampleFrame * _ab, Uint32 _frames,
mixer::inst()->sampleRate() );
}
if( /*m_filterState->isChecked()*/ m_filterGroupBox->isActive() )
if( m_filterGroupBox->isActive() )
{
int old_filter_cut = 0;
int old_filter_res = 0;
basicFilters<>::filterTypes filter = basicFilters<>::getFilterType( m_filterComboBox->
#ifdef QT4
currentIndex()
#else
currentItem()
#endif
);
basicFilters<>::filterTypes filter =
basicFilters<>::getFilterType(
m_filterComboBox->currentIndex() );
if( m_envLFOWidgets[VOLUME]->used() &&
m_envLFOWidgets[CUT]->used() &&
@@ -492,11 +492,7 @@ void envelopeTabWidget::saveSettings( QDomDocument & _doc,
QDomElement & _parent )
{
QDomElement etw_de = _doc.createElement( nodeName() );
#ifdef QT4
etw_de.setAttribute( "ftype", m_filterComboBox->currentIndex() );
#else
etw_de.setAttribute( "ftype", m_filterComboBox->currentItem() );
#endif
etw_de.setAttribute( "fcut", m_filterCutKnob->value() );
etw_de.setAttribute( "fres", m_filterResKnob->value() );
etw_de.setAttribute( "fwet", m_filterGroupBox->isActive() );
@@ -518,11 +514,7 @@ void envelopeTabWidget::saveSettings( QDomDocument & _doc,
void envelopeTabWidget::loadSettings( const QDomElement & _this )
{
#ifdef QT4
m_filterComboBox->setCurrentIndex( _this.attribute( "ftype" ).toInt() );
#else
m_filterComboBox->setCurrentItem( _this.attribute( "ftype" ).toInt() );
#endif
m_filterCutKnob->setValue( _this.attribute( "fcut" ).toFloat() );
m_filterResKnob->setValue( _this.attribute( "fres" ).toFloat() );
/* m_filterState->setChecked( _this.attribute( "fwet" ).toInt() );*/
@@ -550,9 +542,6 @@ void envelopeTabWidget::loadSettings( const QDomElement & _this )
#undef isChecked
#undef setChecked
#include "envelope_tab_widget.moc"

View File

@@ -1,7 +1,7 @@
/*
* export_project_dialog.cpp - implementation of dialog for exporting project
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -30,8 +30,6 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QProgressBar>
#include <QComboBox>
#include <QCheckBox>
#include <QLabel>
#include <QPushButton>
#include <QCloseEvent>
@@ -42,8 +40,6 @@
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qprogressbar.h>
#include <qcombobox.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qapplication.h>
@@ -54,6 +50,8 @@
#include "export_project_dialog.h"
#include "song_editor.h"
#include "lmms_main_win.h"
#include "combobox.h"
#include "led_checkbox.h"
#include "embed.h"
#include "audio_file_wave.h"
@@ -87,7 +85,7 @@ const int LABEL_MARGIN = 6;
const int LABEL_X = 10;
const int LABEL_WIDTH = 48;
const int TYPE_STUFF_Y = 10;
const int TYPE_HEIGHT = 26;
const int TYPE_HEIGHT = 22;
const int TYPE_COMBO_WIDTH = 256;
const int KBPS_STUFF_Y = TYPE_STUFF_Y + TYPE_HEIGHT + LABEL_MARGIN + 6;
const int KBPS_HEIGHT = TYPE_HEIGHT;
@@ -151,7 +149,7 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name,
m_typeLbl->setGeometry( LABEL_X, TYPE_STUFF_Y, LABEL_WIDTH,
TYPE_HEIGHT );
m_typeCombo = new QComboBox( this );
m_typeCombo = new comboBox( this );
m_typeCombo->setGeometry( LABEL_X + LABEL_WIDTH+LABEL_MARGIN,
TYPE_STUFF_Y, TYPE_COMBO_WIDTH,
TYPE_HEIGHT );
@@ -165,13 +163,8 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name,
tr( fileEncodeDevices[idx].m_description ) );
++idx;
}
#ifdef QT4
m_typeCombo->setCurrentIndex( m_typeCombo->findText( tr(
fileEncodeDevices[m_fileType].m_description ) ) );
#else
m_typeCombo->setCurrentText( tr(
fileEncodeDevices[m_fileType].m_description ) );
#endif
// kbps-ui-stuff
@@ -179,7 +172,7 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name,
m_kbpsLbl->setGeometry( LABEL_X, KBPS_STUFF_Y, LABEL_WIDTH,
KBPS_HEIGHT );
m_kbpsCombo = new QComboBox( this );
m_kbpsCombo = new comboBox( this );
m_kbpsCombo->setGeometry( LABEL_X + LABEL_WIDTH + LABEL_MARGIN,
KBPS_STUFF_Y, KBPS_COMBO_WIDTH,
KBPS_HEIGHT );
@@ -191,21 +184,17 @@ exportProjectDialog::exportProjectDialog( const QString & _file_name,
s_availableBitrates[idx] ) );
++idx;
}
#ifdef QT4
m_typeCombo->setCurrentIndex( m_typeCombo->findText(
QString::number( 128 ) ) );
#else
m_kbpsCombo->setCurrentText( QString::number( 128 ) );
#endif
m_vbrCb = new QCheckBox( tr( "variable bitrate" ), this );
m_vbrCb = new ledCheckBox( tr( "variable bitrate" ), this );
m_vbrCb->setGeometry( LABEL_X + LABEL_WIDTH + 3 * LABEL_MARGIN +
KBPS_COMBO_WIDTH, KBPS_STUFF_Y + 3, 190, 20 );
m_vbrCb->setChecked( TRUE );
m_hqmCb = new QCheckBox( tr( "use high-quality-mode (recommened)" ),
m_hqmCb = new ledCheckBox( tr( "use high-quality-mode (recommened)" ),
this );
m_hqmCb->setGeometry( LABEL_X, HQ_MODE_CB_Y + 3, HQ_MODE_CB_WIDTH,
HQ_MODE_CB_HEIGHT );
@@ -278,13 +267,17 @@ void exportProjectDialog::keyPressEvent( QKeyEvent * _ke )
void exportProjectDialog::closeEvent (QCloseEvent * _ce)
void exportProjectDialog::closeEvent( QCloseEvent * _ce )
{
if( songEditor::inst()->exporting() == TRUE )
{
abortProjectExport();
_ce->ignore();
}
else
{
QDialog::closeEvent( _ce );
}
}
@@ -426,6 +419,7 @@ void exportProjectDialog::cancelBtnClicked( void )
abortProjectExport();
return;
}
reject();
}

View File

@@ -2,7 +2,7 @@
* name_label.cpp - implementation of class nameLabel, a label which
* is renamable by double-clicking it
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -30,10 +30,13 @@
#include <QPainter>
#include <QMouseEvent>
#include <QFileDialog>
#else
#include <qpainter.h>
#include <qfiledialog.h>
#include <qimage.h>
#endif
@@ -43,13 +46,14 @@
#include "bb_editor.h"
#include "bb_track.h"
#include "gui_templates.h"
#include "config_mgr.h"
nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent,
const QPixmap & _pm ) :
nameLabel::nameLabel( const QString & _initial_name, QWidget * _parent ) :
QLabel( _initial_name, _parent ),
m_pm( _pm )
m_pixmap(),
m_pixmapFile( "" )
{
#ifdef QT3
setBackgroundMode( Qt::NoBackground );
@@ -65,17 +69,99 @@ nameLabel::~nameLabel()
const QPixmap * nameLabel::pixmap( void ) const
void nameLabel::setPixmap( const QPixmap & _pixmap )
{
return( &m_pm );
m_pixmap = _pixmap;
}
void nameLabel::setPixmap( const QPixmap & _pm )
void nameLabel::setPixmapFile( const QString & _file )
{
m_pm = _pm;
m_pixmapFile = _file;
if( QFileInfo( m_pixmapFile ).isRelative() )
{
m_pixmap = QPixmap( configManager::inst()->trackIconsDir() +
m_pixmapFile );
}
else
{
m_pixmap = QPixmap( m_pixmapFile );
}
emit( pixmapChanged() );
update();
}
void nameLabel::selectPixmap( void )
{
#ifdef QT4
QFileDialog ofd( NULL, tr( "Select icon" ) );
#else
QFileDialog ofd( QString::null, QString::null, NULL, "", TRUE );
ofd.setWindowTitle( tr( "Select icon" ) );
#endif
QString dir;
if( m_pixmapFile != "" )
{
QString f = m_pixmapFile;
if( QFileInfo( f ).isRelative() )
{
f = configManager::inst()->trackIconsDir() + f;
}
#ifdef QT4
dir = QFileInfo( f ).absolutePath();
#else
dir = QFileInfo( f ).dirPath( TRUE );
#endif
}
else
{
dir = configManager::inst()->trackIconsDir();
}
// change dir to position of previously opened file
ofd.setDirectory( dir );
ofd.setFileMode( QFileDialog::ExistingFiles );
// set filters
#ifdef QT4
QStringList types;
types << tr( "All images (*.png *.jpg *.jpeg *.gif *.bmp)" );
ofd.setFilters( types );
#else
ofd.addFilter( tr( "All images (*.png *.jpg *.jpeg *.gif *.bmp)" ) );
ofd.setSelectedFilter( tr( "All images (*.png *.jpg *.jpeg *.gif "
"*.bmp)" ) );
#endif
if( m_pixmapFile != "" )
{
// select previously opened file
ofd.selectFile( QFileInfo( m_pixmapFile ).fileName() );
}
if ( ofd.exec () == QDialog::Accepted )
{
if( ofd.selectedFiles().isEmpty() )
{
return;
}
QString pf = ofd.selectedFiles()[0];
if( !QFileInfo( pf ).isRelative() )
{
#if QT_VERSION >= 0x030100
pf = pf.replace( configManager::inst()->trackIconsDir(),
"" );
#else
pf = pf.replace( QRegExp(
configManager::inst()->trackIconsDir() ), "" );
#endif
}
setPixmapFile( pf );
}
}
@@ -90,53 +176,28 @@ void nameLabel::rename( void )
{
setText( txt );
emit nameChanged( txt );
emit nameChanged();
}
}
void nameLabel::paintEvent( QPaintEvent * )
{
#ifdef QT4
QPainter p( this );
p.fillRect( rect(), palette().color( backgroundRole() ) );
#else
QPixmap draw_pm( rect().size() );
draw_pm.fill( this, rect().topLeft() );
QPainter p( &draw_pm, this );
#endif
p.setFont( pointSize<8>( p.font() ) );
QFontMetrics fm( font() );
p.drawPixmap( 4, ( height() - m_pm.height() ) / 2, m_pm );
p.setPen( QColor( 0, 224, 0 ) );
bbTrack * bbt = bbTrack::findBBTrack( bbEditor::inst()->currentBB() );
if( bbt != NULL && bbt->getTrackSettingsWidget() ==
dynamic_cast<trackSettingsWidget *>( parentWidget() ) )
{
p.setPen( QColor( 255, 255, 255 ) );
}
p.drawText( m_pm.width() + 8, height() / 2 + fm.height() / 2 - 4,
text() );
#ifndef QT4
// and blit all the drawn stuff on the screen...
bitBlt( this, rect().topLeft(), &draw_pm );
#endif
}
void nameLabel::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::RightButton )
{
rename();
QSize s( m_pixmap.width(), m_pixmap.height() );
s.scale( width(), height(), QSize::ScaleMin );
if( _me->x() > 4 + s.width() )
{
rename();
}
else
{
selectPixmap();
}
}
else
{
@@ -150,7 +211,67 @@ void nameLabel::mousePressEvent( QMouseEvent * _me )
void nameLabel::mouseDoubleClickEvent( QMouseEvent * _me )
{
rename();
QSize s( m_pixmap.width(), m_pixmap.height() );
s.scale( width(), height(), QSize::ScaleMin );
if( _me->x() > 4 + s.width() )
{
rename();
}
else
{
selectPixmap();
}
}
void nameLabel::paintEvent( QPaintEvent * )
{
#ifdef QT4
QPainter p( this );
p.fillRect( rect(), palette().color( backgroundRole() ) );
#else
QPixmap draw_pm( size() );
draw_pm.fill( this, rect().topLeft() );
QPainter p( &draw_pm, this );
#endif
p.setFont( pointSize<8>( p.font() ) );
int x = 4;
if( m_pixmap.isNull() == FALSE )
{
QPixmap pm = m_pixmap;
if( pm.height() > height() )
{
#ifndef QT3
pm = pm.scaledToHeight( height(),
Qt::SmoothTransformation );
#else
pm.convertFromImage( pm.convertToImage().smoothScale(
pm.width(), height(),
QImage::ScaleMin ) );
#endif
}
p.drawPixmap( x, ( height() - pm.height() ) / 2, pm );
x += 4 + pm.width();
}
p.setPen( QColor( 0, 224, 0 ) );
bbTrack * bbt = bbTrack::findBBTrack( bbEditor::inst()->currentBB() );
if( bbt != NULL && bbt->getTrackSettingsWidget() ==
dynamic_cast<trackSettingsWidget *>( parentWidget() ) )
{
p.setPen( QColor( 255, 255, 255 ) );
}
p.drawText( x, height() / 2 + p.fontMetrics().height() / 2 - 4,
text() );
#ifndef QT4
// and blit all the drawn stuff on the screen...
bitBlt( this, rect().topLeft(), &draw_pm );
#endif
}

View File

@@ -33,7 +33,6 @@
#include <QPainter>
#include <QKeyEvent>
#include <QWheelEvent>
#include <QComboBox>
#include <QLayout>
#include <QLabel>
@@ -42,12 +41,9 @@
#include <qapplication.h>
#include <qbuttongroup.h>
#include <qpainter.h>
#include <qcombobox.h>
#include <qlayout.h>
#include <qlabel.h>
#define setChecked setOn
#endif
@@ -72,6 +68,8 @@
#include "midi.h"
#include "tool_button.h"
#include "text_float.h"
#include "combobox.h"
extern tones whiteKeys[]; // defined in piano_widget.cpp
@@ -167,22 +165,22 @@ pianoRoll::pianoRoll( void ) :
if( s_toolDraw == NULL )
{
s_toolDraw = new QPixmap( embed::getIconPixmap(
"pr_tool_draw" ) );
"edit_draw" ) );
}
if( s_toolErase == NULL )
{
s_toolErase= new QPixmap( embed::getIconPixmap(
"pr_tool_erase" ) );
"edit_erase" ) );
}
if( s_toolSelect == NULL )
{
s_toolSelect = new QPixmap( embed::getIconPixmap(
"pr_tool_select" ) );
"edit_select" ) );
}
if( s_toolMove == NULL )
{
s_toolMove = new QPixmap( embed::getIconPixmap(
"pr_tool_move" ) );
"edit_move" ) );
}
#ifdef QT4
@@ -272,27 +270,27 @@ pianoRoll::pianoRoll( void ) :
SLOT( verScrolled( int ) ) );
// init edit-buttons at the top
m_drawButton = new toolButton( embed::getIconPixmap( "pr_tool_draw" ),
m_drawButton = new toolButton( embed::getIconPixmap( "edit_draw" ),
tr( "Draw mode (D)" ),
this, SLOT( drawButtonToggled() ),
m_toolBar );
m_drawButton->setCheckable( TRUE );
m_drawButton->setChecked( TRUE );
m_eraseButton = new toolButton( embed::getIconPixmap( "pr_tool_erase" ),
m_eraseButton = new toolButton( embed::getIconPixmap( "edit_erase" ),
tr( "Erase mode (E)" ),
this, SLOT( eraseButtonToggled() ),
m_toolBar );
m_eraseButton->setCheckable( TRUE );
m_selectButton = new toolButton( embed::getIconPixmap(
"pr_tool_select" ),
"edit_select" ),
tr( "Select mode (S)" ),
this, SLOT( selectButtonToggled() ),
m_toolBar );
m_selectButton->setCheckable( TRUE );
m_moveButton = new toolButton( embed::getIconPixmap( "pr_tool_move" ),
m_moveButton = new toolButton( embed::getIconPixmap( "edit_move" ),
tr( "Move selection mode (M)" ),
this, SLOT( moveButtonToggled() ),
m_toolBar );
@@ -392,20 +390,17 @@ pianoRoll::pianoRoll( void ) :
zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) );
// setup zooming-stuff
m_zoomingComboBox = new QComboBox( m_toolBar );
m_zoomingComboBox->setGeometry( 580, 4, 80, 24 );
m_zoomingComboBox = new comboBox( m_toolBar );
m_zoomingComboBox->setFixedSize( 80, 22 );
m_zoomingComboBox->move( 580, 4 );
for( int i = 0; i < 6; ++i )
{
m_zoomingComboBox->addItem( QString::number( 25 *
static_cast<int>( powf( 2.0f, i ) ) ) +
"%" );
}
#ifdef QT4
m_zoomingComboBox->setCurrentIndex( m_zoomingComboBox->findText(
"100%" ) );
#else
m_zoomingComboBox->setCurrentText( "100%" );
#endif
connect( m_zoomingComboBox, SIGNAL( activated( const QString & ) ),
this, SLOT( zoomingChanged( const QString & ) ) );
@@ -573,10 +568,9 @@ inline void pianoRoll::drawNoteRect( QPainter & _p, Uint16 _x, Uint16 _y,
void pianoRoll::update( void )
{
if( m_paintPixmap.isNull() == TRUE ||
m_paintPixmap.size() != rect().size() )
if( m_paintPixmap.isNull() == TRUE || m_paintPixmap.size() != size() )
{
m_paintPixmap = QPixmap( rect().size() );
m_paintPixmap = QPixmap( size() );
}
m_paintPixmap.fill( QColor( 0, 0, 0 ) );
QPainter p( &m_paintPixmap );
@@ -755,7 +749,7 @@ void pianoRoll::update( void )
// draw vertical raster
int tact_16th = m_currentPosition / 4;
int offset = ( m_currentPosition % 4 ) * m_ppt /
const int offset = ( m_currentPosition % 4 ) * m_ppt /
DEFAULT_STEPS_PER_TACT / 4;
for( int x = WHITE_KEY_WIDTH - offset; x < width();
x += m_ppt / DEFAULT_STEPS_PER_TACT, ++tact_16th )
@@ -1964,18 +1958,11 @@ void pianoRoll::wheelEvent( QWheelEvent * _we )
{
m_ppt /= 2;
}
#ifdef QT4
// update combobox with zooming-factor
m_zoomingComboBox->setCurrentIndex(
m_zoomingComboBox->findText( QString::number(
static_cast<int>( m_ppt * 100 /
DEFAULT_PR_PPT ) ) +"%" ) );
#else
// update combobox with zooming-factor
m_zoomingComboBox->setCurrentText( QString::number(
static_cast<int>( m_ppt * 100 /
DEFAULT_PR_PPT ) ) +"%" );
#endif
// update timeline
m_timeLine->setPixelsPerTact( m_ppt );
update();
@@ -2446,8 +2433,6 @@ void pianoRoll::zoomingChanged( const QString & _zfac )
#undef setChecked
#include "piano_roll.moc"

View File

@@ -1,7 +1,7 @@
/*
* song_editor.cpp - basic window for editing song
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -45,8 +45,8 @@
#include <QLabel>
#include <QStatusBar>
#include <QAction>
#include <QComboBox>
#include <QLayout>
#include <QButtonGroup>
#else
@@ -59,8 +59,8 @@
#include <qslider.h>
#include <qlabel.h>
#include <qstatusbar.h>
#include <qcombobox.h>
#include <qlayout.h>
#include <qbuttongroup.h>
#endif
@@ -88,6 +88,7 @@
#include "tool_button.h"
#include "cpuload_widget.h"
#include "text_float.h"
#include "combobox.h"
#include "debug.h"
@@ -96,8 +97,6 @@
extern QString file_to_load;
const int SCROLLBAR_SIZE = 16;
songEditor * songEditor::s_instanceOfMe = NULL;
@@ -329,18 +328,28 @@ songEditor::songEditor() :
this, SLOT( addSampleTrack() ),
m_toolBar );
m_insertBarButton = new toolButton( embed::getIconPixmap(
"insert_bar" ),
tr( "Insert bar "
"(Shift+Insert)" ),
this, SLOT( insertBar() ),
m_toolBar );
m_drawModeButton = new toolButton( embed::getIconPixmap(
"edit_draw" ),
tr( "Draw mode" ),
NULL, NULL, m_toolBar );
m_drawModeButton->setCheckable( TRUE );
m_drawModeButton->setChecked( TRUE );
m_editModeButton = new toolButton( embed::getIconPixmap(
"edit_arrow" ),
tr( "Edit mode (select and move)" ),
NULL, NULL, m_toolBar );
m_editModeButton->setCheckable( TRUE );
QButtonGroup * tool_button_group = new QButtonGroup( this );
tool_button_group->addButton( m_drawModeButton );
tool_button_group->addButton( m_editModeButton );
tool_button_group->setExclusive( TRUE );
#ifndef QT4
tool_button_group->hide();
#endif
m_removeBarButton = new toolButton( embed::getIconPixmap(
"remove_bar" ),
tr( "Remove bar (Shift+Delete)" ),
this, SLOT( removeBar() ),
m_toolBar );
#ifdef QT4
#else
QWhatsThis::add( m_playButton, tr( "Click here, if you want to play "
@@ -354,13 +363,13 @@ songEditor::songEditor() :
"song-position-marker will be "
"set to the start of your song."
) );
QWhatsThis::add( m_insertBarButton, tr( "If you click here, a "
/* QWhatsThis::add( m_insertBarButton, tr( "If you click here, a "
"bar will "
"be inserted at the "
"current bar." ) );
QWhatsThis::add( m_removeBarButton, tr( "If you click here, the "
"current bar will be "
"removed." ) );
"removed." ) );*/
#endif
@@ -368,20 +377,17 @@ songEditor::songEditor() :
zoom_lbl->setPixmap( embed::getIconPixmap( "zoom" ) );
// setup zooming-stuff
m_zoomingComboBox = new QComboBox( m_toolBar );
m_zoomingComboBox->setGeometry( 580, 4, 80, 24 );
m_zoomingComboBox = new comboBox( m_toolBar );
m_zoomingComboBox->setFixedSize( 80, 22 );
m_zoomingComboBox->move( 580, 4 );
for( int i = 0; i < 7; ++i )
{
m_zoomingComboBox->addItem( QString::number( 25 *
static_cast<int>( powf( 2.0f, i ) ) ) +
"%" );
}
#ifdef QT4
m_zoomingComboBox->setCurrentIndex( m_zoomingComboBox->findText(
"100%" ) );
#else
m_zoomingComboBox->setCurrentText( "100%" );
#endif
connect( m_zoomingComboBox, SIGNAL( activated( const QString & ) ),
this, SLOT( zoomingChanged( const QString & ) ) );
@@ -393,8 +399,8 @@ songEditor::songEditor() :
tb_layout->addWidget( m_addBBTrackButton );
tb_layout->addWidget( m_addSampleTrackButton );
tb_layout->addSpacing( 10 );
tb_layout->addWidget( m_insertBarButton );
tb_layout->addWidget( m_removeBarButton );
tb_layout->addWidget( m_drawModeButton );
tb_layout->addWidget( m_editModeButton );
tb_layout->addSpacing( 10 );
tl->addToolButtons( m_toolBar );
tb_layout->addSpacing( 15 );
@@ -407,14 +413,14 @@ songEditor::songEditor() :
m_leftRightScroll = new QScrollBar( Qt::Horizontal, cw );
m_leftRightScroll->setMinimum( 0 );
m_leftRightScroll->setMaximum( 0 );
#ifdef QT4
#ifndef QT3
m_leftRightScroll->setSingleStep( 1 );
m_leftRightScroll->setPageStep( 20 );
#else
m_leftRightScroll->setSteps( 1, 20 );
#endif
connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this,
SLOT( scrolled( int ) ) );
connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ),
this, SLOT( scrolled( int ) ) );
@@ -472,17 +478,31 @@ void songEditor::paintEvent( QPaintEvent * _pe )
QRect songEditor::scrollAreaRect( void ) const
{
if( centralWidget() == NULL )
{
return( rect() );
}
return( QRect( 0, 0, centralWidget()->width(),
centralWidget()->height() - m_toolBar->height() -
m_playPos[PLAY_SONG].m_timeLine->height() -
DEFAULT_SCROLLBAR_SIZE ) );
}
// responsible for moving scrollbars after resizing
void songEditor::resizeEvent( QResizeEvent * _re )
{
if( centralWidget() != NULL )
{
m_leftRightScroll->setGeometry( 0,
centralWidget()->height() - 2 -
SCROLLBAR_SIZE,
centralWidget()->width() -
SCROLLBAR_SIZE,
SCROLLBAR_SIZE );
centralWidget()->height() -
DEFAULT_SCROLLBAR_SIZE,
centralWidget()->width(),
DEFAULT_SCROLLBAR_SIZE );
m_playPos[PLAY_SONG].m_timeLine->setFixedWidth(
centralWidget()->width() );
@@ -575,18 +595,11 @@ void songEditor::wheelEvent( QWheelEvent * _we )
{
setPixelsPerTact( (int) pixelsPerTact() / 2 );
}
#ifdef QT4
// update combobox with zooming-factor
m_zoomingComboBox->setCurrentIndex(
m_zoomingComboBox->findText( QString::number(
static_cast<int>( pixelsPerTact() *
100 / DEFAULT_PIXELS_PER_TACT ) ) + "%" ) );
#else
// update combobox with zooming-factor
m_zoomingComboBox->setCurrentText( QString::number(
static_cast<int>( pixelsPerTact() *
100 / DEFAULT_PIXELS_PER_TACT ) ) + "%" );
#endif
// update timeline
m_playPos[PLAY_SONG].m_timeLine->setPixelsPerTact(
pixelsPerTact() );
@@ -1028,11 +1041,9 @@ void songEditor::processNextBuffer( void )
64 / frames_per_tact) % 64 );
}
if( m_playPos[m_playMode].m_timeLine != NULL &&
m_playPos[m_playMode].m_timeLineUpdate == TRUE &&
m_exporting == FALSE )
if( m_exporting == FALSE )
{
m_playPos[m_playMode].m_timeLine->updatePosition();
updateTimeLinePosition();
}
}
@@ -1041,9 +1052,6 @@ void songEditor::processNextBuffer( void )
void songEditor::play( void )
{
if( m_playing == TRUE )
@@ -1147,7 +1155,9 @@ void songEditor::updateTimeLinePosition( void )
if( m_playPos[m_playMode].m_timeLine != NULL &&
m_playPos[m_playMode].m_timeLineUpdate == TRUE )
{
m_playPos[m_playMode].m_timeLine->updatePosition();
/* QTimer::singleShot( 1, m_playPos[m_playMode].m_timeLine,
SLOT( updatePosition() ) );*/
//m_playPos[m_playMode].m_timeLine->updatePosition();
}
}

View File

@@ -112,10 +112,9 @@ timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
m_pos.m_timeLine = this;
updatePosition();
QTimer * update_timer = new QTimer( this );
connect( update_timer, SIGNAL( timeout() ), this,
SLOT( checkForUpdatedPosition() ) );
connect( update_timer, SIGNAL( timeout() ),
this, SLOT( updatePosition() ) );
update_timer->start( 50 );
}
@@ -184,6 +183,7 @@ void timeLine::updatePosition( const midiTime & )
{
emit positionChanged( m_pos );
}
update();
}
}
@@ -215,18 +215,6 @@ void timeLine::toggleBehaviourAtStop( int _n )
void timeLine::checkForUpdatedPosition( void )
{
if( m_changedPosition == TRUE )
{
repaint();
m_changedPosition = FALSE;
}
}
void timeLine::paintEvent( QPaintEvent * )
{
#ifdef QT4

View File

@@ -43,9 +43,6 @@
#include <qcursor.h>
#include <qwhatsthis.h>
#define setChecked setOn
#define isChecked isOn
#endif
@@ -73,6 +70,7 @@ const Sint16 RESIZE_GRIP_WIDTH = 4;
const Uint16 TRACK_OP_BTN_WIDTH = 20;
const Uint16 TRACK_OP_BTN_HEIGHT = 14;
const Uint16 MINIMAL_TRACK_HEIGHT = 32;
textFloat * trackContentObject::s_textFloat = NULL;
@@ -82,16 +80,15 @@ textFloat * trackContentObject::s_textFloat = NULL;
// trackContentObject
// ===========================================================================
trackContentObject::trackContentObject( track * _track ) :
QWidget( _track->getTrackContentWidget()
#ifndef QT4
, NULL, Qt::WDestructiveClose
selectableObject( _track->getTrackContentWidget()
#ifdef QT3
, Qt::WDestructiveClose
#endif
),
m_track( _track ),
m_startPosition(),
m_length(),
m_moving( FALSE ),
m_resizing( FALSE ),
m_action( NONE ),
m_autoResize( FALSE ),
m_initialMouseX( 0 )
{
@@ -172,9 +169,10 @@ float trackContentObject::pixelsPerTact( void )
{
if( fixedTCOs() )
{
return( getTrack()->getTrackContentWidget()->width() -
2 * TCO_BORDER_WIDTH ) /
tMax<float>( length().getTact(), 1.0f );
return( ( getTrack()->getTrackContentWidget()->width() -
2 * TCO_BORDER_WIDTH -
DEFAULT_SCROLLBAR_SIZE ) /
tMax<float>( length().getTact(), 1.0f ) );
}
return( getTrack()->getTrackContainer()->pixelsPerTact() );
}
@@ -229,7 +227,32 @@ void trackContentObject::leaveEvent( QEvent * _e )
void trackContentObject::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
if( m_track->getTrackContainer()->allowRubberband() == TRUE &&
_me->button() == Qt::LeftButton )
{
if( m_track->getTrackContainer()->rubberBandActive() == FALSE )
{
if( lmmsMainWin::isCtrlPressed() == TRUE )
{
setSelected( !isSelected() );
}
else if( isSelected() == TRUE )
{
m_action = MOVE_SELECTION;
m_initialMouseX = _me->x();
}
}
else
{
selectableObject::mousePressEvent( _me );
}
return;
}
else if( lmmsMainWin::isShiftPressed() == TRUE )
{
selectableObject::mousePressEvent( _me );
}
else if( _me->button() == Qt::LeftButton &&
lmmsMainWin::isCtrlPressed() == TRUE )
{
multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA );
@@ -257,14 +280,14 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
if( _me->x() < width() - RESIZE_GRIP_WIDTH )
{
m_moving = TRUE;
m_action = MOVE;
QCursor c( Qt::SizeAllCursor );
QApplication::setOverrideCursor( c );
s_textFloat->setTitle( tr( "Current position" ) );
}
else if( m_autoResize == FALSE )
{
m_resizing = TRUE;
m_action = RESIZE;
QCursor c( Qt::SizeHorCursor );
QApplication::setOverrideCursor( c );
s_textFloat->setTitle( tr( "Current length" ) );
@@ -289,9 +312,9 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
void trackContentObject::mouseMoveEvent( QMouseEvent * _me )
{
const float ppt = m_track->getTrackContainer()->pixelsPerTact();
if( m_moving == TRUE )
if( m_action == MOVE )
{
int x = mapToParent( _me->pos() ).x() - m_initialMouseX;
const int x = mapToParent( _me->pos() ).x() - m_initialMouseX;
movePosition( tMax( 0, (Sint32) m_track->getTrackContainer()->
currentPosition() +
static_cast<int>( x * 64 / ppt ) ) );
@@ -302,7 +325,38 @@ void trackContentObject::mouseMoveEvent( QMouseEvent * _me )
s_textFloat->move( mapTo( topLevelWidget(), QPoint( 0, 0 ) ) +
QPoint( -2 - s_textFloat->width(), 8 ) );
}
else if( m_resizing == TRUE )
else if( m_action == MOVE_SELECTION )
{
const int dx = _me->x() - m_initialMouseX;
vvector<selectableObject *> so =
m_track->getTrackContainer()->selectedObjects();
vvector<trackContentObject *> tcos;
midiTime smallest_pos;
// find out smallest position of all selected objects for not
// moving an object before zero
for( vvector<selectableObject *>::iterator it = so.begin();
it != so.end(); ++it )
{
trackContentObject * tco =
dynamic_cast<trackContentObject *>( *it );
if( tco == NULL )
{
continue;
}
tcos.push_back( tco );
smallest_pos = tMin<Sint32>( smallest_pos,
(Sint32)tco->startPosition() +
static_cast<int>( dx * 64 / ppt ) );
}
for( vvector<trackContentObject *>::iterator it = tcos.begin();
it != tcos.end(); ++it )
{
( *it )->movePosition( ( *it )->startPosition() +
static_cast<int>( dx * 64 / ppt ) -
smallest_pos );
}
}
else if( m_action == RESIZE )
{
changeLength( tMax( 64,
static_cast<int>( _me->x() * 64 / ppt ) ) );
@@ -344,10 +398,10 @@ void trackContentObject::mouseMoveEvent( QMouseEvent * _me )
void trackContentObject::mouseReleaseEvent( QMouseEvent * _me )
{
m_action = NONE;
s_textFloat->hide();
leaveEvent( NULL );
m_moving = FALSE;
m_resizing = FALSE;
selectableObject::mouseReleaseEvent( _me );
}
@@ -448,7 +502,6 @@ trackContentWidget::trackContentWidget( trackWidget * _parent ) :
#else
setPaletteBackgroundColor( QColor( 96, 96, 96 ) );
#endif
setMouseTracking( TRUE );
setAcceptDrops( TRUE );
}
@@ -609,6 +662,7 @@ void trackContentWidget::updateTCOs( void )
for( tcoVector::iterator it = m_trackContentObjects.begin();
it != m_trackContentObjects.end(); ++it )
{
( *it )->setFixedHeight( height() - 2 );
( *it )->update();
}
}
@@ -638,7 +692,7 @@ void trackContentWidget::dropEvent( QDropEvent * _de )
// value contains our XML-data so simply create a
// multimediaProject which does the rest for us...
multimediaProject mmp( value, FALSE );
// at least save position before getting to moved to somewhere
// at least save position before getting moved to somewhere
// the user doesn't expect...
tco->loadSettings( mmp.content().firstChild().toElement() );
tco->movePosition( position );
@@ -653,7 +707,15 @@ void trackContentWidget::dropEvent( QDropEvent * _de )
void trackContentWidget::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton &&
if( getTrack()->getTrackContainer()->allowRubberband() == TRUE )
{
QWidget::mousePressEvent( _me );
}
else if( lmmsMainWin::isShiftPressed() == TRUE )
{
QWidget::mousePressEvent( _me );
}
else if( _me->button() == Qt::LeftButton &&
getTrack()->getTrackContainer()->fixedTCOs() == FALSE )
{
const midiTime position = getPosition( _me->x() );
@@ -666,27 +728,33 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me )
void trackContentWidget::mouseMoveEvent( QMouseEvent * _me )
void trackContentWidget::paintEvent( QPaintEvent * _pe )
{
// if user moved TCO out of visible area, TCO doesn't receive
// mouse-events, so we have to do it here
while( QApplication::overrideCursor() != NULL )
#ifdef QT4
QPainter p( this );
p.fillRect( rect(), QColor( 96, 96, 96 ) );
#else
// create pixmap for whole widget
QPixmap pm( rect().size() );
pm.fill( QColor( 96, 96, 96 ) );
// and a painter for it
QPainter p( &pm );
#endif
const trackContainer * tc = getTrack()->getTrackContainer();
const int offset = (int)( ( tc->currentPosition() % 4 ) *
tc->pixelsPerTact() );
// draw vertical lines
p.setPen( QColor( 128, 128, 128 ) );
for( int x = -offset; x < width(); x += (int) tc->pixelsPerTact() )
{
QApplication::restoreOverrideCursor();
p.drawLine( x, 0, x, height() );
}
}
void trackContentWidget::mouseReleaseEvent( QMouseEvent * _me )
{
// if user moved TCO out of visible area, TCO doesn't receive
// mouseRelease-events...
while( QApplication::overrideCursor() != NULL )
{
QApplication::restoreOverrideCursor();
}
#ifndef QT4
// blit drawn pixmap to actual widget
bitBlt( this, rect().topLeft(), &pm );
#endif
}
@@ -759,7 +827,7 @@ trackOperationsWidget::trackOperationsWidget( trackWidget * _parent ) :
m_muteBtn = new pixmapButton( this );
m_muteBtn->setActiveGraphic( embed::getIconPixmap( "mute_on" ) );
m_muteBtn->setInactiveGraphic( embed::getIconPixmap( "mute_off" ) );
m_muteBtn->move( 44, 8 );
m_muteBtn->move( 44, 4 );
m_muteBtn->show();
connect( m_muteBtn, SIGNAL( toggled( bool ) ), this,
SLOT( setMuted( bool ) ) );
@@ -814,7 +882,7 @@ void trackOperationsWidget::mousePressEvent( QMouseEvent * _me )
&m_trackWidget->getTrackSettingsWidget() ),
this );
}
else if( _me->button() == Qt::LeftButton && _me->x() < 10 )
else if( _me->button() == Qt::LeftButton )
{
// track-widget (parent-widget) initiates track-move
_me->ignore();
@@ -841,14 +909,8 @@ void trackOperationsWidget::paintEvent( QPaintEvent * _pe )
if( m_trackWidget->isMovingTrack() == FALSE )
{
p.drawPixmap( 2, 2, *s_grip );
/* if( m_trackOps->isVisible() == FALSE )
{*/
m_trackOps->show();
/* }
if( m_muteBtn->isVisible() == FALSE )
{*/
m_muteBtn->show();
// }
m_trackOps->show();
m_muteBtn->show();
}
else
{
@@ -895,9 +957,9 @@ void trackOperationsWidget::setMuted( bool _muted )
void trackOperationsWidget::muteBtnRightClicked( void )
{
const bool m = muted(); // next function might modify our mute-state,
// so save it
m_trackWidget->getTrack()->getTrackContainer()->setMutedOfAllTracks(
m );
// so save it now
m_trackWidget->getTrack()->getTrackContainer()->
setMutedOfAllTracks( m );
setMuted( !m );
}
@@ -916,8 +978,7 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) :
m_trackOperationsWidget( this ),
m_trackSettingsWidget( this ),
m_trackContentWidget( this ),
m_movingTrack( FALSE ),
m_initialMouseX( -1 )
m_action( NONE )
{
#ifdef QT4
QPalette pal;
@@ -937,11 +998,12 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) :
m_trackSettingsWidget.setPalette( pal );
#else
m_trackSettingsWidget.setPaletteBackgroundColor( QColor( 64, 64, 64 ) );
// set background-mode for flicker-free redraw
setBackgroundMode( Qt::NoBackground );
#endif
setAcceptDrops( TRUE );
setMouseTracking( TRUE );
}
@@ -954,6 +1016,15 @@ trackWidget::~trackWidget()
void trackWidget::repaint( void )
{
m_trackContentWidget.repaint();
QWidget::repaint();
}
// resposible for moving track-content-widgets to appropriate position after
// change of visible viewport
void trackWidget::changePosition( const midiTime & _new_pos )
@@ -1022,15 +1093,30 @@ void trackWidget::dropEvent( QDropEvent * _de )
void trackWidget::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton )
if( m_track->getTrackContainer()->allowRubberband() == TRUE )
{
m_movingTrack = TRUE;
m_initialMouseX = _me->x();
QWidget::mousePressEvent( _me );
}
else if( _me->button() == Qt::LeftButton )
{
if( lmmsMainWin::isShiftPressed() == TRUE )
{
m_action = RESIZE_TRACK;
QCursor::setPos( mapToGlobal( QPoint( _me->x(),
height() ) ) );
QCursor c( Qt::SizeVerCursor);
QApplication::setOverrideCursor( c );
}
else
{
m_action = MOVE_TRACK;
QCursor c( Qt::SizeAllCursor );
QApplication::setOverrideCursor( c );
m_trackOperationsWidget.update();
QCursor c( Qt::SizeAllCursor );
QApplication::setOverrideCursor( c );
// update because in move-mode, all elements in
// track-op-widgets are hidden as a visual feedback
m_trackOperationsWidget.update();
}
_me->accept();
}
@@ -1045,7 +1131,11 @@ void trackWidget::mousePressEvent( QMouseEvent * _me )
void trackWidget::mouseMoveEvent( QMouseEvent * _me )
{
if( m_movingTrack == TRUE )
if( m_track->getTrackContainer()->allowRubberband() == TRUE )
{
QWidget::mouseMoveEvent( _me );
}
else if( m_action == MOVE_TRACK )
{
trackContainer * tc = m_track->getTrackContainer();
// look which track-widget the mouse-cursor is over
@@ -1065,6 +1155,11 @@ void trackWidget::mouseMoveEvent( QMouseEvent * _me )
}
}
}
else if( m_action == RESIZE_TRACK )
{
setFixedHeight( tMax<int>( _me->y(), MINIMAL_TRACK_HEIGHT ) );
m_track->getTrackContainer()->realignTracks();
}
}
@@ -1072,12 +1167,14 @@ void trackWidget::mouseMoveEvent( QMouseEvent * _me )
void trackWidget::mouseReleaseEvent( QMouseEvent * _me )
{
m_movingTrack = FALSE;
m_action = NONE;
while( QApplication::overrideCursor() != NULL )
{
QApplication::restoreOverrideCursor();
}
m_trackOperationsWidget.update();
QWidget::mouseReleaseEvent( _me );
}
@@ -1226,6 +1323,7 @@ void FASTCALL track::saveSettings( QDomDocument & _doc, QDomElement & _parent )
QDomElement track_de = _doc.createElement( "track" );
track_de.setAttribute( "type", type() );
track_de.setAttribute( "muted", muted() );
track_de.setAttribute( "height", m_trackWidget->height() );
_parent.appendChild( track_de );
// let actual track (channelTrack, bbTrack, sampleTrack etc.) save
@@ -1275,6 +1373,12 @@ void FASTCALL track::loadSettings( const QDomElement & _this )
}
node = node.nextSibling();
}
if( _this.attribute( "height" ).toInt() >= MINIMAL_TRACK_HEIGHT )
{
m_trackWidget->setFixedHeight(
_this.attribute( "height" ).toInt() );
}
}
@@ -1376,13 +1480,6 @@ void FASTCALL track::swapPositionOfTCOs( csize _tco_num1, csize _tco_num2 )
#ifndef QT4
#undef isChecked
#undef setChecked
#endif
#include "track.moc"

View File

@@ -58,18 +58,22 @@
#include "config_mgr.h"
#include "midi_file.h"
#include "instrument.h"
#include "rubberband.h"
trackContainer::trackContainer() :
QMainWindow( lmmsMainWin::inst()->workspace()
#ifndef QT4
#ifdef QT3
, 0, Qt::WStyle_Title
#endif
),
settings(),
m_currentPosition( 0, 0 ),
m_ppt( DEFAULT_PIXELS_PER_TACT )
m_scrollArea( new scrollArea( this ) ),
m_ppt( DEFAULT_PIXELS_PER_TACT ),
m_rubberBand( new rubberBand( m_scrollArea ) ),
m_origin()
{
#ifdef QT4
if( lmmsMainWin::inst()->workspace() != NULL )
@@ -78,8 +82,8 @@ trackContainer::trackContainer() :
}
#endif
m_scrollArea = new scrollArea( this );
m_scrollArea->show();
m_rubberBand->hide();
setAcceptDrops( TRUE );
}
@@ -281,23 +285,20 @@ void trackContainer::realignTracks( bool _complete_update )
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
it != m_trackWidgets.end(); ++it )
{
if( _complete_update )
{
( *it )->hide();
}
( *it )->show();
( *it )->repaint();
#ifdef QT4
( *it )->move( 0, y );
#else
m_scrollArea->moveChild( *it, 0, y );
#endif
( *it )->resize( width(), ( *it )->height() );
( *it )->resize( width() - DEFAULT_SCROLLBAR_SIZE,
( *it )->height() );
( *it )->changePosition( m_currentPosition );
y += ( *it )->height();
}
#ifndef QT4
m_scrollArea->resizeContents( m_scrollArea->parentWidget()->width(),
y );
#ifdef QT3
m_scrollArea->resizeContents( width() - DEFAULT_SCROLLBAR_SIZE, y );
#endif
updateScrollArea();
}
@@ -324,6 +325,14 @@ const trackWidget * trackContainer::trackWidgetAt( const int _y ) const
bool trackContainer::allowRubberband( void ) const
{
return( FALSE );
}
unsigned int trackContainer::countTracks( track::trackTypes _tt ) const
{
unsigned int cnt = 0;
@@ -390,14 +399,6 @@ void trackContainer::setPixelsPerTact( Uint16 _ppt )
void trackContainer::resizeEvent( QResizeEvent * )
{
realignTracks();
}
void trackContainer::dragEnterEvent( QDragEnterEvent * _dee )
{
stringPairDrag::processDragEnterEvent( _dee,
@@ -464,13 +465,56 @@ void trackContainer::dropEvent( QDropEvent * _de )
void trackContainer::mousePressEvent( QMouseEvent * _me )
{
if( allowRubberband() == TRUE )
{
m_origin = m_scrollArea->mapFromParent( _me->pos() );
m_rubberBand->setGeometry( QRect( m_origin, QSize() ) );
m_rubberBand->show();
}
}
void trackContainer::mouseMoveEvent( QMouseEvent * _me )
{
if( rubberBandActive() == TRUE )
{
m_rubberBand->setGeometry( QRect( m_origin,
m_scrollArea->mapFromParent( _me->pos() ) ).
normalized() );
}
}
void trackContainer::mouseReleaseEvent( QMouseEvent * _me )
{
m_rubberBand->hide();
}
void trackContainer::resizeEvent( QResizeEvent * )
{
realignTracks();
}
void trackContainer::updateScrollArea( void )
{
m_scrollArea->resize( tMax( m_scrollArea->parentWidget()->width() -
m_scrollArea->resize( width(), scrollAreaRect().height() );
/* m_scrollArea->resize( tMax( m_scrollArea->parentWidget()->width() -
m_scrollArea->x() - 2, 0 ),
tMax( m_scrollArea->parentWidget()->height() -
m_scrollArea->y() - 2, 0 ) );
//m_scrollArea->updateContents();
m_scrollArea->y() - 2, 0 ) );*/
}
@@ -486,6 +530,13 @@ trackContainer::scrollArea::scrollArea( trackContainer * _parent ) :
Qt::ScrollBarAlwaysOff
#else
QScrollArea::AlwaysOff
#endif
);
setVerticalScrollBarPolicy(
#ifdef QT4
Qt::ScrollBarAlwaysOn
#else
QScrollArea::AlwaysOn
#endif
);
}

View File

@@ -1005,7 +1005,7 @@ QString sampleBuffer::openAudioFile( void ) const
ofd.selectFile( QFileInfo( m_audioFile ).fileName() );
}
if ( ofd.exec () == QDialog::Accepted )
if( ofd.exec () == QDialog::Accepted )
{
if( ofd.selectedFiles().isEmpty() )
{

View File

@@ -1,7 +1,7 @@
/*
* bb_track.cpp - implementation of class bbTrack
* bb_track.cpp - implementation of class bbTrack and bbTCO
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -49,10 +49,11 @@
#include "name_label.h"
#include "embed.h"
#include "rename_dialog.h"
#include "templates.h"
QMap<bbTrack *, bbTrack::bbInfoStruct> bbTrack::s_bbNums;
bbTrack::infoMap bbTrack::s_infoMap;
bbTCO::bbTCO( track * _track, const QColor & _c ) :
@@ -134,6 +135,11 @@ void bbTCO::paintEvent( QPaintEvent * )
{
col = QColor( 160, 160, 160 );
}
if( isSelected() == TRUE )
{
col = QColor( tMax( col.red() - 128, 0 ),
tMax( col.green() - 128, 0 ), 255 );
}
#ifdef QT4
QPainter p( this );
// TODO: set according brush/pen for gradient!
@@ -154,10 +160,10 @@ void bbTCO::paintEvent( QPaintEvent * )
tact t = bbEditor::inst()->lengthOfBB( bbTrack::numOfBBTrack(
getTrack() ) );
if( length().getTact() > 1 && t > 0 )
if( length() > 64 && t > 0 )
{
for( int x = TCO_BORDER_WIDTH + static_cast<int>( t *
pixelsPerTact() ); x < width();
for( int x = static_cast<int>( t * pixelsPerTact() );
x < width();
x += static_cast<int>( t * pixelsPerTact() ) )
{
p.setPen( col.light( 80 ) );
@@ -273,25 +279,33 @@ void bbTCO::changeColor( void )
bbTrack::bbTrack( trackContainer * _tc )
: track( _tc )
bbTrack::bbTrack( trackContainer * _tc ) :
track( _tc )
{
getTrackWidget()->setFixedHeight( 32 );
// drag'n'drop with bb-tracks only causes troubles (and makes no sense
// too), so disable it
getTrackWidget()->setAcceptDrops( FALSE );
csize bbNum = s_bbNums.size();
bbInfoStruct bis = { bbNum, "" };
s_bbNums[this] = bis;
csize bbNum = s_infoMap.size();
s_infoMap[this] = bbNum;
m_trackLabel = new nameLabel( tr( "Beat/Bassline %1" ).arg( bbNum ),
getTrackSettingsWidget(),
embed::getIconPixmap( "bb_track" ) );
m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 );
getTrackSettingsWidget() );
m_trackLabel->setPixmap( embed::getIconPixmap( "bb_track" ) );
m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH - 2,
29 );
m_trackLabel->show();
connect( m_trackLabel, SIGNAL( clicked() ), this,
SLOT( clickedTrackLabel() ) );
connect( m_trackLabel, SIGNAL( clicked() ),
this, SLOT( clickedTrackLabel() ) );
connect( m_trackLabel, SIGNAL( nameChanged() ),
bbEditor::inst(), SLOT( updateComboBox() ) );
connect( m_trackLabel, SIGNAL( pixmapChanged() ),
bbEditor::inst(), SLOT( updateComboBox() ) );
bbEditor::inst()->setCurrentBB( bbNum );
bbEditor::inst()->updateComboBox();
_tc->updateAfterTrackAdd();
}
@@ -301,24 +315,24 @@ bbTrack::bbTrack( trackContainer * _tc )
bbTrack::~bbTrack()
{
csize bb = s_bbNums[this].num;
csize bb = s_infoMap[this];
bbEditor::inst()->removeBB( bb );
for( QMap<bbTrack *, bbTrack::bbInfoStruct>::iterator it =
s_bbNums.begin(); it != s_bbNums.end(); ++it )
for( infoMap::iterator it = s_infoMap.begin(); it != s_infoMap.end();
++it )
{
#ifdef QT4
if( it.value().num > bb )
if( it.value() > bb )
{
--it.value().num;
--it.value();
}
#else
if( it.data().num > bb )
if( it.data() > bb )
{
--it.data().num;
--it.data();
}
#endif
}
s_bbNums.remove( this );
s_infoMap.remove( this );
}
@@ -340,7 +354,7 @@ bool FASTCALL bbTrack::play( const midiTime & _start, Uint32 _start_frame,
{
return( bbEditor::inst()->play( _start, _start_frame, _frames,
_frame_base,
s_bbNums[this].num ) );
s_infoMap[this] ) );
}
vlist<trackContentObject *> tcos;
@@ -368,7 +382,7 @@ bool FASTCALL bbTrack::play( const midiTime & _start, Uint32 _start_frame,
return( bbEditor::inst()->play( _start - lastPosition,
_start_frame, _frames,
_frame_base,
s_bbNums[this].num ) );
s_infoMap[this] ) );
}
return( FALSE );
}
@@ -402,10 +416,11 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc,
{
QDomElement bbt_de = _doc.createElement( nodeName() );
bbt_de.setAttribute( "name", m_trackLabel->text() );
/* bbt_de.setAttribute( "current", s_bbNums[this].num ==
bbt_de.setAttribute( "icon", m_trackLabel->pixmapFile() );
/* bbt_de.setAttribute( "current", s_infoMap[this] ==
bbEditor::inst()->currentBB() );*/
_parent.appendChild( bbt_de );
if( s_bbNums[this].num == 0 &&
if( s_infoMap[this] == 0 &&
_parent.parentNode().nodeName() != "clone" )
{
bbEditor::inst()->saveSettings( _doc, bbt_de );
@@ -418,6 +433,10 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc,
void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
{
m_trackLabel->setText( _this.attribute( "name" ) );
if( _this.attribute( "icon" ) != "" )
{
m_trackLabel->setPixmapFile( _this.attribute( "icon" ) );
}
if( _this.firstChild().isElement() )
{
bbEditor::inst()->loadSettings(
@@ -428,7 +447,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
help at all....
if( _this.attribute( "current" ).toInt() )
{
bbEditor::inst()->setCurrentBB( s_bbNums[this].num );
bbEditor::inst()->setCurrentBB( s_infoMap[this] );
}*/
}
@@ -438,14 +457,13 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
// return pointer to bbTrack specified by _bb_num
bbTrack * bbTrack::findBBTrack( csize _bb_num )
{
for( QMap<bbTrack *, bbTrack::bbInfoStruct>::iterator it =
s_bbNums.begin();
it != s_bbNums.end(); ++it )
for( infoMap::iterator it = s_infoMap.begin(); it != s_infoMap.end();
++it )
{
#ifdef QT4
if( it.value().num == _bb_num )
if( it.value() == _bb_num )
#else
if( it.data().num == _bb_num )
if( it.data() == _bb_num )
#endif
{
return( it.key() );
@@ -461,7 +479,7 @@ csize bbTrack::numOfBBTrack( track * _track )
{
if( dynamic_cast<bbTrack *>( _track ) != NULL )
{
return( s_bbNums[dynamic_cast<bbTrack *>( _track )].num );
return( s_infoMap[dynamic_cast<bbTrack *>( _track )] );
}
return( 0 );
}
@@ -475,9 +493,9 @@ void bbTrack::swapBBTracks( track * _track1, track * _track2 )
bbTrack * t2 = dynamic_cast<bbTrack *>( _track2 );
if( t1 != NULL && t2 != NULL )
{
qSwap( s_bbNums[t1].num, s_bbNums[t2].num );
bbEditor::inst()->swapBB( s_bbNums[t1].num, s_bbNums[t2].num );
bbEditor::inst()->setCurrentBB( s_bbNums[t2].num );
qSwap( s_infoMap[t1], s_infoMap[t2] );
bbEditor::inst()->swapBB( s_infoMap[t1], s_infoMap[t2] );
bbEditor::inst()->setCurrentBB( s_infoMap[t2] );
}
}
@@ -486,7 +504,7 @@ void bbTrack::swapBBTracks( track * _track1, track * _track2 )
void bbTrack::clickedTrackLabel( void )
{
bbEditor::inst()->setCurrentBB( s_bbNums[this].num );
bbEditor::inst()->setCurrentBB( s_infoMap[this] );
bbEditor::inst()->show();
}

View File

@@ -2,7 +2,7 @@
* pattern.cpp - implementation of class pattern which holds notes
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005 Danny McRae <khjklujn@yahoo.com>
* Copyright (c) 2005 Danny McRae <khjklujn/at/yahoo.com>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -69,7 +69,6 @@
#include "string_pair_drag.h"
QPixmap * pattern::s_patternBg = NULL;
QPixmap * pattern::s_stepBtnOn = NULL;
QPixmap * pattern::s_stepBtnOverlay = NULL;
QPixmap * pattern::s_stepBtnOff = NULL;
@@ -78,9 +77,10 @@ QPixmap * pattern::s_frozen = NULL;
pattern::pattern ( channelTrack * _channel_track ) :
trackContentObject( _channel_track ),
m_paintPixmap(),
m_needsUpdate( TRUE ),
m_channelTrack( _channel_track ),
m_patternType( BEAT_PATTERN ),
m_name( _channel_track->name() ),
@@ -98,6 +98,8 @@ pattern::pattern ( channelTrack * _channel_track ) :
pattern::pattern( const pattern & _pat_to_copy ) :
trackContentObject( _pat_to_copy.m_channelTrack ),
m_paintPixmap(),
m_needsUpdate( TRUE ),
m_channelTrack( _pat_to_copy.m_channelTrack ),
m_patternType( _pat_to_copy.m_patternType ),
m_name( "" ),
@@ -142,31 +144,30 @@ pattern::~pattern()
void pattern::init( void )
{
if( s_patternBg == NULL )
{
s_patternBg = new QPixmap( embed::getIconPixmap(
"pattern_bg" ) );
}
if( s_stepBtnOn == NULL )
{
s_stepBtnOn = new QPixmap( embed::getIconPixmap(
"step_btn_on_100" ) );
}
if( s_stepBtnOverlay == NULL )
{
s_stepBtnOverlay = new QPixmap( embed::getIconPixmap(
"step_btn_on_yellow" ) );
}
if( s_stepBtnOff == NULL )
{
s_stepBtnOff = new QPixmap( embed::getIconPixmap(
"step_btn_off" ) );
}
if( s_stepBtnOffLight == NULL )
{
s_stepBtnOffLight = new QPixmap( embed::getIconPixmap(
"step_btn_off_light" ) );
}
if( s_frozen == NULL )
{
s_frozen = new QPixmap( embed::getIconPixmap( "frozen" ) );
@@ -174,14 +175,14 @@ void pattern::init( void )
ensureBeatNotes();
changeLength( length() );
#ifndef QT4
// set background-mode for flicker-free redraw
setBackgroundMode( Qt::NoBackground );
#endif
setFixedHeight( s_patternBg->height() + 4 );
changeLength( length() );
setFixedHeight( parentWidget()->height() - 2 );
setAutoResizeEnabled( FALSE );
toolTip::add( this,
@@ -192,15 +193,6 @@ void pattern::init( void )
void pattern::movePosition( const midiTime & _pos )
{
// patterns are always aligned on tact-boundaries
trackContentObject::movePosition( midiTime( _pos.getTact(), 0 ) );
}
midiTime pattern::length( void ) const
{
if( m_patternType == BEAT_PATTERN )
@@ -319,6 +311,10 @@ void pattern::clearNotes( void )
m_notes.clear();
checkType();
update();
if( pianoRoll::inst()->currentPattern() == this )
{
pianoRoll::inst()->update();
}
}
@@ -474,6 +470,15 @@ void pattern::loadSettings( const QDomElement & _this )
void pattern::update( void )
{
m_needsUpdate = TRUE;
changeLength( length() );
trackContentObject::update();
}
void pattern::openInPianoRoll( void )
{
@@ -488,7 +493,6 @@ void pattern::openInPianoRoll( bool )
pianoRoll::inst()->setCurrentPattern( this );
pianoRoll::inst()->show();
pianoRoll::inst()->setFocus();
return;
}
@@ -582,6 +586,7 @@ void pattern::unfreeze( void )
delete m_frozenPattern;
m_frozenPattern = NULL;
m_frozenPatternMutex.unlock();
update();
}
}
@@ -870,22 +875,54 @@ void pattern::wheelEvent( QWheelEvent * _we )
void pattern::paintEvent( QPaintEvent * )
{
if( m_needsUpdate == FALSE )
{
QPainter p( this );
p.drawPixmap( 0, 0, m_paintPixmap );
return;
}
changeLength( length() );
#ifdef QT4
QPainter p( this );
#else
// create pixmap for whole widget
QPixmap pm( rect().size() );
m_needsUpdate = FALSE;
// and a painter for it
QPainter p( &pm );
if( m_paintPixmap.isNull() == TRUE || m_paintPixmap.size() != size() )
{
m_paintPixmap = QPixmap( size() );
}
QPainter p( &m_paintPixmap );
#ifdef QT4
// TODO: gradient!
#else
for( int y = 1; y < height() / 2; ++y )
{
const int gray = 96 - y * 192 / height();
if( isSelected() == TRUE )
{
p.setPen( QColor( 0, 0, 128 + gray ) );
}
else
{
p.setPen( QColor( gray, gray, gray ) );
}
p.drawLine( 1, y, width() - 1, y );
}
for( int y = height() / 2; y < height() - 1; ++y )
{
const int gray = ( y - height() / 2 ) * 192 / height();
if( isSelected() == TRUE )
{
p.setPen( QColor( 0, 0, 128 + gray ) );
}
else
{
p.setPen( QColor( gray, gray, gray ) );
}
p.drawLine( 1, y, width() - 1, y );
}
#endif
for( Sint16 x = 2; x < width() - 1; x += 2 )
{
p.drawPixmap( x, 2, *s_patternBg );
}
p.setPen( QColor( 57, 69, 74 ) );
p.drawLine( 0, 0, width(), 0 );
p.drawLine( 0, 0, 0, height() );
@@ -896,7 +933,7 @@ void pattern::paintEvent( QPaintEvent * )
p.setPen( QColor( 0, 0, 0 ) );
p.drawRect( 1, 1, width() - 2, height() - 2 );
float ppt = pixelsPerTact();
const float ppt = pixelsPerTact();
if( m_patternType == pattern::MELODY_PATTERN )
{
@@ -920,7 +957,7 @@ void pattern::paintEvent( QPaintEvent * )
{
central_key = central_key / total_notes;
Sint16 central_y = s_patternBg->height() / 2;
Sint16 central_y = height() / 2;
Sint16 y_base = central_y + TCO_BORDER_WIDTH -1;
const Sint16 x_base = TCO_BORDER_WIDTH;
@@ -929,12 +966,13 @@ void pattern::paintEvent( QPaintEvent * )
for( tact tact_num = 1; tact_num <
length().getTact(); ++tact_num )
{
p.drawLine( x_base + static_cast<int>(
ppt*tact_num ),
TCO_BORDER_WIDTH,
x_base +
static_cast<int>( ppt * tact_num ),
height() - 2 *
p.drawLine(
x_base + static_cast<int>(
ppt * tact_num ) - 1,
TCO_BORDER_WIDTH,
x_base + static_cast<int>(
ppt * tact_num ) - 1,
height() - 2 *
TCO_BORDER_WIDTH );
}
if( getTrack()->muted() )
@@ -973,42 +1011,42 @@ void pattern::paintEvent( QPaintEvent * )
}
}
else if( m_patternType == pattern::BEAT_PATTERN &&
( ppt >= 192 || m_steps != DEFAULT_STEPS_PER_TACT ) )
( ppt >= 96 || m_steps != DEFAULT_STEPS_PER_TACT ) )
{
QPixmap stepon;
QPixmap stepoverlay;
QPixmap stepoff;
QPixmap stepoffl;
int steps = length() / BEATS_PER_TACT;
const int steps = length() / BEATS_PER_TACT;
const int w = width() - 2 * TCO_BORDER_WIDTH;
#ifdef QT4
stepon = s_stepBtnOn->scaled( width() / steps,
stepon = s_stepBtnOn->scaled( w / steps,
s_stepBtnOn->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation );
stepoverlay = s_stepBtnOverlay->scaled( width() / steps,
stepoverlay = s_stepBtnOverlay->scaled( w / steps,
s_stepBtnOn->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation );
stepoff = s_stepBtnOff->scaled( width() / steps,
stepoff = s_stepBtnOff->scaled( w / steps,
s_stepBtnOff->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation );
stepoffl = s_stepBtnOffLight->scaled( width() / steps,
stepoffl = s_stepBtnOffLight->scaled( w / steps,
s_stepBtnOffLight->height(),
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation );
#else
stepon.convertFromImage(
s_stepBtnOn->convertToImage().scale(
width() / steps, s_stepBtnOn->height() ) );
w / steps, s_stepBtnOn->height() ) );
stepoverlay.convertFromImage(
s_stepBtnOverlay->convertToImage().scale(
width() / steps, s_stepBtnOverlay->height() ) );
w / steps, s_stepBtnOverlay->height() ) );
stepoff.convertFromImage( s_stepBtnOff->convertToImage().scale(
width() / steps, s_stepBtnOff->height() ) );
w / steps, s_stepBtnOff->height() ) );
stepoffl.convertFromImage( s_stepBtnOffLight->convertToImage().
scale( width() / steps,
scale( w / steps,
s_stepBtnOffLight->height() ) );
#endif
for( noteVector::iterator it = m_notes.begin();
@@ -1016,7 +1054,7 @@ void pattern::paintEvent( QPaintEvent * )
{
Sint16 no = it - m_notes.begin();
Sint16 x = TCO_BORDER_WIDTH + static_cast<int>( no *
width() / steps );
w / steps );
Sint16 y = height() - s_stepBtnOff->height() - 1;
Uint8 vol = ( *it )->getVolume();
@@ -1055,10 +1093,11 @@ void pattern::paintEvent( QPaintEvent * )
p.drawPixmap( 3, height() - s_frozen->height() - 4, *s_frozen );
}
#ifndef QT4
// blit drawn pixmap to actual widget
bitBlt( this, rect().topLeft(), &pm );
#endif
p.end();
p.begin( this );
p.drawPixmap( 0, 0, m_paintPixmap );
}
@@ -1223,6 +1262,7 @@ patternFreezeThread::patternFreezeThread( pattern * _pattern ) :
patternFreezeThread::~patternFreezeThread()
{
m_pattern->update();
}

View File

@@ -2,7 +2,7 @@
* sample_track.cpp - implementation of class sampleTrack, a track which
* provides arrangement of samples
*
* Copyright (c) 2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -186,17 +186,29 @@ void sampleTCO::paintEvent( QPaintEvent * )
{
#ifdef QT4
QPainter p( this );
// TODO: set according brush/pen for gradient!
p.fillRect( rect(), QColor( 64, 64, 64 ) );
#else
// create pixmap for whole widget
QPixmap pm( size() );
// and a painter for it
QPainter p( &pm );
#endif
QPixmap bg = embed::getIconPixmap( "sample_track_bg" );
for( Sint16 x = 1; x < width() - 1; x += 10 )
for( int y = 1; y < height() - 1; ++y )
{
p.drawPixmap( x, 1, bg );
const int gray = 96 - y * 96 / height();
if( isSelected() == TRUE )
{
p.setPen( QColor( 0, 0, 128 + gray ) );
}
else
{
p.setPen( QColor( gray, gray, gray ) );
}
p.drawLine( 1, y, width() - 1, y );
}
#endif
p.setPen( QColor( 0, 0, 0 ) );
p.drawRect( 0, 0, width(), height() );
if( getTrack()->muted() )
@@ -348,9 +360,8 @@ sampleTrack::sampleTrack( trackContainer * _tc ) :
getTrackWidget()->setFixedHeight( 32 );
m_trackLabel = new nameLabel( tr( "Sample track" ),
getTrackSettingsWidget(),
embed::getIconPixmap(
"sample_track" ) );
getTrackSettingsWidget() );
m_trackLabel->setPixmap( embed::getIconPixmap( "sample_track" ) );
m_trackLabel->setGeometry( 1, 1, DEFAULT_SETTINGS_WIDGET_WIDTH-2, 29 );
m_trackLabel->show();
@@ -438,6 +449,7 @@ void sampleTrack::saveTrackSpecificSettings( QDomDocument & _doc,
{
QDomElement st_de = _doc.createElement( nodeName() );
st_de.setAttribute( "name", m_trackLabel->text() );
st_de.setAttribute( "icon", m_trackLabel->pixmapFile() );
_parent.appendChild( st_de );
}
@@ -447,6 +459,10 @@ void sampleTrack::saveTrackSpecificSettings( QDomDocument & _doc,
void sampleTrack::loadTrackSpecificSettings( const QDomElement & _this )
{
m_trackLabel->setText( _this.attribute( "name" ) );
if( _this.attribute( "icon" ) != "" )
{
m_trackLabel->setPixmapFile( _this.attribute( "icon" ) );
}
}

294
src/widgets/combobox.cpp Normal file
View File

@@ -0,0 +1,294 @@
/*
* combobox.cpp - implementation of LMMS-combobox
*
* Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "combobox.h"
#include "templates.h"
#include "embed.h"
#include "gui_templates.h"
#ifndef QT3
#include <QPainter>
#include <QPixmap>
#include <QApplication>
#include <QDesktopWidget>
#else
#include <qpainter.h>
#include <qpixmap.h>
#include <qimage.h>
#include <qapplication.h>
#endif
QPixmap * comboBox::s_background = NULL;
QPixmap * comboBox::s_arrow = NULL;
const int CB_ARROW_BTN_WIDTH = 20;
comboBox::comboBox( QWidget * _parent ) :
QWidget( _parent ),
m_menu( this ),
m_currentIndex( 0 ),
m_pressed( FALSE )
{
if( s_background == NULL )
{
s_background = new QPixmap( embed::getIconPixmap(
"combobox_bg" ) );
}
if( s_arrow == NULL )
{
s_arrow = new QPixmap( embed::getIconPixmap(
"combobox_arrow" ) );
}
setFont( pointSize<8>( font() ) );
m_menu.setFont( pointSize<8>( m_menu.font() ) );
#ifndef QT3
connect( &m_menu, SIGNAL( triggered( QAction * ) ),
this, SLOT( setItem( QAction * ) ) );
#else
connect( &m_menu, SIGNAL( activated( int ) ),
this, SLOT( setItem( int ) ) );
#endif
#ifdef QT3
setBackgroundMode( NoBackground );
#endif
}
comboBox::~comboBox()
{
}
void comboBox::addItem( const QString & _item, const QPixmap & _pixmap )
{
QPixmap pm = _pixmap;
if( pm.height() > 16 )
{
#ifndef QT3
pm = pm.scaledToHeight( 16, Qt::SmoothTransformation );
#else
pm.convertFromImage( pm.convertToImage().smoothScale(
pm.width(), 16,
QImage::ScaleMin ) );
#endif
}
m_items.push_back( qMakePair( _item, pm ) );
m_menu.clear();
for( vvector<item>::iterator it = m_items.begin();
it != m_items.end(); ++it )
{
m_menu.addItem( ( *it ).second, ( *it ).first
// when using Qt3, we pass item-index as id for using
// it in setItem( int ) as index
#ifdef QT3
, it - m_items.begin()
#endif
);
}
}
int comboBox::findText( const QString & _txt ) const
{
for( vvector<item>::const_iterator it = m_items.begin();
it != m_items.end(); ++it )
{
if( ( *it ).first == _txt )
{
return( it - m_items.begin() );
}
}
return( -1 );
}
void comboBox::setCurrentIndex( int _idx )
{
m_currentIndex = tLimit<int>( _idx, 0, ( m_items.size() > 0 ) ?
m_items.size() - 1 : 0 );
emit( currentIndexChanged( m_currentIndex ) );
emit( activated( ( m_items.size() > 0 ) ?
m_items[m_currentIndex].first : "" ) );
update();
}
void comboBox::mousePressEvent( QMouseEvent * _me )
{
if( _me->x() > width() - CB_ARROW_BTN_WIDTH )
{
m_pressed = TRUE;
update();
QPoint gpos = mapToGlobal( QPoint( 0, height() ) );
if( gpos.y() + m_menu.sizeHint().height() <
qApp->desktop()->height() )
{
m_menu.exec( gpos );
}
else
{
m_menu.exec( mapToGlobal( QPoint( width(), 0 ) ) );
}
m_pressed = FALSE;
update();
}
else if( _me->button() == Qt::LeftButton )
{
setCurrentIndex( currentIndex() + 1 );
}
else if( _me->button() == Qt::RightButton )
{
setCurrentIndex( currentIndex() - 1 );
}
}
void comboBox::paintEvent( QPaintEvent * _pe )
{
#ifndef QT3
QPainter p( this );
#else
QPixmap draw_pm( rect().size() );
QPainter p( &draw_pm, this );
#endif
p.fillRect( rect(), QColor( 0, 0, 0 ) );
for( int x = 2; x < width() - 2; x += s_background->width() )
{
p.drawPixmap( x, 2, *s_background );
}
p.setPen( QColor( 0, 0, 0 ) );
p.drawLine( width() - 2, 1, width() - 2, height() - 2 );
// outer rect
p.setPen( QColor( 64, 64, 64 ) );
p.drawRect( 0, 0, width(), height() );
// button-separator
p.setPen( QColor( 64, 64, 64 ) );
p.drawLine( width() - CB_ARROW_BTN_WIDTH - 1, 0, width() -
CB_ARROW_BTN_WIDTH - 1, height() - 2 );
p.setPen( QColor( 0, 0, 0 ) );
p.drawLine( width() - CB_ARROW_BTN_WIDTH, 0, width() -
CB_ARROW_BTN_WIDTH, height() - 2 );
// brighter line at bottom/right
p.setPen( QColor( 160, 160, 160 ) );
p.drawLine( width() - 1, 0, width() - 1, height() - 1 );
p.drawLine( 0, height() - 1, width() - 1, height() - 1 );
const int dxy = ( m_pressed == TRUE ) ? 1 : 0;
p.drawPixmap( width() - CB_ARROW_BTN_WIDTH + 4 + dxy, 4 + dxy,
*s_arrow );
if( m_items.size() > 0 )
{
p.setPen( QColor( 224, 224, 224 ) );
p.setFont( font() );
p.setClipRect( QRect( 5, 2, width() - CB_ARROW_BTN_WIDTH - 8,
height() - 2 ) );
const QPixmap & item_pm = m_items[currentIndex()].second;
int tx = 4;
if( item_pm.isNull() == FALSE )
{
p.drawPixmap( tx, 3, item_pm );
tx += item_pm.width() + 2;
}
p.drawText( tx, p.fontMetrics().height(),
m_items[currentIndex()].first );
}
#ifdef QT3
// and blit all the drawn stuff on the screen...
bitBlt( this, rect().topLeft(), &draw_pm );
#endif
}
void comboBox::wheelEvent( QWheelEvent * _we )
{
setCurrentIndex( currentIndex() + ( ( _we->delta() < 0 ) ? 1 : -1 ) );
_we->accept();
}
#ifndef QT3
void comboBox::setItem( QAction * _item )
{
setCurrentIndex( findText( _item->text() ) );
}
void comboBox::setItem( int )
{
}
#else
void comboBox::setItem( QAction * )
{
}
void comboBox::setItem( int _item )
{
setCurrentIndex( _item );
}
#endif
#include "combobox.moc"

View File

@@ -88,11 +88,7 @@ void pixmapButton::paintEvent( QPaintEvent * )
p.drawPixmap( 0, 0, *m_bgPixmap );
}
#ifdef QT4
if( isChecked() || isDown() )
#else
if( isOn() || isDown() )
#endif
{
if( m_activePixmap != NULL )
{

153
src/widgets/rubberband.cpp Normal file
View File

@@ -0,0 +1,153 @@
/*
* rubberband.cpp - rubberband - either own implementation for Qt3 or wrapper
* for Qt4
*
* Copyright (c) 2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program (see COPYING); if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
#include "rubberband.h"
#ifdef QT3
#include <qbitmap.h>
#include <qevent.h>
#include <qobjectlist.h>
#include <qpainter.h>
#endif
rubberBand::rubberBand( QWidget * _parent ) :
#ifndef QT3
QRubberBand( Rectangle, _parent )
#else
QWidget( _parent )
#endif
{
#ifdef QT3
setBackgroundColor( QColor( 0, 64, 255 ) );
#endif
}
rubberBand::~rubberBand()
{
}
vvector<selectableObject *> rubberBand::selectedObjects( void ) const
{
vvector<selectableObject *> so = selectableObjects();
for( vvector<selectableObject *>::iterator it = so.begin();
it != so.end(); )
{
if( ( *it )->isSelected() == FALSE )
{
so.erase( it );
}
else
{
++it;
}
}
return( so );
}
void rubberBand::resizeEvent( QResizeEvent * _re )
{
rubberBandBase::resizeEvent( _re );
#ifdef QT3
updateMask();
#endif
vvector<selectableObject *> so = selectableObjects();
for( vvector<selectableObject *>::iterator it = so.begin();
it != so.end(); ++it )
{
( *it )->setSelected( QRect( pos(), size() ).intersects(
QRect( ( *it )->mapTo( parentWidget(),
QPoint() ),
( *it )->size() ) ) );
}
}
#ifdef QT3
bool rubberBand::event( QEvent * _e )
{
bool ret = QWidget::event( _e );
if( isVisible() == TRUE )
{
raise();
}
return( ret );
}
void rubberBand::updateMask( void )
{
QBitmap rb_mask( size(), TRUE );
QPainter p( &rb_mask );
p.setPen( Qt::color1 );
p.drawRect( 0, 0, width() - 1, height() - 1 );
p.end();
setMask( rb_mask );
}
#endif
vvector<selectableObject *> rubberBand::selectableObjects( void ) const
{
vvector<selectableObject *> so;
if( parentWidget() == NULL )
{
return( so );
}
QObjectList * l = parentWidget()->queryList( "selectableObject" );
for( QObjectListIt it = *l; it.current() != NULL; ++it )
{
so.push_back( static_cast<selectableObject *>( *it ) );
}
delete l;
return( so );
}
#include "rubberband.moc"

View File

@@ -1,7 +1,7 @@
/*
* tab_bar.cpp - implementation of tab-bar
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -31,8 +31,6 @@
#ifndef QT4
#define value data
#define setChecked setOn
#define isChecked isOn
#define removeWidget remove
#endif
@@ -256,8 +254,6 @@ bool tabBar::allHidden( void )
#undef value
#undef setChecked
#undef isChecked
#undef removeWidget