better attachment between labels and tracks

This commit is contained in:
itsmattkc
2019-04-04 19:35:52 +11:00
parent e708791e90
commit d7091c2b10
9 changed files with 53 additions and 27 deletions
+16 -17
View File
@@ -2,10 +2,10 @@
int olive::timeline::kTimelineLabelFixedWidth = 200;
TimelineArea::TimelineArea(Timeline* timeline) :
TimelineArea::TimelineArea(Timeline* timeline, olive::timeline::Alignment alignment) :
timeline_(timeline),
track_list_(nullptr),
alignment_(olive::timeline::kAlignmentTop)
alignment_(alignment)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setMargin(0);
@@ -17,10 +17,12 @@ TimelineArea::TimelineArea(Timeline* timeline) :
label_container_layout_ = new QVBoxLayout(label_container);
label_container_layout_->setMargin(0);
label_container_layout_->setSpacing(0);
label_container_layout_->addStretch();
layout->addWidget(label_container);
// VIEW
view_ = new TimelineView(timeline_);
view_->SetAlignment(alignment_);
layout->addWidget(view_);
// SCROLLBAR
@@ -30,33 +32,25 @@ TimelineArea::TimelineArea(Timeline* timeline) :
view_->scrollBar = scrollbar;
}
void TimelineArea::SetAlignment(olive::timeline::Alignment alignment)
{
alignment_ = alignment;
view_->SetAlignment(alignment);
}
void TimelineArea::SetTrackList(Sequence *sequence, Track::Type track_list)
{
if (track_list_ != nullptr) {
disconnect(track_list_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels()));
}
if (sequence == nullptr) {
track_list_ = nullptr;
labels_.clear();
} else {
track_list_ = sequence->GetTrackList(track_list);
labels_.resize(track_list_->TrackCount());
for (int i=0;i<labels_.size();i++) {
labels_[i] = std::make_shared<TimelineLabel>();
labels_[i]->SetTrack(track_list_->TrackAt(i));
label_container_layout_->addWidget(labels_[i].get());
}
connect(track_list_, SIGNAL(TrackCountChanged()), this, SLOT(RefreshLabels()));
}
RefreshLabels();
view_->SetTrackList(track_list_);
}
@@ -64,12 +58,17 @@ void TimelineArea::SetTrackList(Sequence *sequence, Track::Type track_list)
void TimelineArea::RefreshLabels()
{
if (track_list_ == nullptr) {
labels_.clear();
} else {
labels_.resize(track_list_->TrackCount());
for (int i=0;i<labels_.size();i++) {
labels_[i] = std::make_shared<TimelineLabel>();
labels_[i]->SetTrack(track_list_->TrackAt(i));
label_container_layout_->insertWidget(label_container_layout_->count()-1, labels_[i].get());
}
}