Esempio n. 1
0
void EditToolBar::ForAllButtons(int Action)
{
   AudacityProject *p;
   CommandManager* cm = nullptr;

   if( Action & ETBActEnableDisable ){
      p = GetActiveProject();
      if (!p) return;
      cm = p->GetCommandManager();
      if (!cm) return;
#ifdef OPTION_SYNC_LOCK_BUTTON
      bool bSyncLockTracks;
      gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false);

      if (bSyncLockTracks)
         mButtons[ETBSyncLockID]->PushDown();
      else
         mButtons[ETBSyncLockID]->PopUp();
#endif
   }


   for (const auto &entry : EditToolbarButtonList) {
#if wxUSE_TOOLTIPS
      if( Action & ETBActTooltips ){
         TranslatedInternalString command{
            entry.commandName, wxGetTranslation(entry.untranslatedLabel) };
         ToolBar::SetButtonToolTip( *mButtons[entry.tool], &command, 1u );
      }
#endif
      if (cm) {
         mButtons[entry.tool]->SetEnabled(cm->GetEnabled(entry.commandName));
      }
   }
}
Esempio n. 2
0
void KeyConfigPrefs::Populate()
{
   ShuttleGui S(this, eIsCreatingFromPrefs);
   AudacityProject *project = GetActiveProject();

   if (!project) {
      S.StartVerticalLay(true);
      {
         S.StartStatic(wxEmptyString, true);
         {
            S.AddTitle(_("Keyboard preferences currently unavailable."));
            S.AddTitle(_("Open a new project to modify keyboard shortcuts."));
         }
         S.EndStatic();
      }
      S.EndVerticalLay();

      return;
   }

   mManager = project->GetCommandManager();
   mManager->GetCategories(mCats);
   mCats.Insert(_("All"), 0);

   PopulateOrExchange(S);

   CreateList();
   mCommandSelected = -1;
}
Esempio n. 3
0
void ControlToolBar::EnablePauseCommand(bool bEnable)
{
   // Enable/disable the "P" key command. 
   // GetActiveProject() won't work for all callers, e.g., MakeButton(), because it hasn't finished initializing.
   AudacityProject* pProj = (AudacityProject*)GetParent(); 
   if (pProj)
   {
      CommandManager* pCmdMgr = pProj->GetCommandManager();
      if (pCmdMgr)
         pCmdMgr->Enable(wxT("Pause"), bEnable);
   }
}
Esempio n. 4
0
void EditToolBar::OnButton(wxCommandEvent &event)
{
   int id = event.GetId()-first_ETB_ID;
   // Be sure the pop-up happens even if there are exceptions, except for buttons which toggle.
   auto cleanup = finally( [&] { mButtons[id]->InteractionOver();});

   AudacityProject *p = GetActiveProject();
   if (!p) return;
   CommandManager* cm = p->GetCommandManager();
   if (!cm) return;

   auto flags = GetMenuManager(*p).GetUpdateFlags(*p);
   const CommandContext context( *GetActiveProject() );
   cm->HandleTextualCommand(EditToolbarButtonList[id].commandName, context, flags, NoFlagsSpecified);
}
Esempio n. 5
0
void ControlToolBar::RegenerateToolsTooltips()
{
#if wxUSE_TOOLTIPS
   for (long iWinID = ID_PLAY_BUTTON; iWinID < BUTTON_COUNT; iWinID++)
   {
      wxWindow* pCtrl = this->FindWindow(iWinID);
      wxString strToolTip = pCtrl->GetLabel();
      AudacityProject* pProj = GetActiveProject();
      CommandManager* pCmdMgr = (pProj) ? pProj->GetCommandManager() : NULL;
      if (pCmdMgr)
      {
         wxString strKey(wxT(" ("));
         switch (iWinID)
         {
            case ID_PLAY_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Play"));
               strKey += _(") / Loop Play (");
               strKey += pCmdMgr->GetKeyFromName(wxT("PlayLooped"));
               break;
            case ID_RECORD_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Record"));
               strKey += _(") / Append Record (");
               strKey += pCmdMgr->GetKeyFromName(wxT("RecordAppend"));
               break;
            case ID_PAUSE_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Pause"));
               break;
            case ID_STOP_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("Stop"));
               break;
            case ID_FF_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("SkipEnd"));
               break;
            case ID_REW_BUTTON:
               strKey += pCmdMgr->GetKeyFromName(wxT("SkipStart"));
               break;
         }
         strKey += wxT(")");
         strToolTip += strKey;
      }
      pCtrl->SetToolTip(strToolTip);
   }
