1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-11 14:41:06 +02:00

Highlighting of time-shift grips

This commit is contained in:
Paul Licameli 2017-06-22 09:11:29 -04:00
parent 7fb107e143
commit 2d65cdc46a
3 changed files with 24 additions and 9 deletions

View File

@ -1484,6 +1484,7 @@ void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &rect, int x0, int y0, int
} }
} }
#include "tracks/ui/TimeShiftHandle.h"
void TrackArtist::DrawWaveform(TrackPanelDrawingContext &context, void TrackArtist::DrawWaveform(TrackPanelDrawingContext &context,
const WaveTrack *track, const WaveTrack *track,
const wxRect & rect, const wxRect & rect,
@ -1495,6 +1496,15 @@ void TrackArtist::DrawWaveform(TrackPanelDrawingContext &context,
bool muted) bool muted)
{ {
auto &dc = context.dc; auto &dc = context.dc;
bool highlight = false;
bool gripHit = false;
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
auto target = dynamic_cast<TimeShiftHandle*>(context.target.get());
gripHit = target && target->IsGripHit();
highlight = target && target->GetTrack().get() == track;
#endif
const bool dB = !track->GetWaveformSettings().isLinear(); const bool dB = !track->GetWaveformSettings().isLinear();
DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush, DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush,
@ -1534,8 +1544,8 @@ void TrackArtist::DrawWaveform(TrackPanelDrawingContext &context,
} }
if (drawSliders) { if (drawSliders) {
DrawTimeSlider(dc, rect, true); // directed right DrawTimeSlider(dc, rect, true, highlight && gripHit); // directed right
DrawTimeSlider(dc, rect, false); // directed left DrawTimeSlider(dc, rect, false, highlight && gripHit); // directed left
} }
} }
@ -2006,7 +2016,7 @@ void TrackArtist::DrawClipWaveform(TrackPanelDrawingContext &context,
void TrackArtist::DrawTimeSlider(wxDC & dc, void TrackArtist::DrawTimeSlider(wxDC & dc,
const wxRect & rect, const wxRect & rect,
bool rightwards) bool rightwards, bool highlight)
{ {
const int border = 3; // 3 pixels all round. const int border = 3; // 3 pixels all round.
const int width = 6; // width of the drag box. const int width = 6; // width of the drag box.
@ -2032,12 +2042,12 @@ void TrackArtist::DrawTimeSlider(wxDC & dc,
int yTop = rect.y + border; int yTop = rect.y + border;
int yBot = rect.y + rect.height - border - 1; int yBot = rect.y + rect.height - border - 1;
AColor::Light(&dc, false); AColor::Light(&dc, false, highlight);
AColor::Line(dc, xLeft, yBot - leftTaper, xLeft, yTop + leftTaper); AColor::Line(dc, xLeft, yBot - leftTaper, xLeft, yTop + leftTaper);
AColor::Line(dc, xLeft, yTop + leftTaper, xLeft + xFlat, yTop); AColor::Line(dc, xLeft, yTop + leftTaper, xLeft + xFlat, yTop);
AColor::Line(dc, xLeft + xFlat, yTop, xLeft + width, yTop + rightTaper); AColor::Line(dc, xLeft + xFlat, yTop, xLeft + width, yTop + rightTaper);
AColor::Dark(&dc, false); AColor::Dark(&dc, false, highlight);
AColor::Line(dc, xLeft + width, yTop + rightTaper, xLeft + width, yBot - rightTaper); AColor::Line(dc, xLeft + width, yTop + rightTaper, xLeft + width, yBot - rightTaper);
AColor::Line(dc, xLeft + width, yBot - rightTaper, xLeft + width-xFlat, yBot); AColor::Line(dc, xLeft + width, yBot - rightTaper, xLeft + width-xFlat, yBot);
AColor::Line(dc, xLeft + width - xFlat, yBot, xLeft, yBot - leftTaper); AColor::Line(dc, xLeft + width - xFlat, yBot, xLeft, yBot - leftTaper);
@ -2048,12 +2058,12 @@ void TrackArtist::DrawTimeSlider(wxDC & dc,
int yy; int yy;
int i; int i;
AColor::Light(&dc, false); AColor::Light(&dc, false, highlight);
for (i = 0;i < nBars; i++) { for (i = 0;i < nBars; i++) {
yy = firstBar + barSpacing * i; yy = firstBar + barSpacing * i;
AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy); AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);
} }
AColor::Dark(&dc, false); AColor::Dark(&dc, false, highlight);
for(i = 0;i < nBars; i++){ for(i = 0;i < nBars; i++){
yy = firstBar + barSpacing * i + 1; yy = firstBar + barSpacing * i + 1;
AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy); AColor::Line(dc, xLeft, yy, xLeft + barWidth, yy);

View File

@ -133,7 +133,7 @@ class AUDACITY_DLL_API TrackArtist {
const wxRect & rect, const ZoomInfo &zoomInfo); const wxRect & rect, const ZoomInfo &zoomInfo);
void DrawTimeSlider(wxDC & dc, const wxRect & rect, void DrawTimeSlider(wxDC & dc, const wxRect & rect,
bool rightwards); bool rightwards, bool highlight);
void DrawClipWaveform(TrackPanelDrawingContext &context, void DrawClipWaveform(TrackPanelDrawingContext &context,
const WaveTrack *track, const WaveClip *clip, const WaveTrack *track, const WaveClip *clip,

View File

@ -10,6 +10,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../Audacity.h" #include "../../Audacity.h"
#include "TimeShiftHandle.h" #include "TimeShiftHandle.h"
#include "../../Experimental.h"
#include "TrackControls.h" #include "TrackControls.h"
#include "../../AColor.h" #include "../../AColor.h"
@ -27,7 +28,11 @@ TimeShiftHandle::TimeShiftHandle
( const std::shared_ptr<Track> &pTrack, bool gripHit ) ( const std::shared_ptr<Track> &pTrack, bool gripHit )
: mCapturedTrack{ pTrack } : mCapturedTrack{ pTrack }
, mGripHit{ gripHit } , mGripHit{ gripHit }
{} {
#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
mChangeHighlight = RefreshCode::RefreshCell;
#endif
}
HitTestPreview TimeShiftHandle::HitPreview HitTestPreview TimeShiftHandle::HitPreview
(const AudacityProject *pProject, bool unsafe) (const AudacityProject *pProject, bool unsafe)