Audacity  2.2.2
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
TranscriptionToolBar Class Referencefinal

A kind of ToolBar used to help with analysing voice recordings. More...

#include <TranscriptionToolBar.h>

Inheritance diagram for TranscriptionToolBar:
ToolBar wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 TranscriptionToolBar ()
 
virtual ~TranscriptionToolBar ()
 
void Create (wxWindow *parent) override
 
void OnKeyEvent (wxKeyEvent &event)
 
void OnPlaySpeed (wxCommandEvent &event)
 
void OnSpeedSlider (wxCommandEvent &event)
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void OnFocus (wxFocusEvent &event)
 
void OnCaptureKey (wxCommandEvent &event)
 
void PlayAtSpeed (bool looped, bool cutPreview)
 
void ShowPlaySpeedDialog ()
 
void AdjustPlaySpeed (float adj)
 
void SetEnabled (bool enabled)
 
void SetPlaying (bool down, bool looped, bool cutPreview)
 
double GetPlaySpeed () const
 
- Public Member Functions inherited from ToolBar
 ToolBar (int type, const wxString &label, const wxString &section, bool resizable=false)
 
virtual ~ToolBar ()
 
bool AcceptsFocus () const override
 
virtual void ReCreateButtons ()
 
int GetType ()
 
wxString GetTitle ()
 
wxString GetLabel ()
 
wxString GetSection ()
 
ToolDockGetDock ()
 
void SetLabel (const wxString &label) override
 
void SetDocked (ToolDock *dock, bool pushed)
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void InitializeTranscriptionToolBar ()
 
void MakeAlternateImages (teBmps eFore, teBmps eDisabled, int id, unsigned altIdx)
 
void GetSamples (const WaveTrack *t, sampleCount *s0, sampleCount *slen)
 
void SetButton (bool newstate, AButton *button)
 
void RegenerateTooltips () override
 

Static Private Member Functions

static AButtonAddButton (TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const wxChar *label)
 

Private Attributes

AButtonmButtons [TTBNumButtons]
 
wxImage * upImage
 
wxImage * downImage
 
wxImage * hiliteImage
 
ASlidermPlaySpeedSlider
 
double mPlaySpeed
 
ASlidermSensitivitySlider
 
wxBrush mBackgroundBrush
 
wxPen mBackgroundPen
 
int mBackgroundWidth
 
int mBackgroundHeight
 
std::unique_ptr< TimeTrackmTimeTrack
 

Additional Inherited Members

- Public Types inherited from ToolBar
using Holder = Destroy_ptr< ToolBar >
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AButton &button, const TranslatedInternalString commands[], size_t nCommands)
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
void MakeButtonBackgroundsLarge ()
 
void MakeButtonBackgroundsSmall ()
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Attributes inherited from ToolBar
wxString mLabel
 
wxString mSection
 
int mType
 

Detailed Description

A kind of ToolBar used to help with analysing voice recordings.

Definition at line 68 of file TranscriptionToolBar.h.

Constructor & Destructor Documentation

TranscriptionToolBar::TranscriptionToolBar ( )

Definition at line 90 of file TranscriptionToolBar.cpp.

References mPlaySpeed.

