global clipboard, groupbox automation, volume vector, several segfaults

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@486 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Javier Serrano Polo
2007-05-12 14:56:52 +00:00
parent 734077c1f1
commit 20f631bdca
31 changed files with 493 additions and 232 deletions

View File

@@ -1,3 +1,56 @@
2007-05-12 Javier Serrano Polo <jasp00/at/terra/dot/es>
* include/clipboard.h:
* include/mmp.h:
* include/note.h:
* include/piano_roll.h:
* src/core/note.cpp:
* src/core/piano_roll.cpp:
* src/lib/clipboard.cpp:
* src/lib/mmp.cpp:
use the global clipboard to copy notes
* include/group_box.h:
* src/core/arp_and_chords_tab_widget.cpp:
* src/core/envelope_tab_widget.cpp:
* src/lib/mmp.cpp:
* src/widgets/group_box.cpp:
save groupbox automation
* include/surround_area.h:
* src/core/surround_area.cpp:
* src/core/track.cpp:
* src/lib/mmp.cpp:
calculate volume vector in a more consistent way
* src/core/track.cpp:
fixed drag track onto another segfault
* include/piano_widget.h:
* src/core/piano_widget.cpp:
fixed release invalid key segfault
* src/tracks/instrument_track.cpp:
fixed freeze pattern segfault
* include/preset_preview_play_handle.h:
* src/core/engine.cpp:
* src/core/preset_preview_play_handle.cpp:
fixed uninitialized preset preview container segfault
* include/main_window.h:
* src/core/main_window.cpp:
added Qt4 menu implementations
* include/file_browser.h:
* include/qt3support.h:
* src/core/file_browser.cpp:
fixed Qt4 context menu
* data/locale/ca.ts:
* src/tracks/pattern.cpp:
hide irrelevant freeze options from context menu
2007-05-07 Javier Serrano Polo <jasp00/at/terra/dot/es>
* include/audio_jack.h:
@@ -9,7 +62,7 @@
* include/pattern.h:
* include/sample_buffer.h:
* include/shared_object.h:
* plugins/ladspa_base/ladspa_control.cpp:
* plugins/ladspa_bas:e/ladspa_control.cpp:
* plugins/ladspa_base/ladspa_control.h:
* plugins/ladspa_effect/ladspa_effect.cpp:
* src/audio/audio_jack.cpp:

View File

@@ -2,8 +2,8 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(lmms, 0.2.1-svn20070507, lmms-devel/at/lists/dot/sf/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20070507)
AC_INIT(lmms, 0.2.1-svn20070512, lmms-devel/at/lists/dot/sf/dot/net)
AM_INIT_AUTOMAKE(lmms, 0.2.1-svn20070512)
AM_CONFIG_HEADER(config.h)

Binary file not shown.

View File

@@ -2795,14 +2795,6 @@ use mouse wheel to set volume of a step</source>
<translation>pica dos cops per a obrir aquest patró al rotlle de piano
usa la roda del ratolí per a ajustar el volum d&apos;un pas</translation>
</message>
<message>
<source>Pattern muted</source>
<translation>Patró apagat</translation>
</message>
<message>
<source>The track this pattern belongs to or the pattern itself is currently muted therefore freezing makes no sense! Do you still want to continue?</source>
<translation>La pista a la que pertany aquest patró o el patró mateix està apagat actualment, per tant congelar no sentit! Encara vols continuar?</translation>
</message>
<message>
<source>Add steps</source>
<translation>Afegeix passos</translation>

View File

