improved undo/redo-system

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@109 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2006-03-21 13:42:28 +00:00
parent bf139a65e4
commit fe9dc8c391
88 changed files with 3327 additions and 772 deletions

View File

@@ -2,7 +2,7 @@
/*
* arp_and_chords_tab_widget.cpp - widget for use in arp/chord-tab of
* channel-window
* instrument-track-window
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -57,7 +57,7 @@
#include "tooltip.h"
#include "gui_templates.h"
#include "tempo_sync_knob.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "led_checkbox.h"
#include "preset_preview_play_handle.h"
#include "combobox.h"
@@ -194,10 +194,9 @@ const int ARP_GROUPBOX_HEIGHT = 240 - ARP_GROUPBOX_Y;
arpAndChordsTabWidget::arpAndChordsTabWidget( channelTrack * _channel_track ) :
QWidget( _channel_track->tabWidgetParent() ),
settings(),
engineObject( _channel_track->eng() )
arpAndChordsTabWidget::arpAndChordsTabWidget( instrumentTrack * _instrument_track ) :
QWidget( _instrument_track->tabWidgetParent() ),
journallingObject( _instrument_track->eng() )
{
m_chordsGroupBox = new groupBox( tr( "CHORDS" ), this, eng() );
m_chordsGroupBox->setGeometry( CHORDS_GROUPBOX_X, CHORDS_GROUPBOX_Y,
@@ -449,7 +448,8 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
break;
}
// create copy of base-note
note note_copy( 0, 0, (tones)( sub_note_key %
note note_copy( NULL, 0, 0,
(tones)( sub_note_key %
NOTES_PER_OCTAVE ),
(octaves)( sub_note_key /
NOTES_PER_OCTAVE ),
@@ -459,9 +459,9 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
// different
notePlayHandle * note_play_handle =
new notePlayHandle(
_n->getChannelTrack(),
_n->getInstrumentTrack(),
_n->framesAhead(),
_n->frames(), &note_copy );
_n->frames(), note_copy );
// add sub-note to base-note, now all stuff is
// done by notePlayHandle::play_note()
_n->addSubNote( note_play_handle );
@@ -484,12 +484,12 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
const int selected_arp = m_arpComboBox->value();
constNotePlayHandleVector cnphv = notePlayHandle::nphsOfChannelTrack(
_n->getChannelTrack() );
_n->getInstrumentTrack() );
if( m_arpModeComboBox->value() != FREE && cnphv.size() == 0 )
{
// maybe we're playing only a preset-preview-note?
cnphv = presetPreviewPlayHandle::nphsOfChannelTrack(
_n->getChannelTrack() );
_n->getInstrumentTrack() );
if( cnphv.size() == 0 )
{
// still nothing found here, so lets return
@@ -600,7 +600,7 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
}
// create new arp-note
note new_note( midiTime( 0 ), midiTime( 0 ),
note new_note( NULL, midiTime( 0 ), midiTime( 0 ),
static_cast<tones>( sub_note_key %
NOTES_PER_OCTAVE ),
static_cast<octaves>( sub_note_key /
@@ -612,14 +612,14 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
// duplicate note-play-handle, only ptr to note is different
// and is_arp_note=TRUE
notePlayHandle * note_play_handle = new notePlayHandle(
_n->getChannelTrack(),
_n->getInstrumentTrack(),
( ( m_arpModeComboBox->value() !=
FREE ) ?
cnphv.first()->framesAhead() :
_n->framesAhead() ) +
frames_processed,
gated_frames,
&new_note,
new_note,
TRUE );
// add sub-note to base-note - now all stuff is done by
@@ -643,24 +643,22 @@ void arpAndChordsTabWidget::processNote( notePlayHandle * _n )
void arpAndChordsTabWidget::saveSettings( QDomDocument & _doc,
QDomElement & _parent )
QDomElement & _this )
{
QDomElement act_de = _doc.createElement( nodeName() );
act_de.setAttribute( "chorddisabled", !m_chordsGroupBox->isActive() );
act_de.setAttribute( "chord", m_chordsComboBox->value() );
act_de.setAttribute( "chordrange", m_chordRangeKnob->value() );
_this.setAttribute( "chorddisabled", !m_chordsGroupBox->isActive() );
_this.setAttribute( "chord", m_chordsComboBox->value() );
_this.setAttribute( "chordrange", m_chordRangeKnob->value() );
act_de.setAttribute( "arpdisabled", !m_arpGroupBox->isActive() );
act_de.setAttribute( "arp", m_arpComboBox->value() );
act_de.setAttribute( "arprange", m_arpRangeKnob->value() );
act_de.setAttribute( "arptime", m_arpTimeKnob->value() );
act_de.setAttribute( "arpgate", m_arpGateKnob->value() );
act_de.setAttribute( "arpdir", m_arpDirectionBtnGrp->value() );
act_de.setAttribute( "arpsyncmode",
_this.setAttribute( "arpdisabled", !m_arpGroupBox->isActive() );
_this.setAttribute( "arp", m_arpComboBox->value() );
_this.setAttribute( "arprange", m_arpRangeKnob->value() );
_this.setAttribute( "arptime", m_arpTimeKnob->value() );
_this.setAttribute( "arpgate", m_arpGateKnob->value() );
_this.setAttribute( "arpdir", m_arpDirectionBtnGrp->value() );
_this.setAttribute( "arpsyncmode",
( int ) m_arpTimeKnob->getSyncMode() );
act_de.setAttribute( "arpmode", m_arpModeComboBox->value() );
_parent.appendChild( act_de );
_this.setAttribute( "arpmode", m_arpModeComboBox->value() );
}

View File

@@ -26,7 +26,7 @@
#include "bb_editor.h"
#include "edit_history.h"
#include "project_journal.h"
#include "engine.h"
#include "main_window.h"
#include "mixer.h"
@@ -43,9 +43,9 @@ engine::engine( const bool _has_gui ) :
m_songEditor( NULL ),
m_bbEditor( NULL ),
m_pianoRoll( NULL ),
m_editHistory( NULL )
m_projectJournal( NULL )
{
m_editHistory = new editHistory( this );
m_projectJournal = new projectJournal( this );
m_mainWindow = new mainWindow( this );
m_mixer = new mixer( this );
m_songEditor = new songEditor( this );

View File

@@ -110,13 +110,12 @@ envelopeAndLFOWidget::envelopeAndLFOWidget( float _value_for_zero_amount,
QWidget * _parent,
engine * _engine ) :
QWidget( _parent ),
settings(),
journallingObject( _engine ),
#ifdef QT4
specialBgHandlingWidget( palette().color( backgroundRole() ) ),
#else
specialBgHandlingWidget( paletteBackgroundColor() ),
#endif
engineObject( _engine ),
m_used( FALSE ),
m_valueForZeroAmount( _value_for_zero_amount ),
m_pahdEnv( NULL ),

View File

@@ -2,7 +2,7 @@
/*
* envelope_tab_widget.cpp - widget for use in envelope/lfo/filter-tab of
* channel-window
* instrument-track-window
*
* Copyright (c) 2004-2006 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
@@ -50,7 +50,7 @@
#include "tab_widget.h"
#include "embed.h"
#include "gui_templates.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "combobox.h"
@@ -83,10 +83,9 @@ static const QString targetNames[envelopeTabWidget::TARGET_COUNT][2] =
envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
QWidget( _channel_track->tabWidgetParent() ),
settings(),
engineObject( _channel_track->eng() )
envelopeTabWidget::envelopeTabWidget( instrumentTrack * _instrument_track ) :
QWidget( _instrument_track->tabWidgetParent() ),
journallingObject( _instrument_track->eng() )
{
m_targetsTabWidget = new tabWidget( tr( "TARGET" ), this );
@@ -171,14 +170,14 @@ envelopeTabWidget::envelopeTabWidget( channelTrack * _channel_track ) :
QWhatsThis::add( m_filterComboBox,
#endif
tr( "Here you can select the built-in filter you want to use "
"in this channel. Filters are very important for "
"changing the characteristics of a sound." ) );
"for this instrument-track. Filters are very important "
"for changing the characteristics of a sound." ) );
m_filterCutKnob = new knob( knobBright_26, m_filterGroupBox, tr(
"cutoff-frequency" ), eng() );
m_filterCutKnob->setLabel( tr( "CUTOFF" ) );
m_filterCutKnob->setRange( 0.0, 10000.0, 1.0 );
m_filterCutKnob->setRange( 0.0, 14000.0, 1.0 );
m_filterCutKnob->move( 140, 18 );
m_filterCutKnob->setInitValue( 16000.0 );
m_filterCutKnob->setHintText( tr( "cutoff-frequency:" ) + " ", " " +
@@ -494,24 +493,18 @@ f_cnt_t envelopeTabWidget::releaseFrames( void )
void envelopeTabWidget::saveSettings( QDomDocument & _doc,
QDomElement & _parent )
void envelopeTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement etw_de = _doc.createElement( nodeName() );
etw_de.setAttribute( "ftype", m_filterComboBox->value() );
etw_de.setAttribute( "fcut", m_filterCutKnob->value() );
etw_de.setAttribute( "fres", m_filterResKnob->value() );
etw_de.setAttribute( "fwet", m_filterGroupBox->isActive() );
_parent.appendChild( etw_de );
_this.setAttribute( "ftype", m_filterComboBox->value() );
_this.setAttribute( "fcut", m_filterCutKnob->value() );
_this.setAttribute( "fres", m_filterResKnob->value() );
_this.setAttribute( "fwet", m_filterGroupBox->isActive() );
for( int i = 0; i < TARGET_COUNT; ++i )
{
QDomElement target_de = _doc.createElement(
m_envLFOWidgets[i]->nodeName() +
QString(
targetNames[i][1] ).toLower() );
m_envLFOWidgets[i]->saveSettings( _doc, target_de );
etw_de.appendChild( target_de );
m_envLFOWidgets[i]->saveState( _doc, _this ).setTagName(
m_envLFOWidgets[i]->nodeName() +
QString( targetNames[i][1] ).toLower() );
}
}
@@ -537,7 +530,7 @@ void envelopeTabWidget::loadSettings( const QDomElement & _this )
m_envLFOWidgets[i]->nodeName() +
QString( targetNames[i][1] ).toLower() )
{
m_envLFOWidgets[i]->loadSettings(
m_envLFOWidgets[i]->restoreState(
node.toElement() );
}
}

View File

@@ -51,7 +51,7 @@
#include "song_editor.h"
#include "bb_editor.h"
#include "embed.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "mmp.h"
#include "preset_preview_play_handle.h"
#include "sample_play_handle.h"
@@ -177,14 +177,17 @@ void fileBrowser::contextMenuRequest( QListViewItem * i, const QPoint &, int )
{
m_contextMenuItem = f;
QMenu * contextMenu = new QMenu( this );
contextMenu->addAction( tr( "Send to active channel" ), this,
SLOT( sendToActiveChannel() ) );
contextMenu->addAction( tr( "Open in new channel/Song-Editor" ),
contextMenu->addAction( tr( "Send to active instrument-track" ),
this,
SLOT( openInNewChannelSE() ) );
contextMenu->addAction( tr( "Open in new channel/B+B Editor" ),
SLOT( sendToActiveInstrumentTrack() ) );
contextMenu->addAction( tr( "Open in new instrument-track/"
"Song-Editor" ),
this,
SLOT( openInNewChannelBBE() ) );
SLOT( openInNewInstrumentTrackSE() ) );
contextMenu->addAction( tr( "Open in new instrument-track/"
"B+B Editor" ),
this,
SLOT( openInNewInstrumentTrackBBE() ) );
contextMenu->exec( QCursor::pos() );
m_contextMenuItem = NULL;
delete contextMenu;
@@ -195,7 +198,7 @@ void fileBrowser::contextMenuRequest( QListViewItem * i, const QPoint &, int )
void fileBrowser::sendToActiveChannel( void )
void fileBrowser::sendToActiveInstrumentTrack( void )
{
if( eng()->getMainWindow()->workspace() != NULL )
{
@@ -209,24 +212,24 @@ void fileBrowser::sendToActiveChannel( void )
#ifdef QT4
QListIterator<QWidget *> w( pl );
w.toBack();
// now we travel through the window-list until we find a
// channel-track
// now we travel through the window-list until we find an
// instrument-track
while( w.hasPrevious() )
{
channelTrack * ct = dynamic_cast<channelTrack *>(
instrumentTrack * ct = dynamic_cast<instrumentTrack *>(
w.previous() );
#else
QWidget * w = pl.last();
// now we travel through the window-list until we find a
// channel-track
// now we travel through the window-list until we find an
// instrument-track
while( w != NULL )
{
channelTrack * ct = dynamic_cast<channelTrack *>( w );
instrumentTrack * ct = dynamic_cast<instrumentTrack *>( w );
#endif
if( ct != NULL && ct->isHidden() == FALSE )
{
// ok, it's a channel-track, so we can apply the
// sample or the preset
// ok, it's an instrument-track, so we can apply
// the sample or the preset
if( m_contextMenuItem->type() ==
fileItem::SAMPLE_FILE )
{
@@ -248,7 +251,7 @@ void fileBrowser::sendToActiveChannel( void )
firstChild().
toElement() );
}
ct->toggledChannelButton( TRUE );
ct->toggledInstrumentTrackButton( TRUE );
break;
}
#ifndef QT4
@@ -261,11 +264,11 @@ void fileBrowser::sendToActiveChannel( void )
void fileBrowser::openInNewChannel( trackContainer * _tc )
void fileBrowser::openInNewInstrumentTrack( trackContainer * _tc )
{
if( m_contextMenuItem->type() == fileItem::SAMPLE_FILE )
{
channelTrack * ct = dynamic_cast<channelTrack *>(
instrumentTrack * ct = dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK, _tc ) );
#ifdef LMMS_DEBUG
assert( ct != NULL );
@@ -276,19 +279,19 @@ void fileBrowser::openInNewChannel( trackContainer * _tc )
afp->setParameter( "samplefile",
m_contextMenuItem->fullName() );
}
ct->toggledChannelButton( TRUE );
ct->toggledInstrumentTrackButton( TRUE );
}
else if( m_contextMenuItem->type() == fileItem::PRESET_FILE )
{
multimediaProject mmp( m_contextMenuItem->fullName() );
track * t = track::create( track::CHANNEL_TRACK, _tc );
channelTrack * ct = dynamic_cast<channelTrack *>( t );
instrumentTrack * ct = dynamic_cast<instrumentTrack *>( t );
if( ct != NULL )
{
ct->loadTrackSpecificSettings( mmp.content().
firstChild().
toElement() );
ct->toggledChannelButton( TRUE );
ct->toggledInstrumentTrackButton( TRUE );
}
}
}
@@ -296,17 +299,17 @@ void fileBrowser::openInNewChannel( trackContainer * _tc )
void fileBrowser::openInNewChannelSE( void )
void fileBrowser::openInNewInstrumentTrackSE( void )
{
openInNewChannel( eng()->getSongEditor() );
openInNewInstrumentTrack( eng()->getSongEditor() );
}
void fileBrowser::openInNewChannelBBE( void )
void fileBrowser::openInNewInstrumentTrackBBE( void )
{
openInNewChannel( eng()->getBBEditor() );
openInNewInstrumentTrack( eng()->getBBEditor() );
}
@@ -352,7 +355,7 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
{
// samples are per default opened in bb-editor because
// they're likely drum-samples etc.
channelTrack * ct = dynamic_cast<channelTrack *>(
instrumentTrack * ct = dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK,
eng()->getBBEditor() ) );
#ifdef LMMS_DEBUG
@@ -365,7 +368,7 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
afp->setParameter( "samplefile",
f->fullName() );
}
ct->toggledChannelButton( TRUE );
ct->toggledInstrumentTrackButton( TRUE );
}
else if( f->type() == fileItem::PRESET_FILE )
{
@@ -373,13 +376,13 @@ void listView::contentsMouseDoubleClickEvent( QMouseEvent * _me )
multimediaProject mmp( f->fullName() );
track * t = track::create( track::CHANNEL_TRACK,
eng()->getBBEditor() );
channelTrack * ct = dynamic_cast<channelTrack *>( t );
instrumentTrack * ct = dynamic_cast<instrumentTrack *>( t );
if( ct != NULL )
{
ct->loadTrackSpecificSettings( mmp.content().
firstChild().
toElement() );
ct->toggledChannelButton( TRUE );
ct->toggledInstrumentTrackButton( TRUE );
}
}
else if( f->type() == fileItem::PROJECT_FILE )
@@ -797,7 +800,7 @@ void fileItem::determineFileType( void )
{
m_type = PROJECT_FILE;
}
else if( t == multimediaProject::CHANNEL_SETTINGS )
else if( t == multimediaProject::INSTRUMENT_TRACK_SETTINGS )
{
m_type = PRESET_FILE;
}

View File

@@ -26,19 +26,19 @@
#include "instrument.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "dummy_instrument.h"
instrument::instrument( channelTrack * _channel_track,
instrument::instrument( instrumentTrack * _instrument_track,
const descriptor * _descriptor ) :
QWidget( _channel_track->tabWidgetParent() ),
plugin( _descriptor, _channel_track->eng() ),
m_channelTrack( _channel_track ),
QWidget( _instrument_track->tabWidgetParent() ),
plugin( _descriptor, _instrument_track->eng() ),
m_instrumentTrack( _instrument_track ),
m_valid( TRUE )
{
setFixedSize( 250, 250 );
m_channelTrack->setWindowIcon( *getDescriptor()->logo );
m_instrumentTrack->setWindowIcon( *getDescriptor()->logo );
}
@@ -81,9 +81,9 @@ f_cnt_t instrument::beatLen( notePlayHandle * ) const
instrument * instrument::instantiate( const QString & _plugin_name,
channelTrack * _channel_track )
instrumentTrack * _instrument_track )
{
plugin * p = plugin::instantiate( _plugin_name, _channel_track );
plugin * p = plugin::instantiate( _plugin_name, _instrument_track );
// check whether instantiated plugin is an instrument
if( dynamic_cast<instrument *>( p ) != NULL )
{
@@ -93,7 +93,7 @@ instrument * instrument::instantiate( const QString & _plugin_name,
// not quite... so delete plugin and return dummy instrument
delete p;
return( new dummyInstrument( _channel_track ) );
return( new dummyInstrument( _instrument_track ) );
}

View File

@@ -76,7 +76,7 @@
#include "setup_dialog.h"
#include "audio_dummy.h"
#include "tool_button.h"
#include "edit_history.h"
#include "project_journal.h"
#if QT_VERSION >= 0x030100
@@ -621,8 +621,9 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de )
_de.attribute( "height" ).toInt() );
if( !r.isNull() )
{
_w->setShown( _de.attribute( "visible" ).toInt() );
_w->show();
_w->parentWidget()->move( r.topLeft() );
_w->setShown( _de.attribute( "visible" ).toInt() );
_w->resize( r.size() );
}
}
@@ -857,7 +858,7 @@ void mainWindow::togglePianoRollWin( void )
void mainWindow::undo( void )
{
eng()->getEditHistory()->undo();
eng()->getProjectJournal()->undo();
}
@@ -865,7 +866,7 @@ void mainWindow::undo( void )
void mainWindow::redo( void )
{
eng()->getEditHistory()->redo();
eng()->getProjectJournal()->redo();
}

View File

@@ -48,7 +48,7 @@
#include "midi_tab_widget.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "midi_port.h"
#include "tab_widget.h"
#include "led_checkbox.h"
@@ -60,12 +60,11 @@
midiTabWidget::midiTabWidget( channelTrack * _channel_track,
midiTabWidget::midiTabWidget( instrumentTrack * _instrument_track,
midiPort * _port ) :
QWidget( _channel_track->tabWidgetParent() ),
settings(),
engineObject( _channel_track->eng() ),
m_channelTrack( _channel_track ),
QWidget( _instrument_track->tabWidgetParent() ),
journallingObject( _instrument_track->eng() ),
m_instrumentTrack( _instrument_track ),
m_midiPort( _port ),
m_readablePorts( NULL ),
m_writeablePorts( NULL )
@@ -194,13 +193,12 @@ midiTabWidget::~midiTabWidget()
void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement mw_de = _doc.createElement( nodeName() );
mw_de.setAttribute( "inputchannel", m_inputChannelSpinBox->value() );
mw_de.setAttribute( "outputchannel", m_outputChannelSpinBox->value() );
mw_de.setAttribute( "receive", m_receiveCheckBox->isChecked() );
mw_de.setAttribute( "send", m_sendCheckBox->isChecked() );
_this.setAttribute( "inputchannel", m_inputChannelSpinBox->value() );
_this.setAttribute( "outputchannel", m_outputChannelSpinBox->value() );
_this.setAttribute( "receive", m_receiveCheckBox->isChecked() );
_this.setAttribute( "send", m_sendCheckBox->isChecked() );
if( m_readablePorts != NULL && m_receiveCheckBox->isChecked() == TRUE )
{
@@ -230,7 +228,7 @@ void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent )
{
rp.truncate( rp.length() - 1 );
}
mw_de.setAttribute( "inports", rp );
_this.setAttribute( "inports", rp );
}
if( m_writeablePorts != NULL && m_sendCheckBox->isChecked() == TRUE )
@@ -261,10 +259,8 @@ void midiTabWidget::saveSettings( QDomDocument & _doc, QDomElement & _parent )
{
wp.truncate( wp.length() - 1 );
}
mw_de.setAttribute( "outports", wp );
_this.setAttribute( "outports", wp );
}
_parent.appendChild( mw_de );
}

View File

@@ -45,8 +45,10 @@
note::note( const midiTime & _length, const midiTime & _pos, tones _tone,
octaves _octave, volume _volume, panning _panning ) :
note::note( engine * _engine, const midiTime & _length, const midiTime & _pos,
tones _tone, octaves _octave, volume _volume,
panning _panning ) :
journallingObject( _engine ),
m_tone( C ),
m_octave( DEFAULT_OCTAVE ),
m_volume( DEFAULT_VOLUME ),
@@ -54,10 +56,15 @@ note::note( const midiTime & _length, const midiTime & _pos, tones _tone,
m_length( _length ),
m_pos( _pos )
{
//saveJournallingState( FALSE );
setJournalling( FALSE );
setTone( _tone );
setOctave( _octave );
setVolume( _volume );
setPanning( _panning );
//restoreJournallingState();
}
@@ -72,6 +79,7 @@ note::~note()
void note::setLength( const midiTime & _length )
{
addJournalEntry( journalEntry( CHANGE_LENGTH, m_length - _length ) );
m_length = _length;
}
@@ -80,6 +88,7 @@ void note::setLength( const midiTime & _length )
void note::setPos( const midiTime & _pos )
{
addJournalEntry( journalEntry( CHANGE_POSITION, m_pos - _pos ) );
m_pos = _pos;
}
@@ -88,17 +97,9 @@ void note::setPos( const midiTime & _pos )
void note::setTone( const tones _tone )
{
if( _tone >= C && _tone <= H )
{
m_tone = _tone;
}
else
{
m_tone = tLimit( _tone, C, H );
#ifdef LMMS_DEBUG
printf ( "Tone out of range (note::setTone)\n" );
#endif
}
const tones t = tLimit( _tone, C, H );
addJournalEntry( journalEntry( CHANGE_KEY, (int) m_tone - t ) );
m_tone = t;
}
@@ -106,17 +107,10 @@ void note::setTone( const tones _tone )
void note::setOctave( const octaves _octave )
{
if( _octave >= MIN_OCTAVE && _octave <= MAX_OCTAVE )
{
m_octave = _octave;
}
else
{
m_octave = tLimit( _octave, MIN_OCTAVE, MAX_OCTAVE );
#ifdef LMMS_DEBUG
printf( "Octave out of range (note::setOctave)\n" );
#endif
}
const octaves o = tLimit( _octave, MIN_OCTAVE, MAX_OCTAVE );
addJournalEntry( journalEntry( CHANGE_KEY, NOTES_PER_OCTAVE *
( (int) m_octave - o ) ) );
m_octave = o;
}
@@ -124,8 +118,12 @@ void note::setOctave( const octaves _octave )
void note::setKey( const int _key )
{
const int k = key();
saveJournallingState( FALSE );
setTone( static_cast<tones>( _key % NOTES_PER_OCTAVE ) );
setOctave( static_cast<octaves>( _key / NOTES_PER_OCTAVE ) );
restoreJournallingState();
addJournalEntry( journalEntry( CHANGE_KEY, k - key() ) );
}
@@ -133,17 +131,9 @@ void note::setKey( const int _key )
void note::setVolume( const volume _volume )
{
if( _volume <= MAX_VOLUME )
{
m_volume = _volume;
}
else
{
m_volume = tMin( _volume, MAX_VOLUME );
#ifdef LMMS_DEBUG
printf( "Volume out of range (note::setVolume)\n" );
#endif
}
const volume v = tMin( _volume, MAX_VOLUME );
addJournalEntry( journalEntry( CHANGE_VOLUME, (int) m_volume - v ) );
m_volume = v;
}
@@ -151,16 +141,9 @@ void note::setVolume( const volume _volume )
void note::setPanning( const panning _panning )
{
if( _panning >= PANNING_LEFT && _panning <= PANNING_RIGHT )
{
m_panning = _panning;
}
#ifdef LMMS_DEBUG
else
{
printf( "Paning out of range (note::setPanning)\n" );
}
#endif
const panning p = tLimit( _panning, PANNING_LEFT, PANNING_RIGHT );
addJournalEntry( journalEntry( CHANGE_PANNING, (int) m_panning - p ) );
m_panning = p;
}
@@ -199,16 +182,14 @@ void note::quantizePos( const int _q_grid )
void note::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void note::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement note_de = _doc.createElement( "note" );
note_de.setAttribute( "tone", m_tone );
note_de.setAttribute( "oct", m_octave );
note_de.setAttribute( "vol", m_volume );
note_de.setAttribute( "pan", m_panning );
note_de.setAttribute( "len", m_length );
note_de.setAttribute( "pos", m_pos );
_parent.appendChild( note_de );
_this.setAttribute( "tone", m_tone );
_this.setAttribute( "oct", m_octave );
_this.setAttribute( "vol", m_volume );
_this.setAttribute( "pan", m_panning );
_this.setAttribute( "len", m_length );
_this.setAttribute( "pos", m_pos );
}
@@ -227,5 +208,43 @@ void note::loadSettings( const QDomElement & _this )
void note::undoStep( journalEntry & _je )
{
saveJournallingState( FALSE );
switch( static_cast<actions>( _je.actionID() ) )
{
case CHANGE_KEY:
setKey( key() - _je.data().toInt() );
break;
case CHANGE_VOLUME:
setVolume( getVolume() - _je.data().toInt() );
break;
case CHANGE_PANNING:
setVolume( getPanning() - _je.data().toInt() );
break;
case CHANGE_LENGTH:
setLength( length() - _je.data().toInt() );
break;
case CHANGE_POSITION:
setPos( pos() - _je.data().toInt() );
break;
}
restoreJournallingState();
}
void note::redoStep( journalEntry & _je )
{
journalEntry je( _je.actionID(), -_je.data().toInt() );
undoStep( je );
}
#endif

View File

@@ -27,26 +27,27 @@
#include "note_play_handle.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "envelope_tab_widget.h"
#include "midi.h"
#include "midi_port.h"
#include "song_editor.h"
#include "piano_widget.h"
#include "config_mgr.h"
#include "project_journal.h"
notePlayHandle::notePlayHandle( channelTrack * _chnl_trk,
notePlayHandle::notePlayHandle( instrumentTrack * _it,
const f_cnt_t _frames_ahead,
const f_cnt_t _frames,
note * _n,
const note & _n,
const bool _arp_note ) :
playHandle( NOTE_PLAY_HANDLE, _chnl_trk->eng() ),
note( *_n ),
playHandle( NOTE_PLAY_HANDLE ),
note( NULL, _n.length(), _n.pos(), _n.tone(), _n.octave(),
_n.getVolume(), _n.getPanning() ),
m_pluginData( NULL ),
m_filter( NULL ),
m_channelTrack( _chnl_trk ),
m_instrumentTrack( _it ),
m_frames( 0 ),
m_framesAhead( _frames_ahead ),
m_totalFramesPlayed( 0 ),
@@ -62,18 +63,18 @@ notePlayHandle::notePlayHandle( channelTrack * _chnl_trk,
if( !configManager::inst()->value( "ui",
"manualchannelpiano" ).toInt() )
{
m_channelTrack->m_pianoWidget->setKeyState( key(), TRUE );
m_instrumentTrack->m_pianoWidget->setKeyState( key(), TRUE );
}
// send MIDI-note-on-event
m_channelTrack->processOutEvent( midiEvent( NOTE_ON,
m_channelTrack->m_midiPort->outputChannel(),
m_instrumentTrack->processOutEvent( midiEvent( NOTE_ON,
m_instrumentTrack->m_midiPort->outputChannel(),
key(),
tLimit<Uint16>(
(Uint16) ( ( getVolume() / 100.0f ) *
( m_channelTrack->getVolume() / 100.0f ) *
( m_instrumentTrack->getVolume() / 100.0f ) *
127 ), 0, 127 ) ),
midiTime::fromFrames( m_framesAhead,
eng()->getSongEditor()->framesPerTact() ) );
m_instrumentTrack->eng()->getSongEditor()->framesPerTact() ) );
}
@@ -86,9 +87,9 @@ notePlayHandle::~notePlayHandle()
noteOff( 0 );
}
if( m_channelTrack != NULL )
if( m_instrumentTrack != NULL )
{
m_channelTrack->deleteNotePluginData( this );
m_instrumentTrack->deleteNotePluginData( this );
}
for( notePlayHandleVector::iterator it = m_subNotes.begin();
@@ -106,24 +107,26 @@ notePlayHandle::~notePlayHandle()
void notePlayHandle::play( void )
{
if( m_muted == TRUE || m_channelTrack == NULL )
if( m_muted == TRUE || m_instrumentTrack == NULL )
{
return;
}
if( m_released == FALSE &&
m_totalFramesPlayed +
eng()->getMixer()->framesPerAudioBuffer() >= m_frames )
m_instrumentTrack->eng()->getMixer()->framesPerAudioBuffer() >=
m_frames )
{
noteOff( m_frames - m_totalFramesPlayed );
}
// play note!
m_channelTrack->playNote( this );
m_instrumentTrack->playNote( this );
if( m_released == TRUE )
{
f_cnt_t todo = eng()->getMixer()->framesPerAudioBuffer();
f_cnt_t todo =
m_instrumentTrack->eng()->getMixer()->framesPerAudioBuffer();
// if this note is base-note for arpeggio, always set
// m_releaseFramesToDo to bigger value than m_releaseFramesDone
// because we do not allow notePlayHandle::done() to be true
@@ -132,7 +135,7 @@ void notePlayHandle::play( void )
if( arpBaseNote() == TRUE )
{
m_releaseFramesToDo = m_releaseFramesDone + 2 *
eng()->getMixer()->framesPerAudioBuffer();
m_instrumentTrack->eng()->getMixer()->framesPerAudioBuffer();
}
// look whether we have frames left to be done before release
if( m_framesBeforeRelease )
@@ -140,7 +143,7 @@ void notePlayHandle::play( void )
// yes, then look whether these samples can be played
// within one audio-buffer
if( m_framesBeforeRelease <=
eng()->getMixer()->framesPerAudioBuffer() )
m_instrumentTrack->eng()->getMixer()->framesPerAudioBuffer() )
{
// yes, then we did less releaseFramesDone
todo -= m_framesBeforeRelease;
@@ -153,7 +156,7 @@ void notePlayHandle::play( void )
// release-phase yet)
todo = 0;
m_framesBeforeRelease -=
eng()->getMixer()->framesPerAudioBuffer();
m_instrumentTrack->eng()->getMixer()->framesPerAudioBuffer();
}
}
// look whether we're in release-phase
@@ -201,7 +204,8 @@ void notePlayHandle::play( void )
}
// update internal data
m_totalFramesPlayed += eng()->getMixer()->framesPerAudioBuffer();
m_totalFramesPlayed +=
m_instrumentTrack->eng()->getMixer()->framesPerAudioBuffer();
}
@@ -209,8 +213,8 @@ void notePlayHandle::play( void )
void notePlayHandle::checkValidity( void )
{
if( m_channelTrack != NULL &&
m_channelTrack->type() == track::NULL_TRACK )
if( m_instrumentTrack != NULL &&
m_instrumentTrack->type() == track::NULL_TRACK )
{
// track-type being track::NULL_TRACK indicates a track whose
// removal is in progress, so we have to invalidate ourself
@@ -218,8 +222,8 @@ void notePlayHandle::checkValidity( void )
{
noteOff( 0 );
}
m_channelTrack->deleteNotePluginData( this );
m_channelTrack = NULL;
m_instrumentTrack->deleteNotePluginData( this );
m_instrumentTrack = NULL;
}
// sub-notes might not be registered at mixer (for example arpeggio-
// notes), so they wouldn't invalidate them-selves
@@ -244,23 +248,23 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
// then set some variables indicating release-state
m_framesBeforeRelease = _s;
if( m_channelTrack != NULL )
if( m_instrumentTrack != NULL )
{
m_releaseFramesToDo = tMax<f_cnt_t>( 10,
m_channelTrack->m_envWidget->releaseFrames() );
m_instrumentTrack->m_envWidget->releaseFrames() );
if( !configManager::inst()->value( "ui",
"manualchannelpiano" ).toInt() )
{
m_channelTrack->m_pianoWidget->setKeyState( key(),
m_instrumentTrack->m_pianoWidget->setKeyState( key(),
FALSE );
}
// send MIDI-note-off-event
m_channelTrack->processOutEvent( midiEvent( NOTE_OFF,
m_channelTrack->m_midiPort->outputChannel(),
m_instrumentTrack->processOutEvent( midiEvent( NOTE_OFF,
m_instrumentTrack->m_midiPort->outputChannel(),
key(), 0 ),
midiTime::fromFrames(
m_framesBeforeRelease,
eng()->getSongEditor()->framesPerTact() ) );
m_instrumentTrack->eng()->getSongEditor()->framesPerTact() ) );
}
else
{
@@ -275,8 +279,8 @@ void notePlayHandle::noteOff( const f_cnt_t _s )
f_cnt_t notePlayHandle::actualReleaseFramesToDo( void ) const
{
return( ( m_channelTrack != NULL ) ?
m_channelTrack->m_envWidget->releaseFrames() : 0 );
return( ( m_instrumentTrack != NULL ) ?
m_instrumentTrack->m_envWidget->releaseFrames() : 0 );
}
@@ -285,9 +289,9 @@ f_cnt_t notePlayHandle::actualReleaseFramesToDo( void ) const
void notePlayHandle::setFrames( const f_cnt_t _frames )
{
m_frames = _frames;
if( m_frames == 0 && m_channelTrack != NULL )
if( m_frames == 0 && m_instrumentTrack != NULL )
{
m_frames = m_channelTrack->beatLen( this );
m_frames = m_instrumentTrack->beatLen( this );
}
}
@@ -296,8 +300,8 @@ void notePlayHandle::setFrames( const f_cnt_t _frames )
float notePlayHandle::volumeLevel( const f_cnt_t _frame )
{
return( ( m_channelTrack != NULL ) ?
m_channelTrack->m_envWidget->volumeLevel( this, _frame ) : 0 );
return( ( m_instrumentTrack != NULL ) ?
m_instrumentTrack->m_envWidget->volumeLevel( this, _frame ) : 0 );
}
@@ -319,14 +323,15 @@ void notePlayHandle::mute( void )
int notePlayHandle::index( void ) const
{
const playHandleVector & phv = eng()->getMixer()->playHandles();
const playHandleVector & phv =
m_instrumentTrack->eng()->getMixer()->playHandles();
int idx = 0;
for( constPlayHandleVector::const_iterator it = phv.begin();
it != phv.end(); ++it )
{
const notePlayHandle * nph =
dynamic_cast<const notePlayHandle *>( *it );
if( nph == NULL || nph->m_channelTrack != m_channelTrack ||
if( nph == NULL || nph->m_instrumentTrack != m_instrumentTrack ||
nph->released() == TRUE )
{
continue;
@@ -344,9 +349,9 @@ int notePlayHandle::index( void ) const
constNotePlayHandleVector notePlayHandle::nphsOfChannelTrack(
const channelTrack * _ct )
const instrumentTrack * _it )
{
const playHandleVector & phv = _ct->eng()->getMixer()->playHandles();
const playHandleVector & phv = _it->eng()->getMixer()->playHandles();
constNotePlayHandleVector cnphv;
for( constPlayHandleVector::const_iterator it = phv.begin();
@@ -354,7 +359,7 @@ constNotePlayHandleVector notePlayHandle::nphsOfChannelTrack(
{
const notePlayHandle * nph =
dynamic_cast<const notePlayHandle *>( *it );
if( nph != NULL && nph->m_channelTrack == _ct &&
if( nph != NULL && nph->m_instrumentTrack == _it &&
nph->released() == FALSE )
{
cnphv.push_back( nph );
@@ -372,7 +377,7 @@ bool notePlayHandle::operator==( const notePlayHandle & _nph ) const
key() == _nph.key() &&
getVolume() == _nph.getVolume() &&
getPanning() == _nph.getPanning() &&
m_channelTrack == _nph.m_channelTrack &&
m_instrumentTrack == _nph.m_instrumentTrack &&
m_frames == _nph.m_frames &&
m_framesAhead == _nph.m_framesAhead &&
m_totalFramesPlayed == _nph.m_totalFramesPlayed &&

View File

@@ -49,6 +49,7 @@
#include <qdom.h>
#define addButton insert
#define setCheckable setToggleButton
#endif
@@ -69,7 +70,7 @@
#include "templates.h"
#include "gui_templates.h"
#include "timeline.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "tooltip.h"
#include "midi.h"
#include "tool_button.h"
@@ -131,7 +132,7 @@ const int DEFAULT_PR_PPT = KEY_LINE_HEIGHT * DEFAULT_STEPS_PER_TACT;
pianoRoll::pianoRoll( engine * _engine ) :
QWidget( _engine->getMainWindow()->workspace() ),
engineObject( _engine ),
journallingObject( _engine ),
m_paintPixmap(),
m_cursorInside( FALSE ),
m_pattern( NULL ),
@@ -545,7 +546,7 @@ void pianoRoll::setCurrentPattern( pattern * _new_pattern )
// and now connect to noteDone()-signal of channel so that
// we receive note-off-events from it's midi-port for recording it
connect( m_pattern->getChannelTrack(),
connect( m_pattern->getInstrumentTrack(),
SIGNAL( noteDone( const note & ) ),
this, SLOT( recordNote( const note & ) ) );
@@ -557,11 +558,9 @@ void pianoRoll::setCurrentPattern( pattern * _new_pattern )
void pianoRoll::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void pianoRoll::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement pr_de = _doc.createElement( nodeName() );
mainWindow::saveWidgetState( this, pr_de );
_parent.appendChild( pr_de );
mainWindow::saveWidgetState( this, _this );
}
@@ -1243,7 +1242,8 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
midiTime note_pos( pos_tact_64th );
midiTime note_len( newNoteLen() );
note new_note( note_len, note_pos,
note new_note( eng(),
note_len, note_pos,
(tones)( key_num %
NOTES_PER_OCTAVE ),
(octaves)( key_num /
@@ -1370,7 +1370,7 @@ void pianoRoll::mousePressEvent( QMouseEvent * _me )
if( play_note == TRUE && m_recording == FALSE &&
eng()->getSongEditor()->playing() == FALSE )
{
m_pattern->getChannelTrack()->processInEvent(
m_pattern->getInstrumentTrack()->processInEvent(
midiEvent( NOTE_ON, 0, key_num,
vol * 127 / 100 ),
midiTime() );
@@ -1387,13 +1387,13 @@ void pianoRoll::mouseReleaseEvent( QMouseEvent * _me )
{
if( m_action == CHANGE_NOTE_VOLUME && m_currentNote != NULL )
{
m_pattern->getChannelTrack()->processInEvent(
m_pattern->getInstrumentTrack()->processInEvent(
midiEvent( NOTE_OFF, 0,
m_currentNote->key(), 0 ), midiTime() );
}
else
{
m_pattern->getChannelTrack()->processInEvent(
m_pattern->getInstrumentTrack()->processInEvent(
midiEvent( NOTE_OFF, 0, getKey( _me->y() ), 0 ),
midiTime() );
}
@@ -1446,7 +1446,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
#endif
Qt::LeftButton )
{
m_pattern->getChannelTrack()->processInEvent(
m_pattern->getInstrumentTrack()->processInEvent(
midiEvent( NOTE_OFF, 0, released_key, 0 ),
midiTime() );
if(
@@ -1462,7 +1462,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
m_recording == FALSE &&
eng()->getSongEditor()->playing() == FALSE )
{
m_pattern->getChannelTrack()->processInEvent(
m_pattern->getInstrumentTrack()->processInEvent(
midiEvent( NOTE_ON, 0, key_num,
DEFAULT_VOLUME * 127 / 100 ),
midiTime() );
@@ -1487,7 +1487,7 @@ void pianoRoll::mouseMoveEvent( QMouseEvent * _me )
MAX_VOLUME );
m_currentNote->setVolume( vol );
m_pattern->update();
m_pattern->getChannelTrack()->processInEvent(
m_pattern->getInstrumentTrack()->processInEvent(
midiEvent( KEY_PRESSURE, 0, key_num,
vol * 127 / 100 ),
midiTime() );
@@ -2524,6 +2524,7 @@ midiTime pianoRoll::newNoteLen( void ) const
#ifdef QT3
#undef addButton
#undef setCheckable
#endif

View File

@@ -42,7 +42,7 @@
#include "piano_widget.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "midi.h"
#include "templates.h"
#include "embed.h"
@@ -77,9 +77,9 @@ const int PW_BLACK_KEY_HEIGHT = 38;
const int LABEL_TEXT_SIZE = 7;
pianoWidget::pianoWidget (channelTrack * _parent ) :
pianoWidget::pianoWidget( instrumentTrack * _parent ) :
QWidget( _parent ),
m_channelTrack( _parent ),
m_instrumentTrack( _parent ),
m_startTone( C ),
m_startOctave( OCTAVE_3 )
{
@@ -242,7 +242,7 @@ void pianoWidget::mousePressEvent( QMouseEvent * _me )
vol = DEFAULT_VOLUME;
}
// set note on
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_ON, 0, key_num,
vol * 127 / 100 ),
midiTime() );
@@ -250,9 +250,9 @@ void pianoWidget::mousePressEvent( QMouseEvent * _me )
}
else
{
m_channelTrack->setBaseTone( static_cast<tones>(
m_instrumentTrack->setBaseTone( static_cast<tones>(
key_num % NOTES_PER_OCTAVE ) );
m_channelTrack->setBaseOctave( static_cast<octaves>(
m_instrumentTrack->setBaseOctave( static_cast<octaves>(
key_num / NOTES_PER_OCTAVE ) );
}
@@ -269,7 +269,7 @@ void pianoWidget::mouseReleaseEvent( QMouseEvent * _me )
{
int released_key = getKeyFromMouse( _me->pos() );
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, released_key, 0 ), midiTime() );
m_pressedKeys[released_key] = FALSE;
@@ -309,7 +309,7 @@ void pianoWidget::mouseMoveEvent( QMouseEvent * _me )
// user just moved the cursor one pixel left but on the same key)
if( key_num != released_key )
{
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, released_key, 0 ),
midiTime() );
m_pressedKeys[released_key] = FALSE;
@@ -321,16 +321,16 @@ void pianoWidget::mouseMoveEvent( QMouseEvent * _me )
{
if( _me->pos().y() > PIANO_BASE )
{
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_ON, 0, key_num, vol ),
midiTime() );
m_pressedKeys[key_num] = TRUE;
}
else
{
m_channelTrack->setBaseTone( (tones)
m_instrumentTrack->setBaseTone( (tones)
( key_num % NOTES_PER_OCTAVE ) );
m_channelTrack->setBaseOctave( (octaves)
m_instrumentTrack->setBaseOctave( (octaves)
( key_num / NOTES_PER_OCTAVE ) );
}
}
@@ -339,7 +339,7 @@ void pianoWidget::mouseMoveEvent( QMouseEvent * _me )
}
else if( m_pressedKeys[key_num] == TRUE )
{
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( KEY_PRESSURE, 0, key_num, vol ),
midiTime() );
}
@@ -397,7 +397,7 @@ void pianoWidget::keyPressEvent( QKeyEvent * _ke )
if( _ke->isAutoRepeat() == FALSE && key_num > -1 )
{
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_ON, 0, key_num, DEFAULT_VOLUME ),
midiTime() );
m_pressedKeys[key_num] = TRUE;
@@ -418,7 +418,7 @@ void pianoWidget::keyReleaseEvent( QKeyEvent * _ke )
( DEFAULT_OCTAVE - 1 ) * NOTES_PER_OCTAVE;
if( _ke->isAutoRepeat() == FALSE && key_num > -1 )
{
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, key_num, 0 ),
midiTime() );
m_pressedKeys[key_num] = FALSE;
@@ -442,7 +442,7 @@ void pianoWidget::focusOutEvent( QFocusEvent * )
{
if( m_pressedKeys[i] == TRUE )
{
m_channelTrack->processInEvent(
m_instrumentTrack->processInEvent(
midiEvent( NOTE_OFF, 0, i, 0 ),
midiTime() );
m_pressedKeys[i] = FALSE;
@@ -523,8 +523,8 @@ void pianoWidget::paintEvent( QPaintEvent * )
p.setPen( QColor ( 0xFF, 0xFF, 0xFF ) );
int base_key = m_channelTrack->baseTone() +
m_channelTrack->baseOctave() * NOTES_PER_OCTAVE;
int base_key = m_instrumentTrack->baseTone() +
m_instrumentTrack->baseOctave() * NOTES_PER_OCTAVE;
if( KEY_ORDER[base_key % NOTES_PER_OCTAVE] == WHITE_KEY )
{
p.fillRect( QRect( getKeyX( base_key ), 1, PW_WHITE_KEY_WIDTH-1,

View File

@@ -64,8 +64,7 @@ static plugin::descriptor dummy_plugin_descriptor =
plugin::plugin( const descriptor * _descriptor, engine * _engine ) :
settings(),
engineObject( _engine ),
journallingObject( _engine ),
m_descriptor( _descriptor )
{
if( dummy_plugin_descriptor.logo == NULL )

View File

@@ -42,7 +42,7 @@
#include "preset_preview_play_handle.h"
#include "note_play_handle.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "track_container.h"
#include "mmp.h"
#include "debug.h"
@@ -56,7 +56,7 @@ class previewTrackContainer : public trackContainer
public:
previewTrackContainer( engine * _engine ) :
trackContainer( _engine ),
m_previewChannelTrack( dynamic_cast<channelTrack *>(
m_previewChannelTrack( dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK,
this ) )),
m_previewNote( NULL ),
@@ -81,7 +81,7 @@ public:
return( "previewtc" );
}
channelTrack * previewChannelTrack( void )
instrumentTrack * previewChannelTrack( void )
{
return( m_previewChannelTrack );
}
@@ -108,7 +108,7 @@ public:
private:
channelTrack * m_previewChannelTrack;
instrumentTrack * m_previewChannelTrack;
notePlayHandle * m_previewNote;
QMutex m_dataMutex;
@@ -123,7 +123,8 @@ QMap<const engine *, previewTrackContainer *>
presetPreviewPlayHandle::presetPreviewPlayHandle(
const QString & _preset_file,
engine * _engine ) :
playHandle( PRESET_PREVIEW_PLAY_HANDLE, _engine ),
playHandle( PRESET_PREVIEW_PLAY_HANDLE ),
engineObject( _engine ),
m_previewNote( NULL )
{
if( s_previewTCs.contains( _engine ) == FALSE )
@@ -149,11 +150,12 @@ presetPreviewPlayHandle::presetPreviewPlayHandle(
midiPort::DUMMY );
// create temporary note
note n( 0, 0, static_cast<tones>( A ),
static_cast<octaves>( DEFAULT_OCTAVE-1 ), 100 );
note n();
// create note-play-handle for it
m_previewNote = new notePlayHandle( previewTC()->previewChannelTrack(),
0, ~0, &n );
0, ~0,
note( NULL, 0, 0, static_cast<tones>( A ),
static_cast<octaves>( DEFAULT_OCTAVE-1 ), 100 ) );
previewTC()->setPreviewNote( m_previewNote );
@@ -209,15 +211,15 @@ void presetPreviewPlayHandle::cleanUp( engine * _engine )
constNotePlayHandleVector presetPreviewPlayHandle::nphsOfChannelTrack(
const channelTrack * _ct )
const instrumentTrack * _it )
{
constNotePlayHandleVector cnphv;
if( s_previewTCs.contains( _ct->eng() ) == TRUE )
if( s_previewTCs.contains( _it->eng() ) == TRUE )
{
previewTrackContainer * tc = s_previewTCs[_ct->eng()];
previewTrackContainer * tc = s_previewTCs[_it->eng()];
tc->lockData();
if( tc->previewNote() != NULL &&
tc->previewNote()->getChannelTrack() == _ct )
tc->previewNote()->getInstrumentTrack() == _it )
{
cnphv.push_back( tc->previewNote() );
}

View File

@@ -34,7 +34,8 @@
samplePlayHandle::samplePlayHandle( const QString & _sample_file,
engine * _engine ) :
playHandle( SAMPLE_PLAY_HANDLE, _engine ),
playHandle( SAMPLE_PLAY_HANDLE ),
engineObject( _engine ),
m_sampleBuffer( new sampleBuffer( eng(), _sample_file ) ),
m_ownSampleBuffer( TRUE ),
m_doneMayReturnTrue( TRUE ),
@@ -47,7 +48,8 @@ samplePlayHandle::samplePlayHandle( const QString & _sample_file,
samplePlayHandle::samplePlayHandle( sampleBuffer * _sample_buffer ) :
playHandle( SAMPLE_PLAY_HANDLE, _sample_buffer->eng() ),
playHandle( SAMPLE_PLAY_HANDLE ),
engineObject( _sample_buffer->eng() ),
m_sampleBuffer( _sample_buffer ),
m_ownSampleBuffer( FALSE ),
m_doneMayReturnTrue( TRUE ),

View File

@@ -65,6 +65,7 @@
#include <qbuttongroup.h>
#define addButton insert
#define setCheckable setToggleButton
#endif
@@ -76,7 +77,7 @@
#include "templates.h"
#include "export_project_dialog.h"
#include "bb_track.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "mmp.h"
#include "midi_client.h"
#include "timeline.h"
@@ -94,7 +95,7 @@
#include "combobox.h"
#include "main_window.h"
#include "import_filter.h"
#include "edit_history.h"
#include "project_journal.h"
#include "debug.h"
@@ -382,7 +383,7 @@ songEditor::songEditor( engine * _engine ) :
static_cast<int>( powf( 2.0f, i ) ) ) +
"%" );
}
m_zoomingComboBox->setValue( m_zoomingComboBox->findText(
m_zoomingComboBox->setInitValue( m_zoomingComboBox->findText(
"100%" ) );
connect( m_zoomingComboBox, SIGNAL( activated( const QString & ) ),
this, SLOT( zoomingChanged( const QString & ) ) );
@@ -1339,7 +1340,7 @@ bool songEditor::mayChangeProject( void )
void songEditor::clearProject( void )
{
eng()->getEditHistory()->setGlobalStepRecording( FALSE );
eng()->getProjectJournal()->setJournalling( FALSE );
if( m_playing )
{
@@ -1362,11 +1363,14 @@ void songEditor::clearProject( void )
}
clearAllTracks();
eng()->getBBEditor()->clearAllTracks();
eng()->getProjectNotes()->clear();
eng()->getEditHistory()->setGlobalStepRecording( TRUE );
eng()->getProjectJournal()->clear();
eng()->getProjectJournal()->setJournalling( TRUE );
}
@@ -1378,15 +1382,15 @@ void songEditor::createNewProject( void )
{
clearProject();
eng()->getEditHistory()->setGlobalStepRecording( FALSE );
eng()->getProjectJournal()->setJournalling( FALSE );
track * t;
t = track::create( track::CHANNEL_TRACK, this );
dynamic_cast< channelTrack * >( t )->loadInstrument(
dynamic_cast< instrumentTrack * >( t )->loadInstrument(
"tripleoscillator" );
track::create( track::SAMPLE_TRACK, this );
t = track::create( track::CHANNEL_TRACK, eng()->getBBEditor() );
dynamic_cast< channelTrack * >( t )->loadInstrument(
dynamic_cast< instrumentTrack * >( t )->loadInstrument(
"tripleoscillator" );
track::create( track::BB_TRACK, this );
@@ -1402,7 +1406,7 @@ void songEditor::createNewProject( void )
eng()->getMainWindow()->resetWindowTitle( "" );
eng()->getEditHistory()->setGlobalStepRecording( TRUE );
eng()->getProjectJournal()->setJournalling( TRUE );
}
@@ -1426,7 +1430,7 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
{
clearProject();
eng()->getEditHistory()->setGlobalStepRecording( FALSE );
eng()->getProjectJournal()->setJournalling( FALSE );
m_fileName = _file_name;
m_oldFileName = _file_name;
@@ -1485,24 +1489,24 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
{
if( node.nodeName() == "trackcontainer" )
{
loadSettings( node.toElement() );
restoreState( node.toElement() );
}
else if( node.nodeName() ==
eng()->getPianoRoll()->nodeName() )
{
eng()->getPianoRoll()->loadSettings(
eng()->getPianoRoll()->restoreState(
node.toElement() );
}
else if( node.nodeName() ==
eng()->getProjectNotes()->nodeName() )
{
eng()->getProjectNotes()->loadSettings(
eng()->getProjectNotes()->restoreState(
node.toElement() );
}
else if( node.nodeName() ==
m_playPos[PLAY_SONG].m_timeLine->nodeName() )
{
m_playPos[PLAY_SONG].m_timeLine->loadSettings(
m_playPos[PLAY_SONG].m_timeLine->restoreState(
node.toElement() );
}
}
@@ -1516,7 +1520,7 @@ void FASTCALL songEditor::loadProject( const QString & _file_name )
eng()->getMainWindow()->resetWindowTitle( "" );
eng()->getEditHistory()->setGlobalStepRecording( TRUE );
eng()->getProjectJournal()->setJournalling( TRUE );
}
@@ -1540,11 +1544,11 @@ bool songEditor::saveProject( void )
mmp.head().appendChild( mp );
saveSettings( mmp, mmp.content() );
saveState( mmp, mmp.content() );
eng()->getPianoRoll()->saveSettings( mmp, mmp.content() );
eng()->getProjectNotes()->saveSettings( mmp, mmp.content() );
m_playPos[PLAY_SONG].m_timeLine->saveSettings( mmp, mmp.content() );
eng()->getPianoRoll()->saveState( mmp, mmp.content() );
eng()->getProjectNotes()->saveState( mmp, mmp.content() );
m_playPos[PLAY_SONG].m_timeLine->saveState( mmp, mmp.content() );
if( mmp.writeFile( m_fileName, m_oldFileName == "" ||
m_fileName != m_oldFileName ) == TRUE )
@@ -1687,27 +1691,12 @@ void songEditor::exportProject( void )
void songEditor::saveSettings( QDomDocument & _doc, QDomElement & _parent )
{
trackContainer::saveSettings( _doc, _parent );
}
void songEditor::loadSettings( const QDomElement & _this )
{
trackContainer::loadSettings( _this );
}
#include "song_editor.moc"
#ifdef QT3
#undef addButton
#undef setCheckable
#endif

View File

@@ -66,7 +66,7 @@ timeLine::timeLine( const int _xoff, const int _yoff, const float _ppt,
songEditor::playPos & _pos, const midiTime & _begin,
QWidget * _parent, engine * _engine ) :
QWidget( _parent ),
engineObject( _engine ),
journallingObject( _engine ),
m_autoScroll( AUTOSCROLL_ENABLED ),
m_loopPoints( LOOP_POINTS_DISABLED ),
m_behaviourAtStop( BACK_TO_ZERO ),
@@ -176,13 +176,11 @@ void timeLine::addToolButtons( QWidget * _tool_bar )
void timeLine::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void timeLine::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement tl_de = _doc.createElement( nodeName() );
tl_de.setAttribute( "lp0pos", (int) loopBegin() );
tl_de.setAttribute( "lp1pos", (int) loopEnd() );
tl_de.setAttribute( "lpstate", m_loopPoints );
_parent.appendChild( tl_de );
_this.setAttribute( "lp0pos", (int) loopBegin() );
_this.setAttribute( "lp1pos", (int) loopEnd() );
_this.setAttribute( "lpstate", m_loopPoints );
}

View File

@@ -51,7 +51,7 @@
#include "track.h"
#include "track_container.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "bb_track.h"
#include "sample_track.h"
#include "song_editor.h"
@@ -65,7 +65,7 @@
#include "mmp.h"
#include "main_window.h"
#include "text_float.h"
#include "project_journal.h"
const Sint16 RESIZE_GRIP_WIDTH = 4;
@@ -88,8 +88,7 @@ trackContentObject::trackContentObject( track * _track ) :
, Qt::WDestructiveClose
#endif
),
settings(),
editableObject( _track->eng() ),
journallingObject( _track->eng() ),
m_track( _track ),
m_startPosition(),
m_length(),
@@ -112,10 +111,10 @@ trackContentObject::trackContentObject( track * _track ) :
#endif
show();
setStepRecording( FALSE );
setJournalling( FALSE );
movePosition( 0 );
changeLength( 0 );
setStepRecording( TRUE );
setJournalling( TRUE );
setFixedHeight( parentWidget()->height() - 2 );
setAcceptDrops( TRUE );
@@ -146,7 +145,7 @@ void trackContentObject::movePosition( const midiTime & _pos )
if( m_startPosition != _pos )
{
//getTrack()->eng()->getSongEditor()->setModified();
addStep( editStep( MOVE, m_startPosition - _pos ) );
addJournalEntry( journalEntry( MOVE, m_startPosition - _pos ) );
m_startPosition = _pos;
}
m_track->getTrackWidget()->changePosition();
@@ -163,7 +162,7 @@ void trackContentObject::changeLength( const midiTime & _length )
if( m_length != _length )
{
//getTrack()->eng()->getSongEditor()->setModified();
addStep( editStep( RESIZE, m_length - _length ) );
addJournalEntry( journalEntry( RESIZE, m_length - _length ) );
m_length = _length;
}
setFixedWidth( static_cast<int>( m_length * pixelsPerTact() /
@@ -197,7 +196,7 @@ void trackContentObject::dropEvent( QDropEvent * _de )
// at least save position before getting to moved to somewhere
// the user doesn't expect...
midiTime pos = startPosition();
loadSettings( mmp.content().firstChild().toElement() );
restoreState( mmp.content().firstChild().toElement() );
movePosition( pos );
_de->accept();
}
@@ -253,7 +252,7 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE )
{
multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA );
saveSettings( mmp, mmp.content() );
saveState( mmp, mmp.content() );
#ifdef QT4
QPixmap thumbnail = QPixmap::grabWidget( this ).scaled(
128, 128,
@@ -265,8 +264,7 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
QPixmap thumbnail = QPixmap::grabWidget( this ).
convertToImage().smoothScale( s );
#endif
new stringPairDrag( "tco_" +
QString::number( m_track->type() ),
new stringPairDrag( QString( "tco_%1" ).arg( m_track->type() ),
mmp.toString(), thumbnail, this,
m_track->eng() );
}
@@ -274,7 +272,7 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
/* eng()->getMainWindow()->isShiftPressed() == FALSE &&*/
fixedTCOs() == FALSE )
{
setStepRecording( FALSE );
setJournalling( FALSE );
m_initialMouseX = _me->x();
@@ -308,7 +306,6 @@ void trackContentObject::mousePressEvent( QMouseEvent * _me )
// setup text-float as if TCO was already moved/resized
mouseMoveEvent( _me );
s_textFloat->show();
}
else if( ( _me->button() == Qt::MidButton/* ||
( _me->button() == Qt::LeftButton &&
@@ -431,8 +428,8 @@ void trackContentObject::mouseReleaseEvent( QMouseEvent * _me )
{
if( m_action == MOVE || m_action == RESIZE )
{
setStepRecording( TRUE );
addStep( editStep( m_action, m_oldTime -
setJournalling( TRUE );
addJournalEntry( journalEntry( m_action, m_oldTime -
( ( m_action == MOVE ) ?
m_startPosition : m_length ) ) );
}
@@ -493,29 +490,28 @@ float trackContentObject::pixelsPerTact( void )
void trackContentObject::undoStep( const editStep & _edit_step )
void trackContentObject::undoStep( journalEntry & _je )
{
saveStepRecordingState( FALSE );
switch( _edit_step.actionID() )
saveJournallingState( FALSE );
switch( _je.actionID() )
{
case MOVE:
movePosition( startPosition() +
_edit_step.data().toInt() );
movePosition( startPosition() + _je.data().toInt() );
break;
case RESIZE:
changeLength( length() + _edit_step.data().toInt() );
changeLength( length() + _je.data().toInt() );
break;
}
restoreStepRecordingState();
restoreJournallingState();
}
void trackContentObject::redoStep( const editStep & _edit_step )
void trackContentObject::redoStep( journalEntry & _je )
{
undoStep( editStep( _edit_step.actionID(),
-_edit_step.data().toInt() ) );
journalEntry je( _je.actionID(), -_je.data().toInt() );
undoStep( je );
}
@@ -556,7 +552,7 @@ void trackContentObject::paste( void )
{
if( clipboard::getContent( nodeName() ) != NULL )
{
loadSettings( *( clipboard::getContent( nodeName() ) ) );
restoreState( *( clipboard::getContent( nodeName() ) ) );
}
}
@@ -576,7 +572,7 @@ void trackContentObject::setAutoResizeEnabled( bool _e )
// ===========================================================================
trackContentWidget::trackContentWidget( trackWidget * _parent ) :
QWidget( _parent ),
editableObject( _parent->getTrack()->eng() ),
journallingObject( _parent->getTrack()->eng() ),
m_trackWidget( _parent )
{
#ifdef QT4
@@ -625,15 +621,18 @@ csize trackContentWidget::numOfTCOs( void )
trackContentObject * FASTCALL trackContentWidget::addTCO(
trackContentObject * _tco )
{
//addStep( editStep( ADD_TCO, 0 ) );
QMap<QString, QVariant> map;
map["id"] = _tco->id();
addJournalEntry( journalEntry( ADD_TCO, map ) );
m_trackContentObjects.push_back( _tco );
_tco->move( 0, 1 );
_tco->saveStepRecordingState( FALSE );
_tco->saveJournallingState( FALSE );
m_trackWidget->changePosition();
_tco->restoreStepRecordingState();
_tco->restoreJournallingState();
getTrack()->eng()->getSongEditor()->setModified();
//getTrack()->eng()->getSongEditor()->setModified();
return( _tco ); // just for convenience
}
@@ -656,7 +655,12 @@ void trackContentWidget::removeTCO( trackContentObject * _tco,
_tco );
if( it != m_trackContentObjects.end() )
{
//addStep( editStep( REMOVE_TCO, 0 ) );
QMap<QString, QVariant> map;
multimediaProject mmp( multimediaProject::JOURNAL_DATA );
_tco->saveState( mmp, mmp.content() );
map["id"] = _tco->id();
map["state"] = mmp.toString();
addJournalEntry( journalEntry( REMOVE_TCO, map ) );
if( _also_delete )
{
delete _tco;
@@ -785,7 +789,7 @@ void trackContentWidget::dropEvent( QDropEvent * _de )
multimediaProject mmp( value, FALSE );
// at least save position before getting moved to somewhere
// the user doesn't expect...
tco->loadSettings( mmp.content().firstChild().toElement() );
tco->restoreState( mmp.content().firstChild().toElement() );
tco->movePosition( pos );
_de->accept();
}
@@ -812,9 +816,9 @@ void trackContentWidget::mousePressEvent( QMouseEvent * _me )
const midiTime pos = getPosition( _me->x() ).getTact() * 64;
trackContentObject * tco = addTCO( getTrack()->createTCO(
pos ) );
tco->saveStepRecordingState( FALSE );
tco->saveJournallingState( FALSE );
tco->movePosition( pos );
tco->restoreStepRecordingState();
tco->restoreJournallingState();
}
}
@@ -861,26 +865,57 @@ void trackContentWidget::resizeEvent( QResizeEvent * _re )
void trackContentWidget::undoStep( const editStep & _edit_step )
void trackContentWidget::undoStep( journalEntry & _je )
{
saveStepRecordingState( FALSE );
switch( _edit_step.actionID() )
saveJournallingState( FALSE );
switch( _je.actionID() )
{
case ADD_TCO:
{
QMap<QString, QVariant> map = _je.data().toMap();
journallingObject * jo =
eng()->getProjectJournal()->getJournallingObject( map["id"].toInt() );
assert( jo != NULL );
multimediaProject mmp(
multimediaProject::JOURNAL_DATA );
jo->saveState( mmp, mmp.content() );
map["state"] = mmp.toString();
_je.data() = map;
delete jo;
break;
}
case REMOVE_TCO:
{
trackContentObject * tco = addTCO(
getTrack()->createTCO(
midiTime( 0 ) ) );
multimediaProject mmp(
_je.data().toMap()["state"].toString(), FALSE );
tco->restoreState(
mmp.content().firstChild().toElement() );
break;
}
}
restoreStepRecordingState();
restoreJournallingState();
}
void trackContentWidget::redoStep( const editStep & _edit_step )
void trackContentWidget::redoStep( journalEntry & _je )
{
/* undoStep( editStep( _edit_step.actionID(),
-_edit_step.data().toInt() ) );*/
switch( _je.actionID() )
{
case ADD_TCO:
case REMOVE_TCO:
_je.actionID() = ( _je.actionID() == ADD_TCO ) ?
REMOVE_TCO : ADD_TCO;
undoStep( _je );
_je.actionID() = ( _je.actionID() == ADD_TCO ) ?
REMOVE_TCO : ADD_TCO;
break;
}
}
@@ -945,6 +980,7 @@ trackOperationsWidget::trackOperationsWidget( trackWidget * _parent ) :
m_muteBtn = new pixmapButton( this, m_trackWidget->getTrack()->eng() );
m_muteBtn->setActiveGraphic( embed::getIconPixmap( "mute_on" ) );
m_muteBtn->setInactiveGraphic( embed::getIconPixmap( "mute_off" ) );
m_muteBtn->setCheckable( TRUE );
m_muteBtn->move( 44, 4 );
m_muteBtn->show();
connect( m_muteBtn, SIGNAL( toggled( bool ) ), this,
@@ -993,9 +1029,9 @@ m_trackWidget->getTrack()->eng()->getMainWindow()->isCtrlPressed() == TRUE &&
m_trackWidget->getTrack()->type() != track::BB_TRACK )
{
multimediaProject mmp( multimediaProject::DRAG_N_DROP_DATA );
m_trackWidget->getTrack()->saveSettings( mmp, mmp.content() );
new stringPairDrag( "track_" +
QString::number( m_trackWidget->getTrack()->type() ),
m_trackWidget->getTrack()->saveState( mmp, mmp.content() );
new stringPairDrag( QString( "track_%1" ).arg(
m_trackWidget->getTrack()->type() ),
mmp.toString(), QPixmap::grabWidget(
&m_trackWidget->getTrackSettingsWidget() ),
this, m_trackWidget->getTrack()->eng() );
@@ -1214,7 +1250,7 @@ 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 );
m_track->loadSettings( mmp.content().firstChild().toElement() );
m_track->restoreState( mmp.content().firstChild().toElement() );
_de->accept();
}
}
@@ -1370,8 +1406,7 @@ midiTime trackWidget::endPosition( const midiTime & _pos_start )
// ===========================================================================
track::track( trackContainer * _tc ) :
settings(),
engineObject( _tc->eng() ),
journallingObject( _tc->eng() ),
m_trackContainer( _tc )
{
m_trackWidget = new trackWidget( this,
@@ -1404,7 +1439,7 @@ track * FASTCALL track::create( trackTypes _tt, trackContainer * _tc )
switch( _tt )
{
case CHANNEL_TRACK: t = new channelTrack( _tc ); break;
case CHANNEL_TRACK: t = new instrumentTrack( _tc ); break;
case BB_TRACK: t = new bbTrack( _tc ); break;
case SAMPLE_TRACK: t = new sampleTrack( _tc ); break;
// case EVENT_TRACK:
@@ -1430,7 +1465,7 @@ track * FASTCALL track::create( const QDomElement & _this,
{
track * t = create( static_cast<trackTypes>( _this.attribute(
"type" ).toInt() ), _tc );
t->loadSettings( _this );
t->restoreState( _this );
return( t );
}
@@ -1441,7 +1476,7 @@ track * FASTCALL track::clone( track * _track )
{
QDomDocument doc;
QDomElement parent = doc.createElement( "clone" );
_track->saveSettings( doc, parent );
_track->saveState( doc, parent );
QDomElement e = parent.firstChild().toElement();
return( create( e, _track->getTrackContainer() ) );
}
@@ -1457,25 +1492,26 @@ tact track::length( void ) const
void FASTCALL track::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void FASTCALL track::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
csize num_of_tcos = getTrackContentWidget()->numOfTCOs();
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 );
_this.setTagName( "track" );
_this.setAttribute( "type", type() );
_this.setAttribute( "muted", muted() );
_this.setAttribute( "height", m_trackWidget->height() );
// let actual track (channelTrack, bbTrack, sampleTrack etc.) save
QDomElement ts_de = _doc.createElement( nodeName() );
// let actual track (instrumentTrack, bbTrack, sampleTrack etc.) save
// its settings
saveTrackSpecificSettings( _doc, track_de );
saveTrackSpecificSettings( _doc, ts_de );
_this.appendChild( ts_de );
// now save settings of all TCO's
for( csize i = 0; i < num_of_tcos; ++i )
{
trackContentObject * tco = getTCO( i );
tco->saveSettings( _doc, track_de );
tco->saveState( _doc, _this );
}
}
@@ -1500,15 +1536,20 @@ void FASTCALL track::loadSettings( const QDomElement & _this )
{
if( node.isElement() )
{
if( nodeName() == node.nodeName() )
if( node.nodeName() == nodeName() ||
#warning compat-code, remove in 0.3.0
( node.nodeName() == "channeltrack" &&
nodeName() == "instrumenttrack" )
)
{
loadTrackSpecificSettings( node.toElement() );
}
else
else if(
!node.toElement().attribute( "metadata" ).toInt() )
{
trackContentObject * tco = createTCO(
midiTime( 0 ) );
tco->loadSettings( node.toElement() );
tco->restoreState( node.toElement() );
addTCO( tco );
}
}

View File

@@ -55,7 +55,7 @@
#include "mixer.h"
#include "song_editor.h"
#include "string_pair_drag.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "mmp.h"
#include "config_mgr.h"
#include "import_filter.h"
@@ -70,8 +70,7 @@ trackContainer::trackContainer( engine * _engine ) :
, 0, Qt::WStyle_Title
#endif
),
settings(),
engineObject( _engine ),
journallingObject( _engine ),
m_currentPosition( 0, 0 ),
m_scrollArea( new scrollArea( this ) ),
m_ppt( DEFAULT_PIXELS_PER_TACT ),
@@ -105,18 +104,17 @@ trackContainer::~trackContainer()
void trackContainer::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void trackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement tc_de = _doc.createElement( "trackcontainer" );
tc_de.setAttribute( "type", nodeName() );
mainWindow::saveWidgetState( this, tc_de );
_parent.appendChild( tc_de );
_this.setTagName( "trackcontainer" );
_this.setAttribute( "type", nodeName() );
mainWindow::saveWidgetState( this, _this );
// save settings of each track
for( trackWidgetVector::iterator it = m_trackWidgets.begin();
it != m_trackWidgets.end(); ++it )
{
( *it )->getTrack()->saveSettings( _doc, tc_de );
( *it )->getTrack()->saveState( _doc, _this );
}
}
@@ -170,7 +168,8 @@ void trackContainer::loadSettings( const QDomElement & _this )
break;
}
if( node.isElement() )
if( node.isElement() &&
!node.toElement().attribute( "metadata" ).toInt() )
{
track::create( node.toElement(), this );
}
@@ -436,32 +435,32 @@ void trackContainer::dropEvent( QDropEvent * _de )
QString value = stringPairDrag::decodeValue( _de );
if( type == "instrument" )
{
channelTrack * ct = dynamic_cast<channelTrack *>(
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK,
this ) );
ct->loadInstrument( value );
ct->toggledChannelButton( TRUE );
it->loadInstrument( value );
it->toggledInstrumentTrackButton( TRUE );
_de->accept();
}
else if( type == "sampledata" || type == "samplefile" )
{
channelTrack * ct = dynamic_cast<channelTrack *>(
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK,
this ) );
instrument * i = ct->loadInstrument( "audiofileprocessor" );
instrument * i = it->loadInstrument( "audiofileprocessor" );
i->setParameter( type, value );
ct->toggledChannelButton( TRUE );
it->toggledInstrumentTrackButton( TRUE );
_de->accept();
}
else if( type == "presetfile" )
{
multimediaProject mmp( value );
channelTrack * ct = dynamic_cast<channelTrack *>(
instrumentTrack * it = dynamic_cast<instrumentTrack *>(
track::create( track::CHANNEL_TRACK,
this ) );
ct->loadTrackSpecificSettings( mmp.content().firstChild().
it->loadTrackSpecificSettings( mmp.content().firstChild().
toElement() );
ct->toggledChannelButton( TRUE );
it->toggledInstrumentTrackButton( TRUE );
_de->accept();
}
else if( type == "midifile" )

View File

@@ -30,8 +30,16 @@
#include "base64.h"
#include "types.h"
#ifndef QT3
#include <QVariant>
#include <QBuffer>
#else
#include <qvariant.h>
#include <qbuffer.h>
#ifdef QT3
namespace base64
{
@@ -168,4 +176,55 @@ void decode( const QString & _b64, char * * _data, int * _size )
#endif
namespace base64
{
QString encode( const QVariant & _data )
{
QBuffer buf;
#ifndef QT3
buf.open( QBuffer::WriteOnly );
#else
buf.open( IO_WriteOnly );
#endif
QDataStream out( &buf );
out << _data;
QByteArray data = buf.buffer();
QString dst;
#ifndef QT3
encode( data.constData(), data.size(), dst );
#else
encode( data.data(), data.size(), dst );
#endif
return( dst );
}
QVariant decode( const QString & _b64 )
{
char * dst = NULL;
int dsize = 0;
base64::decode( _b64, &dst, &dsize );
#ifndef QT3
QByteArray ba( dst, dsize );
QBuffer buf( &ba );
buf.open( QBuffer::ReadOnly );
#else
QByteArray ba;
ba.setRawData( dst, dsize );
QBuffer buf( ba );
buf.open( IO_ReadOnly );
#endif
QDataStream in( &buf );
QVariant ret;
in >> ret;
return( ret );
}
} ;
#endif

View File

@@ -26,7 +26,7 @@
#include "clipboard.h"
#include "settings.h"
#include "journalling_object.h"
namespace clipboard
@@ -35,13 +35,12 @@ namespace clipboard
map content;
void copy( settings * _settings_object )
void copy( journallingObject * _obj )
{
QDomDocument doc;
QDomElement parent = doc.createElement( "clipboard" );
_settings_object->saveSettings( doc, parent );
content[_settings_object->nodeName()] =
parent.firstChild().toElement();
_obj->saveState( doc, parent );
content[_obj->nodeName()] = parent.firstChild().toElement();
}

View File

@@ -0,0 +1,222 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* journalling_object.cpp - implementation of journalling-object related stuff
*
* 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 "journalling_object.h"
#include "project_journal.h"
#include "base64.h"
#include "qt3support.h"
#ifndef QT3
#include <Qt/QtXml>
#else
#include <qdom.h>
#endif
journallingObject::journallingObject( engine * _engine ) :
engineObject( _engine ),
m_id( ( eng() != NULL ) ? eng()->getProjectJournal()->allocID( this ) :
0 ),
m_journalEntries(),
m_currentJournalEntry( m_journalEntries.end() ),
m_journalling( TRUE )
{
}
journallingObject::~journallingObject()
{
if( eng() != NULL )
{
eng()->getProjectJournal()->freeID( id() );
}
}
void journallingObject::undo( void )
{
if( m_journalEntries.empty() == TRUE )
{
return;
}
if( m_currentJournalEntry - 1 >= m_journalEntries.begin() )
{
undoStep( *--m_currentJournalEntry );
}
}
void journallingObject::redo( void )
{
if( m_journalEntries.empty() == TRUE )
{
return;
}
if( m_currentJournalEntry < m_journalEntries.end() )
{
redoStep( *m_currentJournalEntry++ );
}
}
QDomElement journallingObject::saveState( QDomDocument & _doc,
QDomElement & _parent )
{
QDomElement _this = _doc.createElement( nodeName() );
saveSettings( _doc, _this );
saveJournal( _doc, _this );
_parent.appendChild( _this );
return( _this );
}
void journallingObject::restoreState( const QDomElement & _this )
{
saveJournallingState( FALSE );
loadSettings( _this );
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() && node.nodeName() == "journal" )
{
loadJournal( node.toElement() );
}
node = node.nextSibling();
}
restoreJournallingState();
}
void journallingObject::addJournalEntry( const journalEntry & _edit_step )
{
if( !( eng() == NULL ||
eng()->getProjectJournal()->isJournalling() == FALSE ||
isJournalling() == FALSE ) )
{
m_journalEntries.erase( m_currentJournalEntry,
m_journalEntries.end() );
m_journalEntries.push_back( _edit_step );
m_currentJournalEntry = m_journalEntries.end();
eng()->getProjectJournal()->journalEntryAdded( id() );
}
}
void journallingObject::saveJournal( QDomDocument & _doc,
QDomElement & _parent )
{
/* // avoid creating empty journal-nodes
if( m_journalEntries.size() == 0 )
{
return;
}*/
QDomElement journal_de = _doc.createElement( "journal" );
journal_de.setAttribute( "id", id() );
journal_de.setAttribute( "entries", m_journalEntries.size() );
journal_de.setAttribute( "curentry", m_currentJournalEntry -
m_journalEntries.begin() );
journal_de.setAttribute( "metadata", TRUE );
for( journalEntryVector::const_iterator it = m_journalEntries.begin();
it != m_journalEntries.end(); ++it )
{
QDomElement je_de = _doc.createElement( "entry" );
je_de.setAttribute( "pos", it - m_journalEntries.begin() );
je_de.setAttribute( "actionid", it->actionID() );
je_de.setAttribute( "data", base64::encode( it->data() ) );
journal_de.appendChild( je_de );
}
_parent.appendChild( journal_de );
}
void journallingObject::loadJournal( const QDomElement & _this )
{
clear();
const jo_id_t new_id = _this.attribute( "id" ).toInt();
if( new_id == 0 )
{
return;
}
if( id() != new_id )
{
eng()->getProjectJournal()->forgetAboutID( id() );
eng()->getProjectJournal()->reallocID( new_id, this );
m_id = new_id;
}
m_journalEntries.resize( _this.attribute( "entries" ).toInt() );
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
{
const QDomElement & je = node.toElement();
m_journalEntries[je.attribute( "pos" ).toInt()] =
journalEntry(
je.attribute( "actionid" ).toInt(),
base64::decode( je.attribute( "data" ) ) );
}
node = node.nextSibling();
}
m_currentJournalEntry = m_journalEntries.begin() +
_this.attribute( "curentry" ).toInt();
}
#endif

