mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 17:11:17 +02:00
Dialog for the name of a label: positioning fixes
Problems fixed: 1. When adding a label at playback position, the position of the dialog was calculated using the position of the edit cursor 2. When adding a label at selection, the dialog could be to the left of the Audacity Window, and indeed offscreen.
This commit is contained in:
parent
d716b61b1e
commit
5494185a88
@ -2102,7 +2102,7 @@ bool LabelTrack::OnChar(SelectedRegion &WXUNUSED(newSel), wxKeyEvent & event)
|
|||||||
gPrefs->Read(wxT("/Gui/DialogForNameNewLabel"), &useDialog, false);
|
gPrefs->Read(wxT("/Gui/DialogForNameNewLabel"), &useDialog, false);
|
||||||
if (useDialog) {
|
if (useDialog) {
|
||||||
wxString title;
|
wxString title;
|
||||||
if (MenuCommandHandler::DialogForLabelName(*p, charCode, title) ==
|
if (MenuCommandHandler::DialogForLabelName(*p, p->mViewInfo.selectedRegion, charCode, title) ==
|
||||||
wxID_CANCEL) {
|
wxID_CANCEL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9437,14 +9437,18 @@ void MenuCommandHandler::OnRescanDevices(const CommandContext &WXUNUSED(context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MenuCommandHandler::DialogForLabelName(
|
int MenuCommandHandler::DialogForLabelName(
|
||||||
AudacityProject &project, const wxString& initialValue, wxString& value)
|
AudacityProject &project,
|
||||||
|
const SelectedRegion& region, const wxString& initialValue, wxString& value)
|
||||||
{
|
{
|
||||||
auto trackPanel = project.GetTrackPanel();
|
auto trackPanel = project.GetTrackPanel();
|
||||||
auto &viewInfo = project.GetViewInfo();
|
auto &viewInfo = project.GetViewInfo();
|
||||||
|
|
||||||
wxPoint position = trackPanel->FindTrackRect(trackPanel->GetFocusedTrack(), false).GetBottomLeft();
|
wxPoint position = trackPanel->FindTrackRect(trackPanel->GetFocusedTrack(), false).GetBottomLeft();
|
||||||
// the start of the text in the text box will be roughly in line with Audacity's edit cursor
|
// The start of the text in the text box will be roughly in line with the label's position
|
||||||
position.x += trackPanel->GetLabelWidth() + viewInfo.TimeToPosition(viewInfo.selectedRegion.t0()) - 40;
|
// if it's a point label, or the start of its region if it's a region label.
|
||||||
|
position.x += trackPanel->GetLabelWidth()
|
||||||
|
+ std::max(0, static_cast<int>(viewInfo.TimeToPosition(region.t0())))
|
||||||
|
-40;
|
||||||
position.y += 2; // just below the bottom of the track
|
position.y += 2; // just below the bottom of the track
|
||||||
position = trackPanel->ClientToScreen(position);
|
position = trackPanel->ClientToScreen(position);
|
||||||
AudacityTextEntryDialog dialog{ &project,
|
AudacityTextEntryDialog dialog{ &project,
|
||||||
@ -9615,7 +9619,7 @@ int MenuCommandHandler::DoAddLabel(
|
|||||||
bool useDialog;
|
bool useDialog;
|
||||||
gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
|
gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
|
||||||
if (useDialog) {
|
if (useDialog) {
|
||||||
if (DialogForLabelName(project, wxEmptyString, title) == wxID_CANCEL)
|
if (DialogForLabelName(project, region, wxEmptyString, title) == wxID_CANCEL)
|
||||||
return -1; // index
|
return -1; // index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,8 @@ int DoAddLabel(
|
|||||||
AudacityProject &project,
|
AudacityProject &project,
|
||||||
const SelectedRegion& region, bool preserveFocus = false);
|
const SelectedRegion& region, bool preserveFocus = false);
|
||||||
static int DialogForLabelName(
|
static int DialogForLabelName(
|
||||||
AudacityProject &project, const wxString& initialValue, wxString& value);
|
AudacityProject &project,
|
||||||
|
const SelectedRegion& region, const wxString& initialValue, wxString& value);
|
||||||
|
|
||||||
double NearestZeroCrossing(AudacityProject &project, double t0);
|
double NearestZeroCrossing(AudacityProject &project, double t0);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user