@@ -1,7 +1,7 @@
/*
* clipboard.h - the clipboard for patterns, notes etc.
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -48,13 +48,24 @@
class journallingObject;
namespace clipboard
class clipboard
{
public:
typedef QMap<QString, QDomElement> map;
extern map content;
void FASTCALL copy( journallingObject * _object );
const QDomElement * FASTCALL getContent( const QString & _node_name );
static void FASTCALL copy( journallingObject * _object );
static const QDomElement * FASTCALL getContent(
const QString & _node_name );
static const char * mimeType( void )
{
return( "application/x-lmms-clipboard" );
}
private:
static map content;
} ;
#endif

View File

@@ -50,10 +50,16 @@
#include "side_bar_widget.h"
#ifndef QT3
class QListViewItem;
#else
class Q3ListViewItem;
#endif
class QPixmap;
class fileItem;
class listView;
class playHandle;
class QPixmap;
class trackContainer;
@@ -76,13 +82,10 @@ public slots:
protected slots:
#ifdef QT4
void contextMenuRequest( Q3ListViewItem * _i, const QPoint & _pos,
int _col );
#else
void contextMenuRequest( QListViewItem * _i, const QPoint & _pos,
int _col );
#endif
void sendToActiveInstrumentTrack( void );
void openInNewInstrumentTrackSE( void );
void openInNewInstrumentTrackBBE( void );
@@ -132,7 +135,16 @@ private:
class directory : public Q3ListViewItem
class directory :
#ifndef QT3
public Q3ListViewItem
// trick moc
#if 0
,
#endif
#else
public QListViewItem
#endif
{
public:
directory( Q3ListView * _parent, const QString & _filename,
@@ -186,13 +198,27 @@ private:
class fileItem : public Q3ListViewItem
class fileItem :
#ifndef QT3
public Q3ListViewItem
// trick moc
#if 0
,
#endif
#else
public QListViewItem
#endif
{
public:
fileItem( Q3ListView * _parent, const QString & _name,
const QString & _path );
#ifndef QT3
fileItem( Q3ListViewItem * _parent, const QString & _name,
const QString & _path );
#else
fileItem( QListViewItem * _parent, const QString & _name,
const QString & _path );
#endif
inline QString fullName( void ) const
{

View File

@@ -56,14 +56,20 @@ public:
return( m_led->isChecked() );
}
void saveSettings( QDomDocument & _doc, QDomElement & _this,
const QString & _name );
void loadSettings( const QDomElement & _this, const QString & _name );
public slots:
void setState( bool _on, bool _anim = FALSE );
void animate( void );
signals:
void toggled( bool _state );
protected:
virtual void resizeEvent( QResizeEvent * _re );
virtual void mousePressEvent( QMouseEvent * _me );

View File

@@ -48,6 +48,7 @@
#endif
class QAction;
class QDomElement;
class QGridLayout;
class QSplashScreen;
@@ -108,6 +109,7 @@ public slots:
QWhatsThis::enterWhatsThisMode();
}
void createNewProject( void );
void createNewProjectFromTemplate( QAction * _idx );
void createNewProjectFromTemplate( int _idx );
void openProject( void );
bool saveProject( void );
@@ -174,6 +176,7 @@ private:
private slots:
void browseHelp( void );
void fillTemplatesMenu( void );
void showTool( QAction * _idx );
void showTool( int _idx );
} ;

View File

@@ -39,6 +39,11 @@
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "types.h"
@@ -52,6 +57,7 @@ public:
SONG_PROJECT_TEMPLATE,
INSTRUMENT_TRACK_SETTINGS,
DRAG_N_DROP_DATA,
CLIPBOARD_DATA,
JOURNAL_DATA,
EFFECT_SETTINGS,
VIDEO_PROJECT, // might come later...

View File

@@ -161,11 +161,16 @@ public:
return( m_panning );
}
inline virtual QString nodeName( void ) const
static QString classNodeName( void )
{
return( "note" );
}
inline virtual QString nodeName( void ) const
{
return( classNodeName() );
}
static midiTime FASTCALL quantized( const midiTime & _m,
const int _q_grid );
@@ -175,7 +180,6 @@ public:
}
void editDetuningPattern( void );
void detachCurrentDetuning( void );
bool hasDetuningInfo( void );

View File

@@ -105,7 +105,7 @@ protected:
virtual bool x11Event( XEvent * _xe );
#endif
int FASTCALL getKey( int _y );
int FASTCALL getKey( int _y ) const;
static inline void drawNoteRect( QPainter & _p, Uint16 _x, Uint16 _y,
Sint16 _width,
const bool _is_selected,
@@ -239,7 +239,6 @@ private:
int m_startKey; // first key when drawing
int m_lastKey;
noteVector m_notesToCopy;
noteVector m_selNotesForMove;
@@ -249,6 +248,8 @@ private:
timeLine * m_timeLine;
bool m_scrollBack;
void copy_to_clipboard( const noteVector & _notes ) const;
void drawDetuningInfo( QPainter & _p, note * _n, Uint16 _x, Uint16 _y );
bool mouseOverNote( void );
note * noteUnderMouse( void );

View File

@@ -94,9 +94,9 @@ protected:
private:
int FASTCALL getKeyFromMouse( const QPoint & _p );
int FASTCALL getKeyFromMouse( const QPoint & _p ) const;
int FASTCALL getKeyFromKeyboard( int _k ) const;
int FASTCALL getKeyX( int _key_num );
int FASTCALL getKeyX( int _key_num ) const;
static QPixmap * s_whiteKeyPm;
static QPixmap * s_blackKeyPm;

View File

@@ -48,10 +48,12 @@ public:
virtual bool isFromTrack( const track * _track ) const;
static void init( void );
static void cleanUp( void );
static constNotePlayHandleVector nphsOfInstrumentTrack(
const instrumentTrack * _ct );
private:
static previewTrackContainer * s_previewTC;

View File

@@ -53,7 +53,6 @@ class QColorGroup;
typedef int csize;
#define QListViewItem Q3ListViewItem
#define vlist QList
#define vstack QStack
@@ -82,7 +81,6 @@ inline QString baseName( const QString & _file )
#define QScrollArea QScrollView
#define Q3ListView QListView
#define Q3ListViewItem QListViewItem
#define Q3ScrollView QScrollView
#define QMatrix QWMatrix

View File

@@ -59,7 +59,7 @@ public:
surroundArea( QWidget * _parent, const QString & _name,
track * _track );
virtual ~surroundArea();
volumeVector getVolumeVector( float _v_scale = 0.0f ) const;
volumeVector getVolumeVector( float _v_scale ) const;
inline const QPoint & value( void ) const
{
return( m_sndSrcPos );
@@ -85,12 +85,8 @@ signals:
private:
float FASTCALL getVolume( const QPoint & _speaker_pos,
float _v_scale ) const;
QPoint m_sndSrcPos;
static const QPoint s_defaultSpeakerPositions[SURROUND_CHANNELS];
static QPixmap * s_backgroundArtwork;
knob * m_position_x;

View File

@@ -648,11 +648,11 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc,
QDomElement & _this )
{
_this.setAttribute( "chorddisabled", !m_chordsGroupBox->isActive() );
m_chordsGroupBox->saveSettings( _doc, _this, "chord-enabled" );
m_chordsComboBox->saveSettings( _doc, _this, "chord" );
m_chordRangeKnob->saveSettings( _doc, _this, "chordrange" );
_this.setAttribute( "arpdisabled", !m_arpGroupBox->isActive() );
m_arpGroupBox->saveSettings( _doc, _this, "arp-enabled" );
m_arpComboBox->saveSettings( _doc, _this, "arp" );
m_arpRangeKnob->saveSettings( _doc, _this, "arprange" );
m_arpTimeKnob->saveSettings( _doc, _this, "arptime" );
@@ -667,16 +667,16 @@ void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc,
void arpAndChordsTabWidget::loadSettings( const QDomElement & _this )
{
m_chordsGroupBox->setState( !_this.attribute
( "chorddisabled" ).toInt() );
m_chordsGroupBox->loadSettings( _this, "chord-enabled" );
m_chordsComboBox->loadSettings( _this, "chord" );
m_chordRangeKnob->loadSettings( _this, "chordrange" );
m_arpGroupBox->loadSettings( _this, "arp-enabled" );
m_arpComboBox->loadSettings( _this, "arp" );
m_arpRangeKnob->loadSettings( _this, "arprange" );
m_arpTimeKnob->loadSettings( _this, "arptime" );
m_arpGateKnob->loadSettings( _this, "arpgate" );
m_arpDirectionBtnGrp->loadSettings( _this, "arpdir" );
m_arpGroupBox->setState( !_this.attribute( "arpdisabled" ).toInt() );
// Keep compatibility with version 2.1 file format
if( _this.hasAttribute( "arpsyncmode" ) )

View File

@@ -83,6 +83,8 @@ void engine::init( const bool _has_gui )
s_mainWindow->finalize();
presetPreviewPlayHandle::init();
s_mixer->startProcessing();
}
@@ -110,10 +112,6 @@ void engine::destroy( void )
presetPreviewPlayHandle::cleanUp();
// now we can clean up all allocated buffer
//bufferAllocator::cleanUp( 0 );
delete s_mixer;
s_mixer = NULL;
//delete configManager::inst();

View File

@@ -50,7 +50,6 @@
#include "instrument_track.h"
#include "knob.h"
#include "note_play_handle.h"
#include "pixmap_button.h"
#include "tab_widget.h"
@@ -468,7 +467,7 @@ void envelopeTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _this )
m_filterComboBox->saveSettings( _doc, _this, "ftype" );
m_filterCutKnob->saveSettings( _doc, _this, "fcut" );
m_filterResKnob->saveSettings( _doc, _this, "fres" );
_this.setAttribute( "fwet", m_filterGroupBox->isActive() );
m_filterGroupBox->saveSettings( _doc, _this, "fwet" );
for( int i = 0; i < TARGET_COUNT; ++i )
{
@@ -486,8 +485,7 @@ void envelopeTabWidget::loadSettings( const QDomElement & _this )
m_filterComboBox->loadSettings( _this, "ftype" );
m_filterCutKnob->loadSettings( _this, "fcut" );
m_filterResKnob->loadSettings( _this, "fres" );
/* m_filterState->setChecked( _this.attribute( "fwet" ).toInt() );*/
m_filterGroupBox->setState( _this.attribute( "fwet" ).toInt() );
m_filterGroupBox->loadSettings( _this, "fwet" );
QDomNode node = _this.firstChild();
while( !node.isNull() )

