timeline alignment works now

This commit is contained in:
itsmattkc
2019-04-06 20:56:08 +11:00
parent dd9a9ba4fd
commit a0557dbba6
6 changed files with 59 additions and 28 deletions
+1 -1
View File
@@ -90,7 +90,7 @@ Timeline::Timeline(QWidget *parent) :
headers->viewer = panel_sequence_viewer;
// video_area->SetAlignment(olive::timeline::kAlignmentBottom);
video_area->SetAlignment(olive::timeline::kAlignmentBottom);
tool_buttons.append(toolArrowButton);
tool_buttons.append(toolEditButton);
+1
View File
@@ -166,6 +166,7 @@ void TimelineArea::RefreshLabels()
for (int i=0;i<labels_.size();i++) {
labels_[i] = std::make_shared<TimelineLabel>();
labels_[i]->SetTrack(track_list_->TrackAt(i));
labels_[i]->SetAlignment(alignment_);
switch (alignment_) {
case olive::timeline::kAlignmentTop:
+16 -2
View File
@@ -5,7 +5,8 @@
#include <QInputDialog>
TimelineLabel::TimelineLabel() :
track_(nullptr)
track_(nullptr),
alignment_(olive::timeline::kAlignmentTop)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setMargin(0);
@@ -68,12 +69,25 @@ void TimelineLabel::UpdateState()
lock_button_->setChecked(track_->IsLocked());
}
void TimelineLabel::SetAlignment(olive::timeline::Alignment alignment)
{
alignment_ = alignment;
update();
}
void TimelineLabel::paintEvent(QPaintEvent *)
{
if (alignment_ != olive::timeline::kAlignmentTop && alignment_ != olive::timeline::kAlignmentBottom) {
return;
}
QPainter p(this);
p.setPen(QColor(0, 0, 0, 96));
p.drawLine(0, height() - 1, width(), height() - 1);
int line_y = (alignment_ == olive::timeline::kAlignmentTop) ? height() - 1 : 0;
p.drawLine(0, line_y, width(), line_y);
}
void TimelineLabel::RenameTrack()
+4
View File
@@ -6,6 +6,7 @@
#include "ui/clickablelabel.h"
#include "timeline/track.h"
#include "timeline/timelinefunctions.h"
class TimelineLabel : public QWidget
{
@@ -15,6 +16,7 @@ public:
void SetTrack(Track* track);
void UpdateState();
void SetAlignment(olive::timeline::Alignment alignment);
protected:
virtual void paintEvent(QPaintEvent *event) override;
private:
@@ -25,6 +27,8 @@ private:
ClickableLabel* label_;
Track* track_;
olive::timeline::Alignment alignment_;
private slots:
void RenameTrack();
void UpdateHeight(int h);
+35 -25
View File
@@ -929,6 +929,18 @@ void TimelineView::VerifyTransitionsAfterCreating(ComboAction* ca, Clip* open, C
}
}
int TimelineView::GetTotalAreaHeight()
{
// start by adding a track height worth of padding
int panel_height = olive::timeline::kTrackDefaultHeight;
for (int i=0;i<track_list_->TrackCount();i++) {
panel_height += track_list_->TrackAt(i)->height();
}
return panel_height;
}
void TimelineView::mouseReleaseEvent(QMouseEvent *event) {
QToolTip::hideText();
if (sequence() != nullptr) {
@@ -2865,15 +2877,7 @@ void TimelineView::paintEvent(QPaintEvent*) {
QPainter p(this);
// get widget width and height
// start by adding a track height worth of padding
int panel_height = olive::timeline::kTrackDefaultHeight;
for (int i=0;i<track_list_->TrackCount();i++) {
panel_height += track_list_->TrackAt(i)->height();
}
emit setScrollMaximum(panel_height);
emit setScrollMaximum(GetTotalAreaHeight());
for (int i=0;i<track_list_->TrackCount();i++) {
@@ -2890,7 +2894,14 @@ void TimelineView::paintEvent(QPaintEvent*) {
QRect clip_rect(ParentTimeline()->getTimelineScreenPointFromFrame(clip->timeline_in()),
track_top,
getScreenPointFromFrame(ParentTimeline()->zoom, clip->length()),
track->height() - 1);
track->height());
if (alignment_ == olive::timeline::kAlignmentTop) {
clip_rect.setHeight(track->height() - 1);
} else if (alignment_ == olive::timeline::kAlignmentBottom) {
clip_rect.setTop(track_top + 1);
}
QRect text_rect(clip_rect.left() + olive::timeline::kClipTextPadding,
clip_rect.top() + olive::timeline::kClipTextPadding,
clip_rect.width() - olive::timeline::kClipTextPadding - 1,
@@ -3206,7 +3217,11 @@ void TimelineView::paintEvent(QPaintEvent*) {
// Draw track line
p.setPen(QColor(0, 0, 0, 96));
p.drawLine(0, track_bottom, rect().width(), track_bottom);
if (alignment_ == olive::timeline::kAlignmentTop) {
p.drawLine(0, track_bottom, rect().width(), track_bottom);
} else if (alignment_ == olive::timeline::kAlignmentBottom) {
p.drawLine(0, track_top, rect().width(), track_top);
}
}
}
@@ -3315,18 +3330,16 @@ int TimelineView::getTrackIndexFromScreenPoint(int y)
return 0;
}
if (alignment_ == olive::timeline::kAlignmentBottom) {
y = -(y + 1 + scroll - qMax(height(), GetTotalAreaHeight()));
} else {
y += scroll;
}
if (y < 0) {
return 0;
}
y += scroll;
/*
if (alignment_ == olive::timeline::kAlignmentBottom) {
y = height() - y;
}
*/
int heights = 0;
int i = 0;
@@ -3363,14 +3376,11 @@ int TimelineView::getScreenPointFromTrackIndex(int track)
point += getTrackHeightFromTrackIndex(i) + 1;
}
int screen_point = point - scroll;
/*
if (alignment_ == olive::timeline::kAlignmentBottom) {
return height() - screen_point - track_list_->First()->height();
return qMax(height(), GetTotalAreaHeight()) - point - scroll - track_list_->First()->height() - 1;
}
*/
return screen_point;
return point - scroll;
}
int TimelineView::getTrackHeightFromTrackIndex(int track)
+2
View File
@@ -86,6 +86,8 @@ private:
void VerifyTransitionsAfterCreating(ComboAction* ca, Clip* open, Clip* close, long transition_start, long transition_end);
void VerifyTransitionHelper();
int GetTotalAreaHeight();
Timeline* timeline_;
olive::timeline::Alignment alignment_;