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
+10 -13
View File
@@ -53,6 +53,8 @@ SeekableWidget::SeekableWidget(QWidget* parent) :
setContextMenuPolicy(Qt::CustomContextMenu);
setFocusPolicy(Qt::ClickFocus);
selection_manager_.SetSnapMask(TimeBasedWidget::kSnapAll & ~TimeBasedWidget::kSnapToMarkers);
}
void SeekableWidget::ConnectTimelinePoints(TimelinePoints *points)
@@ -212,11 +214,6 @@ void SeekableWidget::focusOutEvent(QFocusEvent *event)
}
}
TimelinePoints *SeekableWidget::timeline_points() const
{
return timeline_points_;
}
void SeekableWidget::DeselectAllMarkers()
{
selection_manager_.ClearSelection();
@@ -262,7 +259,7 @@ void SeekableWidget::SeekToScenePoint(qreal scene)
GetSnapService()->SnapPoint({playhead_time},
&movement,
SnapService::kSnapAll & ~SnapService::kSnapToPlayhead);
TimeBasedWidget::kSnapAll & ~TimeBasedWidget::kSnapToPlayhead);
playhead_time += movement;
}
@@ -290,7 +287,7 @@ void SeekableWidget::SelectionManagerDeselectEvent(void *obj)
void SeekableWidget::DrawTimelinePoints(QPainter* p, int marker_bottom)
{
if (!timeline_points()) {
if (!GetTimelinePoints()) {
return;
}
@@ -300,22 +297,22 @@ void SeekableWidget::DrawTimelinePoints(QPainter* p, int marker_bottom)
selection_manager_.ClearDrawnObjects();
// Draw in/out workarea
if (timeline_points()->workarea()->enabled()) {
int workarea_left = qMax(qreal(lim_left), TimeToScene(timeline_points()->workarea()->in()));
if (GetTimelinePoints()->workarea()->enabled()) {
int workarea_left = qMax(qreal(lim_left), TimeToScene(GetTimelinePoints()->workarea()->in()));
int workarea_right;
if (timeline_points()->workarea()->out() == TimelineWorkArea::kResetOut) {
if (GetTimelinePoints()->workarea()->out() == TimelineWorkArea::kResetOut) {
workarea_right = lim_right;
} else {
workarea_right = qMin(qreal(lim_right), TimeToScene(timeline_points()->workarea()->out()));
workarea_right = qMin(qreal(lim_right), TimeToScene(GetTimelinePoints()->workarea()->out()));
}
p->fillRect(workarea_left, 0, workarea_right - workarea_left, height(), palette().highlight());
}
// Draw markers
if (marker_bottom > 0 && !timeline_points()->markers()->empty()) {
for (auto it=timeline_points()->markers()->cbegin(); it!=timeline_points()->markers()->cend(); it++) {
if (marker_bottom > 0 && !GetTimelinePoints()->markers()->empty()) {
for (auto it=GetTimelinePoints()->markers()->cbegin(); it!=GetTimelinePoints()->markers()->cend(); it++) {
TimelineMarker* marker = *it;
int marker_right = TimeToScene(marker->time_range().out());
+1 -3
View File
@@ -27,7 +27,6 @@
#include "common/rational.h"
#include "timeline/timelinepoints.h"
#include "widget/menu/menu.h"
#include "widget/snapservice/snapservice.h"
#include "widget/timebased/timebasedviewselectionmanager.h"
namespace olive {
@@ -43,6 +42,7 @@ public:
return horizontalScrollBar()->value();
}
TimelinePoints* GetTimelinePoints() const { return timeline_points_; }
void ConnectTimelinePoints(TimelinePoints* points);
bool IsDraggingPlayhead() const
@@ -81,8 +81,6 @@ protected:
void DrawTimelinePoints(QPainter *p, int marker_bottom = 0);
TimelinePoints* timeline_points() const;
void DrawPlayhead(QPainter* p, int x, int y);
inline const int& text_height() const {
+1 -1
View File
@@ -105,7 +105,7 @@ void TimeRuler::drawForeground(QPainter *p, const QRectF &rect)
// Draw timeline points if connected
int marker_height = TimelineMarker::GetMarkerHeight(p->fontMetrics());
if (timeline_points()) {
if (GetTimelinePoints()) {
DrawTimelinePoints(p, marker_height);
}