From 47ac55b29cf8b2ce3499a38cff2a67daa4169861 Mon Sep 17 00:00:00 2001 From: mchinen Date: Sat, 29 Jan 2011 18:46:06 +0000 Subject: [PATCH] bug 11 followup: Add dialogs and shortcuts for each combo of device toolbar --- src/Menus.cpp | 46 ++++++++++++++++++++++++++++ src/Menus.h | 7 ++++- src/toolbars/DeviceToolBar.cpp | 56 ++++++++++++++++++++++++++++++++++ src/toolbars/DeviceToolBar.h | 8 +++++ 4 files changed, 116 insertions(+), 1 deletion(-) diff --git a/src/Menus.cpp b/src/Menus.cpp index 29d01fdbc..d0cd0538d 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -92,6 +92,7 @@ simplifies construction of menu items. #include "toolbars/ControlToolBar.h" #include "toolbars/ToolsToolBar.h" #include "toolbars/EditToolBar.h" +#include "toolbars/DeviceToolBar.h" #include "toolbars/MixerToolBar.h" #include "toolbars/TranscriptionToolBar.h" @@ -1128,6 +1129,19 @@ void AudacityProject::CreateMenusAndCommands() c->AddCommand(wxT("FullScreenOnOff"), _("Full screen on/off"), FN(OnFullScreen), wxT("F11")); + c->AddCommand(wxT("InputDevice"), _("Change input device"), FN(OnInputDevice), wxT("Shift+I"), + AudioIONotBusyFlag, + AudioIONotBusyFlag); + c->AddCommand(wxT("OutputDevice"), _("Change output device"), FN(OnOutputDevice), wxT("Shift+O"), + AudioIONotBusyFlag, + AudioIONotBusyFlag); + c->AddCommand(wxT("AudioHost"), _("Change audio host"), FN(OnAudioHost), wxT("Shift+H"), + AudioIONotBusyFlag, + AudioIONotBusyFlag); + c->AddCommand(wxT("InputChannels"), _("Change input channels"), FN(OnInputChannels), wxT("Shift+N"), + AudioIONotBusyFlag, + AudioIONotBusyFlag); + c->AddCommand(wxT("OutputGain"), _("Adjust output gain"), FN(OnOutputGain)); c->AddCommand(wxT("OutputGainInc"), _("Increase output gain"), FN(OnOutputGainInc)); c->AddCommand(wxT("OutputGainDec"), _("Decrease output gain"), FN(OnOutputGainDec)); @@ -2396,6 +2410,38 @@ void AudacityProject::OnTrackClose() mTrackPanel->OnTrackClose(); } +void AudacityProject::OnInputDevice() +{ + DeviceToolBar *tb = GetDeviceToolBar(); + if (tb) { + tb->ShowInputDialog(); + } +} + +void AudacityProject::OnOutputDevice() +{ + DeviceToolBar *tb = GetDeviceToolBar(); + if (tb) { + tb->ShowOutputDialog(); + } +} + +void AudacityProject::OnAudioHost() +{ + DeviceToolBar *tb = GetDeviceToolBar(); + if (tb) { + tb->ShowHostDialog(); + } +} + +void AudacityProject::OnInputChannels() +{ + DeviceToolBar *tb = GetDeviceToolBar(); + if (tb) { + tb->ShowChannelsDialog(); + } +} + void AudacityProject::OnOutputGain() { MixerToolBar *tb = GetMixerToolBar(); diff --git a/src/Menus.h b/src/Menus.h index a280c505c..da04af41a 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -106,11 +106,16 @@ void OnTrackMute(); void OnTrackSolo(); void OnTrackClose(); + // Device control +void OnInputDevice(); +void OnOutputDevice(); +void OnAudioHost(); +void OnInputChannels(); + // Mixer control void OnOutputGain(); void OnInputGain(); -void OnInputSource(); void OnOutputGainInc(); void OnOutputGainDec(); void OnInputGainInc(); diff --git a/src/toolbars/DeviceToolBar.cpp b/src/toolbars/DeviceToolBar.cpp index 61475081e..a08296c24 100644 --- a/src/toolbars/DeviceToolBar.cpp +++ b/src/toolbars/DeviceToolBar.cpp @@ -812,3 +812,59 @@ void DeviceToolBar::OnChoice(wxCommandEvent &event) } } +void DeviceToolBar::ShowInputDialog() +{ + ShowComboDialog(mInput, wxString(_("Select Input Device"))); +} +void DeviceToolBar::ShowOutputDialog() +{ + ShowComboDialog(mOutput, wxString(_("Select Output Device"))); +} +void DeviceToolBar::ShowHostDialog() +{ + ShowComboDialog(mHost, wxString(_("Select Audio Host"))); +} +void DeviceToolBar::ShowChannelsDialog() +{ + ShowComboDialog(mInputChannels, wxString(_("Select Input Channels"))); +} + +void DeviceToolBar::ShowComboDialog(wxChoice *combo, wxString &title) +{ + if (!combo || combo->GetCount() == 0) { + wxMessageBox(_("Device information is not available.")); + return; + } + +#if USE_PORTMIXER + wxArrayString inputSources = combo->GetStrings(); + + wxDialog dlg(NULL, wxID_ANY, title); + ShuttleGui S(&dlg, eIsCreating); + wxChoice *c; + + S.StartVerticalLay(true); + { + S.StartHorizontalLay(wxCENTER, false); + { + c = S.AddChoice(combo->GetName(), + combo->GetStringSelection(), + &inputSources); + } + S.EndHorizontalLay(); + S.AddStandardButtons(); + } + S.EndVerticalLay(); + + dlg.SetSize(dlg.GetSizer()->GetMinSize()); + dlg.Center(); + + if (dlg.ShowModal() == wxID_OK) + { + wxCommandEvent e(wxEVT_COMMAND_CHOICE_SELECTED, dlg.GetId()); + combo->SetSelection(c->GetSelection()); + // This will fire an event which will invoke OnChoice above. + combo->ProcessCommand(e); + } +#endif +} diff --git a/src/toolbars/DeviceToolBar.h b/src/toolbars/DeviceToolBar.h index b49f3c0fe..428f0ffbb 100644 --- a/src/toolbars/DeviceToolBar.h +++ b/src/toolbars/DeviceToolBar.h @@ -57,6 +57,12 @@ class DeviceToolBar:public ToolBar { /// It should be small enough to work on tiny screens int GetInitialWidth() {return 520;} virtual int GetMinToolbarWidth() {return 200;} + + void ShowInputDialog(); + void ShowOutputDialog(); + void ShowHostDialog(); + void ShowChannelsDialog(); + private: int ChangeHost(); void FillHostDevices(); @@ -65,6 +71,8 @@ class DeviceToolBar:public ToolBar { void RepositionCombos(); void RegenerateTooltips(); + void ShowComboDialog(wxChoice *combo, wxString &title); + wxBitmap *mPlayBitmap; wxBitmap *mRecordBitmap;