reworked and vastly improved snapping subsystem

This commit is contained in:
itsmattkc
2022-05-02 00:01:49 -07:00
parent 756ff77ae8
commit e6d4fe43de
29 changed files with 289 additions and 225 deletions
+24 -2
View File
@@ -25,13 +25,15 @@
#include "node/output/viewer/viewer.h"
#include "timeline/timelinecommon.h"
#include "widget/keyframeview/keyframeviewinputconnection.h"
#include "widget/resizablescrollbar/resizabletimelinescrollbar.h"
#include "widget/timebased/timescaledobject.h"
#include "widget/timelinewidget/view/timelineview.h"
#include "widget/timeruler/timeruler.h"
namespace olive {
class TimeRuler;
class TimeBasedWidget : public TimelineScaledWidget
{
Q_OBJECT
@@ -54,6 +56,22 @@ public:
virtual bool eventFilter(QObject* object, QEvent* event) override;
using SnapMask = uint32_t;
enum SnapPoints {
kSnapToClips = 0x1,
kSnapToPlayhead = 0x2,
kSnapToMarkers = 0x4,
kSnapToKeyframes = 0x8,
kSnapAll = UINT32_MAX
};
/**
* @brief Snaps point `start_point` that is moving by `movement` to currently existing clips
*/
bool SnapPoint(const std::vector<rational> &start_times, rational *movement, SnapMask snap_points = kSnapAll);
void ShowSnaps(const std::vector<rational> &times);
void HideSnaps();
public slots:
void SetTime(const rational &time);
@@ -119,6 +137,10 @@ protected:
void PassWheelEventsToScrollBar(QObject* object);
virtual const QVector<Block*> *GetSnapBlocks() const { return nullptr; }
virtual const QVector<KeyframeViewInputConnection*> *GetSnapKeyframes() const { return nullptr; }
virtual const std::vector<NodeKeyframe*> *GetSnapIgnoreKeyframes() const { return nullptr; }
protected slots:
/**
* @brief Slot to center the horizontal scroll bar on the playhead's current position
@@ -141,7 +163,7 @@ signals:
void ConnectedNodeChanged(ViewerOutput* old, ViewerOutput* now);
private:
/**
* @brief Set either in or out point to the current playhead