Skip to content

Commit

Permalink
Merge pull request #3230 from JoshuaBonn1/6-timeline-class
Browse files Browse the repository at this point in the history
Timeline Basic Functionality
  • Loading branch information
lasconic committed Jul 7, 2017
2 parents 6413ac1 + 9eefdb8 commit a64198e
Show file tree
Hide file tree
Showing 9 changed files with 1,745 additions and 4 deletions.
1 change: 1 addition & 0 deletions mscore/CMakeLists.txt
Expand Up @@ -241,6 +241,7 @@ add_executable ( ${ExecutableName}
instrdialog.cpp instrwidget.cpp
debugger/debugger.cpp menus.cpp
musescore.cpp navigator.cpp pagesettings.cpp palette.cpp
timeline.cpp
mixer.cpp playpanel.cpp selectionwindow.cpp preferences.cpp measureproperties.cpp
seq.cpp textpalette.cpp
timedialog.cpp symboldialog.cpp shortcutcapturedialog.cpp
Expand Down
2 changes: 1 addition & 1 deletion mscore/data/shortcuts.xml
Expand Up @@ -527,7 +527,7 @@
<seq>F11</seq>
</SC>
<SC>
<key>toggle-navigator</key>
<key>toggle-timeline</key>
<seq>F12</seq>
</SC>
<SC>
Expand Down
44 changes: 44 additions & 0 deletions mscore/musescore.cpp
Expand Up @@ -55,6 +55,7 @@
#include "keyedit.h"
#include "harmonyedit.h"
#include "navigator.h"
#include "timeline.h"
#include "importmidi/importmidi_panel.h"
#include "libmscore/chord.h"
#include "mstyle/mstyle.h"
Expand Down Expand Up @@ -648,6 +649,12 @@ MuseScore::MuseScore()
scorePageLayoutChanged();
showNavigator(preferences.showNavigator);

_timeline = new TDockWidget;
_timeline->setFocusPolicy(Qt::NoFocus);
addDockWidget(Qt::BottomDockWidgetArea, _timeline);
scorePageLayoutChanged();
showTimeline(false);

mainWindow->setStretchFactor(0, 1);
mainWindow->setStretchFactor(1, 0);
mainWindow->setSizes(QList<int>({500, 50}));
Expand Down Expand Up @@ -928,6 +935,10 @@ MuseScore::MuseScore()
a->setChecked(preferences.showNavigator);
menuView->addAction(a);

a = getAction("toggle-timeline");
a->setCheckable(true);
menuView->addAction(a);

a = getAction("toggle-mixer");
a->setCheckable(true);
menuView->addAction(a);
Expand Down Expand Up @@ -1555,6 +1566,8 @@ void MuseScore::selectionChanged(SelState selectionState)
pianorollEditor->changeSelection(selectionState);
if (drumrollEditor)
drumrollEditor->changeSelection(selectionState);
if (timeline())
timeline()->changeSelection(selectionState);
updateInspector();
}

Expand Down Expand Up @@ -1774,6 +1787,10 @@ void MuseScore::setCurrentScoreView(ScoreView* view)
navigator()->setScoreView(cv);
navigator()->setScore(0);
}
if (_timeline && _timeline->widget()) {
timeline()->setScoreView(cv);
timeline()->setScore(0);
}
if (_inspector)
_inspector->update(0);
viewModeCombo->setEnabled(false);
Expand Down Expand Up @@ -1832,6 +1849,14 @@ void MuseScore::setCurrentScoreView(ScoreView* view)
navigator()->setScore(cs);
navigator()->setScoreView(view);
}
if (_timeline && _timeline->widget()) {
QSplitter* s = static_cast<QSplitter*>(_timeline->widget());
if (s && s->count() > 0) {
Timeline* t = static_cast<Timeline*>(s->widget(1));
t->setScore(cs);
t->setScoreView(view);
}
}
ScoreAccessibility::instance()->updateAccessibilityInfo();
}

Expand Down Expand Up @@ -4597,6 +4622,8 @@ void MuseScore::cmd(QAction* a)

