Split TimeLineWidget into core and GUI parts (#7004)
This commit is contained in:
@@ -248,7 +248,6 @@ private slots:
|
||||
void onExportProject();
|
||||
void onExportProjectTracks();
|
||||
void onImportProject();
|
||||
void onSongStopped();
|
||||
void onSongModified();
|
||||
void onProjectFileNameChanged();
|
||||
|
||||
|
||||
@@ -55,25 +55,20 @@ public:
|
||||
|
||||
|
||||
public slots:
|
||||
void changeState( int _n );
|
||||
|
||||
void changeState(int state);
|
||||
|
||||
signals:
|
||||
void changedState( int _n );
|
||||
|
||||
void changedState(int state);
|
||||
|
||||
protected:
|
||||
void mousePressEvent( QMouseEvent * _me ) override;
|
||||
|
||||
void mousePressEvent(QMouseEvent* me) override;
|
||||
|
||||
private:
|
||||
QVector<QPair<QPixmap, QString> > m_states;
|
||||
QVector<QPair<QPixmap, QString>> m_states;
|
||||
QString m_generalToolTip;
|
||||
|
||||
int m_curState;
|
||||
|
||||
} ;
|
||||
|
||||
};
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
|
||||
@@ -25,16 +25,18 @@
|
||||
#ifndef LMMS_SONG_H
|
||||
#define LMMS_SONG_H
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
#include <QHash>
|
||||
#include <QString>
|
||||
|
||||
#include "TrackContainer.h"
|
||||
#include "AudioEngine.h"
|
||||
#include "Controller.h"
|
||||
#include "lmms_constants.h"
|
||||
#include "MeterModel.h"
|
||||
#include "Timeline.h"
|
||||
#include "TrackContainer.h"
|
||||
#include "VstSyncController.h"
|
||||
|
||||
namespace lmms
|
||||
@@ -105,7 +107,6 @@ public:
|
||||
public:
|
||||
PlayPos( const int abs = 0 ) :
|
||||
TimePos( abs ),
|
||||
m_timeLine( nullptr ),
|
||||
m_currentFrame( 0.0f )
|
||||
{
|
||||
}
|
||||
@@ -125,13 +126,11 @@ public:
|
||||
{
|
||||
return m_jumped;
|
||||
}
|
||||
gui::TimeLineWidget * m_timeLine;
|
||||
|
||||
private:
|
||||
float m_currentFrame;
|
||||
bool m_jumped;
|
||||
|
||||
} ;
|
||||
};
|
||||
|
||||
void processNextBuffer();
|
||||
|
||||
@@ -274,6 +273,11 @@ public:
|
||||
return getPlayPos(m_playMode);
|
||||
}
|
||||
|
||||
auto getTimeline(PlayMode mode) -> Timeline& { return m_timelines[static_cast<std::size_t>(mode)]; }
|
||||
auto getTimeline(PlayMode mode) const -> const Timeline& { return m_timelines[static_cast<std::size_t>(mode)]; }
|
||||
auto getTimeline() -> Timeline& { return getTimeline(m_playMode); }
|
||||
auto getTimeline() const -> const Timeline& { return getTimeline(m_playMode); }
|
||||
|
||||
void updateLength();
|
||||
bar_t length() const
|
||||
{
|
||||
@@ -402,7 +406,7 @@ private slots:
|
||||
|
||||
void masterVolumeChanged();
|
||||
|
||||
void savePos();
|
||||
void savePlayStartPosition();
|
||||
|
||||
void updateFramesPerTick();
|
||||
|
||||
@@ -481,6 +485,8 @@ private:
|
||||
|
||||
QHash<QString, int> m_errors;
|
||||
|
||||
std::array<Timeline, PlayModeCount> m_timelines;
|
||||
|
||||
PlayMode m_playMode;
|
||||
PlayPos m_playPos[PlayModeCount];
|
||||
bar_t m_length;
|
||||
|
||||
@@ -34,6 +34,12 @@
|
||||
class QPixmap;
|
||||
class QToolBar;
|
||||
|
||||
namespace lmms {
|
||||
|
||||
class Timeline;
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
namespace lmms::gui
|
||||
{
|
||||
|
||||
@@ -42,7 +48,7 @@ class TextFloat;
|
||||
class SongEditor;
|
||||
|
||||
|
||||
class TimeLineWidget : public QWidget, public JournallingObject
|
||||
class TimeLineWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -60,24 +66,10 @@ public:
|
||||
{
|
||||
Enabled,
|
||||
Disabled
|
||||
} ;
|
||||
};
|
||||
|
||||
enum class LoopPointState
|
||||
{
|
||||
Disabled,
|
||||
Enabled
|
||||
} ;
|
||||
|
||||
enum class BehaviourAtStopState
|
||||
{
|
||||
BackToZero,
|
||||
BackToStart,
|
||||
KeepStopPosition
|
||||
} ;
|
||||
|
||||
|
||||
TimeLineWidget(int xoff, int yoff, float ppb, Song::PlayPos & pos,
|
||||
const TimePos & begin, Song::PlayMode mode, QWidget * parent);
|
||||
TimeLineWidget(int xoff, int yoff, float ppb, Song::PlayPos& pos, Timeline& timeline,
|
||||
const TimePos& begin, Song::PlayMode mode, QWidget* parent);
|
||||
~TimeLineWidget() override;
|
||||
|
||||
inline QColor const & getBarLineColor() const { return m_barLineColor; }
|
||||
@@ -117,42 +109,6 @@ public:
|
||||
return m_autoScroll;
|
||||
}
|
||||
|
||||
BehaviourAtStopState behaviourAtStop() const
|
||||
{
|
||||
return m_behaviourAtStop;
|
||||
}
|
||||
|
||||
void setBehaviourAtStop (int state)
|
||||
{
|
||||
emit loadBehaviourAtStop (state);
|
||||
}
|
||||
|
||||
bool loopPointsEnabled() const
|
||||
{
|
||||
return m_loopPoints == LoopPointState::Enabled;
|
||||
}
|
||||
|
||||
inline const TimePos & loopBegin() const
|
||||
{
|
||||
return ( m_loopPos[0] < m_loopPos[1] ) ?
|
||||
m_loopPos[0] : m_loopPos[1];
|
||||
}
|
||||
|
||||
inline const TimePos & loopEnd() const
|
||||
{
|
||||
return ( m_loopPos[0] > m_loopPos[1] ) ?
|
||||
m_loopPos[0] : m_loopPos[1];
|
||||
}
|
||||
|
||||
inline void savePos( const TimePos & pos )
|
||||
{
|
||||
m_savedPos = pos;
|
||||
}
|
||||
inline const TimePos & savedPos() const
|
||||
{
|
||||
return m_savedPos;
|
||||
}
|
||||
|
||||
inline void setPixelsPerBar( float ppb )
|
||||
{
|
||||
m_ppb = ppb;
|
||||
@@ -163,14 +119,6 @@ public:
|
||||
|
||||
void addToolButtons(QToolBar* _tool_bar );
|
||||
|
||||
|
||||
void saveSettings( QDomDocument & _doc, QDomElement & _parent ) override;
|
||||
void loadSettings( const QDomElement & _this ) override;
|
||||
inline QString nodeName() const override
|
||||
{
|
||||
return "timeline";
|
||||
}
|
||||
|
||||
inline int markerX( const TimePos & _t ) const
|
||||
{
|
||||
return m_xOffset + static_cast<int>( ( _t - m_begin ) *
|
||||
@@ -178,25 +126,17 @@ public:
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
void positionChanged(const lmms::TimePos& postion);
|
||||
void regionSelectedFromPixels( int, int );
|
||||
void selectionFinished();
|
||||
|
||||
|
||||
public slots:
|
||||
void updatePosition( const lmms::TimePos & );
|
||||
void updatePosition()
|
||||
{
|
||||
updatePosition( TimePos() );
|
||||
}
|
||||
void updatePosition();
|
||||
void setSnapSize( const float snapSize )
|
||||
{
|
||||
m_snapSize = snapSize;
|
||||
}
|
||||
void toggleAutoScroll( int _n );
|
||||
void toggleLoopPoints( int _n );
|
||||
void toggleBehaviourAtStop( int _n );
|
||||
|
||||
|
||||
protected:
|
||||
void paintEvent( QPaintEvent * _pe ) override;
|
||||
@@ -222,8 +162,6 @@ private:
|
||||
QColor m_barNumberColor;
|
||||
|
||||
AutoScrollState m_autoScroll;
|
||||
LoopPointState m_loopPoints;
|
||||
BehaviourAtStopState m_behaviourAtStop;
|
||||
|
||||
bool m_changedPosition;
|
||||
|
||||
@@ -232,12 +170,9 @@ private:
|
||||
float m_ppb;
|
||||
float m_snapSize;
|
||||
Song::PlayPos & m_pos;
|
||||
Timeline* m_timeline;
|
||||
const TimePos & m_begin;
|
||||
const Song::PlayMode m_mode;
|
||||
TimePos m_loopPos[2];
|
||||
|
||||
TimePos m_savedPos;
|
||||
|
||||
|
||||
TextFloat * m_hint;
|
||||
int m_initalXSelect;
|
||||
@@ -253,17 +188,7 @@ private:
|
||||
} m_action;
|
||||
|
||||
int m_moveXOff;
|
||||
|
||||
|
||||
signals:
|
||||
void positionChanged( const lmms::TimePos & _t );
|
||||
void loopPointStateLoaded( int _n );
|
||||
void positionMarkerMoved();
|
||||
void loadBehaviourAtStop( int _n );
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
|
||||
82
include/Timeline.h
Normal file
82
include/Timeline.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Timeline.h
|
||||
*
|
||||
* Copyright (c) 2023 Dominic Clark
|
||||
*
|
||||
* This file is part of LMMS - https://lmms.io
|
||||
*
|
||||
* 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 LMMS_TIMELINE_H
|
||||
#define LMMS_TIMELINE_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "JournallingObject.h"
|
||||
#include "TimePos.h"
|
||||
|
||||
namespace lmms {
|
||||
|
||||
class Timeline : public QObject, public JournallingObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum class StopBehaviour
|
||||
{
|
||||
BackToZero,
|
||||
BackToStart,
|
||||
KeepPosition
|
||||
};
|
||||
|
||||
auto loopBegin() const -> TimePos { return m_loopBegin; }
|
||||
auto loopEnd() const -> TimePos { return m_loopEnd; }
|
||||
auto loopEnabled() const -> bool { return m_loopEnabled; }
|
||||
|
||||
void setLoopBegin(TimePos begin);
|
||||
void setLoopEnd(TimePos end);
|
||||
void setLoopPoints(TimePos begin, TimePos end);
|
||||
void setLoopEnabled(bool enabled);
|
||||
|
||||
auto playStartPosition() const -> TimePos { return m_playStartPosition; }
|
||||
auto stopBehaviour() const -> StopBehaviour { return m_stopBehaviour; }
|
||||
|
||||
void setPlayStartPosition(TimePos position) { m_playStartPosition = position; }
|
||||
void setStopBehaviour(StopBehaviour behaviour);
|
||||
|
||||
auto nodeName() const -> QString override { return "timeline"; }
|
||||
|
||||
signals:
|
||||
void loopEnabledChanged(bool enabled);
|
||||
void stopBehaviourChanged(lmms::Timeline::StopBehaviour behaviour);
|
||||
|
||||
protected:
|
||||
void saveSettings(QDomDocument& doc, QDomElement& element) override;
|
||||
void loadSettings(const QDomElement& element) override;
|
||||
|
||||
private:
|
||||
TimePos m_loopBegin = TimePos{0};
|
||||
TimePos m_loopEnd = TimePos{DefaultTicksPerBar};
|
||||
bool m_loopEnabled = false;
|
||||
|
||||
StopBehaviour m_stopBehaviour = StopBehaviour::BackToStart;
|
||||
TimePos m_playStartPosition = TimePos{-1};
|
||||
};
|
||||
|
||||
} // namespace lmms
|
||||
|
||||
#endif // LMMS_TIMELINE_H
|
||||
Reference in New Issue
Block a user