From d3c33b9bd61f6bf94bd1c979af9411541c441a03 Mon Sep 17 00:00:00 2001 From: Javier Serrano Polo Date: Fri, 7 Dec 2007 21:08:01 +0000 Subject: [PATCH] fixed modified project indicator and scrolling git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@619 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 59 +++++++ configure.in | 4 +- data/locale/ca.qm | Bin 170013 -> 170013 bytes data/locale/ca.ts | 302 ++++++++++++++++---------------- data/themes/default/style.css | 5 + include/bb_editor.h | 12 +- include/main_window.h | 11 +- include/song_editor.h | 10 -- include/track.h | 5 +- include/track_container.h | 35 ++-- src/core/bb_editor.cpp | 160 ++++++----------- src/core/file_browser.cpp | 2 +- src/core/main_window.cpp | 59 +++++-- src/core/song_editor.cpp | 137 ++++----------- src/core/track.cpp | 164 +++++++++-------- src/core/track_container.cpp | 153 +++++++--------- src/tracks/bb_track.cpp | 11 +- src/tracks/instrument_track.cpp | 2 - src/tracks/pattern.cpp | 22 ++- src/tracks/sample_track.cpp | 8 +- src/widgets/project_notes.cpp | 1 - 21 files changed, 561 insertions(+), 601 deletions(-) diff --git a/ChangeLog b/ChangeLog index 81a6ab6f7..f58c388fd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,62 @@ +2007-12-07 Javier Serrano Polo + + * include/main_window.h: + * include/song_editor.h: + * src/core/file_browser.cpp: + * src/core/main_window.cpp: + * src/core/song_editor.cpp: + use custom modified project indicator, fixed + + * include/bb_editor.h: + * include/song_editor.h: + * include/track.h: + * include/track_container.h: + * src/core/bb_editor.cpp: + * src/core/song_editor.cpp: + * src/core/track.cpp: + * src/core/track_container.cpp: + * src/tracks/pattern.cpp: + * src/tracks/sample_track.cpp: + added layouts, fixes scrolling + + * include/track.h: + * include/track_container.h: + * src/core/bb_editor.cpp: + * src/core/song_editor.cpp: + * src/core/track.cpp: + * src/core/track_container.cpp: + * src/tracks/bb_track.cpp: + associate track containers with tracks directly + + * src/core/track.cpp: + * src/core/track_container.cpp: + * src/tracks/bb_track.cpp: + * src/tracks/instrument_track.cpp: + * src/tracks/sample_track.cpp: + simplified updateAfterTrackAdd() calls + + * data/themes/default/style.css: + * src/core/track.cpp: + use style sheet painting + + * include/track.h: + * src/core/track.cpp: + removed discouraged repaint() + + * include/bb_editor.h: + * include/song_editor.h: + * src/core/bb_editor.cpp: + * src/core/song_editor.cpp: + * src/widgets/project_notes.cpp: + use default close event handler + + * src/core/bb_editor.cpp: + * src/core/track.cpp: + removed trivial asserts + + * data/locale/ca.ts: + updated translation + 2007-11-27 Tobias Doerffel * include/plugin.h: diff --git a/configure.in b/configure.in index ab83448a7..15b092e4d 100644 --- a/configure.in +++ b/configure.in @@ -2,8 +2,8 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT(lmms, 0.4.0-svn20071127, lmms-devel/at/lists/dot/sf/dot/net) -AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20071127) +AC_INIT(lmms, 0.4.0-svn20071207, lmms-devel/at/lists/dot/sf/dot/net) +AM_INIT_AUTOMAKE(lmms, 0.4.0-svn20071207) AM_CONFIG_HEADER(config.h) diff --git a/data/locale/ca.qm b/data/locale/ca.qm index f119e6c1b048a1aba0efa31f99818ba80dd5d0e7..5ff995ef039809fbb043ab4daa93ca4958e4577c 100644 GIT binary patch delta 42 zcmV+_0M-AUunL{93b1(hlU79!gNOIGhxY-ONS7!o0S^Nl08f{Zg#sG4N bbEditor - + Play/pause current beat/bassline (Space) Reprodueix/pausa el ritme base actual (Espai) - + Stop playing of current beat/bassline (Space) Atura el ritme base actual (Espai) - + Click here, if you want to play the current beat/bassline. The beat/bassline is automatically looped when its end is reached. Pica aquí si vols reproduir el ritme base actual. El ritme base és repetit automàticament quan arriba al final. - + Click here, if you want to stop playing of current beat/bassline. Pica aquí si vols aturar el ritme base actual. - + Beat+Baseline Editor Editor de Ritme Base - + Add beat/bassline Afegeix ritme de base @@ -2058,17 +2058,17 @@ Assegura't que tens permís d'escriptura per al fitxer/dispositiu sele Sortida MIDI - + Save channel-settings in file Desa configuració de canal en fitxer - + Channel-Settings-File (*.cs.xml) Fitxer de Configuració de Canal (*.cs.xml) - + PLUGIN CONN @@ -2634,262 +2634,272 @@ Les tecles F1-F10 apaguen els 10 primers instruments a l'Editor de Ritme Ba Preparant finestra principal i espai de treball... - + Creating new song... Creant nova cançó... - + Creating GUI... Creant interfície... - + &New &Nou - + &Open... &Obre... - + &Save &Desa - + Save &As... &Anomena i desa... - + &Quit &Surt - + Help Ajuda - + About Quant a - + &Help &Ajuda - + What's this? Què és això? - + My samples Les meves mostres - + My presets Les meves plantilles - + My projects Els meus projectes - + Loading song... Carregant cançó... - + &Settings &Configuració - + Show setup wizard Mostra l'assistent de configuració - + By pressing this button, you can show or hide the project notes window. In this window you can put down your project notes. Pitjant aquest botó, pots mostrar o amagar la finestra de notes del projecte. En aquesta finestra pots escriure les teves notes del projecte. - + LMMS %1 LMMS %1 - + Create new project Crea nou projecte - + Open existing project Obre projecte existent - + Save current project Desa projecte actual - + Export current project Exporta projecte actual - + By pressing this button, you can show or hide the Piano-Roll. With the help of the Piano-Roll you can edit melody-patterns in an easy way. Pitjant aquest botó pots mostrar o amagar el Rotlle de Piano. Amb l'ajuda del Rotlle de Piano pots editar patrons de melodia fàcilment. - + &Project &Projecte - + Open project Obre projecte - + Save project Desa projecte - + My home El meu cau - + Root directory Directori arrel - + Show/hide Beat+Baseline Editor Mostra/amaga Editor de Ritme Base - + By pressing this button, you can show or hide the Beat+Baseline Editor. The Beat+Baseline Editor is needed for creating beats, opening, adding and removing channels, cutting, copying and pasting beat- and baseline-patterns and other things like that. Pitjant aquest botó pots mostrar o amagar l'Editor de Ritme Base. L'Editor de Ritme Base és necessari per a crear ritmes; obrir, afegir i eliminar canals; tallar, copiar i enganxar patrons de ritme; i altres funcions similars. - + Show/hide Piano-Roll Mostra/amaga Rotlle de Piano - + Show/hide Song-Editor Mostra/amaga Editor de Cançó - + By pressing this button, you can show or hide the Song-Editor. With the help of the Song-Editor you can edit song-playlist and specify when which track should be played. You can also insert and move samples (e.g. rap-samples) directly into the playlist. Pitjant aquest botó pots mostrar o amagar l'Editor de Cançó. Amb l'ajuda de l'Editor de Cançó pots editar la llista de reproducció de la cançó i especificar quan ha de tocar-se cada pista. També pots inserir i moure mostres (p.e. mostres de rap) directament a la llista de reproducció. - + Show/hide project notes Mostra/amaga les notes del projecte - + &Edit &Edita - + Undo Desfés - + Redo Refés - + Show settings dialog Mostra el diàleg de configuració - + Help not available Ajuda no disponible - + Show/hide Automation Editor Mostra/amaga Editor d'Automatització - + By pressing this button, you can show or hide the Automation Editor. With the help of the Automation Editor you can edit dynamic values in an easy way. Pitjant aquest botó pots mostrar o amagar l'Editor d'Automatització. Amb l'ajuda de l'Editor d'Automatització pots editar valors dinàmics fàcilment. - + &Tools E&ines - + MultiMedia Project (*.mmp *.mmpz *.xml) Projecte MultiMèdia (*.mmp *.mmpz *.xml) - + MultiMedia Project (*.mmp *.mmpz);;MultiMedia Project Template (*.mpt) Projecte MultiMèdia (*.mmp *.mmpz);;Plantilla de Projecte MultiMèdia (*.mpt) - + Online help Ajuda en línia - + Import... Importa... - + E&xport... E&xporta... - + Currently there's no help available in LMMS. Please visit http://lmms.sf.net/wiki for documentation on LMMS. Actualment no hi ha ajuda disponible a LMMS. Per favor, visita http://lmms.sf.net/wiki per a documentació sobre LMMS. - + Recently opened projects Projectes oberts recentment - + Untitled Sense títol + + + Project not saved + Projecte no desat + + + + The current project was modified since last saving. Do you want to save it now? + El projecte actual ha estat modificat des del darrer desament. Vols desar-lo ara? + mallets @@ -3474,12 +3484,12 @@ usa la roda del ratolí per a ajustar el volum d'un pas patternFreezeStatusDialog - + Freezing pattern... Congelant patró... - + Cancel Cancel·la @@ -3937,147 +3947,147 @@ usa la roda del ratolí per a ajustar el volum d'un pas projectNotes - + Put down your project notes here. Escriu aquí les teves notes del projecte. - + Project notes Notes del projecte - + Edit Actions Accions d'Editar - + &Undo &Desfés - + Ctrl+Z Ctrl+Z - + &Redo &Refés - + Ctrl+Y Ctrl+Y - + &Copy &Copia - + Ctrl+C Ctrl+C - + Cu&t &Talla - + Ctrl+X Ctrl+X - + &Paste &Enganxa - + Ctrl+V Ctrl+V - + Format Actions Accions de Format - + &Bold &Negreta - + Ctrl+B Ctrl+B - + &Italic Curs&iva - + Ctrl+I Ctrl+I - + &Underline &Subratllat - + Ctrl+U Ctrl+U - + &Left &Esquerra - + Ctrl+L Ctrl+L - + C&enter Cen&tre - + Ctrl+E Ctrl+E - + &Right &Dreta - + Ctrl+R Ctrl+R - + &Justify &Justifica - + Ctrl+J Ctrl+J - + &Color... &Color... @@ -4603,12 +4613,12 @@ Fixa't que en alguns casos la paral·lelització no funcionarà amb memòri songEditor - + Click here, if you want to stop playing of your song. The song-position-marker will be set to the start of your song. Pica aquí si vols aturar la reproducció de la cançó. El marcador de posició de cançó serà col·locat a l'inici de la cançó. - + untitled sense títol @@ -4638,57 +4648,57 @@ Fixa't que en alguns casos la paral·lelització no funcionarà amb memòri No es pot escriure el fitxer - + Song-Editor Editor de Cançó - + The file "%1" already exists. Do you want to overwrite it? El fitxer "%1" ja existeix. Vols sobreescriure'l? - + Click here, if you want to play your whole song. Playing will be started at the song-position-marker (green). You can also move it while playing. Pica aquí si vols reproduir la cançó sencera. La reproducció començarà al marcador de posició de cançó (verd). També pots moure'l mentre es reprodueix. - + Play song (Space) Reprodueix cançó (Espai) - + Stop song (Space) Atura cançó (Espai) - + The tempo of a song is specified in beats per minute (BPM). If you want to change the tempo of your song, change this value. Every tact has four beats, so the tempo in BPM specifies, how many tacts / 4 should be played within a minute (or how many tacts should be played within four minutes). El tempo d'una cançó s'especifica en batecs per minut (BPM). Si vols canviar el tempo de la cançó, canvia aquest valor. Cada compàs té quatre batecs, llavors el tempo en BPM especifica quants compassos / 4 s'han de tocar en un minut (o quants compassos s'han de tocar en quatre minuts). - + master pitch to mestre - + tempo of song tempo de cançó - + Add beat/bassline Afegeix ritme base - + Add sample-track Afegeix pista de mostra - + Project NOT saved. Projecte NO desat. @@ -4700,27 +4710,17 @@ Do you want to overwrite it? Vols sobreescriure'l? - + Select file for project-export... Selecciona fitxer per a exportar projecte... - - Project not saved - Projecte no desat - - - - The current project was modified since last saving. Do you want to save it now? - El projecte actual ha estat modificat des del darrer desament. Vols desar-lo ara? - - - + Import file Importa fitxer - + TEMPO/BPM TEMPO/BPM @@ -4732,62 +4732,62 @@ Please make sure you have at least read-access to the file and try again. - + High quality mode Mode alta qualitat - + Auto limiter Autolimitador - + master volume volum mestre - + Master volume Volum mestre - + Master pitch To mestre - + Draw mode Mode dibuixar - + Edit mode (select and move) Mode editar (selecciona i mou) - + Value: %1% Valor: %1% - + Value: %1 semitones Valor: %1 semitons - + Project saved Projecte desat - + The project %1 is now saved. El projecte %1 està desat. - + The project %1 was not saved! El projecte %1 no està desat! @@ -4799,7 +4799,7 @@ Please make sure you have write-access to the file and try again. Per favor, assegura't que tens permís d'escriptura per a aquest fitxer i torna-ho a provar. - + Tempo Tempo @@ -5022,7 +5022,7 @@ Per favor, assegura't que tens permís d'escriptura per a aquest fitxe trackContainer - + Loading project... Carregant projecte... @@ -5074,57 +5074,57 @@ Per favor, assegura't que tens permís de lectura per al fitxer i el direct trackContentObject - + Cut Talla - + Copy Copia - + Paste Enganxa - + Current position Posició actual - + Hint Consell - + Press <Ctrl> for free positioning. Pitja <Ctrl> per a col·locar lliurement. - + Current length Longitud actual - + Press <Ctrl> for free resizing. Pitja <Ctrl> per a redimensionar lliurement. - + %1:%2 (%3:%4 to %5:%6) %1:%2 (%3:%4 a %5:%6) - + Delete (middle mousebutton) Esborra (botó del mig del ratolí) - + Mute/unmute (<Ctrl> + middle click) Apaga/encén (<Ctrl> + clic del mig) @@ -5132,27 +5132,27 @@ Per favor, assegura't que tens permís de lectura per al fitxer i el direct trackOperationsWidget - + Press <Ctrl> while clicking on move-grip to begin a new drag'n'drop-action. Pitja <Ctrl> quan piquis el control de moviment per a iniciar una nova acció d'arrossegar i amollar. - + Clone this track Clona aquesta pista - + Remove this track Elimina aquesta pista - + Actions for this track Accions per a aquesta pista - + With this switch you can either mute this track or mute all other tracks. By clicking left, this track is muted. This is useful, if you only want to listen to the other tracks without changing this track and loosing information. When you click right on this switch, all other tracks will be muted. This is useful, if you only want to listen to this track. @@ -5161,24 +5161,24 @@ Amb un clic esquerre, aquesta pista s'apaga. Això és útil si només vols Amb un clic dret a l'interruptor, totes les altres pistes s'apagaran. Això és útil si només vols escoltar aquesta pista. - + left click = mute this track right click = mute all other tracks (solo) clic esquerre = apaga aquesta pista clic dret = apaga totes les altres pistes (solo) - + Mute Apaga - + Enable automation Habilita automatització - + Disable automation Inhabilita automatització diff --git a/data/themes/default/style.css b/data/themes/default/style.css index d66f10438..aac19a5f9 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -25,6 +25,11 @@ trackOperationsWidget#automationEnabled > QPushButton::menu-indicator { image: url(resources:track_op_menu.png); } +trackWidget { +/* border-bottom: 1px solid rgb(0, 0, 0);*/ + background-color: rgb(0, 0, 0); +} + QWidget#mainToolbar { background-image: url(resources:main_toolbar_bg.png); } diff --git a/include/bb_editor.h b/include/bb_editor.h index 2a46565da..05e7b58c4 100644 --- a/include/bb_editor.h +++ b/include/bb_editor.h @@ -58,7 +58,11 @@ public: return( TRUE ); } - int currentBB( void ) const; + int currentBB( void ) const + { + return( m_currentBB ); + } + tact FASTCALL lengthOfBB( const int _bb ); inline tact lengthOfCurrentBB( void ) { @@ -80,11 +84,7 @@ public slots: protected: - virtual void closeEvent( QCloseEvent * _ce ); virtual void keyPressEvent( QKeyEvent * _ke ); - virtual void resizeEvent( QResizeEvent * _re ); - - virtual QRect scrollAreaRect( void ) const; private: @@ -95,6 +95,8 @@ private: void FASTCALL createTCOsForBB( const int _bb ); + int m_currentBB; + QWidget * m_toolBar; toolButton * m_playButton; diff --git a/include/main_window.h b/include/main_window.h index 38aee6f20..4c906c9b7 100644 --- a/include/main_window.h +++ b/include/main_window.h @@ -58,7 +58,14 @@ public: int addWidgetToToolBar( QWidget * _w, int _row = -1, int _col = -1 ); void addSpacingToToolBar( int _size ); - void resetWindowTitle( void ); + void resetWindowTitle( bool _modified = FALSE ); + + + // every function that replaces current file (e.g. creates new file, + // opens another file...) has to call this before and may only process + // if this function returns true + bool mayChangeProject( void ); + void clearKeyModifiers( void ); @@ -151,6 +158,8 @@ private: QMenu * m_tools_menu; QList m_tools; + bool m_modified; + friend class engine; diff --git a/include/song_editor.h b/include/song_editor.h index da7bcac21..93901e5f4 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -133,12 +133,6 @@ public: virtual automationPattern * tempoAutomationPattern( void ); - // every function that replaces current file (e.g. creates new file, - // opens another file...) has to call this before and may only process - // if this function returns true - bool mayChangeProject( void ); - - // file management void createNewProject( void ); void FASTCALL createNewProjectFromTemplate( const QString & _template ); @@ -189,14 +183,10 @@ public slots: protected: - virtual void closeEvent( QCloseEvent * _ce ); - virtual void resizeEvent( QResizeEvent * _re ); virtual void keyPressEvent( QKeyEvent * _ke ); virtual void wheelEvent( QWheelEvent * _we ); virtual void paintEvent( QPaintEvent * _pe ); - virtual QRect scrollAreaRect( void ) const; - virtual bool allowRubberband( void ) const; diff --git a/include/track.h b/include/track.h index 5b0c9a319..b8bd94e64 100644 --- a/include/track.h +++ b/include/track.h @@ -192,7 +192,7 @@ public: public slots: void insertTact( const midiTime & _pos ); void removeTact( const midiTime & _pos ); - void updateTCOs( void ); + void update( void ); protected: @@ -338,7 +338,6 @@ public: return( m_action == MOVE_TRACK ); } - virtual void repaint( void ); virtual void update( void ); @@ -511,8 +510,6 @@ private: } ; -typedef QVector trackVector; -typedef QVector constTrackVector; #endif diff --git a/include/track_container.h b/include/track_container.h index fd468d4b7..b02a87791 100644 --- a/include/track_container.h +++ b/include/track_container.h @@ -36,9 +36,7 @@ #include "journalling_object.h" - -const Uint16 DEFAULT_PIXELS_PER_TACT = 16; -const Uint16 DEFAULT_SCROLLBAR_SIZE = 16; +class QVBoxLayout; @@ -49,7 +47,7 @@ public: trackContainer( void ); virtual ~trackContainer(); - inline QWidget * containerWidget( void ) + QWidget * contentWidget( void ) { return( m_scrollArea ); } @@ -93,7 +91,7 @@ public: void FASTCALL moveTrackUp( track * _track ); void FASTCALL moveTrackDown( track * _track ); - void FASTCALL realignTracks( bool _complete_update = FALSE ); + void FASTCALL realignTracks( void ); void clearAllTracks( void ); const trackWidget * trackWidgetAt( const int _y ) const; @@ -116,7 +114,7 @@ public: return( foo );*/ } - trackVector tracks( void ); + QList tracks( void ); static const QString classNodeName( void ) { @@ -124,7 +122,13 @@ public: } +signals: + void positionChanged( const midiTime & _pos ); + + protected: + static const Uint16 DEFAULT_PIXELS_PER_TACT = 16; + virtual void undoStep( journalEntry & _je ); virtual void redoStep( journalEntry & _je ); @@ -137,18 +141,10 @@ protected: virtual void resizeEvent( QResizeEvent * ); - constTrackVector tracks( void ) const; - - virtual QRect scrollAreaRect( void ) const - { - return( rect() ); - } + const QList tracks( void ) const; midiTime m_currentPosition; -protected slots: - void updateScrollArea( void ); - private: enum actions @@ -172,19 +168,14 @@ private: scrollArea * m_scrollArea; - typedef QVector trackWidgetVector; + QVBoxLayout * m_scrollLayout; - trackWidgetVector m_trackWidgets; + QList m_tracks; float m_ppt; rubberBand * m_rubberBand; QPoint m_origin; - -signals: - void positionChanged( const midiTime & _pos ); - - } ; diff --git a/src/core/bb_editor.cpp b/src/core/bb_editor.cpp index 81ad4eb35..7958d9f77 100644 --- a/src/core/bb_editor.cpp +++ b/src/core/bb_editor.cpp @@ -25,37 +25,35 @@ */ -#include +#include "bb_editor.h" + + #include -#include #include #include +#include -#include "bb_editor.h" -#include "song_editor.h" +#include "bb_track.h" +#include "combobox.h" #include "embed.h" #include "engine.h" -#include "tool_button.h" -#include "track_container.h" -#include "bb_track.h" -#include "name_label.h" -#include "templates.h" -#include "debug.h" -#include "tooltip.h" -#include "combobox.h" #include "main_window.h" - - -const int BBE_PPT = 192; +#include "name_label.h" +#include "song_editor.h" +#include "templates.h" +#include "tool_button.h" +#include "tooltip.h" +#include "track_container.h" -bbEditor::bbEditor( void ) +bbEditor::bbEditor( void ) : + m_currentBB( -1 ) { // create toolbar - m_toolBar = new QWidget( this ); + m_toolBar = new QWidget; m_toolBar->setFixedHeight( 32 ); m_toolBar->move( 0, 0 ); m_toolBar->setAutoFillBackground( TRUE ); @@ -63,6 +61,7 @@ bbEditor::bbEditor( void ) pal.setBrush( m_toolBar->backgroundRole(), embed::getIconPixmap( "toolbar_bg" ) ); m_toolBar->setPalette( pal ); + static_cast( layout() )->insertWidget( 0, m_toolBar ); QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); tb_layout->setMargin( 0 ); @@ -70,12 +69,9 @@ bbEditor::bbEditor( void ) setWindowIcon( embed::getIconPixmap( "bb_track" ) ); setWindowTitle( tr( "Beat+Baseline Editor" ) ); - setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH + - BBE_PPT + 2 * TCO_BORDER_WIDTH + - DEFAULT_SCROLLBAR_SIZE ); - - containerWidget()->move( 0, 32 ); - setPixelsPerTact( BBE_PPT ); + // TODO: Use style sheet + setMinimumWidth( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH + + 2 * TCO_BORDER_WIDTH + 192 ); m_playButton = new toolButton( embed::getIconPixmap( "play" ), @@ -123,6 +119,9 @@ bbEditor::bbEditor( void ) if( engine::getMainWindow()->workspace() != NULL ) { engine::getMainWindow()->workspace()->addSubWindow( this ); + parentWidget()->setAttribute( Qt::WA_DeleteOnClose, FALSE ); + parentWidget()->layout()->setSizeConstraint( + QLayout::SetMinimumSize ); } QWidget * w = ( parentWidget() != NULL ) ? parentWidget() : this; @@ -150,23 +149,17 @@ bbEditor::~bbEditor() -int bbEditor::currentBB( void ) const -{ - return( static_cast( currentPosition().getTact() ) ); -} - - - - void bbEditor::setCurrentBB( int _bb ) { + m_currentBB = _bb; + if( m_bbComboBox->value() != _bb ) { m_bbComboBox->setValue( _bb ); } // first make sure, all channels have a TCO at current BB - createTCOsForBB( static_cast( _bb ) ); + createTCOsForBB( _bb ); realignTracks(); @@ -177,8 +170,7 @@ void bbEditor::setCurrentBB( int _bb ) bbTrack::findBBTrack( i )->trackLabel()->update(); } - emit positionChanged( m_currentPosition = midiTime( - static_cast( _bb ), 0 ) ); + emit positionChanged( NULL ); } @@ -188,13 +180,10 @@ tact bbEditor::lengthOfBB( int _bb ) { midiTime max_length; - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - trackContentObject * tco = ( *it )->getTCO( _bb ); -#ifdef LMMS_DEBUG - assert( tco != NULL ); -#endif + trackContentObject * tco = tl[i]->getTCO( _bb ); max_length = tMax( max_length, tco->length() ); } if( max_length.getTact64th() == 0 ) @@ -220,11 +209,10 @@ bool FASTCALL bbEditor::play( midiTime _start, fpp_t _frames, _start = ( _start.getTact() % lengthOfBB( _tco_num ) ) * 64 + _start.getTact64th(); - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - if( ( *it )->play( _start, _frames, _offset, - _tco_num ) == TRUE ) + if( tl[i]->play( _start, _frames, _offset, _tco_num ) == TRUE ) { played_a_note = TRUE; } @@ -246,15 +234,15 @@ int bbEditor::numOfBBs( void ) const void bbEditor::removeBB( int _bb ) { - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - ( *it )->removeTCO( _bb ); - ( *it )->getTrackContentWidget()->removeTact( _bb * 64 ); + tl[i]->removeTCO( _bb ); + tl[i]->getTrackContentWidget()->removeTact( _bb * 64 ); } - if( _bb <= currentBB() ) + if( _bb <= m_currentBB ) { - setCurrentBB( tMax( (int)currentBB() - 1, 0 ) ); + setCurrentBB( tMax( m_currentBB - 1, 0 ) ); } } @@ -265,7 +253,7 @@ void bbEditor::updateBBTrack( trackContentObject * _tco ) bbTrack * t = bbTrack::findBBTrack( _tco->startPosition() / 64 ); if( t != NULL ) { - t->getTrackContentWidget()->updateTCOs(); + t->getTrackContentWidget()->update(); } } @@ -277,8 +265,6 @@ void bbEditor::updateComboBox( void ) disconnect( m_bbComboBox, SIGNAL( valueChanged( int ) ), this, SLOT( setCurrentBB( int ) ) ); - int current_bb = currentBB(); - m_bbComboBox->clear(); for( int i = 0; i < numOfBBs(); ++i ) @@ -287,7 +273,7 @@ void bbEditor::updateComboBox( void ) m_bbComboBox->addItem( bbt->trackLabel()->text(), bbt->trackLabel()->pixmap() ); } - m_bbComboBox->setValue( current_bb ); + m_bbComboBox->setValue( m_currentBB ); connect( m_bbComboBox, SIGNAL( valueChanged( int ) ), this, SLOT( setCurrentBB( int ) ) ); @@ -296,24 +282,6 @@ void bbEditor::updateComboBox( void ) -// close-handler for bb-editor-window because closing of bb-editor isn't allowed -// instead of closing it's being hidden -void bbEditor::closeEvent( QCloseEvent * _ce ) -{ - if( parentWidget() ) - { - parentWidget()->hide(); - } - else - { - hide(); - } - _ce->ignore(); -} - - - - void bbEditor::keyPressEvent( QKeyEvent * _ke ) { if ( _ke->key() == Qt::Key_Space ) @@ -329,16 +297,16 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke ) } else if ( _ke->key() == Qt::Key_Plus ) { - if( currentBB() + 1 < numOfBBs() ) + if( m_currentBB + 1 < numOfBBs() ) { - setCurrentBB( currentBB() + 1 ); + setCurrentBB( m_currentBB + 1 ); } } else if ( _ke->key() == Qt::Key_Minus ) { - if( currentBB() > 0 ) + if( m_currentBB > 0 ) { - setCurrentBB( currentBB() - 1 ); + setCurrentBB( m_currentBB - 1 ); } } else @@ -352,28 +320,6 @@ void bbEditor::keyPressEvent( QKeyEvent * _ke ) -void bbEditor::resizeEvent( QResizeEvent * _re ) -{ - setPixelsPerTact( width() - ( TRACK_OP_WIDTH + - DEFAULT_SETTINGS_WIDGET_WIDTH + 2 * - TCO_BORDER_WIDTH + - DEFAULT_SCROLLBAR_SIZE ) ); - trackContainer::resizeEvent( _re ); - m_toolBar->setFixedWidth( width() ); -} - - - - -QRect bbEditor::scrollAreaRect( void ) const -{ - return( QRect( 0, 0, (int) pixelsPerTact(), - height() - m_toolBar->height() ) ); -} - - - - void bbEditor::play( void ) { if( engine::getSongEditor()->playing() ) @@ -455,14 +401,14 @@ void bbEditor::createTCOsForBB( int _bb ) return; } - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - while( ( *it )->numOfTCOs() < _bb + 1 ) + while( tl[i]->numOfTCOs() < _bb + 1 ) { - midiTime position = midiTime( ( *it )->numOfTCOs(), 0 ); - trackContentObject * tco = ( *it )->addTCO( - ( *it )->createTCO( position ) ); + midiTime position = midiTime( tl[i]->numOfTCOs(), 0 ); + trackContentObject * tco = tl[i]->addTCO( + tl[i]->createTCO( position ) ); tco->movePosition( position ); tco->changeLength( midiTime( 1, 0 ) ); } @@ -474,10 +420,10 @@ void bbEditor::createTCOsForBB( int _bb ) void bbEditor::swapBB( int _bb1, int _bb2 ) { - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - ( *it )->swapPositionOfTCOs( _bb1, _bb2 ); + tl[i]->swapPositionOfTCOs( _bb1, _bb2 ); } updateComboBox(); } diff --git a/src/core/file_browser.cpp b/src/core/file_browser.cpp index 8f6737aa1..e32c57b4b 100644 --- a/src/core/file_browser.cpp +++ b/src/core/file_browser.cpp @@ -300,7 +300,7 @@ void listView::activateListItem( QTreeWidgetItem * _item, int _column ) } else if( f->type() == fileItem::PROJECT_FILE ) { - if( engine::getSongEditor()->mayChangeProject() ) + if( engine::getMainWindow()->mayChangeProject() ) { engine::getSongEditor()->loadProject( f->fullName() ); } diff --git a/src/core/main_window.cpp b/src/core/main_window.cpp index badfb8afd..f8ce51b99 100644 --- a/src/core/main_window.cpp +++ b/src/core/main_window.cpp @@ -33,12 +33,12 @@ #include #include #include +#include +#include #include #include #include #include -#include -#include #ifdef HAVE_CONFIG_H @@ -76,7 +76,8 @@ mainWindow::mainWindow( void ) : m_workspace( NULL ), m_templatesMenu( NULL ), m_recentlyOpenedProjectsMenu( NULL ), - m_tools_menu( NULL ) + m_tools_menu( NULL ), + m_modified( FALSE ) { setAttribute( Qt::WA_DeleteOnClose ); @@ -511,7 +512,7 @@ void mainWindow::addSpacingToToolBar( int _size ) -void mainWindow::resetWindowTitle( void ) +void mainWindow::resetWindowTitle( bool _modified ) { QString title = ""; if( engine::getSongEditor()->projectFileName() != "" ) @@ -523,8 +524,45 @@ void mainWindow::resetWindowTitle( void ) { title = tr( "Untitled" ); } - setWindowTitle( title + "[*] - " + tr( "LMMS %1" ).arg( VERSION ) ); - setWindowModified( FALSE ); + if( _modified ) + { + title += '*'; + } + setWindowTitle( title + " - " + tr( "LMMS %1" ).arg( VERSION ) ); + m_modified = _modified; +} + + + + +bool mainWindow::mayChangeProject( void ) +{ + if( !m_modified ) + { + return( TRUE ); + } + + QMessageBox mb ( tr( "Project not saved" ), + tr( "The current project was modified since " + "last saving. Do you want to save it " + "now?" ), + QMessageBox::Question, + QMessageBox::Yes, + QMessageBox::No, + QMessageBox::Cancel, + this ); + int answer = mb.exec(); + + if( answer == QMessageBox::Yes ) + { + return( saveProject() ); + } + else if( answer == QMessageBox::No ) + { + return( TRUE ); + } + + return( FALSE ); } @@ -584,7 +622,7 @@ void mainWindow::restoreWidgetState( QWidget * _w, const QDomElement & _de ) void mainWindow::createNewProject( void ) { - if( engine::getSongEditor()->mayChangeProject() == TRUE ) + if( mayChangeProject() ) { engine::getSongEditor()->createNewProject(); } @@ -595,8 +633,7 @@ void mainWindow::createNewProject( void ) void mainWindow::createNewProjectFromTemplate( QAction * _idx ) { - if( m_templatesMenu != NULL && - engine::getSongEditor()->mayChangeProject() == TRUE ) + if( m_templatesMenu != NULL && mayChangeProject() ) { QString dir_base = m_templatesMenu->actions().indexOf( _idx ) >= m_custom_templates_count ? @@ -613,7 +650,7 @@ void mainWindow::createNewProjectFromTemplate( QAction * _idx ) void mainWindow::openProject( void ) { - if( engine::getSongEditor()->mayChangeProject() == TRUE ) + if( mayChangeProject() ) { QFileDialog ofd( this, tr( "Open project" ), "", tr( "MultiMedia Project (*.mmp *.mmpz *.xml)" ) ); @@ -823,7 +860,7 @@ void mainWindow::redo( void ) void mainWindow::closeEvent( QCloseEvent * _ce ) { - if( engine::getSongEditor()->mayChangeProject() == TRUE ) + if( mayChangeProject() ) { _ce->accept(); } diff --git a/src/core/song_editor.cpp b/src/core/song_editor.cpp index 893023fdd..4b5561b2e 100644 --- a/src/core/song_editor.cpp +++ b/src/core/song_editor.cpp @@ -78,8 +78,6 @@ #include "tooltip.h" #include "visualization_widget.h" -#include "debug.h" - @@ -102,14 +100,11 @@ songEditor::songEditor( void ) : setFocusPolicy( Qt::StrongFocus ); setFocus(); - QWidget * cw = this; - - // create time-line timeLine * tl = new timeLine( TRACK_OP_WIDTH + DEFAULT_SETTINGS_WIDGET_WIDTH, 32, pixelsPerTact(), m_playPos[PLAY_SONG], - m_currentPosition, cw ); + m_currentPosition, this ); connect( this, SIGNAL( positionChanged( const midiTime & ) ), m_playPos[PLAY_SONG].m_timeLine, SLOT( updatePosition( const midiTime & ) ) ); @@ -253,23 +248,21 @@ songEditor::songEditor( void ) : // create own toolbar - m_toolBar = new QWidget( cw ); + m_toolBar = new QWidget( this ); m_toolBar->setFixedHeight( 32 ); - m_toolBar->move( 0, 0 ); m_toolBar->setAutoFillBackground( TRUE ); QPalette pal; pal.setBrush( m_toolBar->backgroundRole(), embed::getIconPixmap( "toolbar_bg" ) ); m_toolBar->setPalette( pal ); + static_cast( layout() )->insertWidget( 0, m_toolBar ); + static_cast( layout() )->insertWidget( 1, tl ); + QHBoxLayout * tb_layout = new QHBoxLayout( m_toolBar ); tb_layout->setMargin( 0 ); tb_layout->setSpacing( 0 ); - containerWidget()->setParent( cw ); - containerWidget()->move( 0, m_toolBar->height() + tl->height() ); - - // fill own tool-bar m_playButton = new toolButton( embed::getIconPixmap( "play" ), @@ -368,11 +361,12 @@ songEditor::songEditor( void ) : tb_layout->addStretch(); - m_leftRightScroll = new QScrollBar( Qt::Horizontal, cw ); + m_leftRightScroll = new QScrollBar( Qt::Horizontal, this ); m_leftRightScroll->setMinimum( 0 ); m_leftRightScroll->setMaximum( 0 ); m_leftRightScroll->setSingleStep( 1 ); m_leftRightScroll->setPageStep( 20 ); + static_cast( layout() )->addWidget( m_leftRightScroll ); connect( m_leftRightScroll, SIGNAL( valueChanged( int ) ), this, SLOT( scrolled( int ) ) ); @@ -380,6 +374,7 @@ songEditor::songEditor( void ) : if( engine::getMainWindow()->workspace() != NULL ) { engine::getMainWindow()->workspace()->addSubWindow( this ); + parentWidget()->setAttribute( Qt::WA_DeleteOnClose, FALSE ); } QWidget * w = ( parentWidget() != NULL ) ? parentWidget() : this; @@ -410,22 +405,6 @@ songEditor::~songEditor() -void songEditor::closeEvent( QCloseEvent * _ce ) -{ - if( parentWidget() ) - { - parentWidget()->hide(); - } - else - { - hide(); - } - _ce->ignore(); -} - - - - void songEditor::paintEvent( QPaintEvent * _pe ) { m_leftRightScroll->setMaximum( lengthInTacts() ); @@ -435,29 +414,6 @@ void songEditor::paintEvent( QPaintEvent * _pe ) -QRect songEditor::scrollAreaRect( void ) const -{ - return( QRect( 0, 0, width(), height() - m_toolBar->height() - - m_playPos[PLAY_SONG].m_timeLine->height() - - DEFAULT_SCROLLBAR_SIZE ) ); -} - - - - -// responsible for moving scrollbars after resizing -void songEditor::resizeEvent( QResizeEvent * _re ) -{ - m_leftRightScroll->setGeometry( 0, height() - DEFAULT_SCROLLBAR_SIZE, - width(), DEFAULT_SCROLLBAR_SIZE ); - m_playPos[PLAY_SONG].m_timeLine->setFixedWidth( width() ); - m_toolBar->setFixedWidth( width() ); - trackContainer::resizeEvent( _re ); -} - - - - void songEditor::keyPressEvent( QKeyEvent * _ke ) { if( /*_ke->modifiers() & Qt::ShiftModifier*/ @@ -548,7 +504,7 @@ void songEditor::wheelEvent( QWheelEvent * _we ) m_playPos[PLAY_SONG].m_timeLine->setPixelsPerTact( pixelsPerTact() ); // and make sure, all TCO's are resized and relocated - realignTracks( TRUE ); + realignTracks(); } else if( engine::getMainWindow()->isShiftPressed() == TRUE ) { @@ -693,7 +649,7 @@ void songEditor::zoomingChanged( const QString & _zfac ) setPixelsPerTact( _zfac.left( _zfac.length() - 1 ).toInt() * DEFAULT_PIXELS_PER_TACT / 100 ); m_playPos[PLAY_SONG].m_timeLine->setPixelsPerTact( pixelsPerTact() ); - realignTracks( TRUE ); + realignTracks(); } @@ -870,13 +826,13 @@ void songEditor::processNextBuffer( void ) return; } - trackVector tv; + QList trackList; Sint16 tco_num = -1; switch( m_playMode ) { case PLAY_SONG: - tv = tracks(); + trackList = tracks(); // at song-start we have to reset the LFOs if( m_playPos[PLAY_SONG] == 0 ) { @@ -885,14 +841,15 @@ void songEditor::processNextBuffer( void ) break; case PLAY_TRACK: - tv.push_back( m_trackToPlay ); + trackList.push_back( m_trackToPlay ); break; case PLAY_BB: if( engine::getBBEditor()->numOfBBs() > 0 ) { tco_num = engine::getBBEditor()->currentBB(); - tv.push_back( bbTrack::findBBTrack( tco_num ) ); + trackList.push_back( bbTrack::findBBTrack( + tco_num ) ); } break; @@ -901,7 +858,8 @@ void songEditor::processNextBuffer( void ) { tco_num = m_patternToPlay->getTrack()->getTCONum( m_patternToPlay ); - tv.push_back( m_patternToPlay->getTrack() ); + trackList.push_back( + m_patternToPlay->getTrack() ); } break; @@ -910,7 +868,7 @@ void songEditor::processNextBuffer( void ) } - if( tv.empty() == TRUE ) + if( trackList.empty() == TRUE ) { return; } @@ -1033,10 +991,9 @@ void songEditor::processNextBuffer( void ) } // loop through all tracks and play them - for( trackVector::iterator it = tv.begin(); - it != tv.end(); ++it ) + for( int i = 0; i < trackList.size(); ++i ) { - ( *it )->play( m_playPos[m_playMode], + trackList[i]->play( m_playPos[m_playMode], played_frames, total_frames_played, tco_num ); } @@ -1136,11 +1093,10 @@ void songEditor::playPattern( pattern * _patternToPlay, bool _loop ) tact songEditor::lengthInTacts( void ) const { tact len = 0; - constTrackVector ctv = tracks(); - for( constTrackVector::const_iterator it = ctv.begin(); it != ctv.end(); - ++it ) + const QList ctl = tracks(); + for( int i = 0; i < ctl.size(); ++i ) { - len = tMax( ( *it )->length(), len ); + len = tMax( ctl[i]->length(), len ); } return( len ); } @@ -1234,10 +1190,10 @@ void songEditor::stopExport( void ) void songEditor::insertBar( void ) { - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - ( *it )->getTrackContentWidget()->insertTact( + tl[i]->getTrackContentWidget()->insertTact( m_playPos[PLAY_SONG] ); } } @@ -1247,10 +1203,10 @@ void songEditor::insertBar( void ) void songEditor::removeBar( void ) { - trackVector tv = tracks(); - for( trackVector::iterator it = tv.begin(); it != tv.end(); ++it ) + QList tl = tracks(); + for( int i = 0; i < tl.size(); ++i ) { - ( *it )->getTrackContentWidget()->removeTact( + tl[i]->getTrackContentWidget()->removeTact( m_playPos[PLAY_SONG] ); } } @@ -1294,39 +1250,6 @@ automationPattern * songEditor::tempoAutomationPattern( void ) -bool songEditor::mayChangeProject( void ) -{ - if( engine::getMainWindow()->isWindowModified() == FALSE ) - { - return( TRUE ); - } - - QMessageBox mb ( tr( "Project not saved" ), - tr( "The current project was modified since " - "last saving. Do you want to save it " - "now?" ), - QMessageBox::Question, - QMessageBox::Yes, - QMessageBox::No, - QMessageBox::Cancel, - engine::getMainWindow() ); - int answer = mb.exec(); - - if( answer == QMessageBox::Yes ) - { - return( engine::getMainWindow()->saveProject() ); - } - else if( answer == QMessageBox::No ) - { - return( TRUE ); - } - - return( FALSE ); -} - - - - void songEditor::clearProject( void ) { engine::getProjectJournal()->setJournalling( FALSE ); @@ -1658,7 +1581,7 @@ void songEditor::setModified( void ) { if( !m_loadingProject ) { - engine::getMainWindow()->setWindowModified( TRUE ); + engine::getMainWindow()->resetWindowTitle( TRUE ); } } diff --git a/src/core/track.cpp b/src/core/track.cpp index 4b8d4bb68..0f8a19c78 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -26,35 +26,36 @@ */ -#include +#include "track.h" + + #include #include #include #include +#include -#include "track.h" #include "automation_pattern.h" -#include "track_container.h" #include "automation_track.h" -#include "instrument_track.h" #include "bb_editor.h" #include "bb_track.h" -#include "sample_track.h" -#include "song_editor.h" -#include "templates.h" #include "clipboard.h" #include "embed.h" #include "engine.h" #include "gui_templates.h" -#include "pixmap_button.h" -#include "debug.h" -#include "tooltip.h" -#include "string_pair_drag.h" -#include "mmp.h" +#include "instrument_track.h" #include "main_window.h" -#include "text_float.h" +#include "mmp.h" +#include "pixmap_button.h" #include "project_journal.h" +#include "sample_track.h" +#include "song_editor.h" +#include "string_pair_drag.h" +#include "templates.h" +#include "text_float.h" +#include "tooltip.h" +#include "track_container.h" const Sint16 RESIZE_GRIP_WIDTH = 4; @@ -140,17 +141,26 @@ void trackContentObject::movePosition( const midiTime & _pos ) void trackContentObject::changeLength( const midiTime & _length ) { + if( fixedTCOs() ) + { + setFixedWidth( parentWidget()->width() ); + } + else + { + setFixedWidth( static_cast( m_length * pixelsPerTact() / + 64 ) + TCO_BORDER_WIDTH * 2 ); + } + if( m_length != _length ) { //engine::getSongEditor()->setModified(); addJournalEntry( journalEntry( RESIZE, m_length - _length ) ); m_length = _length; + + // changing length of TCO can result in change of song-length + // etc., therefore we update the track-container + m_track->getTrackContainer()->update(); } - setFixedWidth( static_cast( m_length * pixelsPerTact() / - 64 ) + TCO_BORDER_WIDTH * 2 ); - // changing length of TCO can result in change of song-length etc., - // therefore we update the track-container - m_track->getTrackContainer()->update(); } @@ -455,13 +465,6 @@ void trackContentObject::contextMenuEvent( QContextMenuEvent * _cme ) float trackContentObject::pixelsPerTact( void ) { - if( fixedTCOs() ) - { - return( ( getTrack()->getTrackContentWidget()->width() - - 2 * TCO_BORDER_WIDTH - - DEFAULT_SCROLLBAR_SIZE ) / - tMax( length().getTact(), 1.0f ) ); - } return( getTrack()->getTrackContainer()->pixelsPerTact() ); } @@ -734,7 +737,7 @@ void trackContentWidget::removeTact( const midiTime & _pos ) -void trackContentWidget::updateTCOs( void ) +void trackContentWidget::update( void ) { for( tcoVector::iterator it = m_trackContentObjects.begin(); it != m_trackContentObjects.end(); ++it ) @@ -742,6 +745,7 @@ void trackContentWidget::updateTCOs( void ) ( *it )->setFixedHeight( height() - 2 ); ( *it )->update(); } + QWidget::update(); } @@ -812,14 +816,19 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); p.fillRect( rect(), QColor( 96, 96, 96 ) ); + const trackContainer * tc = getTrack()->getTrackContainer(); - const int offset = (int)( ( tc->currentPosition() % 4 ) * - tc->pixelsPerTact() ); - // draw vertical lines - p.setPen( QColor( 128, 128, 128 ) ); - for( int x = -offset; x < width(); x += (int) tc->pixelsPerTact() ) + if( !tc->fixedTCOs() ) { - p.drawLine( x, 0, x, height() ); + const int offset = (int)( ( tc->currentPosition() % 4 ) * + tc->pixelsPerTact() ); + // draw vertical lines + p.setPen( QColor( 128, 128, 128 ) ); + for( int x = -offset; x < width(); + x += (int) tc->pixelsPerTact() ) + { + p.drawLine( x, 0, x, height() ); + } } } @@ -828,7 +837,7 @@ void trackContentWidget::paintEvent( QPaintEvent * _pe ) void trackContentWidget::resizeEvent( QResizeEvent * _re ) { - updateTCOs(); + update(); } @@ -846,7 +855,6 @@ void trackContentWidget::undoStep( journalEntry & _je ) dynamic_cast( engine::getProjectJournal()->getJournallingObject( map["id"].toInt() ) ); - assert( tco != NULL ); multimediaProject mmp( multimediaProject::JOURNAL_DATA ); tco->saveState( mmp, mmp.content() ); @@ -1107,7 +1115,7 @@ void trackOperationsWidget::removeTrack( void ) void trackOperationsWidget::setMuted( bool _muted ) { m_muteBtn->setChecked( _muted ); - m_trackWidget->getTrackContentWidget().updateTCOs(); + m_trackWidget->getTrackContentWidget().update(); } @@ -1221,6 +1229,15 @@ trackWidget::trackWidget( track * _track, QWidget * _parent ) : QColor( 64, 64, 64 ) ); m_trackSettingsWidget.setPalette( pal ); + QHBoxLayout * layout = new QHBoxLayout( this ); + layout->setMargin( 0 ); + layout->setSpacing( 0 ); + layout->addWidget( &m_trackOperationsWidget ); + layout->addWidget( &m_trackSettingsWidget ); + layout->addWidget( &m_trackContentWidget, 1 ); + + resizeEvent( NULL ); + setAcceptDrops( TRUE ); } @@ -1234,10 +1251,12 @@ trackWidget::~trackWidget() -void trackWidget::repaint( void ) +void trackWidget::resizeEvent( QResizeEvent * _re ) { - m_trackContentWidget.repaint(); - QWidget::repaint(); + m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 ); + m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH, + height() - 1 ); + m_trackContentWidget.setFixedHeight( height() - 1 ); } @@ -1246,6 +1265,10 @@ void trackWidget::repaint( void ) void trackWidget::update( void ) { m_trackContentWidget.update(); + if( !m_track->getTrackContainer()->fixedTCOs() ) + { + changePosition(); + } QWidget::update(); } @@ -1256,6 +1279,28 @@ void trackWidget::update( void ) // change of visible viewport void trackWidget::changePosition( const midiTime & _new_pos ) { + const int tcos = m_trackContentWidget.numOfTCOs(); + + if( m_track->getTrackContainer() == engine::getBBEditor() ) + { + const int showTco = engine::getBBEditor()->currentBB(); + for( int i = 0; i < tcos; ++i ) + { + trackContentObject * tco = m_trackContentWidget.getTCO( + i ); + if( i == showTco ) + { + tco->move( 0, tco->y() ); + tco->show(); + } + else + { + tco->hide(); + } + } + return; + } + midiTime pos = _new_pos; if( pos < 0 ) { @@ -1265,7 +1310,6 @@ void trackWidget::changePosition( const midiTime & _new_pos ) const Sint32 begin = pos; const Sint32 end = endPosition( pos ); const float ppt = m_track->getTrackContainer()->pixelsPerTact(); - const int tcos = m_trackContentWidget.numOfTCOs(); for( int i = 0; i < tcos; ++i ) { @@ -1408,7 +1452,7 @@ void trackWidget::mouseMoveEvent( QMouseEvent * _me ) trackContainer * tc = m_track->getTrackContainer(); // look which track-widget the mouse-cursor is over const trackWidget * track_at_y = tc->trackWidgetAt( - mapTo( tc->containerWidget(), _me->pos() ).y() ); + mapTo( tc->contentWidget(), _me->pos() ).y() ); // a track-widget not equal to ourself? if( track_at_y != NULL && track_at_y != this ) { @@ -1451,27 +1495,10 @@ void trackWidget::mouseReleaseEvent( QMouseEvent * _me ) void trackWidget::paintEvent( QPaintEvent * _pe ) { + QStyleOption opt; + opt.initFrom( this ); QPainter p( this ); - p.setPen( QColor( 0, 0, 0 ) ); - p.drawLine( 0, height() - 1, width() - 1, height() - 1 ); -} - - - - -void trackWidget::resizeEvent( QResizeEvent * _re ) -{ - m_trackOperationsWidget.setFixedSize( TRACK_OP_WIDTH, height() - 1 ); - m_trackOperationsWidget.move( 0, 0 ); - m_trackSettingsWidget.setFixedSize( DEFAULT_SETTINGS_WIDGET_WIDTH, - height() - 1 ); - m_trackSettingsWidget.move( TRACK_OP_WIDTH, 0 ); - m_trackContentWidget.resize( m_track->getTrackContainer()->width() - - TRACK_OP_WIDTH - - DEFAULT_SETTINGS_WIDGET_WIDTH, - height() - 1 ); - m_trackContentWidget.move( m_trackOperationsWidget.width() + - m_trackSettingsWidget.width(), 0 ); + style()->drawPrimitive( QStyle::PE_Widget, &opt, &p, this ); } @@ -1499,9 +1526,7 @@ track::track( trackContainer * _tc, bool _create_widget ) : { if( _create_widget ) { - m_trackWidget = new trackWidget( this, - m_trackContainer->containerWidget() ); - + m_trackWidget = new trackWidget( this, m_trackContainer ); m_trackContainer->addTrack( this ); } } @@ -1514,13 +1539,12 @@ track::~track() if( m_trackContainer == engine::getBBEditor() && engine::getSongEditor() ) { - trackVector tracks = engine::getSongEditor()->tracks(); - for( trackVector::iterator it = tracks.begin(); - it != tracks.end(); ++it ) + QList tracks = engine::getSongEditor()->tracks(); + for( int i = 0; i < tracks.size(); ++i ) { - if( ( *it )->type() == BB_TRACK ) + if( tracks[i]->type() == BB_TRACK ) { - bbTrack * bb_track = (bbTrack *)*it; + bbTrack * bb_track = (bbTrack *)tracks[i]; if( bb_track->automationDisabled( this ) ) { // Remove reference from bbTrack @@ -1566,9 +1590,7 @@ track * track::create( trackTypes _tt, trackContainer * _tc ) default: break; } -#ifdef DEBUG_LMMS - assert( t != NULL ); -#endif + _tc->updateAfterTrackAdd(); return( t ); } diff --git a/src/core/track_container.cpp b/src/core/track_container.cpp index 4a86ca59b..8fafb1eed 100644 --- a/src/core/track_container.cpp +++ b/src/core/track_container.cpp @@ -29,11 +29,11 @@ #include "track_container.h" -#include #include -#include -#include #include +#include +#include +#include #include "bb_track.h" @@ -51,7 +51,6 @@ #include "rubberband.h" #include "song_editor.h" #include "string_pair_drag.h" -#include "templates.h" #include "track.h" @@ -62,6 +61,19 @@ trackContainer::trackContainer( void ) : m_rubberBand( new rubberBand( m_scrollArea ) ), m_origin() { + QVBoxLayout * layout = new QVBoxLayout( this ); + layout->setMargin( 0 ); + layout->setSpacing( 0 ); + layout->addWidget( m_scrollArea ); + + QWidget * scrollContent = new QWidget; + m_scrollLayout = new QVBoxLayout( scrollContent ); + m_scrollLayout->setMargin( 0 ); + m_scrollLayout->setSpacing( 0 ); + m_scrollLayout->setSizeConstraint( QLayout::SetMinimumSize ); + + m_scrollArea->setWidget( scrollContent ); + m_scrollArea->show(); m_rubberBand->hide(); @@ -73,14 +85,10 @@ trackContainer::trackContainer( void ) : trackContainer::~trackContainer() { - engine::getProjectJournal()->setJournalling( FALSE ); - - while( m_trackWidgets.size() ) + while( !m_tracks.empty() ) { - removeTrack( m_trackWidgets.front()->getTrack() ); + delete m_tracks.takeFirst(); } - - engine::getProjectJournal()->setJournalling( TRUE ); } @@ -93,10 +101,9 @@ void trackContainer::saveSettings( QDomDocument & _doc, QDomElement & _this ) mainWindow::saveWidgetState( this, _this ); // save settings of each track - for( trackWidgetVector::iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + for( int i = 0; i < m_tracks.size(); ++i ) { - ( *it )->getTrack()->saveState( _doc, _this ); + m_tracks[i]->saveState( _doc, _this ); } } @@ -162,7 +169,8 @@ void trackContainer::addTrack( track * _track ) map["id"] = _track->id(); addJournalEntry( journalEntry( ADD_TRACK, map ) ); - m_trackWidgets.push_back( _track->getTrackWidget() ); + m_tracks.push_back( _track ); + m_scrollLayout->addWidget( _track->getTrackWidget() ); connect( this, SIGNAL( positionChanged( const midiTime & ) ), _track->getTrackWidget(), SLOT( changePosition( const midiTime & ) ) ); @@ -174,9 +182,8 @@ void trackContainer::addTrack( track * _track ) void trackContainer::removeTrack( track * _track ) { - trackWidgetVector::iterator it = qFind( m_trackWidgets.begin(), - m_trackWidgets.end(), _track->getTrackWidget() ); - if( it != m_trackWidgets.end() ) + int index = m_tracks.indexOf( _track ); + if( index != -1 ) { QMap map; multimediaProject mmp( multimediaProject::JOURNAL_DATA ); @@ -185,8 +192,10 @@ void trackContainer::removeTrack( track * _track ) map["state"] = mmp.toString(); addJournalEntry( journalEntry( REMOVE_TRACK, map ) ); - disconnect( *it ); - m_trackWidgets.erase( it ); + m_tracks.removeAt( index ); + + disconnect( _track->getTrackWidget() ); + m_scrollLayout->removeWidget( _track->getTrackWidget() ); delete _track; @@ -203,15 +212,15 @@ void trackContainer::removeTrack( track * _track ) void trackContainer::moveTrackUp( track * _track ) { - for( trackWidgetVector::iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + for( int i = 1; i < m_tracks.size(); ++i ) { - if( *it == _track->getTrackWidget() && - it > m_trackWidgets.begin() ) + if( m_tracks[i] == _track ) { - bbTrack::swapBBTracks( ( *it )->getTrack(), - ( *( it - 1 ) )->getTrack() ); - qSwap( *it, *( it - 1 ) ); + bbTrack::swapBBTracks( m_tracks[i], m_tracks[i - 1] ); + QWidget * tw = m_tracks[i]->getTrackWidget(); + m_scrollLayout->removeWidget( tw ); + m_scrollLayout->insertWidget( i - 1, tw ); + m_tracks.swap( i - 1, i ); realignTracks(); break; } @@ -223,15 +232,15 @@ void trackContainer::moveTrackUp( track * _track ) void trackContainer::moveTrackDown( track * _track ) { - for( trackWidgetVector::iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + for( int i = 0; i < m_tracks.size() - 1; ++i ) { - if( *it == _track->getTrackWidget() && - it + 1 < m_trackWidgets.end() ) + if( m_tracks[i] == _track ) { - bbTrack::swapBBTracks( ( *it )->getTrack(), - ( *( it + 1 ) )->getTrack() ); - qSwap( *it, *( it + 1 ) ); + bbTrack::swapBBTracks( m_tracks[i], m_tracks[i + 1] ); + QWidget * tw = m_tracks[i]->getTrackWidget(); + m_scrollLayout->removeWidget( tw ); + m_scrollLayout->insertWidget( i + 1, tw ); + m_tracks.swap( i, i + 1 ); realignTracks(); break; } @@ -248,21 +257,19 @@ void trackContainer::updateAfterTrackAdd( void ) -void trackContainer::realignTracks( bool _complete_update ) +void trackContainer::realignTracks( void ) { - int y = 0; - for( trackWidgetVector::iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + QWidget * content = m_scrollArea->widget(); + content->setFixedWidth( width() + - m_scrollArea->verticalScrollBar()->width() ); + content->setFixedHeight( content->minimumSizeHint().height() ); + + for( int i = 0; i < m_tracks.size(); ++i ) { - ( *it )->show(); - ( *it )->update(); - ( *it )->move( 0, y ); - ( *it )->resize( width() - DEFAULT_SCROLLBAR_SIZE, - ( *it )->height() ); - ( *it )->changePosition( m_currentPosition ); - y += ( *it )->height(); + trackWidget * tw = m_tracks[i]->getTrackWidget(); + tw->show(); + tw->update(); } - updateScrollArea(); } @@ -270,9 +277,9 @@ void trackContainer::realignTracks( bool _complete_update ) void trackContainer::clearAllTracks( void ) { - while( !m_trackWidgets.empty() ) + while( !m_tracks.empty() ) { - removeTrack( m_trackWidgets.front()->getTrack() ); + removeTrack( m_tracks.front() ); } } @@ -283,14 +290,13 @@ const trackWidget * trackContainer::trackWidgetAt( const int _y ) const { const int abs_y = _y + m_scrollArea->viewport()->y(); int y_cnt = 0; - for( trackWidgetVector::const_iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + for( int i = 0; i < m_tracks.size(); ++i ) { const int y_cnt1 = y_cnt; - y_cnt += ( *it )->height(); + y_cnt += m_tracks[i]->getTrackWidget()->height(); if( abs_y >= y_cnt1 && abs_y < y_cnt ) { - return( *it ); + return( m_tracks[i]->getTrackWidget() ); } } return( NULL ); @@ -310,10 +316,9 @@ bool trackContainer::allowRubberband( void ) const Uint16 trackContainer::countTracks( track::trackTypes _tt ) const { Uint16 cnt = 0; - for( trackWidgetVector::const_iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + for( int i = 0; i < m_tracks.size(); ++i ) { - if( ( *it )->getTrack()->type() == _tt || + if( m_tracks[i]->type() == _tt || _tt == track::TOTAL_TRACK_TYPES ) { ++cnt; @@ -327,39 +332,26 @@ Uint16 trackContainer::countTracks( track::trackTypes _tt ) const void trackContainer::setMutedOfAllTracks( bool _muted ) { - for( trackWidgetVector::iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) + for( int i = 0; i < m_tracks.size(); ++i ) { - ( *it )->getTrack()->setMuted( _muted ); + m_tracks[i]->setMuted( _muted ); } } -constTrackVector trackContainer::tracks( void ) const +const QList trackContainer::tracks( void ) const { - constTrackVector tracks; - for( trackWidgetVector::const_iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) - { - tracks.push_back( ( *it )->getTrack() ); - } - return( tracks ); + return( m_tracks ); } -trackVector trackContainer::tracks( void ) +QList trackContainer::tracks( void ) { - trackVector tracks; - for( trackWidgetVector::iterator it = m_trackWidgets.begin(); - it != m_trackWidgets.end(); ++it ) - { - tracks.push_back( ( *it )->getTrack() ); - } - return( tracks ); + return( m_tracks ); } @@ -487,9 +479,6 @@ void trackContainer::dropEvent( QDropEvent * _de ) { multimediaProject mmp( value, FALSE ); track::create( mmp.content().firstChild().toElement(), this ); - // after adding a track, we have to make sure, actual editor - // can setup new track (e.g. adding TCO's (bbEditor does so)) - updateAfterTrackAdd(); _de->accept(); } engine::getMixer()->unlock(); @@ -541,18 +530,6 @@ void trackContainer::resizeEvent( QResizeEvent * ) -void trackContainer::updateScrollArea( void ) -{ - m_scrollArea->resize( width(), scrollAreaRect().height() ); -/* m_scrollArea->resize( tMax( m_scrollArea->parentWidget()->width() - - m_scrollArea->x() - 2, 0 ), - tMax( m_scrollArea->parentWidget()->height() - - m_scrollArea->y() - 2, 0 ) );*/ -} - - - - trackContainer::scrollArea::scrollArea( trackContainer * _parent ) : QScrollArea( _parent ), m_trackContainer( _parent ) diff --git a/src/tracks/bb_track.cpp b/src/tracks/bb_track.cpp index 3db17bcc9..5cb349069 100644 --- a/src/tracks/bb_track.cpp +++ b/src/tracks/bb_track.cpp @@ -307,8 +307,6 @@ bbTrack::bbTrack( trackContainer * _tc ) : engine::getBBEditor()->setCurrentBB( bbNum ); engine::getBBEditor()->updateComboBox(); - - _tc->updateAfterTrackAdd(); } @@ -428,11 +426,10 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc, } int track_num = 0; - trackVector tracks = engine::getBBEditor()->tracks(); - for( trackVector::iterator it = tracks.begin(); it != tracks.end(); - ++it, ++track_num ) + QList tracks = engine::getBBEditor()->tracks(); + for( int i = 0; i < tracks.size(); ++i, ++track_num ) { - if( automationDisabled( *it ) ) + if( automationDisabled( tracks[i] ) ) { QDomElement disabled = _doc.createElement( "automation-disabled" ); @@ -468,7 +465,7 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this ) engine::getBBEditor()->setCurrentBB( s_infoMap[this] ); }*/ - trackVector tracks = engine::getBBEditor()->tracks(); + QList tracks = engine::getBBEditor()->tracks(); node = _this.firstChild(); while( !node.isNull() ) { diff --git a/src/tracks/instrument_track.cpp b/src/tracks/instrument_track.cpp index f1290f275..bc9636830 100644 --- a/src/tracks/instrument_track.cpp +++ b/src/tracks/instrument_track.cpp @@ -306,8 +306,6 @@ instrumentTrack::instrumentTrack( trackContainer * _tc ) : setWindowIcon( embed::getIconPixmap( "instrument_track" ) ); - _tc->updateAfterTrackAdd(); - setFixedWidth( INSTRUMENT_WIDTH ); resize( sizeHint() ); diff --git a/src/tracks/pattern.cpp b/src/tracks/pattern.cpp index 6c49d63c0..c2ea2abf3 100644 --- a/src/tracks/pattern.cpp +++ b/src/tracks/pattern.cpp @@ -677,10 +677,10 @@ void pattern::mouseDoubleClickEvent( QMouseEvent * _me ) void pattern::mousePressEvent( QMouseEvent * _me ) { if( _me->button() == Qt::LeftButton && - m_patternType == pattern::BEAT_PATTERN && - ( pixelsPerTact() >= 192 || - m_steps != DEFAULT_STEPS_PER_TACT ) && - _me->y() > height() - s_stepBtnOff->height() ) + m_patternType == pattern::BEAT_PATTERN && + ( fixedTCOs() || pixelsPerTact() >= 192 || + m_steps != DEFAULT_STEPS_PER_TACT ) && + _me->y() > height() - s_stepBtnOff->height() ) { int step = ( _me->x() - TCO_BORDER_WIDTH ) * length() / BEATS_PER_TACT / width(); @@ -725,9 +725,9 @@ void pattern::mousePressEvent( QMouseEvent * _me ) void pattern::wheelEvent( QWheelEvent * _we ) { if( m_patternType == pattern::BEAT_PATTERN && - ( pixelsPerTact() >= 192 || - m_steps != DEFAULT_STEPS_PER_TACT ) && - _we->y() > height() - s_stepBtnOff->height() ) + ( fixedTCOs() || pixelsPerTact() >= 192 || + m_steps != DEFAULT_STEPS_PER_TACT ) && + _we->y() > height() - s_stepBtnOff->height() ) { int step = ( _we->x() - TCO_BORDER_WIDTH ) * length() / BEATS_PER_TACT / width(); @@ -816,7 +816,10 @@ void pattern::paintEvent( QPaintEvent * ) p.setPen( QColor( 0, 0, 0 ) ); p.drawRect( 1, 1, width() - 2, height() - 2 ); - const float ppt = pixelsPerTact(); + const float ppt = fixedTCOs() ? + ( parentWidget()->width() - 2 * TCO_BORDER_WIDTH ) + / (float)length().getTact() : + pixelsPerTact(); if( m_patternType == pattern::MELODY_PATTERN ) { @@ -894,7 +897,8 @@ void pattern::paintEvent( QPaintEvent * ) } } else if( m_patternType == pattern::BEAT_PATTERN && - ( ppt >= 96 || m_steps != DEFAULT_STEPS_PER_TACT ) ) + ( fixedTCOs() || ppt >= 96 + || m_steps != DEFAULT_STEPS_PER_TACT ) ) { QPixmap stepon; QPixmap stepoverlay; diff --git a/src/tracks/sample_track.cpp b/src/tracks/sample_track.cpp index 6e2713867..c138005b5 100644 --- a/src/tracks/sample_track.cpp +++ b/src/tracks/sample_track.cpp @@ -356,8 +356,6 @@ sampleTrack::sampleTrack( trackContainer * _tc ) : tr( "With this knob you can set " "the volume of the opened " "channel." ) ); - - _tc->updateAfterTrackAdd(); } @@ -365,6 +363,12 @@ sampleTrack::sampleTrack( trackContainer * _tc ) : sampleTrack::~sampleTrack() { + // disconnect sampleTCOs + for( int i = 0; i < numOfTCOs(); ++i ) + { + disconnect( engine::getSongEditor(), 0, getTCO( i ), 0 ); + } + engine::getMixer()->removePlayHandles( this ); delete m_audioPort; } diff --git a/src/widgets/project_notes.cpp b/src/widgets/project_notes.cpp index ec6a615a1..91745ca31 100644 --- a/src/widgets/project_notes.cpp +++ b/src/widgets/project_notes.cpp @@ -29,7 +29,6 @@ #include #include -#include #include #include #include