View File

@@ -55,11 +55,14 @@ multimediaProject::typeDescStruct
{ multimediaProject::UNKNOWN, "unknown" },
{ multimediaProject::SONG_PROJECT, "song" },
{ multimediaProject::SONG_PROJECT_TEMPLATE, "songtemplate" },
{ multimediaProject::CHANNEL_SETTINGS, "channelsettings" },
#warning compat-code, remove in 0.3.0
{ multimediaProject::INSTRUMENT_TRACK_SETTINGS,
"instrumenttracksettings,channelsettings" },
{ multimediaProject::DRAG_N_DROP_DATA, "dnddata" },
{ multimediaProject::JOURNAL_DATA, "journaldata" },
{ multimediaProject::EFFECT_SETTINGS, "effectsettings" },
{ multimediaProject::VIDEO_PROJECT, "video" },
{ multimediaProject::BURN_PROJECT, "burn" },
{ multimediaProject::VIDEO_PROJECT, "videoproject" },
{ multimediaProject::BURN_PROJECT, "burnproject" },
{ multimediaProject::PLAYLIST, "playlist" }
} ;
@@ -162,7 +165,9 @@ multimediaProject::multimediaProject( const QString & _in_file_name,
{
m_head = node.toElement();
}
else if( node.nodeName() == typeName( m_type ) )
else if( node.nodeName() == typeName( m_type ) ||
#warning compat-code, remove in 0.3.0
node.nodeName() == "channelsettings" )
{
m_content = node.toElement();
}
@@ -189,7 +194,7 @@ bool multimediaProject::writeFile( const QString & _fn, bool _overwrite_check )
#endif
);
QString fn = _fn;
if( type() == CHANNEL_SETTINGS )
if( type() == INSTRUMENT_TRACK_SETTINGS )
{
if( fn.section( '.', -2, -1 ) != "cs.xml" )
{
@@ -282,7 +287,12 @@ multimediaProject::projectTypes multimediaProject::type(
{
for( int i = 0; i < PROJ_TYPE_COUNT; ++i )
{
if( s_types[i].m_name == _type_name )
if( s_types[i].m_name == _type_name || (
s_types[i].m_name.contains( "," ) && (
s_types[i].m_name.section( ',', 0, 0 ) == _type_name ||
s_types[i].m_name.section( ',', 1, 1 ) == _type_name ) )
)
{
return( static_cast<multimediaProject::projectTypes>(
i ) );

162
src/lib/project_journal.cpp Normal file
View File

@@ -0,0 +1,162 @@
#ifndef SINGLE_SOURCE_COMPILE
/*
* project_journal.cpp - implementation of project-journal
*
* 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 <cstdlib>
#include "project_journal.h"
#include "journalling_object.h"
#include "song_editor.h"
projectJournal::projectJournal( engine * _engine ) :
engineObject( _engine ),
m_joIDs(),
m_journalEntries(),
m_currentJournalEntry( m_journalEntries.end() )
{
}
projectJournal::~projectJournal()
{
}
void projectJournal::undo( void )
{
if( m_journalEntries.empty() == TRUE )
{
return;
}
journallingObject * jo;
if( m_currentJournalEntry - 1 >= m_journalEntries.begin() &&
( jo = m_joIDs[*--m_currentJournalEntry] ) != NULL )
{
jo->undo();
eng()->getSongEditor()->setModified();
}
}
void projectJournal::redo( void )
{
if( m_journalEntries.empty() == TRUE )
{
return;
}
journallingObject * jo;
if( m_currentJournalEntry < m_journalEntries.end() &&
( jo = m_joIDs[*m_currentJournalEntry++] ) != NULL )
{
jo->redo();
eng()->getSongEditor()->setModified();
}
}
void projectJournal::journalEntryAdded( const jo_id_t _id )
{
m_journalEntries.erase( m_currentJournalEntry, m_journalEntries.end() );
m_journalEntries.push_back( _id );
m_currentJournalEntry = m_journalEntries.end();
eng()->getSongEditor()->setModified();
printf("history size:%d\n", m_journalEntries.size());
}
jo_id_t projectJournal::allocID( journallingObject * _obj )
{
const jo_id_t EO_ID_MAX = 1 << 20;
jo_id_t id;
while( m_joIDs.contains( id = static_cast<jo_id_t>( (float) rand() /
RAND_MAX * EO_ID_MAX ) ) )
{
}
m_joIDs[id] = _obj;
//printf("new id: %d\n", id );
return( id );
}
void projectJournal::reallocID( const jo_id_t _id, journallingObject * _obj )
{
//printf("realloc %d %d\n", _id, _obj);
if( m_joIDs.contains( _id ) )
{
m_joIDs[_id] = _obj;
}
}
void projectJournal::forgetAboutID( const jo_id_t _id )
{
journalEntryVector::iterator it;
while( ( it = qFind( m_journalEntries.begin(), m_journalEntries.end(),
_id ) ) != m_journalEntries.end() )
{
if( m_currentJournalEntry >= it )
{
--m_currentJournalEntry;
}
m_journalEntries.erase( it );
}
m_joIDs.erase( _id );
}
void projectJournal::clear( void )
{
while( m_joIDs.size() )
{
forgetAboutID( m_joIDs.keys().front() );
}
}
#endif

View File

@@ -1,8 +1,11 @@
#ifdef SINGLE_SOURCE_COMPILE
#undef SINGLE_SOURCE_COMPILE
#include "src/tracks/instrument_track.cpp"
#include "src/core/midi_tab_widget.cpp"
#include "src/lib/string_pair_drag.cpp"
#include "src/lib/buffer_allocator.cpp"
#include "src/lib/edit_history.cpp"
#include "src/lib/journalling_object.cpp"
#include "src/lib/project_journal.cpp"
#include "src/lib/embed.cpp"
#include "src/lib/base64.cpp"
#include "src/lib/mmp.cpp"
@@ -39,7 +42,6 @@
#include "src/core/track.cpp"
#include "src/core/file_browser.cpp"
#include "src/core/surround_area.cpp"
#include "src/core/midi_tab_widget.cpp"
#include "src/midi/midi_alsa_seq.cpp"
#include "src/midi/midi_oss.cpp"
#include "src/midi/midi_port.cpp"
@@ -59,7 +61,6 @@
#include "src/lmms_single_source.cpp"
#include "src/tracks/pattern.cpp"
#include "src/tracks/bb_track.cpp"
#include "src/tracks/channel_track.cpp"
#include "src/tracks/sample_track.cpp"
#include "src/widgets/project_notes.cpp"
#include "src/widgets/led_checkbox.cpp"

View File

@@ -72,9 +72,9 @@ bbTCO::bbTCO( track * _track, const QColor & _c ) :
bbTrack::numOfBBTrack( getTrack() ) );
if( t > 0 )
{
saveStepRecordingState( FALSE );
saveJournallingState( FALSE );
changeLength( midiTime( t, 0 ) );
restoreStepRecordingState();
restoreJournallingState();
}
}
@@ -192,21 +192,19 @@ void bbTCO::paintEvent( QPaintEvent * )
void bbTCO::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void bbTCO::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement bbtco_de = _doc.createElement( nodeName() );
bbtco_de.setAttribute( "name", m_name );
if( _parent.nodeName() == "clipboard" )
_this.setAttribute( "name", m_name );
if( _this.parentNode().nodeName() == "clipboard" )
{
bbtco_de.setAttribute( "pos", -1 );
_this.setAttribute( "pos", -1 );
}
else
{
bbtco_de.setAttribute( "pos", startPosition() );
_this.setAttribute( "pos", startPosition() );
}
bbtco_de.setAttribute( "len", length() );
bbtco_de.setAttribute( "color", m_color.rgb() );
_parent.appendChild( bbtco_de );
_this.setAttribute( "len", length() );
_this.setAttribute( "color", m_color.rgb() );
}
@@ -419,18 +417,16 @@ trackContentObject * bbTrack::createTCO( const midiTime & _pos )
void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent )
QDomElement & _this )
{
QDomElement bbt_de = _doc.createElement( nodeName() );
bbt_de.setAttribute( "name", m_trackLabel->text() );
bbt_de.setAttribute( "icon", m_trackLabel->pixmapFile() );
/* bbt_de.setAttribute( "current", s_infoMap[this] ==
_this.setAttribute( "name", m_trackLabel->text() );
_this.setAttribute( "icon", m_trackLabel->pixmapFile() );
/* _this.setAttribute( "current", s_infoMap[this] ==
eng()->getBBEditor()->currentBB() );*/
_parent.appendChild( bbt_de );
if( s_infoMap[this] == 0 &&
_parent.parentNode().nodeName() != "clone" )
_this.parentNode().nodeName() != "clone" )
{
eng()->getBBEditor()->saveSettings( _doc, bbt_de );
eng()->getBBEditor()->saveState( _doc, _this );
}
}
@@ -446,7 +442,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this )
}
if( _this.firstChild().isElement() )
{
eng()->getBBEditor()->loadSettings(
eng()->getBBEditor()->restoreState(
_this.firstChild().toElement() );
}
/* doesn't work yet because bbTrack-ctor also sets current bb so if

File diff suppressed because it is too large Load Diff

View File

@@ -56,7 +56,7 @@
#include "pattern.h"
#include "channel_track.h"
#include "instrument_track.h"
#include "templates.h"
#include "gui_templates.h"
#include "embed.h"
@@ -81,13 +81,13 @@ QPixmap * pattern::s_frozen = NULL;
pattern::pattern ( channelTrack * _channel_track ) :
trackContentObject( _channel_track ),
pattern::pattern ( instrumentTrack * _instrument_track ) :
trackContentObject( _instrument_track ),
m_paintPixmap(),
m_needsUpdate( TRUE ),
m_channelTrack( _channel_track ),
m_instrumentTrack( _instrument_track ),
m_patternType( BEAT_PATTERN ),
m_name( _channel_track->name() ),
m_name( _instrument_track->name() ),
m_steps( DEFAULT_STEPS_PER_TACT ),
m_frozenPatternMutex(),
m_frozenPattern( NULL ),
@@ -101,10 +101,10 @@ pattern::pattern ( channelTrack * _channel_track ) :
pattern::pattern( const pattern & _pat_to_copy ) :
trackContentObject( _pat_to_copy.m_channelTrack ),
trackContentObject( _pat_to_copy.m_instrumentTrack ),
m_paintPixmap(),
m_needsUpdate( TRUE ),
m_channelTrack( _pat_to_copy.m_channelTrack ),
m_instrumentTrack( _pat_to_copy.m_instrumentTrack ),
m_patternType( _pat_to_copy.m_patternType ),
m_name( "" ),
m_steps( _pat_to_copy.m_steps ),
@@ -186,12 +186,12 @@ void pattern::init( void )
s_frozen = new QPixmap( embed::getIconPixmap( "frozen" ) );
}
saveStepRecordingState( FALSE );
saveJournallingState( FALSE );
ensureBeatNotes();
changeLength( length() );
restoreStepRecordingState();
restoreJournallingState();
#ifndef QT4
// set background-mode for flicker-free redraw
@@ -411,27 +411,25 @@ void pattern::playFrozenData( sampleFrame * _ab, const f_cnt_t _start_frame,
void pattern::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void pattern::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement pattern_de = _doc.createElement( nodeName() );
pattern_de.setAttribute( "type", m_patternType );
pattern_de.setAttribute( "name", m_name );
_this.setAttribute( "type", m_patternType );
_this.setAttribute( "name", m_name );
// as the target of copied/dragged pattern is always an existing
// pattern, we must not store actual position, instead we store -1
// which tells loadSettings() not to mess around with position
if( _parent.nodeName() == "clipboard" ||
_parent.nodeName() == "dnddata" )
if( _this.parentNode().nodeName() == "clipboard" ||
_this.parentNode().nodeName() == "dnddata" )
{
pattern_de.setAttribute( "pos", -1 );
_this.setAttribute( "pos", -1 );
}
else
{
pattern_de.setAttribute( "pos", startPosition() );
_this.setAttribute( "pos", startPosition() );
}
pattern_de.setAttribute( "len", length() );
pattern_de.setAttribute( "steps", m_steps );
pattern_de.setAttribute( "frozen", m_frozenPattern != NULL );
_parent.appendChild( pattern_de );
_this.setAttribute( "len", length() );
_this.setAttribute( "steps", m_steps );
_this.setAttribute( "frozen", m_frozenPattern != NULL );
// now save settings of all notes
for( noteVector::iterator it = m_notes.begin();
@@ -439,7 +437,7 @@ void pattern::saveSettings( QDomDocument & _doc, QDomElement & _parent )
{
if( ( *it )->length() )
{
( *it )->saveSettings( _doc, pattern_de );
( *it )->saveState( _doc, _this );
}
}
}
@@ -465,10 +463,11 @@ void pattern::loadSettings( const QDomElement & _this )
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() )
if( node.isElement() &&
!node.toElement().attribute( "metadata" ).toInt() )
{
note * n = new note();
n->loadSettings( node.toElement() );
note * n = new note( eng() );
n->restoreState( node.toElement() );
m_notes.push_back( n );
}
node = node.nextSibling();
@@ -530,7 +529,7 @@ void pattern::clear( void )
void pattern::resetName( void )
{
m_name = m_channelTrack->name();
m_name = m_instrumentTrack->name();
}
@@ -558,7 +557,7 @@ void pattern::freeze( void )
QMessageBox::Ok );
return;
}
if( m_channelTrack->muted() )
if( m_instrumentTrack->muted() )
{
if( QMessageBox::
#if QT_VERSION >= 0x030200
@@ -1143,7 +1142,7 @@ void pattern::ensureBeatNotes( void )
}
if( found == FALSE )
{
addNote( note( midiTime( 0 ), midiTime( i *
addNote( note( eng(), midiTime( 0 ), midiTime( i *
BEATS_PER_TACT ) ) );
}
}

View File

@@ -64,9 +64,9 @@ sampleTCO::sampleTCO( track * _track ) :
setBackgroundMode( Qt::NoBackground );
#endif
saveStepRecordingState( FALSE );
saveJournallingState( FALSE );
setSampleFile( "" );
restoreStepRecordingState();
restoreJournallingState();
// we need to receive bpm-change-events, because then we have to
// change length of this TCO
@@ -253,26 +253,24 @@ midiTime sampleTCO::getSampleLength( void ) const
void FASTCALL sampleTCO::saveSettings( QDomDocument & _doc,
QDomElement & _parent )
QDomElement & _this )
{
QDomElement sampletco_de = _doc.createElement( nodeName() );
if( _parent.nodeName() == "clipboard" )
if( _this.parentNode().nodeName() == "clipboard" )
{
sampletco_de.setAttribute( "pos", -1 );
_this.setAttribute( "pos", -1 );
}
else
{
sampletco_de.setAttribute( "pos", startPosition() );
_this.setAttribute( "pos", startPosition() );
}
sampletco_de.setAttribute( "len", length() );
sampletco_de.setAttribute( "src", sampleFile() );
_this.setAttribute( "len", length() );
_this.setAttribute( "src", sampleFile() );
if( sampleFile() == "" )
{
QString s;
sampletco_de.setAttribute( "data", m_sampleBuffer.toBase64( s ) );
_this.setAttribute( "data", m_sampleBuffer.toBase64( s ) );
}
// TODO: start- and end-frame
_parent.appendChild( sampletco_de );
}
@@ -454,12 +452,10 @@ trackContentObject * sampleTrack::createTCO( const midiTime & )
void sampleTrack::saveTrackSpecificSettings( QDomDocument & _doc,
QDomElement & _parent )
QDomElement & _this )
{
QDomElement st_de = _doc.createElement( nodeName() );
st_de.setAttribute( "name", m_trackLabel->text() );
st_de.setAttribute( "icon", m_trackLabel->pixmapFile() );
_parent.appendChild( st_de );
_this.setAttribute( "name", m_trackLabel->text() );
_this.setAttribute( "icon", m_trackLabel->pixmapFile() );
}

View File

@@ -33,7 +33,7 @@ automatableButton::automatableButton( QWidget * _parent, engine * _engine ) :
QWidget( _parent ),
autoObj( _engine, FALSE, TRUE, FALSE ),
m_group( NULL ),
m_toggleButton( FALSE )
m_checkable( FALSE )
{
}
@@ -55,7 +55,7 @@ void automatableButton::mousePressEvent( QMouseEvent * _me )
{
if( _me->button() == Qt::LeftButton )
{
if( m_toggleButton == FALSE )
if( m_checkable == FALSE )
{
setChecked( TRUE );
}
@@ -76,7 +76,7 @@ void automatableButton::mousePressEvent( QMouseEvent * _me )
void automatableButton::mouseReleaseEvent( QMouseEvent * _me )
{
if( m_toggleButton == FALSE )
if( m_checkable == FALSE )
{
setChecked( FALSE );
}
@@ -88,7 +88,7 @@ void automatableButton::mouseReleaseEvent( QMouseEvent * _me )
void automatableButton::toggle( void )
{
if( m_toggleButton == TRUE && m_group != NULL )
if( m_checkable == TRUE && m_group != NULL )
{
if( value() == FALSE )
{
@@ -147,11 +147,11 @@ automatableButtonGroup::~automatableButtonGroup()
void automatableButtonGroup::addButton( automatableButton * _btn )
{
_btn->m_group = this;
_btn->setToggleButton( TRUE );
_btn->setCheckable( TRUE );
_btn->setChecked( FALSE );
// disable step-recording as we're recording changes of states of
// button-group members on our own
_btn->setStepRecording( FALSE );
_btn->setJournalling( FALSE );
m_buttons.push_back( _btn );
setRange( 0, m_buttons.size() - 1 );

View File

@@ -74,7 +74,7 @@ groupBox::groupBox( const QString & _caption, QWidget * _parent,
updatePixmap();
m_led = new pixmapButton( this, eng() );
m_led->setToggleButton( TRUE );
m_led->setCheckable( TRUE );
m_led->move( 2, 3 );
m_led->setActiveGraphic( embed::getIconPixmap( "led_green" ) );
m_led->setInactiveGraphic( embed::getIconPixmap( "led_off" ) );

View File

@@ -5,7 +5,7 @@
#include "qt3support.h"
#ifdef QT4
#ifndef QT3
#include "kmultitabbar.h"
@@ -1220,7 +1220,7 @@ KMultiTabBarTab::KMultiTabBarTab(const QPixmap& pic, const QString& text,
d=new KMultiTabBarTabPrivate();
setIcon(pic);
m_expandedSize=24;
setCheckable(true);
setToggleButton(true);
}
KMultiTabBarTab::~KMultiTabBarTab() {

View File

@@ -411,7 +411,7 @@ void knob::mousePressEvent( QMouseEvent * _me )
if( _me->button() == Qt::LeftButton &&
eng()->getMainWindow()->isCtrlPressed() == FALSE )
{
setStepRecording( FALSE );
setJournalling( FALSE );
m_oldValue = value();
const QPoint & p = _me->pos();
@@ -478,8 +478,8 @@ void knob::mouseMoveEvent( QMouseEvent * _me )
//! Mouse Release Event handler
void knob::mouseReleaseEvent( QMouseEvent * /* _me*/ )
{
setStepRecording( TRUE );
addStepFromOldToCurVal();
setJournalling( TRUE );
addJournalEntryFromOldToCurVal();
if( m_buttonPressed )
{

View File

@@ -170,10 +170,10 @@ void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me )
int dy = _me->globalY() - m_origMousePos.y();
if( dy > 1 || dy < -1 )
{
setStepRecording( FALSE );// why is this neccessary?!
setJournalling( FALSE );// why is this neccessary?!
setInitValue( value() - dy / 2 * step() );
emit valueChanged( value() );
setStepRecording( TRUE );
setJournalling( TRUE );
QCursor::setPos( m_origMousePos );
}
}
@@ -184,7 +184,7 @@ void lcdSpinBox::mouseMoveEvent( QMouseEvent * _me )
void lcdSpinBox::mouseReleaseEvent( QMouseEvent * _me )
{
addStepFromOldToCurVal();
addJournalEntryFromOldToCurVal();
QCursor::setPos( m_origMousePos );
QApplication::restoreOverrideCursor();

View File

@@ -59,7 +59,7 @@ ledCheckBox::ledCheckBox( const QString & _text, QWidget * _parent,
automatableButton( _parent, _engine ),
m_text( _text )
{
setToggleButton( TRUE );
setCheckable( TRUE );
if( _color >= TOTAL_COLORS || _color < YELLOW )
{

View File

@@ -79,7 +79,7 @@ projectNotes::projectNotes( engine * _engine) :
, 0, Qt::WStyle_Title
#endif
),
engineObject( _engine )
journallingObject( _engine )
{
#ifdef QT4
eng()->getMainWindow()->workspace()->addWindow( this );
@@ -570,15 +570,12 @@ void projectNotes::alignmentChanged( int _a )
void projectNotes::saveSettings( QDomDocument & _doc, QDomElement & _parent )
void projectNotes::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
QDomElement pn_de = _doc.createElement( nodeName() );
mainWindow::saveWidgetState( this, pn_de );
mainWindow::saveWidgetState( this, _this );
QDomCDATASection ds = _doc.createCDATASection( m_edit->toHtml() );
pn_de.appendChild( ds );
_parent.appendChild( pn_de );
_this.appendChild( ds );
}