View File

@@ -123,7 +123,11 @@ void fileBrowser::reloadTree( void )
addItems( *it );
}
#ifndef QT3
Q3ListViewItem * item = m_l->firstChild();
#else
QListViewItem * item = m_l->firstChild();
#endif
bool resort = FALSE;
// sort merged directories
@@ -136,7 +140,11 @@ void fileBrowser::reloadTree( void )
}
else if( resort == TRUE )
{
#ifndef QT3
Q3ListViewItem * i2 = m_l->firstChild();
#else
QListViewItem * i2 = m_l->firstChild();
#endif
d->moveItem( i2 );
i2->moveItem( d );
directory * d2 = NULL;
@@ -191,7 +199,11 @@ void fileBrowser::addItems( const QString & _path )
isDirWithContent( _path + QDir::separator() + cur_file,
m_filter ) )
{
#ifdef QT4
Q3ListViewItem * item = m_l->findItem( cur_file, 0 );
#else
QListViewItem * item = m_l->findItem( cur_file, 0 );
#endif
if( item == NULL )
{
(void) new directory( m_l, cur_file, _path,
@@ -262,7 +274,6 @@ void fileBrowser::keyPressEvent( QKeyEvent * _ke )
#ifdef QT4
void fileBrowser::contextMenuRequest( Q3ListViewItem * i, const QPoint &, int )
#else
@@ -296,6 +307,17 @@ void fileBrowser::contextMenuRequest( QListViewItem * i, const QPoint &, int )
#ifdef QT4
void fileBrowser::contextMenuRequest( QListViewItem * i, const QPoint &, int )
#else
void fileBrowser::contextMenuRequest( Q3ListViewItem * i, const QPoint &, int )
#endif
{
}
void fileBrowser::sendToActiveInstrumentTrack( void )
{
if( engine::getMainWindow()->workspace() == NULL )
@@ -517,7 +539,11 @@ void listView::contentsMousePressEvent( QMouseEvent * _me )
}
QPoint p( contentsToViewport( _me->pos() ) );
#ifndef QT3
Q3ListViewItem * i = itemAt( p );
#else
QListViewItem * i = itemAt( p );
#endif
if ( i )
{
if ( p.x() > header()->cellPos( header()->mapToActual( 0 ) ) +
@@ -660,7 +686,11 @@ QPixmap * directory::s_folderLockedPixmap = NULL;
directory::directory( directory * _parent, const QString & _name,
const QString & _path, const QString & _filter ) :
#ifndef QT3
Q3ListViewItem( _parent, _name ),
#else
QListViewItem( _parent, _name ),
#endif
m_p( _parent ),
m_pix( NULL ),
m_directories( _path ),
@@ -674,7 +704,11 @@ directory::directory( directory * _parent, const QString & _name,
directory::directory( Q3ListView * _parent, const QString & _name,
const QString & _path, const QString & _filter ) :
#ifndef QT3
Q3ListViewItem( _parent, _name ),
#else
QListViewItem( _parent, _name ),
#endif
m_p( NULL ),
m_pix( NULL ),
m_directories( _path ),
@@ -752,13 +786,21 @@ void directory::setOpen( bool _o )
( *it ).contains(
configManager::inst()->dataDir() ) )
{
#ifndef QT3
( new Q3ListViewItem( this,
#else
( new QListViewItem( this,
#endif
listView::tr( "--- Factory files ---" ) ) )->setPixmap( 0,
embed::getIconPixmap( "factory_files" ) );
}
}
}
#ifndef QT3
Q3ListViewItem::setOpen( _o );
#else
QListViewItem::setOpen( _o );
#endif
}
@@ -767,7 +809,11 @@ void directory::setOpen( bool _o )
void directory::setup( void )
{
setExpandable( TRUE );
#ifndef QT3
Q3ListViewItem::setup();
#else
QListViewItem::setup();
#endif
}
@@ -863,7 +909,11 @@ QPixmap * fileItem::s_unknownFilePixmap = NULL;
fileItem::fileItem( Q3ListView * _parent, const QString & _name,
const QString & _path ) :
#ifndef QT3
Q3ListViewItem( _parent, _name ),
#else
QListViewItem( _parent, _name ),
#endif
m_pix( NULL ),
m_path( _path )
{
@@ -875,9 +925,15 @@ fileItem::fileItem( Q3ListView * _parent, const QString & _name,
#ifndef QT3
fileItem::fileItem( Q3ListViewItem * _parent, const QString & _name,
const QString & _path ) :
Q3ListViewItem( _parent, _name ),
#else
fileItem::fileItem( QListViewItem * _parent, const QString & _name,
const QString & _path ) :
QListViewItem( _parent, _name ),
#endif
m_pix( NULL ),
m_path( _path )
{

View File

@@ -273,8 +273,13 @@ void mainWindow::finalize( void )
m_templatesMenu = new QMenu( project_new );
connect( m_templatesMenu, SIGNAL( aboutToShow( void ) ),
this, SLOT( fillTemplatesMenu( void ) ) );
#ifdef QT4
connect( m_templatesMenu, SIGNAL( triggered( QAction * ) ),
this, SLOT( createNewProjectFromTemplate( QAction * ) ) );
#else
connect( m_templatesMenu, SIGNAL( activated( int ) ),
this, SLOT( createNewProjectFromTemplate( int ) ) );
#endif
project_new->setMenu( m_templatesMenu );
#ifdef QT4
project_new->setPopupMode( toolButton::MenuButtonPopup );
@@ -539,11 +544,13 @@ void mainWindow::finalize( void )
{
#ifdef QT4
menuBar()->addMenu( m_tools_menu )->setText( tr( "&Tools" ) );
connect( m_tools_menu, SIGNAL( triggered( QAction * ) ),
this, SLOT( showTool( QAction * ) ) );
#else
menuBar()->insertItem( tr( "&Tools" ), m_tools_menu );
#endif
connect( m_tools_menu, SIGNAL( activated( int ) ),
this, SLOT( showTool( int ) ) );
#endif
}
@@ -724,23 +731,42 @@ void mainWindow::createNewProject( void )
void mainWindow::createNewProjectFromTemplate( int _idx )
{
#ifdef QT4
// TODO!!!
void mainWindow::createNewProjectFromTemplate( QAction * _idx )
#else
void mainWindow::createNewProjectFromTemplate( int _idx )
#endif
{
if( m_templatesMenu != NULL &&
engine::getSongEditor()->mayChangeProject() == TRUE )
{
#ifdef QT4
QString dir_base = m_templatesMenu->actions().indexOf( _idx )
#else
QString dir_base = m_templatesMenu->indexOf( _idx )
#endif
>= m_custom_templates_count ?
configManager::inst()->factoryProjectsDir() :
configManager::inst()->userProjectsDir();
engine::getSongEditor()->createNewProjectFromTemplate(
dir_base + "templates/" +
#ifdef QT4
_idx->text() + ".mpt" );
#else
m_templatesMenu->text( _idx ) + ".mpt" );
}
#endif
}
}
#ifdef QT4
void mainWindow::createNewProjectFromTemplate( int _idx )
#else
void mainWindow::createNewProjectFromTemplate( QAction * _idx )
#endif
{
}
@@ -1094,15 +1120,30 @@ void mainWindow::fillTemplatesMenu( void )
#ifndef QT3
void mainWindow::showTool( QAction * _idx )
#else
void mainWindow::showTool( int _idx )
#endif
{
#ifndef QT3
#warning TODO: Qt4-implementation
tool * t = m_tools[m_tools_menu->actions().indexOf( _idx )];
#else
tool * t = m_tools[m_tools_menu->indexOf( _idx )];
#endif
t->show();
t->setFocus();
}
#ifndef QT3
void mainWindow::showTool( int _idx )
#else
void mainWindow::showTool( QAction * _idx )
#endif
{
}

View File

@@ -299,19 +299,6 @@ void note::createDetuning( void )
void note::detachCurrentDetuning( void )
{
QDomDocument doc;
QDomElement parent = doc.createElement( "clone" );
m_detuning->saveSettings( doc, parent );
sharedObject::unref( m_detuning );
createDetuning();
m_detuning->loadSettings( parent );
}
bool note::hasDetuningInfo( void )
{
automationPattern::timeMap map =

View File

@@ -33,6 +33,7 @@
#include <Qt/QtXml>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QClipboard>
#include <QtGui/QPainter>
#include <QtGui/QKeyEvent>
#include <QtGui/QWheelEvent>
@@ -43,10 +44,12 @@
#include <qapplication.h>
#include <qbuttongroup.h>
#include <qpainter.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qclipboard.h>
#include <qdom.h>
#include <qdragobject.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpainter.h>
#define addButton insert
#define setCheckable setToggleButton
@@ -63,6 +66,7 @@
#include "piano_roll.h"
#include "automatable_object_templates.h"
#include "clipboard.h"
#include "combobox.h"
#include "debug.h"
#include "detuning_helper.h"
@@ -71,6 +75,7 @@
#include "instrument_track.h"
#include "main_window.h"
#include "midi.h"
#include "mmp.h"
#include "pattern.h"
#include "piano_widget.h"
#include "pixmap_button.h"
@@ -2159,7 +2164,7 @@ void pianoRoll::wheelEvent( QWheelEvent * _we )
int pianoRoll::getKey( int _y )
int pianoRoll::getKey( int _y ) const
{
int key_line_y = height() - PR_BOTTOM_MARGIN - m_notesEditHeight - 1;
// pressed key on piano
@@ -2437,31 +2442,46 @@ void pianoRoll::getSelectedNotes( noteVector & _selected_notes )
void pianoRoll::copySelectedNotes( void )
void pianoRoll::copy_to_clipboard( const noteVector & _notes ) const
{
for( noteVector::iterator it = m_notesToCopy.begin();
it != m_notesToCopy.end(); ++it )
multimediaProject mmp( multimediaProject::CLIPBOARD_DATA );
QDomElement note_list = mmp.createElement( "note-list" );
mmp.content().appendChild( note_list );
midiTime start_pos( _notes.front()->pos().getTact(), 0 );
for( noteVector::const_iterator it = _notes.begin(); it != _notes.end();
++it )
{
delete *it;
note clip_note( **it );
clip_note.setPos( clip_note.pos( start_pos ) );
clip_note.saveState( mmp, note_list );
}
m_notesToCopy.clear();
#ifdef QT4
QMimeData * clip_content = new QMimeData;
clip_content->setData( clipboard::mimeType(), mmp.toString().toUtf8() );
QApplication::clipboard()->setMimeData( clip_content,
QClipboard::Clipboard );
#else
QStoredDrag * clip_content = new QStoredDrag( clipboard::mimeType() );
clip_content->setEncodedData( mmp.toString().utf8() );
QApplication::clipboard()->setData( clip_content,
QClipboard::Clipboard );
#endif
}
void pianoRoll::copySelectedNotes( void )
{
noteVector selected_notes;
getSelectedNotes( selected_notes );
if( selected_notes.empty() == FALSE )
{
midiTime start_pos( selected_notes.front()->pos().getTact(),
0 );
for( noteVector::iterator it = selected_notes.begin();
it != selected_notes.end(); ++it )
{
m_notesToCopy.push_back( new note( **it ) );
m_notesToCopy.back()->setPos( m_notesToCopy.back()->pos(
start_pos ) );
m_notesToCopy.back()->detachCurrentDetuning();
}
copy_to_clipboard( selected_notes );
textFloat::displayMessage( tr( "Notes copied" ),
tr( "All selected notes were copied to the "
"clipboard." ),
@@ -2479,34 +2499,21 @@ void pianoRoll::cutSelectedNotes( void )
return;
}
for( noteVector::iterator it = m_notesToCopy.begin();
it != m_notesToCopy.end(); ++it )
{
delete *it;
}
m_notesToCopy.clear();
noteVector selected_notes;
getSelectedNotes( selected_notes );
if( selected_notes.empty() == FALSE )
{
copy_to_clipboard( selected_notes );
engine::getSongEditor()->setModified();
midiTime start_pos( selected_notes.front()->pos().getTact(),
0 );
while( selected_notes.empty() == FALSE )
for( noteVector::iterator it = selected_notes.begin();
it != selected_notes.end(); ++it )
{
note * new_note = new note( *selected_notes.front() );
new_note->setPos( new_note->pos( start_pos ) );
m_notesToCopy.push_back( new_note );
// note (the memory of it) is also deleted by
// pattern::removeNote(...) so we don't have to do that
m_pattern->removeNote( selected_notes.front() );
selected_notes.erase( selected_notes.begin() );
m_pattern->removeNote( *it );
}
}
@@ -2524,14 +2531,26 @@ void pianoRoll::pasteNotes( void )
return;
}
if( m_notesToCopy.empty() == FALSE )
#ifdef QT4
QString value = QApplication::clipboard()
->mimeData( QClipboard::Clipboard )
->data( clipboard::mimeType() );
#else
QString value = QApplication::clipboard()->data( QClipboard::Clipboard )
->encodedData( clipboard::mimeType() );
#endif
if( !value.isEmpty() )
{
for( noteVector::iterator it = m_notesToCopy.begin();
it != m_notesToCopy.end(); ++it )
multimediaProject mmp( value, FALSE );
QDomNodeList list = mmp.elementsByTagName(
note::classNodeName() );
for( int i = 0; !list.item( i ).isNull(); ++i )
{
note cur_note( **it );
note cur_note;
cur_note.restoreState( list.item( i ).toElement() );
cur_note.setPos( cur_note.pos() + m_currentPosition );
cur_note.detachCurrentDetuning();
m_pattern->addNote( cur_note );
}

View File

@@ -177,7 +177,7 @@ pianoWidget::~pianoWidget()
// gets the key from the given mouse-position
int pianoWidget::getKeyFromMouse( const QPoint & _p )
int pianoWidget::getKeyFromMouse( const QPoint & _p ) const
{
int key_num = (int)( (float) _p.x() / (float) PW_WHITE_KEY_WIDTH );
@@ -220,9 +220,7 @@ int pianoWidget::getKeyFromMouse( const QPoint & _p )
}
// some range-checking-stuff
key_num = tLimit( key_num, 0, NOTES_PER_OCTAVE * OCTAVES - 1 );
return( m_lastKey = key_num );
return( tLimit( key_num, 0, NOTES_PER_OCTAVE * OCTAVES - 1 ) );
}
@@ -301,6 +299,7 @@ void pianoWidget::mousePressEvent( QMouseEvent * _me )
vol * 127 / 100 ),
midiTime() );
m_pressedKeys[key_num] = TRUE;
m_lastKey = key_num;
}
else
{
@@ -319,14 +318,17 @@ void pianoWidget::mousePressEvent( QMouseEvent * _me )
// handler for mouse-release-event
void pianoWidget::mouseReleaseEvent( QMouseEvent * _me )
{
int released_key = getKeyFromMouse( _me->pos() );
if( m_lastKey != -1 )
{
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, m_lastKey, 0 ), midiTime() );
m_pressedKeys[m_lastKey] = FALSE;
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, released_key, 0 ), midiTime() );
m_pressedKeys[released_key] = FALSE;
// and let the user see that he released a key... :)
update();
// and let the user see that he released a key... :)
update();
m_lastKey = -1;
}
}
@@ -335,8 +337,6 @@ void pianoWidget::mouseReleaseEvent( QMouseEvent * _me )
// handler for mouse-move-event
void pianoWidget::mouseMoveEvent( QMouseEvent * _me )
{
// save current last-key-var
int released_key = m_lastKey;
int key_num = getKeyFromMouse( _me->pos() );
int y_diff = _me->pos().y() - PIANO_BASE;
volume vol = (volume)( (float) y_diff /
@@ -359,14 +359,15 @@ void pianoWidget::mouseMoveEvent( QMouseEvent * _me )
// is the calculated key different from current key? (could be the
// user just moved the cursor one pixel left but on the same key)
if( key_num != released_key )
if( key_num != m_lastKey )
{
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, released_key, 0 ),
midiTime() );
if( released_key >= 0 )
if( m_lastKey != -1 )
{
m_pressedKeys[released_key] = FALSE;
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, m_lastKey, 0 ),
midiTime() );
m_pressedKeys[m_lastKey] = FALSE;
m_lastKey = -1;
}
#ifdef QT4
if( _me->buttons() & Qt::LeftButton )
@@ -380,6 +381,7 @@ void pianoWidget::mouseMoveEvent( QMouseEvent * _me )
midiEvent( NOTE_ON, 0, key_num, vol ),
midiTime() );
m_pressedKeys[key_num] = TRUE;
m_lastKey = key_num;
}
else
{
@@ -529,7 +531,7 @@ void pianoWidget::focusOutEvent( QFocusEvent * )
int pianoWidget::getKeyX( int _key_num )
int pianoWidget::getKeyX( int _key_num ) const
{
int k = m_startOctave*NOTES_PER_OCTAVE + m_startTone;
if( _key_num < k )

View File

@@ -128,11 +128,6 @@ presetPreviewPlayHandle::presetPreviewPlayHandle(
playHandle( PresetPreviewHandle ),
m_previewNote( NULL )
{
if( !s_previewTC )
{
s_previewTC = new previewTrackContainer;
}
s_previewTC->lockData();
if( s_previewTC->previewNote() != NULL )
@@ -213,6 +208,17 @@ bool presetPreviewPlayHandle::isFromTrack( const track * _track ) const
void presetPreviewPlayHandle::init( void )
{
if( !s_previewTC )
{
s_previewTC = new previewTrackContainer;
}
}
void presetPreviewPlayHandle::cleanUp( void )
{
delete s_previewTC;

View File

@@ -60,16 +60,6 @@
const QPoint surroundArea::s_defaultSpeakerPositions[SURROUND_CHANNELS] =
{
QPoint( -SURROUND_AREA_SIZE, -SURROUND_AREA_SIZE ),
QPoint( SURROUND_AREA_SIZE, -SURROUND_AREA_SIZE)
#ifndef DISABLE_SURROUND
,
QPoint( -SURROUND_AREA_SIZE, SURROUND_AREA_SIZE ),
QPoint( SURROUND_AREA_SIZE, SURROUND_AREA_SIZE )
#endif
} ;
QPixmap * surroundArea::s_backgroundArtwork = NULL;
@@ -131,12 +121,39 @@ surroundArea::~surroundArea()
volumeVector surroundArea::getVolumeVector( float _v_scale ) const
{
volumeVector v;
for( Uint8 chnl = 0; chnl < SURROUND_CHANNELS; ++chnl )
volumeVector v = { { _v_scale, _v_scale
#ifndef DISABLE_SURROUND
, _v_scale, _v_scale
#endif
} } ;
if( m_sndSrcPos.x() >= 0 )
{
v.vol[chnl] = getVolume( s_defaultSpeakerPositions[chnl],
_v_scale );
v.vol[0] *= 1.0f - m_sndSrcPos.x() / (float)SURROUND_AREA_SIZE;
#ifndef DISABLE_SURROUND
v.vol[2] *= 1.0f - m_sndSrcPos.x() / (float)SURROUND_AREA_SIZE;
#endif
}
else
{
v.vol[1] *= 1.0f + m_sndSrcPos.x() / (float)SURROUND_AREA_SIZE;
#ifndef DISABLE_SURROUND
v.vol[3] *= 1.0f + m_sndSrcPos.x() / (float)SURROUND_AREA_SIZE;
#endif
}
if( m_sndSrcPos.y() >= 0 )
{
v.vol[0] *= 1.0f - m_sndSrcPos.y() / (float)SURROUND_AREA_SIZE;
v.vol[1] *= 1.0f - m_sndSrcPos.y() / (float)SURROUND_AREA_SIZE;
}
#ifndef DISABLE_SURROUND
else
{
v.vol[2] *= 1.0f + m_sndSrcPos.y() / (float)SURROUND_AREA_SIZE;
v.vol[3] *= 1.0f + m_sndSrcPos.y() / (float)SURROUND_AREA_SIZE;
}
#endif
return( v );
}
@@ -162,20 +179,6 @@ void surroundArea::setValue( const QPoint & _p )
FASTCALL float surroundArea::getVolume( const QPoint & _speaker_pos,
float _v_scale ) const
{
const int x = _speaker_pos.x() - m_sndSrcPos.x();
const int y = _speaker_pos.y() - m_sndSrcPos.y();
const float new_vol = 2.0f - sqrt( x*x + y*y ) *
( 1.0f / SURROUND_AREA_SIZE );
return( tLimit( new_vol, 0.0f, 1.0f ) * _v_scale );
}
void surroundArea::contextMenuEvent( QContextMenuEvent * )
{
// for the case, the user clicked right while pressing left mouse-

View File

@@ -1424,7 +1424,9 @@ void trackWidget::dropEvent( QDropEvent * _de )
// value contains our XML-data so simply create a
// multimediaProject which does the rest for us...
multimediaProject mmp( value, FALSE );
engine::getMixer()->lock();
m_track->restoreState( mmp.content().firstChild().toElement() );
engine::getMixer()->unlock();
_de->accept();
}
}
@@ -1734,11 +1736,7 @@ void track::loadSettings( const QDomElement & _this )
{
if( node.isElement() )
{
if( node.nodeName() == nodeName() ||
#warning compat-code, remove in 0.3.0
( node.nodeName() == "channeltrack" &&
nodeName() == "instrumenttrack" )
)
if( node.nodeName() == nodeName() )
{
loadTrackSpecificSettings( node.toElement() );
}

View File

@@ -3,7 +3,7 @@
/*
* clipboard.cpp - the clipboard for patterns, notes etc.
*
* Copyright (c) 2004-2005 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2004-2007 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -29,34 +29,34 @@
#include "journalling_object.h"
namespace clipboard
clipboard::map clipboard::content;
void clipboard::copy( journallingObject * _obj )
{
map content;
QDomDocument doc;
QDomElement parent = doc.createElement( "clipboard" );
_obj->saveState( doc, parent );
content[_obj->nodeName()] = parent.firstChild().toElement();
}
void copy( journallingObject * _obj )
const QDomElement * clipboard::getContent( const QString & _node_name )
{
if( content.find( _node_name ) != content.end() )
{
QDomDocument doc;
QDomElement parent = doc.createElement( "clipboard" );
_obj->saveState( doc, parent );
content[_obj->nodeName()] = parent.firstChild().toElement();
return( &content[_node_name] );
}
return( NULL );
}
const QDomElement * getContent( const QString & _node_name )
{
if( content.find( _node_name ) != content.end() )
{
return( &content[_node_name] );
}
return( NULL );
}
} ;
#endif

View File

@@ -25,7 +25,9 @@
*/
#include "qt3support.h"
#include "mmp.h"
#include <math.h>
#ifdef QT4
@@ -39,12 +41,7 @@
#endif
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "mmp.h"
#include "config_mgr.h"
#include "project_version.h"
#include "song_editor.h"
@@ -56,10 +53,11 @@ multimediaProject::typeDescStruct
{ multimediaProject::UNKNOWN, "unknown" },
{ multimediaProject::SONG_PROJECT, "song" },
{ multimediaProject::SONG_PROJECT_TEMPLATE, "songtemplate" },
#warning compat-code, remove in 0.3.0
#warning compat-code, use upgrade feature
{ multimediaProject::INSTRUMENT_TRACK_SETTINGS,
"instrumenttracksettings,channelsettings" },
{ multimediaProject::DRAG_N_DROP_DATA, "dnddata" },
{ multimediaProject::CLIPBOARD_DATA, "clipboard-data" },
{ multimediaProject::JOURNAL_DATA, "journaldata" },
{ multimediaProject::EFFECT_SETTINGS, "effectsettings" },
{ multimediaProject::VIDEO_PROJECT, "videoproject" },
@@ -177,7 +175,7 @@ multimediaProject::multimediaProject( const QString & _in_file_name,
m_head = node.toElement();
}
else if( node.nodeName() == typeName( m_type ) ||
#warning compat-code, remove in 0.3.0
#warning compat-code, use upgrade feature
node.nodeName() == "channelsettings" )
{
m_content = node.toElement();
@@ -363,7 +361,7 @@ QString multimediaProject::typeName( projectTypes _project_type )
if( _project_type >= UNKNOWN && _project_type < PROJ_TYPE_COUNT )
{
return( s_types[_project_type].m_name
#warning compat-code, remove in 0.3.0
#warning compat-code, use upgrade feature
.section( ',', 0, 0 )
);
}
@@ -519,6 +517,61 @@ void multimediaProject::upgrade( void )
node = node.nextSibling();
}
}
if( version < "0.2.1-svn20070508" )
{
QDomNodeList list = elementsByTagName( "arpandchords" );
for( int i = 0; !list.item( i ).isNull(); ++i )
{
QDomElement el = list.item( i ).toElement();
if( el.hasAttribute( "chorddisabled" ) )
{
el.setAttribute( "chord-enabled",
!el.attribute( "chorddisabled" )
.toInt() );
el.setAttribute( "arp-enabled",
!el.attribute( "arpdisabled" )
.toInt() );
}
}
list = elementsByTagName( "channeltrack" );
for( int i = 0; !list.item( i ).isNull(); ++i )
{
QDomElement el = list.item( i ).toElement();
el.setTagName( "instrumenttrack" );
}
list = elementsByTagName( "instrumenttrack" );
for( int i = 0; !list.item( i ).isNull(); ++i )
{
QDomElement el = list.item( i ).toElement();
if( el.hasAttribute( "vol" ) )
{
float value = el.attribute( "vol" ).toFloat();
value = roundf( value * 0.585786438f );
el.setAttribute( "vol", value );
}
else
{
QDomNodeList vol_list = el.namedItem(
"automation-pattern" )
.namedItem( "vol" ).toElement()
.elementsByTagName( "time" );
for( int j = 0; !vol_list.item( j ).isNull();
++j )
{
QDomElement timeEl = list.item( j )
.toElement();
int value = timeEl.attribute( "value" )
.toInt();
value = (int)roundf( value *
0.585786438f );
timeEl.setAttribute( "value", value );
}
}
}
}
}

View File

@@ -960,7 +960,7 @@ bool FASTCALL instrumentTrack::play( const midiTime & _start,
trackContentObject * tco = getTCO( _tco_num );
tcos.push_back( tco );
bb_track = bbTrack::findBBTrack( _tco_num );
if( !( bb_track->automationDisabled( this )
if( !( ( bb_track && bb_track->automationDisabled( this ) )
|| dynamic_cast<pattern *>( tco )->empty() ) )
{
sendMidiTime( _start );

View File

@@ -527,33 +527,6 @@ void pattern::freeze( void )
QMessageBox::Ok );
return;
}
if( m_instrumentTrack->muted() || muted() )
{
if( QMessageBox::
#if QT_VERSION >= 0x030200
question
#else
information
#endif
( 0, tr( "Pattern muted" ),
tr( "The track this pattern "
"belongs to or the "
"pattern itself is "
"currently muted "
"therefore "
"freezing makes no "
"sense! Do you still "
"want to continue?" ),
QMessageBox::Yes,
QMessageBox::No |
QMessageBox::Default |
QMessageBox::Escape ) ==
QMessageBox::No )
{
return;
}
}
// already frozen?
if( m_frozenPattern != NULL )
@@ -683,13 +656,24 @@ void pattern::constructContextMenu( QMenu * _cm )
this, SLOT( changeName() ) );
_cm->addSeparator();
_cm->addAction( embed::getIconPixmap( "freeze" ),
( m_frozenPattern != NULL )? tr( "Refreeze" ) : tr( "Freeze" ),
bool freeze_separator = FALSE;
if( !( m_instrumentTrack->muted() || muted() ) )
{
_cm->addAction( embed::getIconPixmap( "freeze" ),
m_frozenPattern ? tr( "Refreeze" ) : tr( "Freeze" ),
this, SLOT( freeze() ) );
_cm->addAction( embed::getIconPixmap( "unfreeze" ), tr( "Unfreeze" ),
this, SLOT( unfreeze() ) );
_cm->addSeparator();
freeze_separator = TRUE;
}
if( m_frozenPattern )
{
_cm->addAction( embed::getIconPixmap( "unfreeze" ),
tr( "Unfreeze" ), this, SLOT( unfreeze() ) );
freeze_separator = TRUE;
}
if( freeze_separator )
{
_cm->addSeparator();
}
#ifdef QT4
QMenu * add_step_menu = _cm->addMenu(

View File

@@ -253,6 +253,24 @@ void groupBox::updatePixmap( void )
void groupBox::saveSettings( QDomDocument & _doc, QDomElement & _this,
const QString & _name )
{
m_led->saveSettings( _doc, _this, _name );
}
void groupBox::loadSettings( const QDomElement & _this, const QString & _name )
{
m_led->loadSettings( _this, _name );
}
#include "group_box.moc"