underline clips that are linked
This commit is contained in:
@@ -20,10 +20,10 @@
|
||||
|
||||
#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)
|
||||
return fm->width(s);
|
||||
return fm.width(s);
|
||||
#else
|
||||
return fm->horizontalAdvance(s);
|
||||
return fm.horizontalAdvance(s);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -35,6 +35,6 @@
|
||||
* 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.
|
||||
*/
|
||||
int QFontMetricsWidth(const QFontMetrics* fm, const QString& s);
|
||||
int QFontMetricsWidth(QFontMetrics fm, const QString& s);
|
||||
|
||||
#endif // QTVERSIONABSTRACTION_H
|
||||
|
||||
@@ -273,3 +273,8 @@ const QVector<Block*> &Block::linked_clips()
|
||||
return linked_clips_;
|
||||
}
|
||||
|
||||
bool Block::HasLinks()
|
||||
{
|
||||
return !linked_clips_.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
static void Unlink(Block* a, Block* b);
|
||||
static bool AreLinked(Block* a, Block* b);
|
||||
const QVector<Block*>& linked_clips();
|
||||
bool HasLinks();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ NodeViewItem::NodeViewItem(QGraphicsItem *parent) :
|
||||
//
|
||||
|
||||
// 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
|
||||
node_border_width_ = font_metrics.height() / 12;
|
||||
@@ -203,7 +203,7 @@ void NodeViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
QPointF text_pt = GetParameterTextPoint(i);
|
||||
|
||||
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());
|
||||
|
||||
@@ -64,7 +64,7 @@ void ProjectExplorerIconViewItemDelegate::paint(QPainter *painter, const QStyleO
|
||||
|
||||
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();
|
||||
|
||||
|
||||
@@ -53,8 +53,7 @@ TimelineWidget::ImportTool::ImportTool(TimelineWidget *parent) :
|
||||
Tool(parent)
|
||||
{
|
||||
// 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(&fm, "HHHHHHHH");
|
||||
import_pre_buffer_ = QFontMetricsWidth(parent->fontMetrics(), "HHHHHHHH");
|
||||
}
|
||||
|
||||
void TimelineWidget::ImportTool::DragEnter(TimelineViewMouseEvent *event)
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
#include "common/qtversionabstraction.h"
|
||||
|
||||
TimelineViewBlockItem::TimelineViewBlockItem(QGraphicsItem* parent) :
|
||||
TimelineViewRect(parent),
|
||||
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());
|
||||
|
||||
// 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->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()));
|
||||
|
||||
@@ -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)
|
||||
// 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
|
||||
playhead_width_ = minimum_gap_between_lines_;
|
||||
@@ -156,7 +156,7 @@ void TimeRuler::paintEvent(QPaintEvent *)
|
||||
if (text_visible_) {
|
||||
QFontMetrics fm = p.fontMetrics();
|
||||
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;
|
||||
while (width_of_second * text_skip < average_text_width) {
|
||||
text_skip++;
|
||||
|
||||
Reference in New Issue
Block a user