23#include <wx/scrolbar.h>
24#include <wx/settings.h>
25#include <wx/stattext.h>
26#include <wx/textdlg.h>
107 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
110 , mSelectedTrack(selectedTrack)
112 , mViewInfo(&viewinfo)
114 , mFreqFormat(freqFormat)
127 mGrid->CreateGrid(0,
Col_Max, wxGrid::wxGridSelectRows);
128 mGrid->SetDefaultCellAlignment(wxALIGN_LEFT, wxALIGN_CENTER);
129 mGrid->SetRowLabelSize(0);
132 for (
const auto &
label : {
144 XO(
"High Frequency"),
158 wxGridCellAttr *attr;
168 attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER);
177 attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER);
189 mGrid->SetRowMinimalAcceptableHeight(0);
190 mGrid->EnableDragRowSize(
false);
227 wxRect r =
mGrid->GetGridColLabelWindow()->GetRect();
228 wxScrollBar sb(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_VERTICAL);
229 r.width += sb.GetSize().GetWidth() + 6;
232 wxWindow * w = FindWindowById(
ID_IMPORT,
this );
235 r.width += w->GetSize().GetWidth();
237 SetClientSize(r.width, 300);
241 SetSizeHints(r.GetWidth(), r.GetHeight());
253 S.AddFixedText(
XO(
"Press F2 or double click to edit cell contents."));
254 S.StartHorizontalLay(wxEXPAND,1);
256 S.StartVerticalLay(wxEXPAND,1);
261 S.Prop(1).AddWindow(
mGrid);
264 S.StartVerticalLay(0);
275 S.EndHorizontalLay();
277 S.StartHorizontalLay(wxALIGN_RIGHT,
false);
281 S.EndHorizontalLay();
293 int cnt =
mData.size();
306 if (
mGrid->GetNumberRows()) {
311 mGrid->InsertRows(0, cnt);
314 for (i = 0; i < cnt; i++) {
331 mGrid->AutoSizeRows(
true);
335 wxChoice tc(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
mTrackNames);
355#if defined(__WXMAC__) || defined(__WXGTK__)
372 int cnt =
mData.size();
380 for (i = lt->GetNumLabels() - 1; i >= 0 ; i--) {
399 auto newTrack = std::make_shared<LabelTrack>();
400 newTrack->SetName(
name);
406 for (i = 0; i < cnt; i++) {
414 if (rd.
index == tndx++) {
432 if (
mGrid->IsCellEditControlShown()) {
433 mGrid->HideCellEditControl();
434 mGrid->SaveEditControlValue();
443 if (index < 1 || index >= (
int)
mTrackNames.size()) {
445 mTrackNames.push_back(wxString::Format(
wxT(
"%d - %s"), index, dflt));
461 if (
mData.size() == 0) {
489 int cnt =
mData.size();
497 double distMin = std::numeric_limits<double>::max();
501 for (i = 0; i < cnt; i++)
503 dist = t0 -
mData[i].selectedRegion.t0();
504 if (dist >= 0.0 && dist < distMin)
515 double t0Min = std::numeric_limits<double>::max();
516 for (i = 0; i < cnt; i++)
518 if (
mData[i].selectedRegion.t0() < t0Min)
521 t0Min =
mData[i].selectedRegion.t0();
551 int cnt =
mData.size();
556 if (
mGrid->IsCellEditControlShown()) {
557 mGrid->HideCellEditControl();
562 row =
mGrid->GetGridCursorRow();
563 if (row > 0 && row >= cnt) {
574 if (event.GetId() ==
ID_INSERTA && row < cnt) {
585 mGrid->EnableCellEditControl(
true);
586 mGrid->ShowCellEditControl();
591 int row =
mGrid->GetGridCursorRow();
592 int col =
mGrid->GetGridCursorCol();
593 int cnt =
mData.size();
601 if (
mGrid->IsCellEditControlShown()) {
602 mGrid->HideCellEditControl();
613 if (row > 0 && row >= --cnt) {
616 mGrid->SetGridCursor(row, col);
620 wxWindow *ok = wxWindow::FindWindowById( wxID_OK,
this);
632 XO(
"Select a text file containing labels"),
641 if (!fileName.empty()) {
650 XO(
"Could not open file: %s").
Format( fileName ) );
655 auto lt = std::make_shared<LabelTrack>();
671 int cnt =
mData.size();
682 fName =
SelectFile(FileNames::Operation::Export,
683 XO(
"Export Labels As:"),
688 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
699 if (wxFileExists(fName)) {
701 wxString safetyFileName = fName +
wxT(
"~");
703 wxString safetyFileName = fName +
wxT(
".bak");
706 if (wxFileExists(safetyFileName))
707 wxRemoveFile(safetyFileName);
709 wxRename(fName, safetyFileName);
714 wxFile{}.Create(fName);
721 XO(
"Couldn't write to file: %s").
Format( fName ) );
726 auto lt = std::make_shared<LabelTrack>();
729 for (i = 0; i < cnt; i++) {
739 f.Write(wxTextFileType_Mac);
749 t->SetSelected(
true );
764 static bool guard =
false;
765 int row =
event.GetRow();
780 switch (event.GetCol())
820 XO(
"New Label Track"),
821 XO(
"Enter track name"),
823 XO(
"Label Track").Translation());
827 if (d.ShowModal() == wxID_CANCEL) {
904 wxSize sz = GetSize();
905 int prefWidth, prefHeight;
909 wxRect screenRect(wxGetClientDisplayRect());
910 wxSize prefSize = wxSize(prefWidth, prefHeight);
911 prefSize.DecTo(screenRect.GetSize());
916 wxSize sz = GetSize();
924 if (
mGrid->IsCellEditControlShown()) {
925 mGrid->SaveEditControlValue();
926 mGrid->HideCellEditControl();
941 if (
mGrid->IsCellEditControlShown()) {
942 auto editor =
mGrid->GetCellEditor(
mGrid->GetGridCursorRow(),
943 mGrid->GetGridCursorCol());
947 mGrid->HideCellEditControl();
953 EndModal(wxID_CANCEL);
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XXO("&Cut/Copy/Paste Toolbar")
#define GRID_VALUE_FREQUENCY
#define GRID_VALUE_CHOICE
IteratorRange< Iterator > make_iterator_range(const Iterator &i1, const Iterator &i2)
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
const NumericConverterType & NumericConverterType_FREQUENCY()
const NumericConverterType & NumericConverterType_TIME()
audacity::BasicSettings * gPrefs
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Wrap wxTextEntryDialog so that caption IS translatable.
Modified version of wxGridChoiceEditor using wxChoice instead of wxComboBox.
void SetChoices(const wxArrayString &choices)
const wxString & Internal() const
FILES_API const FileType AllFiles
FILES_API const FileType TextFiles
static FormatterContext ProjectContext(const AudacityProject &project)
Supplies an accessible grid based on wxGrid.
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Dialog for editing labels.
void OnChangeEtime(wxGridEvent &event, int row, RowData *rd)
void OnFreqUpdate(wxCommandEvent &event)
void OnChangeTrack(wxGridEvent &event, int row, RowData *rd)
void OnRemove(wxCommandEvent &event)
wxString TrackName(int &index, const wxString &dflt=_("Label Track"))
ChoiceEditor * mChoiceEditor
bool TransferDataToWindow() override
void AddLabels(const LabelTrack *t)
void OnSelectCell(wxGridEvent &event)
LabelTrack * mSelectedTrack
void OnHelp(wxCommandEvent &event)
void OnOK(wxCommandEvent &event)
void OnCellChange(wxGridEvent &event)
void OnChangeLabel(wxGridEvent &event, int row, RowData *rd)
void OnInsert(wxCommandEvent &event)
void OnChangeLfreq(wxGridEvent &event, int row, RowData *rd)
NumericFormatID mFreqFormat
NumericEditor * mFrequencyEditor
wxArrayString mTrackNames
void OnCancel(wxCommandEvent &event)
ManualPageID GetHelpPageName()
AudacityProject & mProject
bool TransferDataFromWindow() override
void OnExport(wxCommandEvent &event)
void OnChangeStime(wxGridEvent &event, int row, RowData *rd)
void PopulateOrExchange(ShuttleGui &S)
void OnImport(wxCommandEvent &event)
void OnUpdate(wxCommandEvent &event)
NumericEditor * mTimeEditor
bool Show(bool show=true) override
void OnChangeHfreq(wxGridEvent &event, int row, RowData *rd)
void Populate()
Creates the dialog and its contents.
A LabelStruct holds information for ONE label in a LabelTrack.
SelectedRegion selectedRegion
A LabelTrack is a Track that holds labels (LabelStruct).
static const FileNames::FileType WebVTTFiles
const LabelStruct * GetLabel(int index) const
static const FileNames::FileType SubripFiles
static LabelFormat FormatForFileName(const wxString &fileName)
void ResetTextSelection()
static LabelTrackView & Get(LabelTrack &)
wxGridCellEditor for the NumericTextCtrl.
void SetFormat(const NumericFormatID &format)
SelectedRegion selectedRegion
RowData(int index_, const wxString &title_, const SelectedRegion &selectedRegion_)
Defines a selected portion of a project.
bool setF0(double f, bool maySwap=true)
bool setF1(double f, bool maySwap=true)
bool setT0(double t, bool maySwap=true)
bool setT1(double t, bool maySwap=true)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
const wxString & GetName() const
Name is always the same for all channels of a group.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
auto Any() -> TrackIterRange< TrackType >
TrackKind * Add(const std::shared_ptr< TrackKind > &t, bool assignIds=true)
wxString Translation() const
NotifyingSelectedRegion selectedRegion
static Viewport & Get(AudacityProject &project)
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
IMPORT_EXPORT_API ExportResult Show(ExportTask exportTask)