From 0ab6a46c4c18f71683c10ff82e2cb35ff58a3cad Mon Sep 17 00:00:00 2001 From: Be Date: Sun, 5 May 2019 11:31:30 -0500 Subject: [PATCH] move intro/outro duration text outside of range on overviews This avoids the text overlapping the borders of the range, which looks ugly. --- res/skins/Deere/deck_overview.xml | 2 ++ res/skins/LateNight/deck_overview.xml | 2 ++ res/skins/Shade/deck_overview.xml | 2 ++ res/skins/Tango/deck_overview.xml | 2 ++ src/waveform/renderers/waveformmarkrange.cpp | 7 +++++++ src/waveform/renderers/waveformmarkrange.h | 11 +++++++++++ src/widget/woverview.cpp | 19 ++++++++++++++----- 7 files changed, 40 insertions(+), 5 deletions(-) diff --git a/res/skins/Deere/deck_overview.xml b/res/skins/Deere/deck_overview.xml index d13a32aa858..5cf86c6fe9d 100644 --- a/res/skins/Deere/deck_overview.xml +++ b/res/skins/Deere/deck_overview.xml @@ -42,6 +42,7 @@ #0000FF [Skin],show_intro_outro_cues #ffffff + after outro_start_position @@ -49,6 +50,7 @@ #0000FF [Skin],show_intro_outro_cues #ffffff + before intro_start_position diff --git a/res/skins/LateNight/deck_overview.xml b/res/skins/LateNight/deck_overview.xml index d50156f9236..52949506b49 100644 --- a/res/skins/LateNight/deck_overview.xml +++ b/res/skins/LateNight/deck_overview.xml @@ -47,6 +47,7 @@ #0000FF [Skin],show_intro_outro_cues #ffffff + after outro_start_position @@ -54,6 +55,7 @@ #0000FF [Skin],show_intro_outro_cues #ffffff + before intro_start_position diff --git a/res/skins/Shade/deck_overview.xml b/res/skins/Shade/deck_overview.xml index 244154ffe51..875b722b36f 100644 --- a/res/skins/Shade/deck_overview.xml +++ b/res/skins/Shade/deck_overview.xml @@ -33,6 +33,7 @@ #0000FF [Skin],show_intro_outro_cues #ffffff + after outro_start_position @@ -40,6 +41,7 @@ #0000FF [Skin],show_intro_outro_cues #ffffff + before intro_start_position diff --git a/res/skins/Tango/deck_overview.xml b/res/skins/Tango/deck_overview.xml index 5f290f78164..ca27209c1e5 100644 --- a/res/skins/Tango/deck_overview.xml +++ b/res/skins/Tango/deck_overview.xml @@ -57,6 +57,7 @@ Variables: #0000FF [Skin],show_intro_outro_cues #ffffff + after outro_start_position @@ -64,6 +65,7 @@ Variables: #0000FF [Skin],show_intro_outro_cues #ffffff + before intro_start_position diff --git a/src/waveform/renderers/waveformmarkrange.cpp b/src/waveform/renderers/waveformmarkrange.cpp index 51e092084bb..3f2b0e33cb9 100644 --- a/src/waveform/renderers/waveformmarkrange.cpp +++ b/src/waveform/renderers/waveformmarkrange.cpp @@ -52,6 +52,13 @@ WaveformMarkRange::WaveformMarkRange( ConfigKey key = ConfigKey::parseCommaSeparated(visibilityControl); m_markVisibleControl = std::make_unique(key); } + + QString durationTextLocation = context.selectString(node, "DurationTextLocation"); + if (durationTextLocation == "before") { + m_durationTextLocation = DurationTextLocation::Before; + } else { + m_durationTextLocation = DurationTextLocation::After; + } } bool WaveformMarkRange::active() const { diff --git a/src/waveform/renderers/waveformmarkrange.h b/src/waveform/renderers/waveformmarkrange.h index 08881309f04..0b2201c4a72 100644 --- a/src/waveform/renderers/waveformmarkrange.h +++ b/src/waveform/renderers/waveformmarkrange.h @@ -38,6 +38,15 @@ class WaveformMarkRange { bool showDuration() const; + enum class DurationTextLocation { + Before = 0, + After = 1 + }; + + DurationTextLocation durationTextLocation() const { + return m_durationTextLocation; + } + private: void generateImage(int weidth, int height); @@ -53,6 +62,8 @@ class WaveformMarkRange { QImage m_activeImage; QImage m_disabledImage; + DurationTextLocation m_durationTextLocation; + friend class WaveformRenderMarkRange; friend class WOverview; }; diff --git a/src/widget/woverview.cpp b/src/widget/woverview.cpp index 7899b3b6b28..ab3134105b1 100644 --- a/src/widget/woverview.cpp +++ b/src/widget/woverview.cpp @@ -577,18 +577,27 @@ void WOverview::paintEvent(QPaintEvent * /*unused*/) { QString duration = mixxx::Duration::formatTime((endValue - startValue) / m_trackSampleRateControl->get() / 2 / rateRatio); - // Ensure the right end of the text does not get cut off by - // the end of the track QFontMetrics fm(painter.font()); int textWidth = fm.width(duration); - float x = startPosition; - if (startPosition + textWidth > width()) { + float padding = 3.0; + float x; + + WaveformMarkRange::DurationTextLocation textLocation = markRange.durationTextLocation(); + if (textLocation == WaveformMarkRange::DurationTextLocation::Before) { + x = startPosition - textWidth - padding; + } else { + x = endPosition + padding; + } + + // Ensure the right end of the text does not get cut off by + // the end of the track + if (x + textWidth > width()) { x = width() - textWidth; } painter.setOpacity(1.0); painter.setPen(markRange.m_durationTextColor); - painter.drawText(QPointF(x, height() - 2.0), duration); + painter.drawText(QPointF(x, fm.ascent()), duration); } }