Create marker widget and attempt to add to timeline

This commit is contained in:
Thomas Wilshaw
2021-10-22 22:15:47 +01:00
parent be24e7e580
commit 4ce922536e
5 changed files with 39 additions and 0 deletions
+23
View File
@@ -44,6 +44,10 @@ SeekableWidget::SeekableWidget(QWidget* parent) :
playhead_width_ = QtUtils::QFontMetricsWidth(fm, "H");
setContextMenuPolicy(Qt::CustomContextMenu);
marker_layout_ = new QHBoxLayout(this);
UpdateMarkers();
}
void SeekableWidget::ConnectTimelinePoints(TimelinePoints *points)
@@ -62,6 +66,8 @@ void SeekableWidget::ConnectTimelinePoints(TimelinePoints *points)
connect(timeline_points_->workarea(), &TimelineWorkArea::EnabledChanged, this, static_cast<void (SeekableWidget::*)()>(&SeekableWidget::update));
connect(timeline_points_->markers(), &TimelineMarkerList::MarkerAdded, this, static_cast<void (SeekableWidget::*)()>(&SeekableWidget::update));
connect(timeline_points_->markers(), &TimelineMarkerList::MarkerRemoved, this, static_cast<void (SeekableWidget::*)()>(&SeekableWidget::update));
connect(timeline_points_->markers(), &TimelineMarkerList::MarkerAdded, this, static_cast<void (SeekableWidget::*)()>(&SeekableWidget::UpdateMarkers));
}
update();
@@ -127,6 +133,23 @@ void SeekableWidget::SetScroll(int s)
update();
}
void SeekableWidget::UpdateMarkers()
{
printf("Test");
if (timeline_points()) {
foreach(Marker * marker, marker_widgets) {
marker->deleteLater();
}
marker_widgets.clear();
foreach(TimelineMarker * marker, timeline_points()->markers()->list()) {
Marker* marker_widget = new Marker();
marker_widgets.append(marker_widget);
marker_layout_->addWidget(marker_widget);
}
}
}
int SeekableWidget::TimeToScreen(const rational &time) const
{
return qFloor(TimeToScene(time)) - scroll_;