1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-14 09:03:54 +01:00

TrackFocus is a new attached object...

... removing the need to use TrackPanel to get and set the focused track

ProjectAudioManager loses its direct dependency on TrackPanel
This commit is contained in:
Paul Licameli
2019-07-01 18:32:18 -04:00
parent 02075d5b43
commit acfd2b7010
21 changed files with 240 additions and 157 deletions

View File

@@ -32,6 +32,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../RefreshCode.h"
#include "../../../Theme.h"
#include "../../../TrackArtist.h"
#include "../../../TrackPanelAx.h"
#include "../../../TrackPanel.h"
#include "../../../TrackPanelMouseEvent.h"
#include "../../../UndoManager.h"
@@ -1084,10 +1085,11 @@ int LabelTrackView::GetSelectedIndex( AudacityProject &project ) const
// may make delayed update of mutable mSelIndex after track selection change
auto track = FindLabelTrack();
if ( track->GetSelected() ||
TrackPanel::Get(
TrackFocus::Get(
// unhappy const_cast because because focus may be set if undefined
const_cast<AudacityProject&>( project )
).GetFocusedTrack() == track.get() )
).Get() == track.get()
)
return mSelIndex = std::max( -1,
std::min<int>( track->GetLabels().size() - 1, mSelIndex ) );
else
@@ -1476,7 +1478,7 @@ bool LabelTrackView::DoKeyDown(
auto track = *TrackList::Get( project ).Any()
.begin().advance(mRestoreFocus);
if (track)
TrackPanel::Get( project ).SetFocusedTrack(track);
TrackFocus::Get( project ).Set(track);
mRestoreFocus = -2;
}
mSelIndex = -1;
@@ -2058,10 +2060,12 @@ int LabelTrackView::DialogForLabelName(
AudacityProject &project,
const SelectedRegion& region, const wxString& initialValue, wxString& value)
{
auto &trackFocus = TrackFocus::Get( project );
auto &trackPanel = TrackPanel::Get( project );
auto &viewInfo = ViewInfo::Get( project );
wxPoint position = trackPanel.FindTrackRect(trackPanel.GetFocusedTrack()).GetBottomLeft();
wxPoint position =
trackPanel.FindTrackRect( trackFocus.Get() ).GetBottomLeft();
// The start of the text in the text box will be roughly in line with the label's position
// if it's a point label, or the start of its region if it's a region label.
position.x += viewInfo.GetLabelWidth()

View File

@@ -17,8 +17,8 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../ProjectSettings.h"
#include "../../../RefreshCode.h"
#include "../../../Track.h"
#include "../../../TrackPanelAx.h"
#include "../../../TrackInfo.h"
#include "../../../TrackPanel.h"
#include "../../../TrackPanelMouseEvent.h"
#include "../../../TrackUtilities.h"
@@ -46,7 +46,7 @@ wxString MuteButtonHandle::Tip(const wxMouseState &) const
auto name = _("Mute");
auto project = ::GetActiveProject();
auto focused =
TrackPanel::Get( *project ).GetFocusedTrack() == GetTrack().get();
TrackFocus::Get( *project ).Get() == GetTrack().get();
if (!focused)
return name;
@@ -102,7 +102,7 @@ wxString SoloButtonHandle::Tip(const wxMouseState &) const
auto name = _("Solo");
auto project = ::GetActiveProject();
auto focused =
TrackPanel::Get( *project ).GetFocusedTrack() == GetTrack().get();
TrackFocus::Get( *project ).Get() == GetTrack().get();
if (!focused)
return name;

View File

@@ -18,13 +18,14 @@ Paul Licameli split from TrackPanel.cpp
#include "../../../ui/TrackView.h"
#include "../../../../AudioIOBase.h"
#include "../../../../CellularPanel.h"
#include "../../../../Menus.h"
#include "../../../../Project.h"
#include "../../../../ProjectAudioIO.h"
#include "../../../../ProjectHistory.h"
#include "../../../../RefreshCode.h"
#include "../../../../ShuttleGui.h"
#include "../../../../TrackPanel.h"
#include "../../../../TrackPanelAx.h"
#include "../../../../TrackPanelMouseEvent.h"
#include "../../../../WaveTrack.h"
#include "../../../../widgets/PopupMenuTable.h"
@@ -955,8 +956,8 @@ void WaveTrackMenuTable::OnSwapChannels(wxCommandEvent &)
if (channels.size() != 2)
return;
auto &trackPanel = TrackPanel::Get( *project );
Track *const focused = trackPanel.GetFocusedTrack();
auto &trackFocus = TrackFocus::Get( *project );
Track *const focused = trackFocus.Get();
const bool hasFocus = channels.contains( focused );
auto partner = *channels.rbegin();
@@ -968,7 +969,7 @@ void WaveTrackMenuTable::OnSwapChannels(wxCommandEvent &)
tracks.GroupChannels( *partner, 2 );
if (hasFocus)
trackPanel.SetFocusedTrack(partner);
trackFocus.Set(partner);
/* i18n-hint: The string names a track */
ProjectHistory::Get( *project )

View File

@@ -110,7 +110,7 @@ void EditCursorOverlay::Draw(OverlayPanel &panel, wxDC &dc)
return;
const auto pTrack = pTrackView->FindTrack();
if (pTrack->GetSelected() ||
trackPanel.GetAx().IsFocused(pTrack.get()))
TrackFocus::Get( *mProject ).IsFocused( pTrack.get() ))
{
// AColor::Line includes both endpoints so use GetBottom()
AColor::Line(dc, mLastCursorX, rect.GetTop(), mLastCursorX, rect.GetBottom());

View File

@@ -28,6 +28,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../SelectUtilities.h"
#include "../../SelectionState.h"
#include "../../TrackArtist.h"
#include "../../TrackPanelAx.h"
#include "../../TrackPanel.h"
#include "../../TrackPanelDrawingContext.h"
#include "../../TrackPanelMouseEvent.h"
@@ -534,13 +535,12 @@ UIHandle::Result SelectHandle::Click
wxMouseEvent &event = evt.event;
const auto sTrack = TrackList::Get( *pProject ).Lock(mpTrack);
const auto pTrack = sTrack.get();
auto &trackPanel = TrackPanel::Get( *pProject );
auto &viewInfo = ViewInfo::Get( *pProject );
mMostRecentX = event.m_x;
mMostRecentY = event.m_y;
auto &trackPanel = TrackPanel::Get( *pProject );
bool selectChange = (
event.LeftDown() &&
event.ControlDown() &&
@@ -771,7 +771,7 @@ UIHandle::Result SelectHandle::Click
#endif
StartSelection(pProject);
selectionState.SelectTrack( *pTrack, true, true );
trackPanel.SetFocusedTrack(pTrack);
TrackFocus::Get( *pProject ).Set(pTrack);
//On-Demand: check to see if there is an OD thing associated with this track.
pTrack->TypeSwitch( [&](WaveTrack *wt) {
if(ODManager::IsInstanceCreated())
@@ -1429,7 +1429,7 @@ void SelectHandle::MoveSnappingFreqSelection
// SelectNone();
// SelectTrack(pTrack, true);
TrackPanel::Get( *pProject ).SetFocusedTrack(pTrack);
TrackFocus::Get( *pProject ).Set(pTrack);
}
}

View File

@@ -18,6 +18,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../SelectUtilities.h"
#include "../../RefreshCode.h"
#include "../../Track.h"
#include "../../TrackPanelAx.h"
#include "../../TrackInfo.h"
#include "../../TrackPanel.h"
#include "../../TrackUtilities.h"
@@ -174,7 +175,7 @@ wxString CloseButtonHandle::Tip(const wxMouseState &) const
auto name = _("Close");
auto project = ::GetActiveProject();
auto focused =
TrackPanel::Get( *project ).GetFocusedTrack() == GetTrack().get();
TrackFocus::Get( *project ).Get() == GetTrack().get();
if (!focused)
return name;
@@ -234,7 +235,7 @@ wxString MenuButtonHandle::Tip(const wxMouseState &) const
auto name = _("Open menu...");
auto project = ::GetActiveProject();
auto focused =
TrackPanel::Get( *project ).GetFocusedTrack() == GetTrack().get();
TrackFocus::Get( *project ).Get() == GetTrack().get();
if (!focused)
return name;