#endif
}
Esempio n. 6
0
void KeyConfigPrefs::Populate( )
{
   // First any pre-processing for constructing the GUI.
   // These steps set up the pointer to the command manager...
   AudacityProject *project = GetActiveProject();
   if (!project)
      return;
   mManager = project->GetCommandManager();

   //------------------------- Main section --------------------
   // Now construct the GUI itself.
   // Use 'eIsCreatingFromPrefs' so that the GUI is 
   // initialised with values from gPrefs.
   ShuttleGui S(this, eIsCreatingFromPrefs);
   PopulateOrExchange(S);
   // ----------------------- End of main section --------------
   CreateList();
   mCommandSelected = -1;
}
Esempio n. 7
0
void KeyConfigPrefs::Populate()
{
   ShuttleGui S(this, eIsCreatingFromPrefs);
   AudacityProject *project = GetActiveProject();

   if (!project) {
      S.StartVerticalLay(true);
      {
         S.StartStatic(wxEmptyString, true);
         {
            S.AddTitle(_("Keyboard preferences currently unavailable."));
            S.AddTitle(_("Open a new project to modify keyboard shortcuts."));
         }
         S.EndStatic();
      }
      S.EndVerticalLay();

      return;
   }

   PopulateOrExchange(S);

   mCommandSelected = wxNOT_FOUND;

   mManager = project->GetCommandManager();

   RefreshBindings();

   if (mViewByTree->GetValue()) {
      mViewType = ViewByTree;
   }
   else if (mViewByName->GetValue()) {
      mViewType = ViewByName;
   }
   else if (mViewByKey->GetValue()) {
      mViewType = ViewByKey;
      mFilterLabel->SetLabel(_("&Hotkey:"));
      mFilter->SetName(wxStripMenuCodes(mFilterLabel->GetLabel()));
   }

   mView->SetView(mViewType);
}
Esempio n. 8
0
   // ModuleDispatch
   // is called by Audacity to initialize/terminmate the module,
   // and ask if it has anything for the menus.
   int ModuleDispatch(ModuleDispatchTypes type){
      switch (type){
         case AppQuiting: {
            //It is perfectly OK for gBench to be NULL.
            //Can happen if the menu item was never invoked.
            //wxASSERT(gBench != NULL);
            if (gBench) {
               gBench->Destroy();
               gBench = NULL;
            }
         }
         break;
         case ProjectInitialized:
         case MenusRebuilt:  {
            AudacityProject *p = GetActiveProject();
            wxASSERT(p != NULL);
            CommandManager *c = p->GetCommandManager();
            wxASSERT(c != NULL);

            wxMenuBar * pBar = p->GetMenuBar();
            wxASSERT(pBar != NULL );
            wxMenu * pMenu = pBar->GetMenu( 9 );  // Menu 9 is the Tools Menu.
            wxASSERT( pMenu != NULL );

            c->SetCurrentMenu(pMenu);
            c->AddSeparator();
            c->SetDefaultFlags(AudioIONotBusyFlag, AudioIONotBusyFlag);
            c->AddItem(wxT("NyqBench"),
               _("&Nyquist Workbench..."),
               true,
               findme,
               static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench));

            c->ClearCurrentMenu();
         }
         break;
         default:
         break;
      }
      return 1;
   }
Esempio n. 9
0
   // ModuleDispatch
   // is called by Audacity to initialize/terminmate the module,
   // and ask if it has anything for the menus.
   int ModuleDispatch(ModuleDispatchTypes type){
      switch (type){
         case AppInitialized:{
            wxASSERT(gBench == NULL);
            gBench = new NyqBench(NULL);
         }
         break;
         case AppQuiting: {
            wxASSERT(gBench != NULL);
            if (gBench) {
               delete gBench;
               gBench = NULL;
            }
         }
         break;
         case ProjectInitialized:
         case MenusRebuilt:  {
            AudacityProject *p = GetActiveProject();
            wxASSERT(p != NULL);
            CommandManager *c = p->GetCommandManager();
            wxASSERT(c != NULL);

            wxMenuBar * pBar = p->GetMenuBar();
            wxASSERT(pBar != NULL );
            wxMenu * pMenu = pBar->GetMenu( 2 );  // Menu 2 is the View Menu.
            wxASSERT( pMenu != NULL );

            c->SetToMenu( pMenu );
            c->AddSeparator();
            // c->BeginMenu(_("T&ools"));
            c->SetDefaultFlags(AudioIONotBusyFlag, AudioIONotBusyFlag);
            c->AddItem(wxT("NyqBench"),
                       _("&Nyquist Workbench..."),
                       new ModNyqBenchCommandFunctor());
         }
         break;
         default:
         break;
      }
      return 1;
   }
Esempio n. 10
0
// This is the function that connects us to Audacity.
MOD_TRACK_PANEL_DLL_API int ModuleDispatch(ModuleDispatchTypes type)
{
   switch (type)
   {
   case AppInitialized:
      Registrar::Start();
      // Demand that all track panels be created using the TrackPanel2Factory.
      TrackPanel::FactoryFunction = TrackPanel2Factory;
      break;
   case AppQuiting:
      Registrar::Finish();
      break;
   case ProjectInitialized:
   case MenusRebuilt:
      {
         AudacityProject *p = GetActiveProject();
         if( p== NULL )
            return 0;

         wxMenuBar * pBar = p->GetMenuBar();
         wxMenu * pMenu = pBar->GetMenu( 7 );  // Menu 7 is the Analyze Menu.
         CommandManager * c = p->GetCommandManager();

         c->SetToMenu( pMenu );
         c->AddSeparator();
         // We add two new commands into the Analyze menu.
         c->AddItem( _T("Extra Dialog..."), _T("Experimental Extra Dialog for whatever you want."),
            ModTrackPanelFN( OnFuncShowAudioExplorer ) );
         //Second menu tweak no longer needed as we always make TrackPanel2's.
         //c->AddItem( _T("Replace TrackPanel..."), _T("Replace Current TrackPanel with TrackPanel2"),
         //   ModTrackPanelFN( OnFuncReplaceTrackPanel ) );
      }
      break;
   default:
      break;
   }

   return 1;
}
Esempio n. 11
0
void Lyrics::OnKeyEvent(wxKeyEvent & event)
{
   AudacityProject *project = GetActiveProject();
   project->GetCommandManager()->FilterKeyEvent(project, event, true);
}