diff options
author | Be <be@mixxx.org> | 2019-08-26 19:23:38 -0500 |
---|---|---|
committer | Be <be@mixxx.org> | 2019-08-26 19:25:24 -0500 |
commit | 4439406ad548be2804d05da53572e4cd156f5838 (patch) | |
tree | 13831739ed8af15c8a133b1bef7c59b754c3b15f /src/widget | |
parent | 058f0d4f5a98593df97396ed49f873d65145d840 (diff) |
WOverview: let skins specify label background, text color, and font size
Diffstat (limited to 'src/widget')
-rw-r--r-- | src/widget/woverview.cpp | 39 | ||||
-rw-r--r-- | src/widget/woverview.h | 2 |
2 files changed, 29 insertions, 12 deletions
diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 6e9eb60846..19091fadd9 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -91,8 +91,23 @@ void WOverview::setup(const QDomNode& node, const SkinContext& context) { m_signalColors.setup(node, context); m_qColorBackground = m_signalColors.getBgColor(); - m_labelBackgroundColor = m_qColorBackground; - m_labelBackgroundColor.setAlpha(255 / 2); // 255 == fully transparent + + m_labelBackgroundColor = context.selectColor(node, "LabelBackgroundColor"); + if (!m_labelBackgroundColor.isValid()) { + m_labelBackgroundColor = m_qColorBackground; + m_labelBackgroundColor.setAlpha(255 / 2); // 255 == fully transparent + } + + m_labelTextColor = context.selectColor(node, "LabelTextColor"); + if (!m_labelTextColor.isValid()) { + m_labelTextColor = Qt::white; + } + + bool okay = false; + m_iLabelFontSize = context.selectInt(node, "LabelFontSize", &okay); + if (!okay) { + m_iLabelFontSize = 10; + } // Clear the background pixmap, if it exists. m_backgroundPixmap = QPixmap(); @@ -647,7 +662,7 @@ void WOverview::drawRangeMarks(QPainter* pPainter, const float& offset, const fl void WOverview::drawMarks(QPainter* pPainter, const float offset, const float gain) { QFont markerFont = pPainter->font(); - markerFont.setPixelSize(10 * m_scaleFactor); + markerFont.setPixelSize(m_iLabelFontSize * m_scaleFactor); QFontMetricsF fontMetrics(markerFont); // Text labels are rendered so they do not overlap with other WaveformMarks' @@ -745,7 +760,7 @@ void WOverview::drawMarks(QPainter* pPainter, const float offset, const float ga } pMark->m_label.prerender(textPoint, QPixmap(), text, - markerFont, pMark->m_textColor, m_labelBackgroundColor, + markerFont, m_labelTextColor, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); } @@ -788,11 +803,11 @@ void WOverview::drawMarks(QPainter* pPainter, const float offset, const float ga } m_cuePositionLabel.prerender(positionTextPoint, QPixmap(), cuePositionText, - markerFont, Qt::white, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); + markerFont, m_labelTextColor, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); QPointF timeDistancePoint(markPosition, (fontMetrics.height() + height()) / 2); m_cueTimeDistanceLabel.prerender(timeDistancePoint, QPixmap(), cueTimeDistanceText, - markerFont, Qt::white, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); + markerFont, m_labelTextColor, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); markHovered = true; } } @@ -829,12 +844,12 @@ void WOverview::drawCurrentPosition(QPainter* pPainter) { void WOverview::drawTimeRuler(QPainter* pPainter) { QFont markerFont = pPainter->font(); - markerFont.setPixelSize(10 * m_scaleFactor); + markerFont.setPixelSize(m_iLabelFontSize * m_scaleFactor); QFontMetricsF fontMetrics(markerFont); QFont shadowFont = pPainter->font(); shadowFont.setWeight(99); - shadowFont.setPixelSize(10 * m_scaleFactor); + shadowFont.setPixelSize(m_iLabelFontSize * m_scaleFactor); QPen shadowPen(Qt::black, 2.5 * m_scaleFactor); if (m_bTimeRulerActive) { @@ -876,7 +891,7 @@ void WOverview::drawTimeRuler(QPainter* pPainter) { + " -" + mixxx::Duration::formatTime(timePositionTillEnd); m_timeRulerPositionLabel.prerender(textPoint, QPixmap(), timeText, - markerFont, Qt::white, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); + markerFont, m_labelTextColor, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); m_timeRulerPositionLabel.draw(pPainter); QString timeDistanceText = mixxx::Duration::formatTime(fabs(timeDistance)); @@ -886,7 +901,7 @@ void WOverview::drawTimeRuler(QPainter* pPainter) { timeDistanceText = "-" + timeDistanceText; } m_timeRulerDistanceLabel.prerender(textPointDistance, QPixmap(), timeDistanceText, - markerFont, Qt::white, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); + markerFont, m_labelTextColor, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); m_timeRulerDistanceLabel.draw(pPainter); } else { m_timeRulerPositionLabel.clear(); @@ -896,7 +911,7 @@ void WOverview::drawTimeRuler(QPainter* pPainter) { void WOverview::drawMarkLabels(QPainter* pPainter, const float offset, const float gain) { QFont markerFont = pPainter->font(); - markerFont.setPixelSize(10 * m_scaleFactor); + markerFont.setPixelSize(m_iLabelFontSize * m_scaleFactor); QFontMetricsF fontMetrics(markerFont); // Draw WaveformMark labels @@ -950,7 +965,7 @@ void WOverview::drawMarkLabels(QPainter* pPainter, const float offset, const flo QPointF durationBottomLeft(x, fontMetrics.height()); markRange.m_durationLabel.prerender(durationBottomLeft, QPixmap(), - duration, markerFont, markRange.m_durationTextColor, + duration, markerFont, m_labelTextColor, m_labelBackgroundColor, width(), getDevicePixelRatioF(this)); if (!(markRange.m_durationLabel.intersects(m_cuePositionLabel) diff --git a/src/widget/woverview.h b/src/widget/woverview.h index da171c4bf2..4fc6ddbdf9 100644 --- a/src/widget/woverview.h +++ b/src/widget/woverview.h @@ -159,6 +159,8 @@ class WOverview : public WWidget, public TrackDropTarget { QPixmap m_backgroundPixmap; QString m_backgroundPixmapPath; QColor m_qColorBackground; + int m_iLabelFontSize; + QColor m_labelTextColor; QColor m_labelBackgroundColor; QColor m_endOfTrackColor; |