underline clips that are linked

This commit is contained in:
itsmattkc
2019-10-17 11:07:36 +11:00
parent 276478c6d0
commit 09b3a1970d
9 changed files with 29 additions and 11 deletions
+3 -3
View File
@@ -20,10 +20,10 @@
#include "qtversionabstraction.h" #include "qtversionabstraction.h"
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s) { int QFontMetricsWidth(QFontMetrics fm, const QString& s) {
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
return fm->width(s); return fm.width(s);
#else #else
return fm->horizontalAdvance(s); return fm.horizontalAdvance(s);
#endif #endif
} }
+1 -1
View File
@@ -35,6 +35,6 @@
* QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the latter was only * QFontMetrics::width() has been deprecatd in favor of QFontMetrics::horizontalAdvance(), but the latter was only
* introduced in 5.11+. This function wraps the latter for 5.11+ and the former for earlier. * introduced in 5.11+. This function wraps the latter for 5.11+ and the former for earlier.
*/ */
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s); int QFontMetricsWidth(QFontMetrics fm, const QString& s);
#endif // QTVERSIONABSTRACTION_H #endif // QTVERSIONABSTRACTION_H
+5
View File
@@ -273,3 +273,8 @@ const QVector<Block*> &Block::linked_clips()
return linked_clips_; return linked_clips_;
} }
bool Block::HasLinks()
{
return !linked_clips_.isEmpty();
}
+1
View File
@@ -76,6 +76,7 @@ public:
static void Unlink(Block* a, Block* b); static void Unlink(Block* a, Block* b);
static bool AreLinked(Block* a, Block* b); static bool AreLinked(Block* a, Block* b);
const QVector<Block*>& linked_clips(); const QVector<Block*>& linked_clips();
bool HasLinks();
public slots: public slots:
/** /**
+2 -2
View File
@@ -53,7 +53,7 @@ NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
// //
// Not particularly great way of using text scaling to set the width (DPI-awareness, etc.) // Not particularly great way of using text scaling to set the width (DPI-awareness, etc.)
int widget_width = QFontMetricsWidth(&font_metrics, "HHHHHHHHHHHHHHHH"); int widget_width = QFontMetricsWidth(font_metrics, "HHHHHHHHHHHHHHHH");
// Set border width // Set border width
node_border_width_ = font_metrics.height() / 12; node_border_width_ = font_metrics.height() / 12;
@@ -203,7 +203,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
QPointF text_pt = GetParameterTextPoint(i); QPointF text_pt = GetParameterTextPoint(i);
if (param->type() == NodeParam::kOutput) { if (param->type() == NodeParam::kOutput) {
text_pt -= QPointF(QFontMetricsWidth(&font_metrics, param->name()), 0); text_pt -= QPointF(QFontMetricsWidth(font_metrics, param->name()), 0);
} }
painter->drawText(text_pt, param->name()); painter->drawText(text_pt, param->name());
@@ -64,7 +64,7 @@ void ProjectExplorerIconViewItemDelegate::paint(QPainter *painter, const QStyleO
QString duration_str = index.data(Qt::UserRole).toString(); QString duration_str = index.data(Qt::UserRole).toString();
int timecode_width = QFontMetricsWidth(&fm, duration_str); int timecode_width = QFontMetricsWidth(fm, duration_str);
int max_name_width = option.rect.width(); int max_name_width = option.rect.width();
+1 -2
View File
@@ -53,8 +53,7 @@ TimelineWidget::ImportTool::ImportTool(TimelineWidget *parent) :
Tool(parent) Tool(parent)
{ {
// Calculate width used for importing to give ghosts a slight lead-in so the ghosts aren't right on the cursor // Calculate width used for importing to give ghosts a slight lead-in so the ghosts aren't right on the cursor
QFontMetrics fm = parent->fontMetrics(); import_pre_buffer_ = QFontMetricsWidth(parent->fontMetrics(), "HHHHHHHH");
import_pre_buffer_ = QFontMetricsWidth(&fm, "HHHHHHHH");
} }
void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event) void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event)
@@ -26,6 +26,8 @@
#include <QPainter> #include <QPainter>
#include <QStyleOptionGraphicsItem> #include <QStyleOptionGraphicsItem>
#include "common/qtversionabstraction.h"
TimelineViewBlockItem::TimelineViewBlockItem(QGraphicsItem* parent) : TimelineViewBlockItem::TimelineViewBlockItem(QGraphicsItem* parent) :
TimelineViewRect(parent), TimelineViewRect(parent),
block_(nullptr) block_(nullptr)
@@ -95,6 +97,17 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
painter->drawText(rect(), static_cast<int>(Qt::AlignLeft | Qt::AlignTop), block_->block_name()); painter->drawText(rect(), static_cast<int>(Qt::AlignLeft | Qt::AlignTop), block_->block_name());
// Linked clips are underlined
if (block_->HasLinks()) {
QFontMetrics fm = painter->fontMetrics();
int text_width = QFontMetricsWidth(fm, block_->block_name());
QPointF underline_start = rect().topLeft() + QPointF(0, fm.height());
QPointF underline_end = underline_start + QPointF(text_width, 0);
painter->drawLine(underline_start, underline_end);
}
painter->setPen(QColor(64, 64, 64)); painter->setPen(QColor(64, 64, 64));
painter->drawLine(QPointF(rect().left(), rect().bottom() - 1), QPointF(rect().right(), rect().bottom() - 1)); painter->drawLine(QPointF(rect().left(), rect().bottom() - 1), QPointF(rect().right(), rect().bottom() - 1));
painter->drawLine(QPointF(rect().right(), rect().bottom() - 1), QPointF(rect().right(), rect().top())); painter->drawLine(QPointF(rect().right(), rect().bottom() - 1), QPointF(rect().right(), rect().top()));
+2 -2
View File
@@ -47,7 +47,7 @@ TimeRuler::TimeRuler(bool text_visible, QWidget* parent) :
// Get the "minimum" space allowed between two line markers on the ruler (in screen pixels) // Get the "minimum" space allowed between two line markers on the ruler (in screen pixels)
// Mediocre but reliable way of scaling UI objects by font/DPI size // Mediocre but reliable way of scaling UI objects by font/DPI size
minimum_gap_between_lines_ = QFontMetricsWidth(&fm, "H"); minimum_gap_between_lines_ = QFontMetricsWidth(fm, "H");
// Set width of playhead marker // Set width of playhead marker
playhead_width_ = minimum_gap_between_lines_; playhead_width_ = minimum_gap_between_lines_;
@@ -156,7 +156,7 @@ void TimeRuler::paintEvent(QPaintEvent *)
if (text_visible_) { if (text_visible_) {
QFontMetrics fm = p.fontMetrics(); QFontMetrics fm = p.fontMetrics();
double width_of_second = scale_; double width_of_second = scale_;
int average_text_width = QFontMetricsWidth(&fm, olive::timestamp_to_timecode(0, timebase_, olive::CurrentTimecodeDisplay())); int average_text_width = QFontMetricsWidth(fm, olive::timestamp_to_timecode(0, timebase_, olive::CurrentTimecodeDisplay()));
half_average_text_width = average_text_width/2; half_average_text_width = average_text_width/2;
while (width_of_second * text_skip < average_text_width) { while (width_of_second * text_skip < average_text_width) {
text_skip++; text_skip++;