diff --git a/ChangeLog b/ChangeLog index 854d5e5d7..2336e6a71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-05-24 Tobias Doerffel + + * include/song.h: + * include/song_editor.h: + * src/core/song.cpp: + * src/gui/song_editor.cpp: + added meterModel and meterDialog (which actually is just a widget) as + preparation for time-signature-support - it doesn't actually work yet! + + * data/themes/default/style.css: + improved appearence of menu in general + + * Makefile.am: + * include/tempo_sync_knob.h: + * include/meter_model.h: + * include/meter_dialog.h: + * src/core/meter_model.cpp: + * src/gui/widgets/meter_dialog.cpp: + splitted source-files for meterModel and meterDialog and added + "simple"-mode for meterDialog + 2008-05-22 Paul Giblock * include/lfo_controller.h: diff --git a/Makefile.am b/Makefile.am index f22d0407b..6bbc2fdb8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,7 +97,7 @@ lmms_MOC = \ ./mv_base.moc \ ./name_label.moc \ ./nstate_button.moc \ - ./meter_dialog.moc \ + ./meter_model.moc \ ./midi_alsa_seq.moc \ ./instrument_midi_io.moc \ ./pattern.moc \ @@ -187,6 +187,7 @@ lmms_SOURCES = \ $(srcdir)/src/core/ladspa_control.cpp \ $(srcdir)/src/core/lfo_controller.cpp \ $(srcdir)/src/core/main.cpp \ + $(srcdir)/src/core/meter_model.cpp \ $(srcdir)/src/core/mixer.cpp \ $(srcdir)/src/core/mmp.cpp \ $(srcdir)/src/core/mv_base.cpp \ @@ -436,6 +437,7 @@ lmms_SOURCES = \ $(srcdir)/include/ladspa-1.1.h \ $(srcdir)/include/sweep_oscillator.h \ $(srcdir)/include/meter_dialog.h \ + $(srcdir)/include/meter_model.h \ $(srcdir)/include/effect_lib.h \ $(srcdir)/include/ladspa_manager.h \ $(srcdir)/include/ladspa_2_lmms.h \ diff --git a/data/themes/default/style.css b/data/themes/default/style.css index e3c5902fc..134a76a2c 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -7,11 +7,48 @@ QMdiArea { automationEditor { background-color: rgb(0, 0, 0); } - +/* captionMenu::item:disabled { color: white; background-color: rgb(0, 0, 192); - text-align: center; + font-size:14px; + font-weight:bold; + margin:0px; + padding: 4px 32px 4px 20px; +}*/ +QMenu { + border:1px solid black; + background-color: rgb( 192, 192, 192 ); + font-size:11px; +} + +QMenu::separator { + height: 1px; + background: rgb(128,128,128); + margin-left: 5px; + margin-right: 5px; +} + +QMenu::item { + color: black; + padding: 2px 32px 2px 20px; + margin:3px; +} + +QMenu::item:selected { + color: white; + font-weight:bold; + background-color: rgba(0, 0, 0, 160); + margin:3px; +} + +QMenu::item:disabled { + color: white; + margin:0px; + background-color: rgba(0,0,0,192); + font-size:12px; + font-weight:bold; + padding: 4px 32px 4px 20px; } pianoRoll { diff --git a/include/meter_dialog.h b/include/meter_dialog.h index 2d5d13b3d..0949e9b56 100644 --- a/include/meter_dialog.h +++ b/include/meter_dialog.h @@ -27,52 +27,16 @@ #include -#include "lcd_spinbox.h" +#include "mv_base.h" -class meterModel : public model -{ - Q_OBJECT -public: - meterModel( ::model * _parent, track * _track ); - ~meterModel(); - - void saveSettings( QDomDocument & _doc, QDomElement & _this, - const QString & _name ); - void loadSettings( const QDomElement & _this, - const QString & _name ); - - inline int getNumerator( void ) - { - return( m_numeratorModel.value() ); - } - - inline int getDenominator( void ) - { - return( m_denominatorModel.value() ); - } - - -private: - lcdSpinBoxModel m_numeratorModel; - lcdSpinBoxModel m_denominatorModel; - - -signals: - void numeratorChanged( void ); - void denominatorChanged( void ); - - - friend class meterDialog; - -} ; +class lcdSpinBox; class meterDialog : public QWidget, public modelView { - Q_OBJECT public: - meterDialog( QWidget * _parent ); + meterDialog( QWidget * _parent, bool _simple = FALSE ); virtual ~meterDialog(); virtual void modelChanged( void ); diff --git a/include/meter_model.h b/include/meter_model.h new file mode 100644 index 000000000..20a66ff7c --- /dev/null +++ b/include/meter_model.h @@ -0,0 +1,68 @@ +/* + * meter_model.h - model for meter specification + * + * Copyright (c) 2008 Tobias Doerffel + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + +#ifndef _METER_MODEL_H +#define _METER_MODEL_H + +#include "lcd_spinbox.h" + + +class meterModel : public model +{ + Q_OBJECT +public: + meterModel( ::model * _parent, track * _track ); + ~meterModel(); + + void saveSettings( QDomDocument & _doc, QDomElement & _this, + const QString & _name ); + void loadSettings( const QDomElement & _this, + const QString & _name ); + + inline int getNumerator( void ) + { + return( m_numeratorModel.value() ); + } + + inline int getDenominator( void ) + { + return( m_denominatorModel.value() ); + } + + +private: + lcdSpinBoxModel m_numeratorModel; + lcdSpinBoxModel m_denominatorModel; + + +signals: + void numeratorChanged( void ); + void denominatorChanged( void ); + + + friend class meterDialog; + +} ; + +#endif diff --git a/include/song.h b/include/song.h index 819386f0d..613001202 100644 --- a/include/song.h +++ b/include/song.h @@ -33,6 +33,7 @@ #include "automatable_slider.h" #include "lcd_spinbox.h" #include "controller.h" +#include "meter_model.h" class pattern; @@ -138,6 +139,11 @@ public: bpm_t getTempo( void ); virtual automationPattern * tempoAutomationPattern( void ); + const meterModel & getTimeSig( void ) const + { + return( m_timeSigModel ); + } + track * getAutomationTrack( void ) { return( m_automationTrack ); @@ -175,7 +181,7 @@ public: void addController( controller * _c ); // QT will implicitly share the Vector I believe.. - controllerVector controllers( void ) const + const controllerVector & controllers( void ) const { return m_controllers; } @@ -209,6 +215,7 @@ private slots: void addSampleTrack( void ); void setTempo( void ); + void setTimeSignature( void ); void masterVolumeChanged( void ); @@ -240,6 +247,7 @@ private: track * m_automationTrack; lcdSpinBoxModel m_tempoModel; + meterModel m_timeSigModel; sliderModel m_masterVolumeModel; sliderModel m_masterPitchModel; @@ -284,6 +292,7 @@ private: signals: void tempoChanged( bpm_t _new_bpm ); + void timeSignatureChanged( int _num, int _den ); } ; diff --git a/include/song_editor.h b/include/song_editor.h index a33293130..7ac57dc1f 100644 --- a/include/song_editor.h +++ b/include/song_editor.h @@ -30,14 +30,15 @@ #include #include "track_container_view.h" -#include "lcd_spinbox.h" -#include "automatable_slider.h" class QLabel; class QScrollBar; +class automatableSlider; class comboBox; +class lcdSpinBox; +class meterDialog; class song; class textFloat; class toolButton; @@ -83,7 +84,6 @@ private: virtual bool allowRubberband( void ) const; -// virtual void modelChanged( void ); song * m_s; @@ -99,6 +99,7 @@ private: toolButton * m_stopButton; lcdSpinBox * m_tempoSpinBox; + meterDialog * m_timeSigDisplay; automatableSlider * m_masterVolumeSlider; automatableSlider * m_masterPitchSlider; diff --git a/include/tempo_sync_knob.h b/include/tempo_sync_knob.h index 5739bd286..4196d57c2 100644 --- a/include/tempo_sync_knob.h +++ b/include/tempo_sync_knob.h @@ -29,7 +29,7 @@ #include #include "knob.h" -#include "meter_dialog.h" +#include "meter_model.h" class QAction; diff --git a/src/core/meter_model.cpp b/src/core/meter_model.cpp new file mode 100644 index 000000000..7688f9a93 --- /dev/null +++ b/src/core/meter_model.cpp @@ -0,0 +1,73 @@ +/* + * meter_model.cpp - model for meter specification + * + * Copyright (c) 2008 Tobias Doerffel + * + * 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., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA. + * + */ + + +#include "meter_model.h" + + +meterModel::meterModel( ::model * _parent, track * _track ) : + model( _parent ), + m_numeratorModel( 4, 1, 32, 1, this ), + m_denominatorModel( 4, 1, 32, 1, this ) +{ + m_numeratorModel.setTrack( _track ); + m_denominatorModel.setTrack( _track ); + + connect( &m_numeratorModel, SIGNAL( dataChanged() ), + this, SIGNAL( numeratorChanged() ) ); + connect( &m_denominatorModel, SIGNAL( dataChanged() ), + this, SIGNAL( denominatorChanged() ) ); +} + + + + +meterModel::~meterModel() +{ +} + + + + +void meterModel::saveSettings( QDomDocument & _doc, QDomElement & _this, + const QString & _name ) +{ + m_numeratorModel.saveSettings( _doc, _this, _name + "_numerator" ); + m_denominatorModel.saveSettings( _doc, _this, _name + "_denominator" ); +} + + + + +void meterModel::loadSettings( const QDomElement & _this, + const QString & _name ) +{ + m_numeratorModel.loadSettings( _this, _name + "_numerator" ); + m_denominatorModel.loadSettings( _this, _name + "_denominator" ); +} + + + +#include "meter_model.moc" + diff --git a/src/core/song.cpp b/src/core/song.cpp index 81a61bb8c..35eb0186c 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -77,6 +77,7 @@ song::song( void ) : m_automationTrack( track::create( track::AutomationTrack, this ) ), m_tempoModel( DEFAULT_BPM, MIN_BPM, MAX_BPM, intModel::defaultRelStep(), this ), + m_timeSigModel( this, m_automationTrack ), m_masterVolumeModel( 100, 0, 200, 1, this ), m_masterPitchModel( 0, -12, 12, 1, this ), m_fileName(), @@ -96,6 +97,8 @@ song::song( void ) : this, SLOT( setTempo() ) ); connect( &m_tempoModel, SIGNAL( dataUnchanged() ), this, SLOT( setTempo() ) ); + connect( &m_timeSigModel, SIGNAL( dataChanged() ), + this, SLOT( setTimeSignature() ) ); connect( engine::getMixer(), SIGNAL( sampleRateChanged() ), this, @@ -155,6 +158,15 @@ void song::setTempo( void ) +void song::setTimeSignature( void ) +{ + emit timeSignatureChanged( m_timeSigModel.getNumerator(), + m_timeSigModel.getDenominator() ); +} + + + + void song::doActions( void ) { while( !m_actions.empty() ) diff --git a/src/gui/song_editor.cpp b/src/gui/song_editor.cpp index bbb50c553..b2beb91ab 100644 --- a/src/gui/song_editor.cpp +++ b/src/gui/song_editor.cpp @@ -61,6 +61,7 @@ #include "instrument_track.h" #include "lcd_spinbox.h" #include "main_window.h" +#include "meter_dialog.h" #include "midi_client.h" #include "mmp.h" #include "note_play_handle.h" @@ -140,6 +141,12 @@ songEditor::songEditor( song * _song, songEditor * & _engine_ptr ) : engine::getMainWindow()->addSpacingToToolBar( 10 ); + m_timeSigDisplay = new meterDialog( this, TRUE ); + m_timeSigDisplay->setModel( &m_s->m_timeSigModel ); + engine::getMainWindow()->addWidgetToToolBar( m_timeSigDisplay ); + + engine::getMainWindow()->addSpacingToToolBar( 10 ); + QLabel * master_vol_lbl = new QLabel( tb ); master_vol_lbl->setPixmap( embed::getIconPixmap( "master_volume" ) ); diff --git a/src/gui/widgets/meter_dialog.cpp b/src/gui/widgets/meter_dialog.cpp index 382f95926..2ba620f87 100644 --- a/src/gui/widgets/meter_dialog.cpp +++ b/src/gui/widgets/meter_dialog.cpp @@ -1,5 +1,3 @@ -#ifndef SINGLE_SOURCE_COMPILE - /* * meter_dialog.cpp - dialog for entering meter settings * @@ -29,63 +27,18 @@ #include #include "meter_dialog.h" +#include "meter_model.h" #include "embed.h" #include "gui_templates.h" -meterModel::meterModel( ::model * _parent, track * _track ) : - model( _parent ), - m_numeratorModel( 4, 1, 32, 1, this ), - m_denominatorModel( 4, 1, 32, 1, this ) -{ - m_numeratorModel.setTrack( _track ); - m_denominatorModel.setTrack( _track ); - - connect( &m_numeratorModel, SIGNAL( dataChanged() ), - this, SIGNAL( numeratorChanged() ) ); - connect( &m_denominatorModel, SIGNAL( dataChanged() ), - this, SIGNAL( denominatorChanged() ) ); -} - - - - -meterModel::~meterModel() -{ -} - - - - -void meterModel::saveSettings( QDomDocument & _doc, QDomElement & _this, - const QString & _name ) -{ - m_numeratorModel.saveSettings( _doc, _this, _name + "_numerator" ); - m_denominatorModel.saveSettings( _doc, _this, _name + "_denominator" ); -} - - - - -void meterModel::loadSettings( const QDomElement & _this, - const QString & _name ) -{ - m_numeratorModel.loadSettings( _this, _name + "_numerator" ); - m_denominatorModel.loadSettings( _this, _name + "_denominator" ); -} - - - - - -meterDialog::meterDialog( QWidget * _parent ) : +meterDialog::meterDialog( QWidget * _parent, bool _simple ) : QWidget( _parent ), modelView( NULL ) { QVBoxLayout * vlayout = new QVBoxLayout( this ); - vlayout->setSpacing( 5 ); - vlayout->setMargin( 5 ); - + vlayout->setSpacing( 0 ); + vlayout->setMargin( 0 ); QWidget * num = new QWidget( this ); QHBoxLayout * num_layout = new QHBoxLayout( num ); @@ -97,11 +50,15 @@ meterDialog::meterDialog( QWidget * _parent ) : num_layout->addWidget( m_numerator ); - QLabel * num_label = new QLabel( num ); - num_label->setText( tr( "Meter Numerator" ) ); - QFont f = num_label->font(); - num_label->setFont( pointSize<7>( f ) ); - num_layout->addWidget( num_label ); + if( !_simple ) + { + QLabel * num_label = new QLabel( tr( "Meter Numerator" ), num ); + QFont f = num_label->font(); + num_label->setFont( pointSize<7>( f ) ); + num_layout->addSpacing( 5 ); + num_layout->addWidget( num_label ); + } + num_layout->addStretch(); QWidget * den = new QWidget( this ); @@ -110,20 +67,30 @@ meterDialog::meterDialog( QWidget * _parent ) : den_layout->setMargin( 0 ); m_denominator = new lcdSpinBox( 2, den, tr( "Meter Denominator" ) ); + if( _simple ) + { + m_denominator->setLabel( tr( "TIME SIG" ) ); + } den_layout->addWidget( m_denominator ); - QLabel * den_label = new QLabel( den ); - f = den_label->font(); - den_label->setFont( pointSize<7>( f ) ); - den_label->setText( tr( "Meter Denominator" ) ); - den_layout->addWidget( den_label ); - + if( !_simple ) + { + QLabel * den_label = new QLabel( tr( "Meter Denominator" ), + den ); + QFont f = den_label->font(); + den_label->setFont( pointSize<7>( f ) ); + den_layout->addSpacing( 5 ); + den_layout->addWidget( den_label ); + } + den_layout->addStretch(); + + + vlayout->addSpacing( _simple ? 1 : 3 ); vlayout->addWidget( num ); + vlayout->addSpacing( 2 ); vlayout->addWidget( den ); - - resize( den_label->width() + m_denominator->width() + 10, - m_numerator->height() + m_denominator->height() + 15 ); + vlayout->addStretch(); } @@ -144,6 +111,3 @@ void meterDialog::modelChanged( void ) } -#include "meter_dialog.moc" - -#endif