Audacity  3.0.3
MousePrefs.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  MousePrefs.cpp
6 
7  James Crook
8 
9 ********************************************************************//********************************************************************/
34 
35 
36 #include "MousePrefs.h"
37 
38 #include <wx/defs.h>
39 #include <wx/intl.h>
40 #include <wx/listctrl.h>
41 
42 #include "../Prefs.h"
43 #include "../ShuttleGui.h"
44 
45 // The numbers of the columns of the mList.
46 enum
47 {
52 };
53 
54 #if defined(__WXMAC__)
55 #define CTRL XO("Command")
56 #else
57 #define CTRL XO("Ctrl")
58 #endif
59 
61 MousePrefs::MousePrefs(wxWindow * parent, wxWindowID winid)
62 : PrefsPanel(parent, winid, XO("Mouse"))
63 {
64  Populate();
65 
66  // See bug #2315 for discussion. This should be reviewed
67  // and (possibly) removed after wx3.1.3.
68  Bind(wxEVT_SHOW, &MousePrefs::OnShow, this);
69 }
70 
72 {
73 }
74 
76 {
78 }
79 
81 {
82  return XO("Preferences for Mouse");
83 }
84 
86 {
87  return "Mouse_Preferences";
88 }
89 
92 {
93  //------------------------- Main section --------------------
94  // Now construct the GUI itself.
95  // Use 'eIsCreatingFromPrefs' so that the GUI is
96  // initialised with values from gPrefs.
99  // ----------------------- End of main section --------------
100  CreateList();
101  if (mList->GetItemCount() > 0) {
102  // set first item to be selected (and the focus when the
103  // list first becomes the focus)
104  mList->SetItemState(0, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
105  wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
106  }
107 }
108 
111 {
112  S.SetBorder(2);
113 
114  S.StartStatic(XO("Mouse Bindings (default values, not configurable)"), 1);
115  {
117  }
118  S.EndStatic();
119 }
120 
123 {
124  //A dummy first column, which is then deleted, is a workaround - under Windows the first column
125  //can't be right aligned.
126  mList->InsertColumn(0, wxT(""), wxLIST_FORMAT_LEFT);
127  mList->InsertColumn(ToolColumn + 1, _("Tool"), wxLIST_FORMAT_RIGHT);
128  mList->InsertColumn(ActionColumn + 1, _("Command Action"), wxLIST_FORMAT_RIGHT);
129  mList->InsertColumn(ButtonsColumn + 1, _("Buttons"), wxLIST_FORMAT_LEFT);
130  mList->InsertColumn(CommentColumn + 1, _("Comments"), wxLIST_FORMAT_LEFT);
131  mList->DeleteColumn(0);
132 
133  AddItem(XO("Left-Click"), XO("Select"), XO("Set Selection Point"));
134  AddItem(XO("Left-Drag"), XO("Select"), XO("Set Selection Range"));
135  AddItem(XO("Shift-Left-Click"), XO("Select"), XO("Extend Selection Range"));
136  AddItem(XO("Left-Double-Click"), XO("Select"), XO("Select Clip or Entire Track"));
137 #ifdef EXPERIMENTAL_SCRUBBING_SCROLL_WHEEL
138  AddItem(XO("Wheel-Rotate"), XO("Select"), XO("Change scrub speed"));
139 #endif
140 
141 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
142  // JKC: Prompt is disabled for now. It's a toggle rather than a drag modifier.
143  // more like Snap-to than anything else.
144  // Spectral selection
145  // AddItem(XO("ESC"), XO("Select"), XO("Toggle center snapping in spectrogram"));
146 #endif
147 
148  AddItem(XO("Left-Click"), XO("Zoom"), XO("Zoom in on Point"));
149  AddItem(XO("Left-Drag"), XO("Zoom"), XO("Zoom in on a Range"), XO("same as right-drag"));
150  AddItem(XO("Right-Click"), XO("Zoom"), XO("Zoom out one step"));
151  AddItem(XO("Right-Drag"), XO("Zoom"), XO("Zoom in on a Range"), XO("same as left-drag"));
152  AddItem(XO("Shift-Drag"), XO("Zoom"), XO("Zoom out on a Range"));
153  AddItem(XO("Middle-Click"), XO("Zoom"), XO("Zoom default"));
154 
155  AddItem(XO("Left-Drag"), XO("Time-Shift"),XO("Move clip left/right or between tracks"));
156  AddItem(XO("Shift-Left-Drag"), XO("Time-Shift"),XO("Move all clips in track left/right"));
157  AddItem(CTRL + XO("-Left-Drag"),XO("Time-Shift"),XO("Move clip up/down between tracks"));
158 
159  AddItem(XO("Left-Drag"),
160  /* i18n-hint: The envelope is a curve that controls the audio loudness.*/
161  XO("Envelope"),
162  /* i18n-hint: The envelope is a curve that controls the audio loudness.*/
163  XO("Change Amplification Envelope"));
164 
165  AddItem(XO("Left-Click"), XO("Pencil"), XO("Change Sample"));
166  AddItem(XO("Alt-Left-Click"), XO("Pencil"), XO("Smooth at Sample"));
167  AddItem(XO("Left-Drag"), XO("Pencil"), XO("Change Several Samples"));
168  AddItem(CTRL + XO("-Left-Drag"),XO("Pencil"), XO("Change ONE Sample only"));
169 
170  AddItem(XO("Left-Click"), XO("Multi"), XO("Set Selection Point"), XO("same as select tool"));
171  AddItem(XO("Left-Drag"), XO("Multi"), XO("Set Selection Range"), XO("same as select tool"));
172  AddItem(XO("Right-Click"), XO("Multi"), XO("Zoom out one step"), XO("same as zoom tool"));
173  AddItem(XO("Right-Drag"), XO("Multi"), XO("Zoom in on a Range"), XO("same as zoom tool"));
174 
175 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
176  // JKC: Prompt is disabled for now. It's a toggle rather than a drag modifier.
177  // more like Snap-to than anything else.
178  // Spectral selection
179  // AddItem(XO("ESC"), XO("Select"), XO("Toggle center snapping in spectrogram"), XO("same as select tool"));
180 #endif
181 
182  AddItem(XO("Wheel-Rotate"), XO("Any"), XO("Scroll tracks up or down"));
183  AddItem(XO("Shift-Wheel-Rotate"), XO("Any"), XO("Scroll waveform"));
184  AddItem(CTRL + XO("-Wheel-Rotate"), XO("Any"), XO("Zoom waveform in or out"));
185  AddItem(CTRL + XO("-Shift-Wheel-Rotate"), XO("Any"), XO("Vertical Scale Waveform (dB) range"));
186 
187  mList->SetColumnWidth(ToolColumn, wxLIST_AUTOSIZE);
188  mList->SetColumnWidth(ActionColumn, wxLIST_AUTOSIZE);
189  mList->SetColumnWidth(ButtonsColumn, wxLIST_AUTOSIZE);
190  mList->SetColumnWidth(CommentColumn, wxLIST_AUTOSIZE);
191 
192 // PRL commented out, didn't look good to me on Mac at least
193 /*
194  // Not sure if this extra column is a good idea or not.
195  // Anyway, 5 pixels wide is wide enough that some people who are curious will drag it
196  // wider to see what's there (the comments show that the duplication of functions
197  // is for a reason, and not just random).
198  mList->SetColumnWidth(CommentColumn, 5);
199  */
200 }
201 
204  TranslatableString const & buttons, TranslatableString const & tool,
205  TranslatableString const & action, TranslatableString const & comment)
206 {
207  int i = mList->GetItemCount();
208  mList->InsertItem(i, tool.Translation());
209  mList->SetItem(i, ActionColumn, action.Translation());
210  mList->SetItem(i, ButtonsColumn, buttons.Translation());
211 
212  // Add a space before the text to work around a minor bug in the
213  // list control when showing narrow columns.
214  mList->SetItem(i, CommentColumn, wxT(" ") + comment.Translation());
215 }
216 
217 // See bug #2315 for discussion. This should be reviewed
218 // and (possibly) removed after wx3.1.3.
219 void MousePrefs::OnShow(wxShowEvent &event)
220 {
221  event.Skip();
222 
223  if (event.IsShown())
224  {
225  mList->Refresh();
226  }
227 }
228 
232 {
233 // Not yet required...
234 // ShuttleGui S(this, eIsSavingToPrefs);
235 // PopulateOrExchange(S);
236  return true;
237 }
238 
239 namespace{
241  [](wxWindow *parent, wxWindowID winid, AudacityProject *)
242  {
243  wxASSERT(parent); // to justify safenew
244  return safenew MousePrefs(parent, winid);
245  }
246 };
247 }
MousePrefs::Commit
bool Commit() override
Definition: MousePrefs.cpp:231
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
MousePrefs::Populate
void Populate()
Creates the dialog and its contents.
Definition: MousePrefs.cpp:91
MousePrefs.h
MousePrefs::GetDescription
TranslatableString GetDescription() override
Definition: MousePrefs.cpp:80
CTRL
#define CTRL
Definition: MousePrefs.cpp:57
ActionColumn
@ ActionColumn
Definition: MousePrefs.cpp:49
MousePrefs::MousePrefs
MousePrefs(wxWindow *parent, wxWindowID winid)
Constructor.
Definition: MousePrefs.cpp:61
CommentColumn
@ CommentColumn
Definition: MousePrefs.cpp:51
MousePrefs::HelpPageName
wxString HelpPageName() override
Definition: MousePrefs.cpp:85
MousePrefs::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: MousePrefs.cpp:75
PrefsPanel::Registration
Definition: PrefsPanel.h:84
XO
#define XO(s)
Definition: Internat.h:31
MOUSE_PREFS_PLUGIN_SYMBOL
#define MOUSE_PREFS_PLUGIN_SYMBOL
Definition: MousePrefs.h:20
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:61
MousePrefs::~MousePrefs
~MousePrefs()
Definition: MousePrefs.cpp:71
ToolColumn
@ ToolColumn
Definition: MousePrefs.cpp:48
MousePrefs
A PrefsPanel that presents an interface for user to view the default bindings of mouse buttons to com...
Definition: MousePrefs.h:23
ButtonsColumn
@ ButtonsColumn
Definition: MousePrefs.cpp:50
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
MousePrefs::AddItem
void AddItem(TranslatableString const &buttons, TranslatableString const &tool, TranslatableString const &action, TranslatableString const &comment={})
Adds an item to mList.
Definition: MousePrefs.cpp:203
MousePrefs::mList
wxListCtrl * mList
Definition: MousePrefs.h:46
_
#define _(s)
Definition: Internat.h:75
ShuttleGuiBase::AddListControlReportMode
wxListCtrl * AddListControlReportMode(std::initializer_list< const ListControlColumn > columns={}, long listControlStyles=0)
Definition: ShuttleGui.cpp:795
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
MousePrefs::CreateList
void CreateList()
Creates the contents of mList.
Definition: MousePrefs.cpp:122
anonymous_namespace{MousePrefs.cpp}::sAttachment
PrefsPanel::Registration sAttachment
Definition: MousePrefs.cpp:240
PrefsPanel
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
TranslatableString::Translation
wxString Translation() const
Definition: TranslatableString.h:79
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:484
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
safenew
#define safenew
Definition: MemoryX.h:10
MousePrefs::OnShow
void OnShow(wxShowEvent &event)
Definition: MousePrefs.cpp:219
MousePrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Places controls on the panel and also exchanges data with them.
Definition: MousePrefs.cpp:110
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625