Skip to content

Commit

Permalink
Merge pull request #14145 from ronso0/woverview-cleanup
Browse files Browse the repository at this point in the history
WOverview: remove unused coefficients
  • Loading branch information
daschuer authored Jan 9, 2025
2 parents 674d4a5 + db4d822 commit 80a86d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
17 changes: 2 additions & 15 deletions src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ WOverview::WOverview(
m_bTimeRulerActive(false),
m_orientation(Qt::Horizontal),
m_iLabelFontSize(10),
m_a(1.0),
m_b(0.0),
m_maxPixelPos(1.0),
m_analyzerProgress(kAnalyzerProgressUnknown),
m_trackLoaded(false),
m_pHoveredMark(nullptr),
Expand Down Expand Up @@ -1634,19 +1633,7 @@ double WOverview::samplePositionToSeconds(double sample) {

void WOverview::resizeEvent(QResizeEvent* pEvent) {
Q_UNUSED(pEvent);
// Play-position potmeters range from 0 to 1 but they allow out-of-range
// sets. This is to give VC access to the pre-roll area.
constexpr double kMaxPlayposRange = 1.0;
constexpr double kMinPlayposRange = 0.0;

// Values of zero and one in normalized space.
const double zero = (0.0 - kMinPlayposRange) / (kMaxPlayposRange - kMinPlayposRange);
const double one = (1.0 - kMinPlayposRange) / (kMaxPlayposRange - kMinPlayposRange);

// These coefficients convert between widget space and normalized value
// space.
m_a = (length() - 1) / (one - zero);
m_b = zero * m_a;
m_maxPixelPos = length() - 1;

m_devicePixelRatio = devicePixelRatioF();

Expand Down
9 changes: 4 additions & 5 deletions src/widget/woverview.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ class WOverview : public WWidget, public TrackDropTarget {
void paintText(const QString& text, QPainter* pPainter);
double samplePositionToSeconds(double sample);
inline int valueToPosition(double value) const {
return static_cast<int>(m_a * value - m_b);
return static_cast<int>(m_maxPixelPos * value);
}
inline double positionToValue(int position) const {
return (static_cast<double>(position) + m_b) / m_a;
return static_cast<double>(position) / m_maxPixelPos;
}

void updateCues(const QList<CuePointer> &loadedCues);
Expand Down Expand Up @@ -166,9 +166,8 @@ class WOverview : public WWidget, public TrackDropTarget {
Qt::Orientation m_orientation;
int m_iLabelFontSize;

// Coefficient value-position linear transposition
double m_a;
double m_b;
// Coefficient for linear value <-> position transposition
double m_maxPixelPos;

AnalyzerProgress m_analyzerProgress;
bool m_trackLoaded;
Expand Down

0 comments on commit 80a86d8

Please sign in to comment.