void MuseScore::endCmd()
{
if (timeline())
timeline()->updateGrid();
if (MScore::_error != MS_NO_ERROR)
showError();
if (cs) {
Expand Down Expand Up @@ -4812,6 +4839,8 @@ void MuseScore::cmd(QAction* a, const QString& cmd)
showPlayPanel(a->isChecked());
else if (cmd == "toggle-navigator")
showNavigator(a->isChecked());
else if (cmd == "toggle-timeline")
showTimeline(a->isChecked());
else if (cmd == "toggle-midiimportpanel")
importmidiPanel->setVisible(a->isChecked());
else if (cmd == "toggle-mixer")
Expand Down Expand Up @@ -5058,6 +5087,21 @@ Navigator* MuseScore::navigator() const
return _navigator ? static_cast<Navigator*>(_navigator->widget()) : 0;
}

//---------------------------------------------------------
// timeline
//---------------------------------------------------------

Timeline* MuseScore::timeline() const
{
if (_timeline) {
QSplitter* s = static_cast<QSplitter *>(_timeline->widget());
if (s && s->count() > 0)
return _timeline ? static_cast<Timeline*>(s->widget(1)) : 0;
return 0;
}
return 0;
}

//---------------------------------------------------------
// getSearchDialog
//---------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions mscore/musescore.h
Expand Up @@ -75,6 +75,7 @@ class ScriptEngine;
class KeyEditor;
class ChordStyleEditor;
class Navigator;
class Timeline;
class PianoTools;
class MediaDialog;
class Workspace;
Expand All @@ -85,6 +86,7 @@ class Capella;
class Inspector;
class OmrPanel;
class NScrollArea;
class TDockWidget;
class Sym;
class MasterPalette;
class PluginCreator;
Expand Down Expand Up @@ -232,6 +234,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
ScoreTab* tab1;
ScoreTab* tab2;
NScrollArea* _navigator;
TDockWidget* _timeline;
ImportMidiPanel* importmidiPanel { 0 };
QFrame* importmidiShowPanel;
QSplitter* mainWindow;
Expand Down Expand Up @@ -428,6 +431,7 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
void showInspector(bool);
void showOmrPanel(bool);
void showNavigator(bool);
void showTimeline(bool);
void showSelectionWindow(bool);
void showSearchDialog();
void showToolbarEditor();
Expand Down Expand Up @@ -669,6 +673,8 @@ class MuseScore : public QMainWindow, public MuseScoreCore {
Q_INVOKABLE QString getLocaleISOCode() const;
Navigator* navigator() const;
NScrollArea* navigatorScrollArea() const { return _navigator; }
Timeline* timeline() const;
TDockWidget* timelineScrollArea() const { return _timeline; }
QWidget* searchDialog() const;
SelectionWindow* getSelectionWindow() const { return selectionWindow; }
void updateLayer();
Expand Down
15 changes: 13 additions & 2 deletions mscore/scoreview.cpp
Expand Up @@ -2717,7 +2717,7 @@ void ScoreView::pageEnd()
// adjustCanvasPosition
//---------------------------------------------------------

void ScoreView::adjustCanvasPosition(const Element* el, bool playBack)
void ScoreView::adjustCanvasPosition(const Element* el, bool playBack, int staff )
{
if (this != mscore->currentScoreView())
return;
Expand Down Expand Up @@ -2831,8 +2831,19 @@ void ScoreView::adjustCanvasPosition(const Element* el, bool playBack)

double _spatium = score()->spatium();
const qreal border = _spatium * 3;
QRectF showRect = QRectF(mRect.x(), sysRect.y(), mRect.width(), sysRect.height())
QRectF showRect;
if (staff == -1) {
showRect = QRectF(mRect.x(), sysRect.y(), mRect.width(), sysRect.height())
.adjusted(-border, -border, border, border);
}
else {
//find a box for the individual stave in a system
QRectF stave = QRectF(sys->canvasBoundingRect().left(),
sys->staffCanvasYpage(staff),
sys->width(),
sys->staff(staff)->bbox().height());
showRect = mRect.intersected(stave).adjusted(-border, -border, border, border);
}

/* printf("%f %f %f %f %f %f %f %f %d\n",
showRect.x(), showRect.y(), showRect.width(), showRect.height(),
Expand Down
2 changes: 1 addition & 1 deletion mscore/scoreview.h
Expand Up @@ -396,7 +396,7 @@ class ScoreView : public QWidget, public MuseScoreView {
virtual void layoutChanged();
virtual void dataChanged(const QRectF&);
virtual void updateAll() { update(); }
virtual void adjustCanvasPosition(const Element* el, bool playBack);
virtual void adjustCanvasPosition(const Element* el, bool playBack, int staff = -1);
virtual void setCursor(const QCursor& c) { QWidget::setCursor(c); }
virtual QCursor cursor() const { return QWidget::cursor(); }
void loopUpdate(bool val) { loopToggled(val); }
Expand Down
10 changes: 10 additions & 0 deletions mscore/shortcut.cpp
Expand Up @@ -1763,6 +1763,16 @@ Shortcut Shortcut::_sc[] = {
Icons::Invalid_ICON,
Qt::ApplicationShortcut
},
{
MsWidget::MAIN_WINDOW,
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_EDIT | STATE_PLAY,
"toggle-timeline",
QT_TRANSLATE_NOOP("action","Timeline"),
0,
0,
Icons::Invalid_ICON,
Qt::ApplicationShortcut
},
{
MsWidget::MAIN_WINDOW,
STATE_NORMAL | STATE_NOTE_ENTRY | STATE_EDIT | STATE_PLAY,
Expand Down

0 comments on commit a64198e

Please sign in to comment.