better attachment between labels and tracks
This commit is contained in:
@@ -71,6 +71,7 @@ int Track::height()
|
||||
void Track::set_height(int h)
|
||||
{
|
||||
height_ = qMax(h, olive::timeline::kTrackMinHeight);
|
||||
emit HeightChanged(h);
|
||||
}
|
||||
|
||||
QString Track::name()
|
||||
|
||||
@@ -98,6 +98,9 @@ public slots:
|
||||
void SetSoloed(bool soloed);
|
||||
void SetLocked(bool locked);
|
||||
|
||||
signals:
|
||||
void HeightChanged(int height);
|
||||
|
||||
private:
|
||||
void ResizeClipArray(int new_size);
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ void TrackList::AddTrack()
|
||||
{
|
||||
Track* track = new Track(this, type_);
|
||||
tracks_.append(track);
|
||||
|
||||
emit TrackCountChanged();
|
||||
}
|
||||
|
||||
void TrackList::RemoveTrack(int i)
|
||||
@@ -45,6 +47,8 @@ void TrackList::RemoveTrack(int i)
|
||||
return;
|
||||
}
|
||||
tracks_.removeAt(i);
|
||||
|
||||
emit TrackCountChanged();
|
||||
}
|
||||
|
||||
Track *TrackList::First()
|
||||
@@ -52,6 +56,11 @@ Track *TrackList::First()
|
||||
return tracks_.first();
|
||||
}
|
||||
|
||||
Track *TrackList::Last()
|
||||
{
|
||||
return tracks_.last();
|
||||
}
|
||||
|
||||
int TrackList::TrackCount()
|
||||
{
|
||||
return tracks_.size();
|
||||
|
||||
@@ -15,6 +15,7 @@ public:
|
||||
void AddTrack();
|
||||
void RemoveTrack(int i);
|
||||
Track* First();
|
||||
Track* Last();
|
||||
int TrackCount();
|
||||
int IndexOfTrack(Track* track);
|
||||
Track* TrackAt(int i);
|
||||
@@ -24,6 +25,9 @@ public:
|
||||
|
||||
Sequence* GetParent();
|
||||
|
||||
signals:
|
||||
void TrackCountChanged();
|
||||
|
||||
private:
|
||||
void ResizeTrackArray(int i);
|
||||
|
||||
|
||||
+16
-17
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-2
@@ -12,9 +12,8 @@ class TimelineArea : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TimelineArea(Timeline *timeline);
|
||||
TimelineArea(Timeline *timeline, olive::timeline::Alignment alignment = olive::timeline::kAlignmentTop);
|
||||
|
||||
void SetAlignment(olive::timeline::Alignment alignment);
|
||||
void SetTrackList(Sequence* sequence, Track::Type track_list);
|
||||
public slots:
|
||||
void RefreshLabels();
|
||||
|
||||
@@ -52,6 +52,8 @@ void TimelineLabel::SetTrack(Track *track)
|
||||
connect(mute_button_, SIGNAL(toggled(bool)), track_, SLOT(SetMuted(bool)));
|
||||
connect(solo_button_, SIGNAL(toggled(bool)), track_, SLOT(SetSoloed(bool)));
|
||||
connect(lock_button_, SIGNAL(toggled(bool)), track_, SLOT(SetLocked(bool)));
|
||||
|
||||
connect(track_, SIGNAL(HeightChanged(int)), this, SLOT(UpdateHeight(int)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +61,8 @@ void TimelineLabel::UpdateState()
|
||||
{
|
||||
label_->setText(track_->name());
|
||||
|
||||
UpdateHeight(track_->height());
|
||||
|
||||
mute_button_->setChecked(track_->IsMuted());
|
||||
solo_button_->setChecked(track_->IsSoloed());
|
||||
lock_button_->setChecked(track_->IsLocked());
|
||||
@@ -79,3 +83,8 @@ void TimelineLabel::RenameTrack()
|
||||
UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineLabel::UpdateHeight(int h)
|
||||
{
|
||||
setFixedHeight(h);
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ private:
|
||||
Track* track_;
|
||||
private slots:
|
||||
void RenameTrack();
|
||||
void UpdateHeight(int h);
|
||||
};
|
||||
|
||||
using TimelineLabelPtr = std::shared_ptr<TimelineLabel>;
|
||||
|
||||
+9
-8
@@ -1614,7 +1614,6 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
|
||||
|
||||
Track* mouse_track = getTrackFromScreenPoint(mouse_pos.y());
|
||||
long frame_diff = (lock_frame) ? 0 : ParentTimeline()->getTimelineFrameFromScreenPoint(mouse_pos.x()) - ParentTimeline()->drag_frame_start;
|
||||
int track_diff = ((effective_tool == olive::timeline::TIMELINE_TOOL_SLIDE || ParentTimeline()->transition_select != kTransitionNone) && !ParentTimeline()->importing) ? 0 : mouse_track - ParentTimeline()->drag_track_start;
|
||||
long validator;
|
||||
long earliest_in_point = LONG_MAX;
|
||||
|
||||
@@ -3321,17 +3320,19 @@ void TimelineView::resizeEvent(QResizeEvent *) {
|
||||
// **************************************
|
||||
|
||||
Track *TimelineView::getTrackFromScreenPoint(int y) {
|
||||
if (y < 0 || y > height()) {
|
||||
return nullptr;
|
||||
if (y < 0) {
|
||||
return track_list_->First();
|
||||
} else if (y > height()) {
|
||||
return track_list_->Last();
|
||||
}
|
||||
|
||||
y += scroll;
|
||||
|
||||
int heights = 0;
|
||||
|
||||
for (int i=0;i<track_list_->TrackCount();i++) {
|
||||
// int i = 0;
|
||||
// while (true) {
|
||||
// for (int i=0;i<track_list_->TrackCount();i++) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
|
||||
int new_heights = heights + 1;
|
||||
|
||||
@@ -3343,10 +3344,10 @@ Track *TimelineView::getTrackFromScreenPoint(int y) {
|
||||
|
||||
heights = new_heights;
|
||||
|
||||
// i++;
|
||||
i++;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
// return nullptr;
|
||||
}
|
||||
|
||||
int TimelineView::getScreenPointFromTrack(Track *track) {
|
||||
|
||||
Reference in New Issue
Block a user