mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 00:19:27 +02:00
Bug 2211 - Mac: keyboard navigation problem in Libraries preferences dialog
This commit is contained in:
parent
d01776be5a
commit
6450495426
@ -942,6 +942,7 @@ list( APPEND SOURCES
|
||||
widgets/PopupMenuTable.h
|
||||
widgets/ProgressDialog.cpp
|
||||
widgets/ProgressDialog.h
|
||||
widgets/ReadOnlyText.h
|
||||
widgets/Ruler.cpp
|
||||
widgets/Ruler.h
|
||||
widgets/Warning.cpp
|
||||
|
@ -114,6 +114,7 @@ for registering for changes.
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/bmpbuttn.h>
|
||||
#include "../include/audacity/ComponentInterface.h"
|
||||
#include "widgets/ReadOnlyText.h"
|
||||
#include "widgets/wxPanelWrapper.h"
|
||||
#include "widgets/wxTextCtrlWrapper.h"
|
||||
#include "AllThemeResources.h"
|
||||
@ -485,6 +486,27 @@ wxStaticText * ShuttleGuiBase::AddVariableText(
|
||||
return pStatic;
|
||||
}
|
||||
|
||||
ReadOnlyText * ShuttleGuiBase::AddReadOnlyText(
|
||||
const TranslatableString &Caption, const wxString &Value)
|
||||
{
|
||||
const auto translated = Caption.Translation();
|
||||
auto style = GetStyle( wxBORDER_NONE );
|
||||
HandleOptionality( Caption );
|
||||
mItem.miStyle = wxALIGN_CENTER_VERTICAL;
|
||||
AddPrompt( Caption );
|
||||
UseUpId();
|
||||
if( mShuttleMode != eIsCreating )
|
||||
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), ReadOnlyText);
|
||||
ReadOnlyText * pReadOnlyText;
|
||||
miProp=0;
|
||||
|
||||
mpWind = pReadOnlyText = safenew ReadOnlyText(GetParent(), miId, Value,
|
||||
wxDefaultPosition, wxDefaultSize, GetStyle( style ));
|
||||
mpWind->SetName(wxStripMenuCodes(translated));
|
||||
UpdateSizers();
|
||||
return pReadOnlyText;
|
||||
}
|
||||
|
||||
wxComboBox * ShuttleGuiBase::AddCombo(
|
||||
const TranslatableString &Prompt,
|
||||
const wxString &Selected, const wxArrayStringEx & choices )
|
||||
|
@ -70,6 +70,7 @@ class wxSpinCtrl;
|
||||
class wxListBox;
|
||||
class wxGrid;
|
||||
class Shuttle;
|
||||
class ReadOnlyText;
|
||||
|
||||
class WrappedType;
|
||||
|
||||
@ -300,6 +301,9 @@ public:
|
||||
wxStaticText * AddVariableText(
|
||||
const TranslatableString &Str, bool bCenter = false,
|
||||
int PositionFlags = 0, int wrapWidth = 0);
|
||||
ReadOnlyText * AddReadOnlyText(
|
||||
const TranslatableString &Caption,
|
||||
const wxString &Value);
|
||||
wxTextCtrl * AddTextBox(
|
||||
const TranslatableString &Caption,
|
||||
const wxString &Value, const int nChars);
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../TempDirectory.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ReadOnlyText.h"
|
||||
#include "../widgets/wxTextCtrlWrapper.h"
|
||||
|
||||
using namespace FileNames;
|
||||
@ -245,10 +246,8 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
|
||||
mTempText->SetValidator(FilesystemValidator(XO("Temporary files directory cannot be on a FAT drive.")));
|
||||
S.Id(TempButtonID).AddButton(XXO("Brow&se..."));
|
||||
|
||||
S.AddPrompt(XXO("&Free Space:"));
|
||||
mFreeSpace = S.AddTextBox({}, wxT(""), 30);
|
||||
mFreeSpace->SetName(XO("Free Space").Translation());
|
||||
((wxTextCtrlWrapper *) mFreeSpace)->SetReadOnly();
|
||||
mFreeSpace = S
|
||||
.AddReadOnlyText(XXO("&Free Space:"), "");
|
||||
}
|
||||
S.EndMultiColumn();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "PrefsPanel.h"
|
||||
|
||||
class ReadOnlyText;
|
||||
class ShuttleGui;
|
||||
|
||||
class wxStaticText;
|
||||
@ -42,7 +43,7 @@ class DirectoriesPrefs final : public PrefsPanel
|
||||
void OnBrowse(wxCommandEvent &evt);
|
||||
void OnText(wxCommandEvent &evt);
|
||||
|
||||
wxTextCtrl *mFreeSpace;
|
||||
ReadOnlyText *mFreeSpace;
|
||||
wxTextCtrl *mTempText;
|
||||
wxTextCtrl *mOpenText;
|
||||
wxTextCtrl *mSaveText;
|
||||
|
@ -29,6 +29,7 @@ MP3 and FFmpeg encoding libraries.
|
||||
#include "../export/ExportMP3.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ReadOnlyText.h"
|
||||
#include "../widgets/wxTextCtrlWrapper.h"
|
||||
|
||||
|
||||
@ -103,8 +104,8 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
S.StartTwoColumn();
|
||||
{
|
||||
mMP3Version = S
|
||||
.AddTextBox(XO("MP3 Library Version:"), "", 50);
|
||||
((wxTextCtrlWrapper *) mMP3Version)->SetReadOnly();
|
||||
.Position(wxALIGN_CENTRE_VERTICAL)
|
||||
.AddReadOnlyText(XO("MP3 Library Version:"), "");
|
||||
}
|
||||
S.EndTwoColumn();
|
||||
}
|
||||
@ -122,8 +123,8 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
#endif
|
||||
|
||||
mFFmpegVersion = S
|
||||
.AddTextBox(XO("FFmpeg Library Version:"), version.Translation(), 50);
|
||||
((wxTextCtrlWrapper *) mFFmpegVersion)->SetReadOnly();
|
||||
.Position(wxALIGN_CENTRE_VERTICAL)
|
||||
.AddReadOnlyText(XO("FFmpeg Library Version:"), version.Translation());
|
||||
|
||||
S.AddVariableText(XO("FFmpeg Library:"),
|
||||
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
||||
@ -155,8 +156,7 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
/// of the MP3 Library version.
|
||||
void LibraryPrefs::SetMP3VersionText(bool prompt)
|
||||
{
|
||||
mMP3Version->SetValue(GetMP3Version(this, prompt).Translation());
|
||||
mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
|
||||
mMP3Version->SetValue(GetMP3Version(this, prompt));
|
||||
}
|
||||
|
||||
/// Opens a file-finder dialog so that the user can
|
||||
@ -175,8 +175,7 @@ void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
|
||||
|
||||
void LibraryPrefs::SetFFmpegVersionText()
|
||||
{
|
||||
mFFmpegVersion->SetValue(GetFFmpegVersion().Translation());
|
||||
mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
|
||||
mFFmpegVersion->SetValue(GetFFmpegVersion());
|
||||
}
|
||||
|
||||
void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
class wxStaticText;
|
||||
class wxTextCtrl;
|
||||
class ReadOnlyText;
|
||||
class ShuttleGui;
|
||||
|
||||
#define LIBRARY_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Library") }
|
||||
@ -45,8 +46,8 @@ class LibraryPrefs final : public PrefsPanel
|
||||
void OnFFmpegFindButton(wxCommandEvent & e);
|
||||
void OnFFmpegDownButton(wxCommandEvent & e);
|
||||
|
||||
wxTextCtrl *mMP3Version;
|
||||
wxTextCtrl *mFFmpegVersion;
|
||||
ReadOnlyText *mMP3Version;
|
||||
ReadOnlyText *mFFmpegVersion;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
134
src/widgets/ReadOnlyText.h
Normal file
134
src/widgets/ReadOnlyText.h
Normal file
@ -0,0 +1,134 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ReadOnlyText.h
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_READONLYTEXT__
|
||||
#define __AUDACITY_READONLYTEXT__
|
||||
|
||||
#include "../Audacity.h"
|
||||
|
||||
#include "WindowAccessible.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
|
||||
class ReadOnlyTextAx final : public WindowAccessible
|
||||
{
|
||||
public:
|
||||
ReadOnlyTextAx(wxWindow * window)
|
||||
: WindowAccessible(window)
|
||||
{
|
||||
}
|
||||
|
||||
~ReadOnlyTextAx()
|
||||
{
|
||||
}
|
||||
|
||||
wxAccStatus GetRole(int childId, wxAccRole *role)
|
||||
{
|
||||
*role = wxROLE_SYSTEM_STATICTEXT;
|
||||
|
||||
return wxACC_OK;
|
||||
}
|
||||
|
||||
wxAccStatus GetState(int childId, long *state)
|
||||
{
|
||||
auto w = GetWindow();
|
||||
*state = wxACC_STATE_SYSTEM_FOCUSABLE | wxACC_STATE_SYSTEM_READONLY;
|
||||
*state |= ( w == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
|
||||
|
||||
return wxACC_OK;
|
||||
}
|
||||
|
||||
wxAccStatus GetValue(int childId, wxString* strValue)
|
||||
{
|
||||
*strValue = GetWindow()->GetLabel();
|
||||
|
||||
return wxACC_OK;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
class ReadOnlyText final : public wxControl
|
||||
{
|
||||
public:
|
||||
ReadOnlyText(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString &value,
|
||||
const wxPoint &pos = wxDefaultPosition,
|
||||
const wxSize &size = wxDefaultSize,
|
||||
long style = wxBORDER_NONE)
|
||||
: wxControl(parent, id, pos, size, style)
|
||||
{
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
SetAccessible(safenew ReadOnlyTextAx(this));
|
||||
#endif
|
||||
SetInitialSize(size);
|
||||
|
||||
Bind(wxEVT_SET_FOCUS, [&](wxFocusEvent &event)
|
||||
{
|
||||
SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
|
||||
Refresh();
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
Bind(wxEVT_KILL_FOCUS, [&](wxFocusEvent &event)
|
||||
{
|
||||
SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
Refresh();
|
||||
event.Skip();
|
||||
});
|
||||
|
||||
Bind(wxEVT_PAINT, [&](wxPaintEvent & WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
|
||||
wxRect rect = GetClientRect();
|
||||
if (!IsEnabled())
|
||||
{
|
||||
// draw shadow of the text
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
|
||||
wxRect rectShadow = rect;
|
||||
rectShadow.Offset(1, 1);
|
||||
dc.DrawLabel(GetLabel(), rectShadow, GetAlignment());
|
||||
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
|
||||
}
|
||||
dc.DrawLabel(GetLabel(), rect, GetAlignment());
|
||||
});
|
||||
};
|
||||
|
||||
~ReadOnlyText()
|
||||
{
|
||||
};
|
||||
|
||||
wxSize DoGetBestClientSize() const override
|
||||
{
|
||||
wxClientDC dc(wxConstCast(this, ReadOnlyText));
|
||||
|
||||
return dc.GetMultiLineTextExtent(GetLabel());
|
||||
}
|
||||
|
||||
wxString GetValue()
|
||||
{
|
||||
return GetLabel();
|
||||
}
|
||||
|
||||
void SetValue(const wxString &value)
|
||||
{
|
||||
SetLabel(value);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void SetValue(const TranslatableString &value)
|
||||
{
|
||||
SetValue(value.Translation());
|
||||
}
|
||||
};
|
||||
|
||||
#endif // __AUDACITY_READONLYTEXT__
|
Loading…
x
Reference in New Issue
Block a user