91 : ToolBar(TranscriptionBarID, _("Transcription"), wxT("Transcription"))
92 {
93  mPlaySpeed = 1.0 * 100.0;
94 #ifdef EXPERIMENTAL_VOICE_DETECTION
95  mVk = std::make_unique<VoiceKey>();
96 #endif
97 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
ToolBar(int type, const wxString &label, const wxString &section, bool resizable=false)
Definition: ToolBar.cpp:311
TranscriptionToolBar::~TranscriptionToolBar ( )
virtual

Definition at line 99 of file TranscriptionToolBar.cpp.

100 {
101 }

Member Function Documentation

AButton * TranscriptionToolBar::AddButton ( TranscriptionToolBar pBar,
teBmps  eFore,
teBmps  eDisabled,
int  id,
const wxChar *  label 
)
staticprivate

This is a convenience function that allows for button creation in MakeButtons() with fewer arguments Very similar to code in ControlToolBar...

Definition at line 139 of file TranscriptionToolBar.cpp.

References ToolBar::Add(), ThemeBase::ImageSize(), ToolBar::MakeButton(), mButtons, and theTheme.

Referenced by Populate().

144 {
145  AButton *&r = pBar->mButtons[id];
146 
147  r = ToolBar::MakeButton(pBar,
148  bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
149  eFore, eFore, eDisabled,
150  wxWindowID(id),
151  wxDefaultPosition,
152  false,
153  theTheme.ImageSize( bmpRecoloredUpSmall ));
154 
155  r->SetLabel(label);
156 // JKC: Unlike ControlToolBar, does not have a focus rect. Shouldn't it?
157 // r->SetFocusRect( r->GetRect().Deflate( 4, 4 ) );
158 
159  pBar->Add( r, 0, wxALIGN_CENTER );
160 
161  return r;
162 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxString label
Definition: Tags.cpp:733
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static AButton * MakeButton(wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
Definition: ToolBar.cpp:769
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:615
AButton * mButtons[TTBNumButtons]
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void TranscriptionToolBar::AdjustPlaySpeed ( float  adj)

Definition at line 958 of file TranscriptionToolBar.cpp.

References ASlider::Decrease(), ASlider::Increase(), mPlaySpeedSlider, and OnSpeedSlider().

Referenced by AudacityProject::OnPlaySpeedDec(), and AudacityProject::OnPlaySpeedInc().

959 {
960  if (adj < 0) {
961  mPlaySpeedSlider->Decrease(-adj);
962  }
963  else {
965  }
966  wxCommandEvent e;
967  OnSpeedSlider(e);
968 }
void OnSpeedSlider(wxCommandEvent &event)
void Increase(float steps)
Definition: ASlider.cpp:1577
void Decrease(float steps)
Definition: ASlider.cpp:1582
void TranscriptionToolBar::Create ( wxWindow *  parent)
overridevirtual

Reimplemented from ToolBar.

Definition at line 103 of file TranscriptionToolBar.cpp.

References ToolBar::Create(), AButton::Disable(), AButton::Enable(), ASlider::Get(), mBackgroundBrush, mBackgroundHeight, mBackgroundPen, mBackgroundWidth, mButtons, mPlaySpeed, and mPlaySpeedSlider.

104 {
105  ToolBar::Create(parent);
106 
107  mBackgroundBrush.SetColour(wxColour(204, 204, 204));
108  mBackgroundPen.SetColour(wxColour(204, 204, 204));
109 
110  mBackgroundHeight = 0;
111  mBackgroundWidth = 0;
112 
113 #ifdef EXPERIMENTAL_VOICE_DETECTION
114  mButtons[TTB_StartOn]->Disable();
115  mButtons[TTB_StartOff]->Disable();
116  mButtons[TTB_EndOn]->Disable();
117  mButtons[TTB_EndOff]->Disable();
118  mButtons[TTB_SelectSound]->Disable();
119  mButtons[TTB_SelectSilence]->Disable();
120  mButtons[TTB_Calibrate]->Enable();
121  mButtons[TTB_AutomateSelection]->Disable();
122  mButtons[TTB_MakeLabel]->Enable();
123 #endif
124 
125  //Old code...
126  //Process a dummy event to set up mPlaySpeed
127  //wxCommandEvent dummy;
128  //OnSpeedSlider(dummy);
129 
130  //JKC: Set speed this way is better, as we don't
131  //then stop Audio if it is playing, so we can be playing
132  //audio and open a second project.
133  mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
134 }
float Get(bool convert=true)
Definition: ASlider.cpp:1567
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:442
void Disable()
Definition: AButton.cpp:502
void Enable()
Definition: AButton.cpp:495
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::EnableDisableButtons ( )
overridevirtual

Implements ToolBar.

Definition at line 268 of file TranscriptionToolBar.cpp.

References GetActiveProject(), AudacityProject::GetSel0(), AudacityProject::GetSel1(), AudacityProject::GetTracks(), mButtons, and AButton::SetEnabled().

269 {
270 #ifdef EXPERIMENTAL_VOICE_DETECTION
272  if (!p) return;
273  // Is anything selected?
274  bool selection = false;
275  TrackListIterator iter(p->GetTracks());
276  for (Track *t = iter.First(); t; t = iter.Next())
277  if (t->GetSelected()) {
278  selection = true;
279  break;
280  }
281  selection &= (p->GetSel0() < p->GetSel1());
282 
283  mButtons[TTB_Calibrate]->SetEnabled(selection);
284 #endif
285 }
double GetSel0() const
Definition: Project.h:204
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetEnabled(bool state)
Definition: AButton.h:98
Fundamental data object of Audacity, placed in the TrackPanel. Classes derived form it include the Wa...
Definition: Track.h:102
An iterator for a TrackList.
Definition: Track.h:402
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
double GetSel1() const
Definition: Project.h:205
TrackList * GetTracks()
Definition: Project.h:192
AButton * mButtons[TTBNumButtons]
double TranscriptionToolBar::GetPlaySpeed ( ) const
inline

Definition at line 120 of file TranscriptionToolBar.h.

References mPlaySpeed.

Referenced by Scrubber::MaybeStartScrubbing().

120 { return mPlaySpeed / 100.0; }
void TranscriptionToolBar::GetSamples ( const WaveTrack t,
sampleCount s0,
sampleCount slen 
)
private

Definition at line 402 of file TranscriptionToolBar.cpp.

References GetActiveProject(), WaveTrack::GetOffset(), WaveTrack::GetRate(), AudacityProject::GetSel0(), and AudacityProject::GetSel1().

404 {
405  // GetSamples attempts to translate the start and end selection markers into sample indices
406  // These selection numbers are doubles.
407 
409  if (!p) {
410  return;
411  }
412 
413  //First, get the current selection. It is part of the mViewInfo, which is
414  //part of the project
415 
416  double start = p->GetSel0();
417  double end = p->GetSel1();
418 
419  auto ss0 = sampleCount( (start - t->GetOffset()) * t->GetRate() );
420  auto ss1 = sampleCount( (end - t->GetOffset()) * t->GetRate() );
421 
422  if (start < t->GetOffset()) {
423  ss0 = 0;
424  }
425 
426 #if 0
427  //This adjusts the right samplecount to the maximum sample.
428  if (ss1 >= t->GetNumSamples()) {
429  ss1 = t->GetNumSamples();
430  }
431 #endif
432 
433  if (ss1 < ss0) {
434  ss1 = ss0;
435  }
436 
437  *s0 = ss0;
438  *slen = ss1 - ss0;
439 }
double GetSel0() const
Definition: Project.h:204
double GetOffset() const override
Definition: WaveTrack.cpp:219
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
double GetRate() const
Definition: WaveTrack.cpp:398
double GetSel1() const
Definition: Project.h:205
void TranscriptionToolBar::InitializeTranscriptionToolBar ( )
private
void TranscriptionToolBar::MakeAlternateImages ( teBmps  eFore,
teBmps  eDisabled,
int  id,
unsigned  altIdx 
)
private

Definition at line 164 of file TranscriptionToolBar.cpp.

References ThemeBase::ImageSize(), ToolBar::MakeAlternateImages(), mButtons, and theTheme.

Referenced by Populate().

167 {
169  bmpRecoloredUpSmall, bmpRecoloredDownSmall, bmpRecoloredUpHiliteSmall,bmpRecoloredHiliteSmall,
170  eFore, eFore, eDisabled,
171  theTheme.ImageSize( bmpRecoloredUpSmall ));
172 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxSize ImageSize(int iIndex)
Definition: Theme.cpp:1257
static void MakeAlternateImages(AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
Definition: ToolBar.cpp:802
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::OnCaptureKey ( wxCommandEvent &  event)

Definition at line 354 of file TranscriptionToolBar.cpp.

References mPlaySpeedSlider.

355 {
356  wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
357  int keyCode = kevent->GetKeyCode();
358 
359  // Pass LEFT/RIGHT/UP/DOWN/PAGEUP/PAGEDOWN through for input/output sliders
360  if (FindFocus() == mPlaySpeedSlider && (keyCode == WXK_LEFT || keyCode == WXK_RIGHT
361  || keyCode == WXK_UP || keyCode == WXK_DOWN
362  || keyCode == WXK_PAGEUP || keyCode == WXK_PAGEDOWN)) {
363  return;
364  }
365 
366  event.Skip();
367 
368  return;
369 }
void TranscriptionToolBar::OnFocus ( wxFocusEvent &  event)

Definition at line 340 of file TranscriptionToolBar.cpp.

References AudacityProject::CaptureKeyboard(), and AudacityProject::ReleaseKeyboard().

Referenced by Populate().

341 {
342  if (event.GetEventType() == wxEVT_KILL_FOCUS) {
344  }
345  else {
347  }
348 
349  Refresh(false);
350 
351  event.Skip();
352 }
static void CaptureKeyboard(wxWindow *handler)
Definition: Project.cpp:5961
static void ReleaseKeyboard(wxWindow *handler)
Definition: Project.cpp:5972
void TranscriptionToolBar::OnKeyEvent ( wxKeyEvent &  event)

Definition at line 372 of file TranscriptionToolBar.cpp.

References gAudioIO, and AudioIO::IsBusy().

373 {
374  if (event.ControlDown()) {
375  event.Skip();
376  return;
377  }
378 
379  if (event.GetKeyCode() == WXK_SPACE) {
380  if (gAudioIO->IsBusy()) {
381  /*Do Stuff Here*/
382  }
383  else {
384  /*Do other stuff Here*/
385  }
386  }
387 }
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2882
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
void TranscriptionToolBar::OnPlaySpeed ( wxCommandEvent &  event)

Definition at line 494 of file TranscriptionToolBar.cpp.

References mButtons, PlayAtSpeed(), TTB_PlaySpeed, and AButton::WasControlDown().

495 {
496  auto button = mButtons[TTB_PlaySpeed];
497 
498  // Let control have precedence over shift
499  const bool cutPreview = mButtons[TTB_PlaySpeed]->WasControlDown();
500  const bool looped = !cutPreview &&
501  button->WasShiftDown();
502  PlayAtSpeed(looped, cutPreview);
503 }
void PlayAtSpeed(bool looped, bool cutPreview)
bool WasControlDown()
Definition: AButton.cpp:490
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::OnSpeedSlider ( wxCommandEvent &  event)

Definition at line 505 of file TranscriptionToolBar.cpp.

References ASlider::Get(), mPlaySpeed, mPlaySpeedSlider, and RegenerateTooltips().

Referenced by AdjustPlaySpeed(), and ShowPlaySpeedDialog().

506 {
507  mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
509 
510  // If IO is busy, abort immediately
511  // AWD: This is disabled to work around a hang on Linux when PulseAudio is
512  // used. If we figure that one out we can re-enable this code.
513  //if (gAudioIO->IsBusy()) {
514  // OnPlaySpeed(event);
515  //}
516 }
float Get(bool convert=true)
Definition: ASlider.cpp:1567
void RegenerateTooltips() override
void TranscriptionToolBar::PlayAtSpeed ( bool  looped,
bool  cutPreview 
)

Definition at line 442 of file TranscriptionToolBar.cpp.

References ControlToolBar::CutPreview, gAudioIO, GetActiveProject(), AudacityProject::GetControlToolBar(), AudacityProject::GetDefaultPlayOptions(), AudacityProject::GetPlayRegion(), AudacityProject::GetTrackFactory(), AudioIO::IsBusy(), ControlToolBar::Looped, mButtons, mPlaySpeed, mTimeTrack, TrackFactory::NewTimeTrack(), normalPlay, AudioIOStartStreamOptions::playLooped, ControlToolBar::PlayPlayRegion(), SetButton(), ControlToolBar::StopPlaying(), and ControlToolBar::Straight.

Referenced by AudacityProject::OnPlayAtSpeed(), AudacityProject::OnPlayAtSpeedCutPreview(), AudacityProject::OnPlayAtSpeedLooped(), and OnPlaySpeed().

443 {
444  // Can't do anything without an active project
446  if (!p) {
447  return;
448  }
449 
450  // Create a TimeTrack if we haven't done so already
451  if (!mTimeTrack) {
453  if (!mTimeTrack) {
454  return;
455  }
456  }
457 
458  // Pop up the button
460 
461  // If IO is busy, abort immediately
462  if (gAudioIO->IsBusy()) {
464  }
465 
466  // Set the speed range
467  //mTimeTrack->SetRangeUpper((double)mPlaySpeed / 100.0);
468  //mTimeTrack->SetRangeLower((double)mPlaySpeed / 100.0);
469  mTimeTrack->GetEnvelope()->Flatten((double)mPlaySpeed / 100.0);
470 
471  // Get the current play region
472  double playRegionStart, playRegionEnd;
473  p->GetPlayRegion(&playRegionStart, &playRegionEnd);
474 
475  // Start playing
476  if (playRegionStart >= 0) {
477 // playRegionEnd = playRegionStart + (playRegionEnd-playRegionStart)* 100.0/mPlaySpeed;
479  options.playLooped = looped;
480  options.timeTrack = mTimeTrack.get();
481  ControlToolBar::PlayAppearance appearance =
486  (SelectedRegion(playRegionStart, playRegionEnd),
487  options,
489  appearance);
490  }
491 }
AudioIOStartStreamOptions GetDefaultPlayOptions()
Definition: Project.cpp:1298
void StopPlaying(bool stopStream=true)
void SetButton(bool newstate, AButton *button)
bool IsBusy()
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIO.cpp:2882
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
std::unique_ptr< TimeTrack > NewTimeTrack()
Definition: TimeTrack.cpp:35
Defines a selected portion of a project.
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:123
std::unique_ptr< TimeTrack > mTimeTrack
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
int PlayPlayRegion(const SelectedRegion &selectedRegion, const AudioIOStartStreamOptions &options, PlayMode playMode, PlayAppearance appearance=PlayAppearance::Straight, bool backwards=false, bool playWhiteSpace=false)
ControlToolBar * GetControlToolBar()
Definition: Project.cpp:5003
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308
void GetPlayRegion(double *playRegionStart, double *playRegionEnd)
Definition: Project.cpp:5448
AButton * mButtons[TTBNumButtons]
TrackFactory * GetTrackFactory()
Definition: Project.cpp:1434
void TranscriptionToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 174 of file TranscriptionToolBar.cpp.

References _(), ToolBar::Add(), AddButton(), ThemeBase::Colour(), AButton::FollowModifierKeys(), ASlider::Options::Line(), MakeAlternateImages(), ToolBar::MakeButtonBackgroundsSmall(), mButtons, mPlaySpeed, mPlaySpeedSlider, mSensitivitySlider, OnFocus(), ASlider::Options::Page(), safenew, ASlider::Set(), SPEED_SLIDER, ASlider::Options::Style(), theTheme, TTB_PlaySpeed, and UpdatePrefs().

175 {
176  SetBackgroundColour( theTheme.Colour( clrMedium ) );
177 // Very similar to code in ControlToolBar...
178 // Very similar to code in EditToolBar
180 
181  AddButton(this, bmpPlay, bmpPlayDisabled, TTB_PlaySpeed,
182  _("Play at selected speed"));
183  MakeAlternateImages(bmpLoop, bmpLoopDisabled, TTB_PlaySpeed, 1);
184  MakeAlternateImages(bmpCutPreview, bmpCutPreviewDisabled, TTB_PlaySpeed, 2);
186 
187  //Add a slider that controls the speed of playback.
188  const int SliderWidth=100;
191  _("Playback Speed"),
192  wxDefaultPosition,
193  wxSize(SliderWidth,25),
195  .Style( SPEED_SLIDER )
196  // 6 steps using page up/down, and 60 using arrow keys
197  .Line( 0.16667f )
198  .Page( 0.16667f )
199  );
200  mPlaySpeedSlider->Set(mPlaySpeed / 100.0);
201  mPlaySpeedSlider->SetLabel(_("Playback Speed"));
202  Add( mPlaySpeedSlider, 0, wxALIGN_CENTER );
203  mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS,
205  this);
206  mPlaySpeedSlider->Bind(wxEVT_KILL_FOCUS,
208  this);
209 
210 #ifdef EXPERIMENTAL_VOICE_DETECTION
211 // If we need these strings translated, then search and replace
212 // TRANSLATBLE by _ and remove this #define.
213 #define TRANSLATABLE( x ) wxT( x )
214  AddButton(this, bmpTnStartOn, bmpTnStartOnDisabled, TTB_StartOn,
215  TRANSLATABLE("Adjust left selection to next onset"));
216  AddButton(this, bmpTnEndOn, bmpTnEndOnDisabled, TTB_EndOn,
217  TRANSLATABLE("Adjust right selection to previous offset"));
218  AddButton(this, bmpTnStartOff, bmpTnStartOffDisabled, TTB_StartOff,
219  TRANSLATABLE("Adjust left selection to next offset"));
220  AddButton(this, bmpTnEndOff, bmpTnEndOffDisabled, TTB_EndOff,
221  TRANSLATABLE("Adjust right selection to previous onset"));
222  AddButton(this, bmpTnSelectSound, bmpTnSelectSoundDisabled, TTB_SelectSound,
223  TRANSLATABLE("Select region of sound around cursor"));
224  AddButton(this, bmpTnSelectSilence, bmpTnSelectSilenceDisabled, TTB_SelectSilence,
225  TRANSLATABLE("Select region of silence around cursor"));
226  AddButton(this, bmpTnAutomateSelection, bmpTnAutomateSelectionDisabled, TTB_AutomateSelection,
227  TRANSLATABLE("Automatically make labels from words"));
228  AddButton(this, bmpTnMakeTag, bmpTnMakeTagDisabled, TTB_MakeLabel,
229  TRANSLATABLE("Add label at selection"));
230  AddButton(this, bmpTnCalibrate, bmpTnCalibrateDisabled, TTB_Calibrate,
231  TRANSLATABLE("Calibrate voicekey"));
232 
234  TTB_SensitivitySlider,
235  TRANSLATABLE("Adjust Sensitivity"),
236  wxDefaultPosition,
237  wxSize(SliderWidth,25),
238  SPEED_SLIDER);
239  mSensitivitySlider->Set(.5);
240  mSensitivitySlider->SetLabel(TRANSLATABLE("Sensitivity"));
241  Add( mSensitivitySlider, 0, wxALIGN_CENTER );
242 
243  wxString choices[] =
244  {
245  TRANSLATABLE("Energy"),
246  TRANSLATABLE("Sign Changes (Low Threshold)"),
247  TRANSLATABLE("Sign Changes (High Threshold)"),
248  TRANSLATABLE("Direction Changes (Low Threshold)"),
249  TRANSLATABLE("Direction Changes (High Threshold)")
250  };
251 
252  mKeyTypeChoice = safenew wxChoice(this, TTB_KeyType,
253  wxDefaultPosition,
254  wxDefaultSize,
255  5,
256  choices );
257  mKeyTypeChoice->SetName(TRANSLATABLE("Key type"));
258  mKeyTypeChoice->SetSelection(0);
259  Add( mKeyTypeChoice, 0, wxALIGN_CENTER );
260 #endif
261 
262  // Add a little space
263  Add(2, -1);
264 
265  UpdatePrefs();
266 }
void MakeButtonBackgroundsSmall()
Definition: ToolBar.cpp:731
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void MakeAlternateImages(teBmps eFore, teBmps eDisabled, int id, unsigned altIdx)
#define SPEED_SLIDER
Definition: ASlider.h:47
void FollowModifierKeys()
Definition: AButton.cpp:258
#define safenew
Definition: Audacity.h:230
Options & Page(float p)
Definition: ASlider.h:268
void OnFocus(wxFocusEvent &event)
static AButton * AddButton(TranscriptionToolBar *pBar, teBmps eFore, teBmps eDisabled, int id, const wxChar *label)
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:615
void Set(float value)
Definition: ASlider.cpp:1572
Options & Line(float l)
Definition: ASlider.h:267
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
ASlider is a custom slider, allowing for a slicker look and feel.
Definition: ASlider.h:243
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
AButton * mButtons[TTBNumButtons]
Options & Style(int s)
Definition: ASlider.h:260
void TranscriptionToolBar::RegenerateTooltips ( )
overrideprivatevirtual

Implements ToolBar.

Definition at line 298 of file TranscriptionToolBar.cpp.

References mButtons, mSensitivitySlider, ToolBar::SetButtonToolTip(), TTB_PlaySpeed, and XO.

Referenced by OnSpeedSlider(), and UpdatePrefs().

299 {
300  // We could also mention the shift- and ctrl-modified versions in the
301  // tool tip... but it would get long
302 
303  static const struct Entry {
304  int tool;
305  wxString commandName;
306  wxString untranslatedLabel;
307  wxString commandName2;
308  wxString untranslatedLabel2;
309  } table[] = {
310  { TTB_PlaySpeed, wxT("PlayAtSpeed"), XO("Play-at-Speed"),
311  wxT("PlayAtSpeedLooped"), XO("Looped-Play-at-Speed")
312  },
313  };
314 
315  for (const auto &entry : table) {
316  TranslatedInternalString commands[] = {
317  { entry.commandName, wxGetTranslation(entry.untranslatedLabel) },
318  { entry.commandName2, wxGetTranslation(entry.untranslatedLabel2) },
319  };
320  ToolBar::SetButtonToolTip( *mButtons[entry.tool], commands, 2u );
321  }
322 
323 
324 #ifdef EXPERIMENTAL_VOICE_DETECTION
325  mButtons[TTB_StartOn]->SetToolTip(TRANSLATABLE("Left-to-On"));
326  mButtons[TTB_EndOn]->SetToolTip( TRANSLATABLE("Right-to-Off"));
327  mButtons[TTB_StartOff]->SetToolTip( TRANSLATABLE("Left-to-Off"));
328  mButtons[TTB_EndOff]->SetToolTip( TRANSLATABLE("Right-to-On"));
329  mButtons[TTB_SelectSound]->SetToolTip( TRANSLATABLE("Select-Sound"));
330  mButtons[TTB_SelectSilence]->SetToolTip( TRANSLATABLE("Select-Silence"));
331  mButtons[TTB_AutomateSelection]->SetToolTip( TRANSLATABLE("Make Labels"));
332  mButtons[TTB_MakeLabel]->SetToolTip( TRANSLATABLE("Add Label"));
333  mButtons[TTB_Calibrate]->SetToolTip( TRANSLATABLE("Calibrate"));
334 
335  mSensitivitySlider->SetToolTip(TRANSLATABLE("Sensitivity"));
336  mKeyTypeChoice->SetToolTip(TRANSLATABLE("Key type"));
337 #endif
338 }
#define XO(s)
Definition: Internat.h:33
AButton * mButtons[TTBNumButtons]
static void SetButtonToolTip(AButton &button, const TranslatedInternalString commands[], size_t nCommands)
Definition: ToolBar.cpp:827
void TranscriptionToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 82 of file TranscriptionToolBar.h.

82 {};
void TranscriptionToolBar::SetButton ( bool  newstate,
AButton button 
)
private

Definition at line 392 of file TranscriptionToolBar.cpp.

References AButton::PopUp(), and AButton::PushDown().

Referenced by PlayAtSpeed().

393 {
394  if (down) {
395  button->PushDown();
396  }
397  else {
398  button->PopUp();
399  }
400 }
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
void TranscriptionToolBar::SetEnabled ( bool  enabled)

Definition at line 940 of file TranscriptionToolBar.cpp.

References mButtons, AButton::SetEnabled(), and TTB_PlaySpeed.

Referenced by ControlToolBar::EnableDisableButtons().

941 {
942  mButtons[TTB_PlaySpeed]->SetEnabled(enabled);
943 }
void SetEnabled(bool state)
Definition: AButton.h:98
AButton * mButtons[TTBNumButtons]
void TranscriptionToolBar::SetPlaying ( bool  down,
bool  looped,
bool  cutPreview 
)

Definition at line 945 of file TranscriptionToolBar.cpp.

References mButtons, AButton::PopUp(), AButton::PushDown(), AButton::SetAlternateIdx(), and TTB_PlaySpeed.

946 {
947  AButton *const button = mButtons[TTB_PlaySpeed];
948  if (down) {
949  button->SetAlternateIdx(cutPreview ? 2 : looped ? 1 : 0);
950  button->PushDown();
951  }
952  else {
953  button->SetAlternateIdx(0);
954  button->PopUp();
955  }
956 }
void SetAlternateIdx(unsigned idx)
Definition: AButton.cpp:248
void PopUp()
Definition: AButton.cpp:525
void PushDown()
Definition: AButton.cpp:517
AButton * mButtons[TTBNumButtons]
A wxButton with mouse-over behaviour.
Definition: AButton.h:28
void TranscriptionToolBar::ShowPlaySpeedDialog ( )

Definition at line 932 of file TranscriptionToolBar.cpp.

References mPlaySpeedSlider, OnSpeedSlider(), and ASlider::ShowDialog().

Referenced by AudacityProject::OnSetPlaySpeed().

933 {
935  mPlaySpeedSlider->Refresh();
936  wxCommandEvent e;
937  OnSpeedSlider(e);
938 }
void OnSpeedSlider(wxCommandEvent &event)
bool ShowDialog(wxPoint pos=wxPoint(-1,-1))
Definition: ASlider.cpp:1587
void TranscriptionToolBar::UpdatePrefs ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 287 of file TranscriptionToolBar.cpp.

References _(), RegenerateTooltips(), ToolBar::SetLabel(), and ToolBar::UpdatePrefs().

Referenced by Populate().

288 {
290 
291  // Set label to pull in language change
292  SetLabel(_("Transcription"));
293 
294  // Give base class a chance
296 }
virtual void UpdatePrefs()
Definition: ToolBar.cpp:539
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:378
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
void RegenerateTooltips() override

Member Data Documentation

wxImage* TranscriptionToolBar::downImage
private

Definition at line 139 of file TranscriptionToolBar.h.

wxImage* TranscriptionToolBar::hiliteImage
private

Definition at line 140 of file TranscriptionToolBar.h.

wxBrush TranscriptionToolBar::mBackgroundBrush
private

Definition at line 152 of file TranscriptionToolBar.h.

Referenced by Create().

int TranscriptionToolBar::mBackgroundHeight
private

Definition at line 155 of file TranscriptionToolBar.h.

Referenced by Create().

wxPen TranscriptionToolBar::mBackgroundPen
private

Definition at line 153 of file TranscriptionToolBar.h.

Referenced by Create().

int TranscriptionToolBar::mBackgroundWidth
private

Definition at line 154 of file TranscriptionToolBar.h.

Referenced by Create().

AButton* TranscriptionToolBar::mButtons[TTBNumButtons]
private
double TranscriptionToolBar::mPlaySpeed
private
ASlider* TranscriptionToolBar::mPlaySpeedSlider
private
ASlider* TranscriptionToolBar::mSensitivitySlider
private

Definition at line 144 of file TranscriptionToolBar.h.

Referenced by Populate(), and RegenerateTooltips().

std::unique_ptr<TimeTrack> TranscriptionToolBar::mTimeTrack
private

Definition at line 157 of file TranscriptionToolBar.h.

Referenced by PlayAtSpeed().

wxImage* TranscriptionToolBar::upImage
private

Definition at line 138 of file TranscriptionToolBar.h.


The documentation for this class was generated from the following files: