From ba4e43028bf066d1bec367321d8e31aacc5ca530 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Wed, 18 Jan 2012 17:08:55 +0000 Subject: added sigedit and tempo toolbar --- muse2/awl/sigedit.cpp | 1 - muse2/muse/app.cpp | 13 ++++ muse2/muse/widgets/CMakeLists.txt | 2 + muse2/muse/widgets/sig_tempo_toolbar.cpp | 121 +++++++++++++++++++++++++++++++ muse2/muse/widgets/sig_tempo_toolbar.h | 75 +++++++++++++++++++ muse2/muse/widgets/songpos_toolbar.h | 2 +- 6 files changed, 212 insertions(+), 2 deletions(-) create mode 100644 muse2/muse/widgets/sig_tempo_toolbar.cpp create mode 100644 muse2/muse/widgets/sig_tempo_toolbar.h (limited to 'muse2') diff --git a/muse2/awl/sigedit.cpp b/muse2/awl/sigedit.cpp index d3685a53..bbe96d61 100644 --- a/muse2/awl/sigedit.cpp +++ b/muse2/awl/sigedit.cpp @@ -54,7 +54,6 @@ SigEdit::SigEdit(QWidget* parent) layout->addWidget(zSpin); layout->addWidget(slash); layout->addWidget(nSpin); - layout->addSpacing(30); connect(zSpin, SIGNAL(valueChanged(int)), SLOT(setZ(int))); connect(nSpin, SIGNAL(valueChanged(int)), SLOT(setN(int))); connect(nSpin, SIGNAL(returnPressed()), SIGNAL(returnPressed())); diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index 6c78eafa..26f2d158 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -83,6 +83,7 @@ #include "functions.h" #include "trackdrummapupdater.h" #include "songpos_toolbar.h" +#include "sig_tempo_toolbar.h" namespace MusECore { extern void initMidiSynth(); @@ -685,6 +686,16 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow() songpos_tb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); songpos_tb->setContextMenuPolicy(Qt::PreventContextMenu); + QToolBar* tempo_tb; + tempo_tb = addToolBar(tr("Tempo")); + tempo_tb->setObjectName("Tempo"); + tempo_tb->addWidget(new MusEGui::TempoToolbarWidget(tempo_tb)); + + QToolBar* sig_tb; + sig_tb = addToolBar(tr("Signature")); + sig_tb->setObjectName("Signature"); + sig_tb->addWidget(new MusEGui::SigToolbarWidget(tempo_tb)); + tools = addToolBar(tr("File Buttons")); tools->setObjectName("File Buttons"); tools->addAction(fileNewAction); @@ -706,6 +717,8 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow() requiredToolbars.push_back(tools); requiredToolbars.push_back(songpos_tb); + requiredToolbars.push_back(sig_tb); + requiredToolbars.push_back(tempo_tb); optionalToolbars.push_back(undoToolbar); optionalToolbars.push_back(transportToolbar); optionalToolbars.push_back(panicToolbar); diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt index 6d457e7e..934caa6a 100644 --- a/muse2/muse/widgets/CMakeLists.txt +++ b/muse2/muse/widgets/CMakeLists.txt @@ -79,6 +79,7 @@ QT4_WRAP_CPP (widget_mocs # sigedit.h siglabel.h sigscale.h + sig_tempo_toolbar.h slider.h sliderbase.h songinfo.h @@ -191,6 +192,7 @@ file (GLOB widgets_source_files # sigedit.cpp siglabel.cpp sigscale.cpp + sig_tempo_toolbar.cpp slider.cpp sliderbase.cpp songpos_toolbar.cpp diff --git a/muse2/muse/widgets/sig_tempo_toolbar.cpp b/muse2/muse/widgets/sig_tempo_toolbar.cpp new file mode 100644 index 00000000..4e767cd1 --- /dev/null +++ b/muse2/muse/widgets/sig_tempo_toolbar.cpp @@ -0,0 +1,121 @@ +//========================================================= +// MusE +// Linux Music Editor +// sig_tempo_toolbar.cpp +// (C) Copyright 2012 Florian Jung (flo93@users.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; 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; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//========================================================= + + +#include "sig_tempo_toolbar.h" +#include "tempolabel.h" +#include "awl/sigedit.h" +#include "song.h" + +#include +#include + + +namespace MusEGui +{ + TempoToolbarWidget::TempoToolbarWidget(QWidget* p) : QWidget(p) + { + tempo_edit=new MusEGui::TempoEdit(this); + tempo_edit->setToolTip(tr("tempo at current position")); + + label=new QLabel(tr("Tempo: "),this); + + layout = new QHBoxLayout(this); + layout->setContentsMargins(0,0,0,0); + layout->setSpacing(1); + layout->addWidget(label); + layout->addWidget(tempo_edit); + + connect(MusEGlobal::song, SIGNAL(songChanged(int)), this, SLOT(song_changed(int))); + connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(pos_changed(int,unsigned,bool))); + + connect(tempo_edit, SIGNAL(tempoChanged(double)), MusEGlobal::song, SLOT(setTempo(double))); + + song_changed(-1); + } + + void TempoToolbarWidget::pos_changed(int,unsigned,bool) + { + song_changed(SC_TEMPO); + } + + void TempoToolbarWidget::song_changed(int type) + { + if (type & SC_TEMPO) + { + int tempo = MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos()); + tempo_edit->blockSignals(true); + tempo_edit->setValue(double(60000000.0/tempo)); + tempo_edit->blockSignals(false); + } + if (type & SC_MASTER) + { + tempo_edit->setEnabled(MusEGlobal::song->masterFlag()); + label->setEnabled(MusEGlobal::song->masterFlag()); + } + } + + SigToolbarWidget::SigToolbarWidget(QWidget* p) : QWidget(p) + { + sig_edit=new Awl::SigEdit(this); + sig_edit->setValue(AL::TimeSignature(4, 4)); + sig_edit->setToolTip(tr("time signature at current position")); + + label=new QLabel(tr("Signature: "),this); + + layout = new QHBoxLayout(this); + layout->setContentsMargins(0,0,0,0); + layout->setSpacing(1); + layout->addWidget(label); + layout->addWidget(sig_edit); + + connect(MusEGlobal::song, SIGNAL(songChanged(int)), this, SLOT(song_changed(int))); + connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(pos_changed(int,unsigned,bool))); + + connect(sig_edit, SIGNAL(valueChanged(const AL::TimeSignature&)), MusEGlobal::song, SLOT(setSig(const AL::TimeSignature&))); + + song_changed(-1); + } + + void SigToolbarWidget::pos_changed(int,unsigned,bool) + { + song_changed(SC_SIG); + } + + void SigToolbarWidget::song_changed(int type) + { + if (type & SC_SIG) + { + int z, n; + AL::sigmap.timesig(MusEGlobal::song->cpos(), z, n); + sig_edit->blockSignals(true); + sig_edit->setValue(AL::TimeSignature(z, n)); + sig_edit->blockSignals(false); + } + if (type & SC_MASTER) + { + sig_edit->setEnabled(MusEGlobal::song->masterFlag()); + label->setEnabled(MusEGlobal::song->masterFlag()); + } + } + +} diff --git a/muse2/muse/widgets/sig_tempo_toolbar.h b/muse2/muse/widgets/sig_tempo_toolbar.h new file mode 100644 index 00000000..0519193d --- /dev/null +++ b/muse2/muse/widgets/sig_tempo_toolbar.h @@ -0,0 +1,75 @@ +//========================================================= +// MusE +// Linux Music Editor +// sig_tempo_toolbar.h +// (C) Copyright 2012 Florian Jung (flo93@users.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; 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; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +// +//========================================================= + +#ifndef __SIG_TEMPO_TOOLBAR_H__ +#define __SIG_TEMPO_TOOLBAR_H__ + +#include + +namespace Awl +{ + class SigEdit; +} + +class QHBoxLayout; +class QLabel; + +namespace MusEGui +{ + class TempoEdit; + + class SigToolbarWidget : public QWidget + { + Q_OBJECT + + private: + QHBoxLayout* layout; + QLabel* label; + Awl::SigEdit* sig_edit; + + public: + SigToolbarWidget(QWidget* parent); + + private slots: + void pos_changed(int,unsigned,bool); + void song_changed(int); + }; + + class TempoToolbarWidget : public QWidget + { + Q_OBJECT + + private: + QHBoxLayout* layout; + QLabel* label; + MusEGui::TempoEdit* tempo_edit; + + public: + TempoToolbarWidget(QWidget* parent); + + private slots: + void pos_changed(int,unsigned,bool); + void song_changed(int); + }; +} + +#endif diff --git a/muse2/muse/widgets/songpos_toolbar.h b/muse2/muse/widgets/songpos_toolbar.h index d199409d..2b69e2f2 100644 --- a/muse2/muse/widgets/songpos_toolbar.h +++ b/muse2/muse/widgets/songpos_toolbar.h @@ -1,7 +1,7 @@ //========================================================= // MusE // Linux Music Editor -// songpos_toolbar.cpp +// songpos_toolbar.h // (C) Copyright 2012 Florian Jung (flo93@users.sourceforge.net) // // This program is free software; you can redistribute it and/or -- cgit v1.2.3