1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 23:33:49 +01:00

Smuggle AudacityProject into LabelTrackView::GetSelectedIndex() ...

... and eliminate some more calls to GetActiveProject
This commit is contained in:
Paul Licameli
2019-06-28 13:31:12 -04:00
parent 30715e4fe2
commit f77ddc43d9
9 changed files with 105 additions and 81 deletions

View File

@@ -48,19 +48,19 @@ bool DoPasteText(AudacityProject &project)
for (auto pLabelTrack : tracks.Any<LabelTrack>())
{
// Does this track have an active label?
if (LabelTrackView::Get( *pLabelTrack ).HasSelection()) {
if (LabelTrackView::Get( *pLabelTrack ).HasSelection( project )) {
// Yes, so try pasting into it
auto &view = LabelTrackView::Get( *pLabelTrack );
if (view.PasteSelectedText(selectedRegion.t0(),
selectedRegion.t1()))
if (view.PasteSelectedText( project, selectedRegion.t0(),
selectedRegion.t1() ))
{
ProjectHistory::Get( project )
.PushState(_("Pasted text from the clipboard"), _("Paste"));
// Make sure caret is in view
int x;
if (view.CalcCursorX(&x)) {
if (view.CalcCursorX( project, &x )) {
trackPanel.ScrollIntoView(x);
}
@@ -246,7 +246,7 @@ void OnCut(const CommandContext &context)
for (auto lt : tracks.Selected< LabelTrack >()) {
auto &view = LabelTrackView::Get( *lt );
if (view.CutSelectedText()) {
if (view.CutSelectedText( context.project )) {
trackPanel.Refresh(false);
return;
}
@@ -354,7 +354,7 @@ void OnCopy(const CommandContext &context)
for (auto lt : tracks.Selected< LabelTrack >()) {
auto &view = LabelTrackView::Get( *lt );
if (view.CopySelectedText()) {
if (view.CopySelectedText( context.project )) {
//trackPanel.Refresh(false);
return;
}
@@ -1034,8 +1034,11 @@ const ReservedCommandFlag
CutCopyAvailableFlag{
[](const AudacityProject &project){
auto range = TrackList::Get( project ).Any<const LabelTrack>()
+ [](const LabelTrack *pTrack){
return LabelTrackView::Get( *pTrack ).IsTextSelected();
+ [&](const LabelTrack *pTrack){
return LabelTrackView::Get( *pTrack ).IsTextSelected(
// unhappy const_cast because track focus might be set
const_cast<AudacityProject&>(project)
);
};
if ( !range.empty() )
return true;

View File

@@ -325,8 +325,8 @@ void OnPasteNewLabel(const CommandContext &context)
// Paul L: copy whatever defines the selected region, not just times
auto &view = LabelTrackView::Get( *lt );
view.AddLabel(selectedRegion);
if (view.PasteSelectedText(selectedRegion.t0(),
selectedRegion.t1()))
if (view.PasteSelectedText( context.project, selectedRegion.t0(),
selectedRegion.t1() ))
bPastedSomething = true;
// Set previous track