summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2012-01-17 23:46:37 +0000
committerFlorian Jung <flo@windfisch.org>2012-01-17 23:46:37 +0000
commitd33b1fa0810a3b115939e99cf72e75243a0d385a (patch)
tree34a660d281282ba43653b3694eeb6d380d9b03ae
parent1fb87721aff3e7bbac536c2e3d71f9fbeabd5abf (diff)
added song position toolbar for rapid position selection
-rw-r--r--muse2/muse/app.cpp9
-rw-r--r--muse2/muse/widgets/CMakeLists.txt2
-rw-r--r--muse2/muse/widgets/mtscale.cpp2
-rw-r--r--muse2/muse/widgets/songpos_toolbar.cpp54
-rw-r--r--muse2/muse/widgets/songpos_toolbar.h49
5 files changed, 115 insertions, 1 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 3dfba915..6c78eafa 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -82,6 +82,7 @@
#include "widgets/unusedwavefiles.h"
#include "functions.h"
#include "trackdrummapupdater.h"
+#include "songpos_toolbar.h"
namespace MusECore {
extern void initMidiSynth();
@@ -677,6 +678,13 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
// when adding a toolbar to the main window, remember adding it to
// either the requiredToolbars or optionalToolbars list!
+ QToolBar* songpos_tb;
+ songpos_tb = addToolBar(tr("Song Position"));
+ songpos_tb->setObjectName("Song Position");
+ songpos_tb->addWidget(new MusEGui::SongPosToolbarWidget(songpos_tb));
+ songpos_tb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ songpos_tb->setContextMenuPolicy(Qt::PreventContextMenu);
+
tools = addToolBar(tr("File Buttons"));
tools->setObjectName("File Buttons");
tools->addAction(fileNewAction);
@@ -697,6 +705,7 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
panicToolbar->addAction(MusEGlobal::panicAction);
requiredToolbars.push_back(tools);
+ requiredToolbars.push_back(songpos_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 0328b89d..6d457e7e 100644
--- a/muse2/muse/widgets/CMakeLists.txt
+++ b/muse2/muse/widgets/CMakeLists.txt
@@ -82,6 +82,7 @@ QT4_WRAP_CPP (widget_mocs
slider.h
sliderbase.h
songinfo.h
+ songpos_toolbar.h
spinbox.h
spinboxFP.h
splitter.h
@@ -192,6 +193,7 @@ file (GLOB widgets_source_files
sigscale.cpp
slider.cpp
sliderbase.cpp
+ songpos_toolbar.cpp
spinbox.cpp
spinboxFP.cpp
splitter.cpp
diff --git a/muse2/muse/widgets/mtscale.cpp b/muse2/muse/widgets/mtscale.cpp
index 3131adcc..a316416d 100644
--- a/muse2/muse/widgets/mtscale.cpp
+++ b/muse2/muse/widgets/mtscale.cpp
@@ -250,7 +250,7 @@ void MTScale::pdraw(QPainter& p, const QRect& r)
if (xp > x+w)
break;
int xe = r.x() + r.width();
- MusECore::iMarker mm = m;
+ MusECore::iMarker mm = m;
++mm;
if (mm != marker->end()) {
diff --git a/muse2/muse/widgets/songpos_toolbar.cpp b/muse2/muse/widgets/songpos_toolbar.cpp
new file mode 100644
index 00000000..4f4f519d
--- /dev/null
+++ b/muse2/muse/widgets/songpos_toolbar.cpp
@@ -0,0 +1,54 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// songpos_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 "songpos_toolbar.h"
+#include "song.h"
+
+namespace MusEGui
+{
+ SongPosToolbarWidget::SongPosToolbarWidget(QWidget* p)
+ : MTScale(&_raster, p, -100 /* some random scale, will be overwritten immediately */)
+ {
+ _raster=0;
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
+ connect(MusEGlobal::song, SIGNAL(songChanged(int)), this, SLOT(song_changed(int)));
+ song_changed(0);
+ }
+
+ void SongPosToolbarWidget::song_changed(int)
+ {
+ if (width()!=0)
+ setXMag(-(MusEGlobal::song->len()/width()));
+ }
+
+ QSize SongPosToolbarWidget::sizeHint() const
+ {
+ return QSize(100, minimumSize().height());
+ }
+
+ void SongPosToolbarWidget::resizeEvent(QResizeEvent* ev)
+ {
+ song_changed(0);
+ MTScale::resizeEvent(ev);
+ }
+}
diff --git a/muse2/muse/widgets/songpos_toolbar.h b/muse2/muse/widgets/songpos_toolbar.h
new file mode 100644
index 00000000..d199409d
--- /dev/null
+++ b/muse2/muse/widgets/songpos_toolbar.h
@@ -0,0 +1,49 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// songpos_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.
+//
+//=========================================================
+
+#ifndef __SONGPOS_TOOLBAR_H__
+#define __SONGPOS_TOOLBAR_H__
+
+#include "mtscale.h"
+
+namespace MusEGui
+{
+ class SongPosToolbarWidget : public MTScale
+ {
+ Q_OBJECT
+
+ private:
+ int _raster;
+
+ public:
+ SongPosToolbarWidget(QWidget* parent);
+
+ virtual QSize sizeHint() const;
+ virtual void resizeEvent(QResizeEvent*);
+
+ private slots:
+ void song_changed(int);
+
+ };
+}
+
+#endif