From da4fa1d965bf7f79cf42d11e3021ebdd99e56cf4 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 2 May 2016 14:32:39 -0400 Subject: [PATCH] Put the scrub bar below --- src/widgets/Ruler.cpp | 48 ++++++++++++++++++++++++++++++++----------- src/widgets/Ruler.h | 3 ++- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index ddaa4ce84..afc8eb09f 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -84,6 +84,8 @@ array of Ruler::Label. #include "../Snap.h" #include "../tracks/ui/Scrubbing.h" +//#define SCRUB_ABOVE + using std::min; using std::max; @@ -2085,7 +2087,7 @@ void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) mBack->Create(sz.x, sz.y, dc); mBackDC.SelectObject(*mBack); - DoDrawBorder(&mBackDC); + DoDrawBackground(&mBackDC); if (!mViewInfo->selectedRegion.isPoint()) { @@ -2110,6 +2112,8 @@ void AdornedRulerPanel::OnPaint(wxPaintEvent & WXUNUSED(evt)) DoDrawPushbuttons(&mBackDC); + DoDrawEdge(&mBackDC); + dc.Blit(0, 0, mBack->GetWidth(), mBack->GetHeight(), &mBackDC, 0, 0); if (mQuickPlayInd) @@ -2137,21 +2141,30 @@ void AdornedRulerPanel::UpdateRects() mInner.x += LeftMargin; mInner.width -= (LeftMargin + RightMargin); - wxRect *top = &mInner; + auto top = &mInner; + auto bottom = &mInner; if (mShowScrubbing) { mScrubZone = mInner; auto scrubHeight = std::min(mScrubZone.height, int(ScrubHeight)); - mScrubZone.height = scrubHeight; - mInner.height -= scrubHeight; - mInner.y += scrubHeight; - top = &mScrubZone; + + int topHeight; +#ifdef SCRUB_ABOVE + top = &mScrubZone, topHeight = scrubHeight; +#else + auto qpHeight = mScrubZone.height - scrubHeight; + bottom = &mScrubZone, topHeight = qpHeight; +#endif + + top->height = topHeight; + bottom->height -= topHeight; + bottom->y += topHeight; } top->y += TopMargin; top->height -= TopMargin; - mInner.height -= BottomMargin; + bottom->height -= BottomMargin; if (!mShowScrubbing) mScrubZone = mInner; @@ -3076,6 +3089,13 @@ void AdornedRulerPanel::DoDrawPushbuttons(wxDC *dc) const { // Paint the area behind the buttons wxRect background = GetButtonAreaRect(); + +#ifndef SCRUB_ABOVE + // Reduce the height + background.y = mInner.y; + background.height = mInner.height; +#endif + AColor::MediumTrackInfo(dc, false); dc->DrawRectangle(background); @@ -3088,7 +3108,7 @@ void AdornedRulerPanel::DoDrawPushbuttons(wxDC *dc) const } } -void AdornedRulerPanel::DoDrawBorder(wxDC * dc) +void AdornedRulerPanel::DoDrawBackground(wxDC * dc) { // Draw AdornedRulerPanel border AColor::MediumTrackInfo( dc, false ); @@ -3101,6 +3121,10 @@ void AdornedRulerPanel::DoDrawBorder(wxDC * dc) dc->DrawRectangle(mScrubZone); } +} + +void AdornedRulerPanel::DoDrawEdge(wxDC *dc) +{ wxRect r = mOuter; r.width -= RightMargin; r.height -= BottomMargin; @@ -3248,13 +3272,13 @@ void AdornedRulerPanel::DoEraseIndicator(wxDC *dc, int x) // Restore the background, but make it a little oversized to make // it happy OSX. - dc->Blit(x - indsize - 1, - mScrubZone.y - 1, + auto xx = x - indsize - 1; + auto yy = mScrubZone.y - 1; + dc->Blit(xx, yy, indsize * 2 + 1 + 2, mScrubZone.y + height + 2, &mBackDC, - x - indsize - 1, - 0); + xx, yy); } } diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 810c54f5f..892e43f91 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -359,7 +359,8 @@ private: void OnCaptureLost(wxMouseCaptureLostEvent &evt); - void DoDrawBorder(wxDC * dc); + void DoDrawBackground(wxDC * dc); + void DoDrawEdge(wxDC *dc); void DoDrawMarks(wxDC * dc, bool /*text */ ); void DoDrawCursor(wxDC * dc); void DoDrawSelection(wxDC * dc);