1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-16 08:34:10 +02:00

Highlighting of resizers

This commit is contained in:
Paul Licameli 2017-06-22 11:04:39 -04:00
parent b11c3c8ccf
commit 3e7f82cf5e
3 changed files with 44 additions and 21 deletions

View File

@ -1648,12 +1648,14 @@ void TrackPanel::RefreshTrack(Track *trk, bool refreshbacking)
link = trk->GetLink(); link = trk->GetLink();
} }
// subtract insets and shadows from the rectangle, but not border // So that the highlighting of the resizer refreshes,
// This matters because some separators do paint over the border // include left and right inset areas,
wxRect rect(kLeftInset, // exclude the inset above,
// but include the inset below.
wxRect rect(0,
-mViewInfo->vpos + trk->GetY() + kTopInset, -mViewInfo->vpos + trk->GetY() + kTopInset,
GetRect().GetWidth() - kLeftInset - kRightInset - kShadowThickness, GetRect().GetWidth(),
trk->GetHeight() - kTopInset - kShadowThickness); trk->GetHeight() );
if (link) { if (link) {
rect.height += link->GetHeight(); rect.height += link->GetHeight();
@ -1749,7 +1751,8 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
trackRect.height = 0; // for drawing background in no tracks case. trackRect.height = 0; // for drawing background in no tracks case.
VisibleTrackIterator iter(GetProject()); VisibleTrackIterator iter(GetProject());
for (Track *t = iter.First(); t; t = iter.Next()) { Track *prev{};
for (Track *t = iter.First(); t; prev = t, t = iter.Next()) {
trackRect.y = t->GetY() - mViewInfo->vpos; trackRect.y = t->GetY() - mViewInfo->vpos;
trackRect.height = t->GetHeight(); trackRect.height = t->GetHeight();
@ -1793,7 +1796,7 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
if (mAx->IsFocused(t)) { if (mAx->IsFocused(t)) {
focusRect = borderRect; focusRect = borderRect;
} }
DrawOutside(context, borderTrack, borderRect); DrawOutside(context, borderTrack, prev, borderRect);
} }
// Believe it or not, we can speed up redrawing if we don't // Believe it or not, we can speed up redrawing if we don't
@ -1835,7 +1838,7 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
mUIHandle->DrawExtras(UIHandle::Cells, dc, region, clip); mUIHandle->DrawExtras(UIHandle::Cells, dc, region, clip);
// Paint over the part below the tracks // Paint over the part below the tracks
trackRect.y += trackRect.height; trackRect.y += trackRect.height + kTopInset;
if (trackRect.y < clip.GetBottom()) { if (trackRect.y < clip.GetBottom()) {
AColor::TrackPanelBackground(dc, false); AColor::TrackPanelBackground(dc, false);
dc->DrawRectangle(trackRect.x, dc->DrawRectangle(trackRect.x,
@ -2291,7 +2294,7 @@ void TrackInfo::Status2DrawFunction
void TrackPanel::DrawOutside void TrackPanel::DrawOutside
(TrackPanelDrawingContext &context, (TrackPanelDrawingContext &context,
Track * t, const wxRect & rec) Track * t, Track *prev, const wxRect & rec)
{ {
auto dc = &context.dc; auto dc = &context.dc;
bool bIsWave = (t->GetKind() == Track::Wave); bool bIsWave = (t->GetKind() == Track::Wave);
@ -2300,7 +2303,7 @@ void TrackPanel::DrawOutside
{ {
// Start with whole track rect // Start with whole track rect
wxRect rect = rec; wxRect rect = rec;
DrawOutsideOfTrack(context, t, rect); DrawOutsideOfTrack(context, t, prev, rect);
// Now exclude left, right, and top insets // Now exclude left, right, and top insets
rect.x += kLeftInset; rect.x += kLeftInset;
@ -2342,7 +2345,7 @@ void TrackPanel::DrawOutside
// If linked to a following channel, also paint the separator area, which // If linked to a following channel, also paint the separator area, which
// overlaps the next track rectangle's top // overlaps the next track rectangle's top
void TrackPanel::DrawOutsideOfTrack void TrackPanel::DrawOutsideOfTrack
(TrackPanelDrawingContext &context, Track * t, const wxRect & rect) (TrackPanelDrawingContext &context, Track * t, Track *prev, const wxRect & rect)
{ {
auto dc = &context.dc; auto dc = &context.dc;
@ -2355,10 +2358,13 @@ void TrackPanel::DrawOutsideOfTrack
side.width = kLeftInset; side.width = kLeftInset;
dc->DrawRectangle(side); dc->DrawRectangle(side);
// Area between panel border and top track border if (!prev)
{
// Area above the first track
side = rect; side = rect;
side.height = kTopInset; side.height = kTopInset;
dc->DrawRectangle(side); dc->DrawRectangle(side);
}
// Area between panel border and right track border // Area between panel border and right track border
side = rect; side = rect;
@ -2366,17 +2372,32 @@ void TrackPanel::DrawOutsideOfTrack
side.width = kTopInset; side.width = kTopInset;
dc->DrawRectangle(side); dc->DrawRectangle(side);
// Area between tracks of stereo group auto target = dynamic_cast<TrackPanelResizeHandle*>(context.target.get());
if (t->GetLinked() auto highlight = target && target->GetTrack().get() == t;
side = rect;
side.y += t->GetHeight();
// Area below the track
if (highlight ||
t->GetLinked()
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY #ifdef EXPERIMENTAL_OUTPUT_DISPLAY
|| MONO_WAVE_PAN(t) || MONO_WAVE_PAN(t)
#endif #endif
) { ) {
// Paint the channel separator over (what would be) the shadow of the top // Paint the channel separator over (what would be) the shadow of the top
// channel, and the top inset of the bottom channel // channel, and the top inset of the bottom channel
side = rect;
side.y += t->GetHeight() - kShadowThickness; // (Or, highlight the resizer area below the track)
side.y -= kShadowThickness;
side.height = kTopInset + kShadowThickness; side.height = kTopInset + kShadowThickness;
if (highlight)
dc->SetBrush( AColor::uglyBrush );
dc->DrawRectangle(side);
}
else
{
side.height = kTopInset;
dc->DrawRectangle(side); dc->DrawRectangle(side);
} }
} }

View File

@ -417,14 +417,14 @@ protected:
const wxRect & clip); const wxRect & clip);
void DrawOutside void DrawOutside
(TrackPanelDrawingContext &context, (TrackPanelDrawingContext &context,
Track *t, const wxRect & rec); Track *t, Track *prev, const wxRect & rec);
void HighlightFocusedTrack (wxDC* dc, const wxRect &rect); void HighlightFocusedTrack (wxDC* dc, const wxRect &rect);
void DrawShadow (Track *t, wxDC* dc, const wxRect & rect); void DrawShadow (Track *t, wxDC* dc, const wxRect & rect);
void DrawBordersAroundTrack(Track *t, wxDC* dc, const wxRect & rect, const int labelw, const int vrul); void DrawBordersAroundTrack(Track *t, wxDC* dc, const wxRect & rect, const int labelw, const int vrul);
void DrawOutsideOfTrack void DrawOutsideOfTrack
(TrackPanelDrawingContext &context, (TrackPanelDrawingContext &context,
Track *t, const wxRect & rect); Track *t, Track *prev, const wxRect & rect);
public: public:
// Set the object that performs catch-all event handling when the pointer // Set the object that performs catch-all event handling when the pointer

View File

@ -67,6 +67,8 @@ TrackPanelResizeHandle::TrackPanelResizeHandle
: mpTrack{ track } : mpTrack{ track }
, mMouseClickY( y ) , mMouseClickY( y )
{ {
mChangeHighlight = RefreshCode::RefreshCell;
#ifdef EXPERIMENTAL_OUTPUT_DISPLAY #ifdef EXPERIMENTAL_OUTPUT_DISPLAY
if (MONO_WAVE_PAN(track)){ if (MONO_WAVE_PAN(track)){
//STM: Determine whether we should rescale one or two tracks //STM: Determine whether we should rescale one or two tracks