timeline: improved beam tool and its derivatives

This commit is contained in:
itsmattkc
2020-07-07 18:43:18 +10:00
parent a239fa0e2f
commit af69f157a3
5 changed files with 24 additions and 16 deletions
+4 -1
View File
@@ -216,6 +216,9 @@ private:
virtual void HoverMove(TimelineViewMouseEvent *event) override;
protected:
TimelineCoordinate ValidatedCoordinate(TimelineCoordinate coord);
};
class PointerTool : public Tool
@@ -415,7 +418,7 @@ private:
};
class AddTool : public Tool
class AddTool : public BeamTool
{
public:
AddTool(TimelineWidget* parent);
+2 -10
View File
@@ -27,7 +27,7 @@
OLIVE_NAMESPACE_ENTER
TimelineWidget::AddTool::AddTool(TimelineWidget *parent) :
Tool(parent),
BeamTool(parent),
ghost_(nullptr)
{
}
@@ -63,15 +63,7 @@ void TimelineWidget::AddTool::MousePress(TimelineViewMouseEvent *event)
if (add_type == Timeline::kTrackTypeNone
|| add_type == track.type()) {
drag_start_point_ = event->GetFrame();
if (Core::instance()->snapping()) {
rational movement;
parent()->SnapPoint({drag_start_point_}, &movement);
if (!movement.isNull()) {
drag_start_point_ += movement;
}
}
drag_start_point_ = ValidatedCoordinate(event->GetCoordinates(true)).GetFrame();
ghost_ = new TimelineViewGhostItem();
ghost_->SetIn(drag_start_point_);
+14 -1
View File
@@ -29,7 +29,20 @@ TimelineWidget::BeamTool::BeamTool(TimelineWidget *parent) :
void TimelineWidget::BeamTool::HoverMove(TimelineViewMouseEvent *event)
{
parent()->SetViewBeamCursor(event->GetCoordinates(true));
parent()->SetViewBeamCursor(ValidatedCoordinate(event->GetCoordinates(true)));
}
TimelineCoordinate TimelineWidget::BeamTool::ValidatedCoordinate(TimelineCoordinate coord)
{
if (Core::instance()->snapping()) {
rational movement;
parent()->SnapPoint({coord.GetFrame()}, &movement);
if (!movement.isNull()) {
coord.SetFrame(coord.GetFrame() + movement);
}
}
return coord;
}
OLIVE_NAMESPACE_EXIT
+1 -1
View File
@@ -37,7 +37,7 @@ void TimelineWidget::RazorTool::MousePress(TimelineViewMouseEvent *event)
void TimelineWidget::RazorTool::MouseMove(TimelineViewMouseEvent *event)
{
if (!dragging_) {
drag_start_ = event->GetCoordinates(true);
drag_start_ = ValidatedCoordinate(event->GetCoordinates(true));
dragging_ = true;
}
@@ -37,6 +37,7 @@ OLIVE_NAMESPACE_ENTER
TimelineView::TimelineView(Qt::Alignment vertical_alignment, QWidget *parent) :
TimelineViewBase(parent),
show_beam_cursor_(false),
connected_track_list_(nullptr)
{
Q_ASSERT(vertical_alignment == Qt::AlignTop || vertical_alignment == Qt::AlignBottom);
@@ -426,9 +427,8 @@ void TimelineView::ConnectTrackList(TrackList *list)
void TimelineView::SetBeamCursor(const TimelineCoordinate &coord)
{
bool update_required = true;/*(coord.GetTrack().type() == connected_track_list_->type()
|| cursor_coord_.GetTrack().type() == connected_track_list_->type()
|| !show_beam_cursor_);*/
bool update_required = coord.GetTrack().type() == connected_track_list_->type()
|| cursor_coord_.GetTrack().type() == connected_track_list_->type();
show_beam_cursor_ = true;
cursor_coord_ = coord;