mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-03 17:19:43 +02:00
Move drawing code for focus border
This commit is contained in:
parent
4633f4f9d4
commit
e6dae33038
@ -71,6 +71,7 @@ public:
|
|||||||
PassControls,
|
PassControls,
|
||||||
PassZooming,
|
PassZooming,
|
||||||
PassBackground,
|
PassBackground,
|
||||||
|
PassFocus,
|
||||||
|
|
||||||
NPasses
|
NPasses
|
||||||
};
|
};
|
||||||
|
@ -973,17 +973,6 @@ void TrackPanel::DrawEverythingElse(TrackPanelDrawingContext &context,
|
|||||||
|
|
||||||
auto target = Target();
|
auto target = Target();
|
||||||
|
|
||||||
// Sometimes highlight is not drawn on backing bitmap. I thought
|
|
||||||
// it was because FindFocus did not return "this" on Mac, but
|
|
||||||
// when I removed that test, yielding this condition:
|
|
||||||
// if (GetFocusedTrack() != NULL) {
|
|
||||||
// the highlight was reportedly drawn even when something else
|
|
||||||
// was the focus and no highlight should be drawn. -RBD
|
|
||||||
if (GetFocusedTrack() != NULL &&
|
|
||||||
wxWindow::FindFocus() == this ) {
|
|
||||||
HighlightFocusedTrack(dc, focusRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (target)
|
if (target)
|
||||||
target->DrawExtras(UIHandle::Panel, dc, region, clip);
|
target->DrawExtras(UIHandle::Panel, dc, region, clip);
|
||||||
}
|
}
|
||||||
@ -999,28 +988,6 @@ std::shared_ptr< TrackPanelCell > TrackPanel::GetBackgroundCell()
|
|||||||
return mpBackground;
|
return mpBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draw a three-level highlight gradient around the focused track.
|
|
||||||
void TrackPanel::HighlightFocusedTrack(wxDC * dc, const wxRect & rect)
|
|
||||||
{
|
|
||||||
wxRect theRect = rect;
|
|
||||||
theRect.Inflate( kBorderThickness );
|
|
||||||
theRect.width += kShadowThickness;
|
|
||||||
theRect.height += kShadowThickness;
|
|
||||||
dc->SetBrush(*wxTRANSPARENT_BRUSH);
|
|
||||||
|
|
||||||
AColor::TrackFocusPen(dc, 0);
|
|
||||||
theRect.Inflate(1);
|
|
||||||
dc->DrawRectangle(theRect);
|
|
||||||
|
|
||||||
AColor::TrackFocusPen(dc, 1);
|
|
||||||
theRect.Inflate(1);
|
|
||||||
dc->DrawRectangle(theRect);
|
|
||||||
|
|
||||||
AColor::TrackFocusPen(dc, 2);
|
|
||||||
theRect.Inflate(1);
|
|
||||||
dc->DrawRectangle(theRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackPanel::UpdateVRulers()
|
void TrackPanel::UpdateVRulers()
|
||||||
{
|
{
|
||||||
for (auto t : GetTracks()->Any< WaveTrack >())
|
for (auto t : GetTracks()->Any< WaveTrack >())
|
||||||
@ -1325,6 +1292,34 @@ struct LabeledChannelGroup final : TrackPanelGroup {
|
|||||||
// right
|
// right
|
||||||
AColor::Line(dc, right, rect.y + 2, right, bottom);
|
AColor::Line(dc, right, rect.y + 2, right, bottom);
|
||||||
}
|
}
|
||||||
|
if ( iPass == TrackArtist::PassFocus ) {
|
||||||
|
// Sometimes highlight is not drawn on backing bitmap. I thought
|
||||||
|
// it was because FindFocus did not return the TrackPanel on Mac, but
|
||||||
|
// when I removed that test, yielding this condition:
|
||||||
|
// if (GetFocusedTrack() != NULL) {
|
||||||
|
// the highlight was reportedly drawn even when something else
|
||||||
|
// was the focus and no highlight should be drawn. -RBD
|
||||||
|
const auto artist = TrackArtist::Get( context );
|
||||||
|
auto &trackPanel = *artist->parent;
|
||||||
|
if (trackPanel.GetFocusedTrack() == mpTrack.get() &&
|
||||||
|
wxWindow::FindFocus() == &trackPanel ) {
|
||||||
|
/// Draw a three-level highlight gradient around the focused track.
|
||||||
|
wxRect theRect = rect;
|
||||||
|
auto &dc = context.dc;
|
||||||
|
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||||
|
|
||||||
|
AColor::TrackFocusPen( &dc, 2 );
|
||||||
|
dc.DrawRectangle(theRect);
|
||||||
|
theRect.Deflate(1);
|
||||||
|
|
||||||
|
AColor::TrackFocusPen( &dc, 1 );
|
||||||
|
dc.DrawRectangle(theRect);
|
||||||
|
theRect.Deflate(1);
|
||||||
|
|
||||||
|
AColor::TrackFocusPen( &dc, 0 );
|
||||||
|
dc.DrawRectangle(theRect);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRect DrawingArea(
|
wxRect DrawingArea(
|
||||||
@ -1337,6 +1332,15 @@ struct LabeledChannelGroup final : TrackPanelGroup {
|
|||||||
rect.width + 2 * kBorderThickness + kShadowThickness,
|
rect.width + 2 * kBorderThickness + kShadowThickness,
|
||||||
rect.height + 2 * kBorderThickness + kShadowThickness
|
rect.height + 2 * kBorderThickness + kShadowThickness
|
||||||
};
|
};
|
||||||
|
else if ( iPass == TrackArtist::PassFocus ) {
|
||||||
|
constexpr auto extra = kBorderThickness + 3;
|
||||||
|
return {
|
||||||
|
rect.x - extra,
|
||||||
|
rect.y - extra,
|
||||||
|
rect.width + 2 * extra + kShadowThickness,
|
||||||
|
rect.height + 2 * extra + kShadowThickness
|
||||||
|
};
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
@ -177,8 +177,6 @@ protected:
|
|||||||
const wxRegion & region,
|
const wxRegion & region,
|
||||||
const wxRect & clip);
|
const wxRect & clip);
|
||||||
|
|
||||||
void HighlightFocusedTrack (wxDC* dc, 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
|
||||||
// is not in any track or ruler or control panel.
|
// is not in any track or ruler or control panel.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user