Audacity 3.2.0
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrackPanelAx Class Referencefinal

Helper to TrackPanel to give accessibility. More...

#include <TrackPanelAx.h>

Inheritance diagram for TrackPanelAx:
[legend]
Collaboration diagram for TrackPanelAx:
[legend]

Classes

struct  Adapter
 

Public Types

using RectangleFinder = std::function< wxRect(Track &) >
 

Public Member Functions

 TrackPanelAx (std::weak_ptr< Viewport > wViewport, std::weak_ptr< TrackFocus > wFocus, RectangleFinder finder)
 
 ~TrackPanelAx () override
 
void Updated ()
 
void MessageForScreenReader (const TranslatableString &message) override
 
wxWindow * GetWindow () const
 
void SetWindow (wxWindow *window)
 
- Public Member Functions inherited from TrackFocusCallbacks
virtual ~TrackFocusCallbacks ()
 
virtual void MessageForScreenReader (const TranslatableString &message)=0
 
virtual void BeginChangeFocus ()=0
 
virtual void EndChangeFocus (const std::shared_ptr< Track > &track)=0
 
virtual void UpdateAccessibility ()=0
 

Private Member Functions

void BeginChangeFocus () override
 
void EndChangeFocus (const std::shared_ptr< Track > &track) override
 
void UpdateAccessibility () override
 

Private Attributes

std::weak_ptr< ViewportmwViewport
 
std::weak_ptr< TrackFocusmwFocus
 
wxWindow * mWindow {}
 
RectangleFinder mFinder
 
wxString mMessage
 
int mMessageCount { 0 }
 
bool mTrackName { true }
 

Detailed Description

Helper to TrackPanel to give accessibility.

Definition at line 28 of file TrackPanelAx.h.

Member Typedef Documentation

◆ RectangleFinder

using TrackPanelAx::RectangleFinder = std::function< wxRect(Track&) >

Definition at line 50 of file TrackPanelAx.h.

Constructor & Destructor Documentation

◆ TrackPanelAx()

TrackPanelAx::TrackPanelAx ( std::weak_ptr< Viewport wViewport,
std::weak_ptr< TrackFocus wFocus,
RectangleFinder  finder 
)

Definition at line 63 of file TrackPanelAx.cpp.

65 :
66#if wxUSE_ACCESSIBILITY
67 // window pointer must be set after construction
68 WindowAccessible(nullptr),
69#endif
70 mwViewport{ move(wViewport) },
71 mwFocus{ move(wFocus) }
72 , mFinder{ move(finder) }
73{
74}
RectangleFinder mFinder
Definition: TrackPanelAx.h:142
std::weak_ptr< Viewport > mwViewport
Definition: TrackPanelAx.h:135
std::weak_ptr< TrackFocus > mwFocus
Definition: TrackPanelAx.h:136
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...

◆ ~TrackPanelAx()

TrackPanelAx::~TrackPanelAx ( )
override

Definition at line 76 of file TrackPanelAx.cpp.

77{
78}

Member Function Documentation

◆ BeginChangeFocus()

void TrackPanelAx::BeginChangeFocus ( )
overrideprivatevirtual

Implements TrackFocusCallbacks.

Definition at line 80 of file TrackPanelAx.cpp.

81{
82 mTrackName = true;
83#if wxUSE_ACCESSIBILITY
84 auto pFocus = mwFocus.lock();
85 if (!pFocus)
86 return;
87
88 auto focusedTrack = pFocus->PeekFocus();
89 if (focusedTrack && !focusedTrack->GetSelected()) {
90 NotifyEvent( wxACC_EVENT_OBJECT_SELECTIONREMOVE,
91 GetWindow(),
92 wxOBJID_CLIENT,
93 pFocus->TrackNum(focusedTrack));
94 }
95#endif
96}
wxWindow * GetWindow() const
Definition: TrackPanelAx.h:126

References GetWindow(), mTrackName, and mwFocus.

Here is the call graph for this function:

◆ EndChangeFocus()

void TrackPanelAx::EndChangeFocus ( const std::shared_ptr< Track > &  track)
overrideprivatevirtual

Implements TrackFocusCallbacks.

Definition at line 98 of file TrackPanelAx.cpp.

99{
100#if wxUSE_ACCESSIBILITY
101 auto pFocus = mwFocus.lock();
102 if (!pFocus)
103 return;
104
105 if (track) {
106 if (GetWindow() == wxWindow::FindFocus()) {
107 NotifyEvent( wxACC_EVENT_OBJECT_FOCUS,
108 GetWindow(),
109 wxOBJID_CLIENT,
110 pFocus->NumFocusedTrack());
111 }
112
113 if (track->GetSelected()) {
114 NotifyEvent( wxACC_EVENT_OBJECT_SELECTION,
115 GetWindow(),
116 wxOBJID_CLIENT,
117 pFocus->NumFocusedTrack());
118 }
119 }
120 else {
121 NotifyEvent(wxACC_EVENT_OBJECT_FOCUS,
122 GetWindow(),
123 wxOBJID_CLIENT,
124 wxACC_SELF);
125 }
126
127#endif
128}
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:375

References BasicUI::FindFocus(), GetWindow(), and mwFocus.

Here is the call graph for this function:

◆ GetWindow()

wxWindow * TrackPanelAx::GetWindow ( ) const
inline

Definition at line 126 of file TrackPanelAx.h.

126{ return mWindow; }
wxWindow * mWindow
Definition: TrackPanelAx.h:139

References mWindow.

Referenced by BeginChangeFocus(), EndChangeFocus(), MessageForScreenReader(), and Updated().

Here is the caller graph for this function:

◆ MessageForScreenReader()

void TrackPanelAx::MessageForScreenReader ( const TranslatableString message)
overridevirtual

Implements TrackFocusCallbacks.

Definition at line 159 of file TrackPanelAx.cpp.

160{
161#if wxUSE_ACCESSIBILITY
162 auto pFocus = mwFocus.lock();
163 if (!pFocus)
164 return;
165
167 {
168 auto t = pFocus->GetFocus();
169 int childId = t ? pFocus->TrackNum(t) : 0;
170
171 mMessage = message.Translation();
172
173 // append \a alternatively, so that the string is never the same as the previous string.
174 // This ensures that screen readers read it.
175 if (mMessageCount % 2 == 0)
176 mMessage.Append('\a');
178
179 mTrackName = false;
180 NotifyEvent(wxACC_EVENT_OBJECT_NAMECHANGE,
181 GetWindow(),
182 wxOBJID_CLIENT,
183 childId);
184 }
185
186#endif
187}
wxString mMessage
Definition: TrackPanelAx.h:144
wxString Translation() const

References BasicUI::FindFocus(), GetWindow(), mMessage, mMessageCount, mTrackName, mwFocus, and TranslatableString::Translation().

Here is the call graph for this function:

◆ SetWindow()

void TrackPanelAx::SetWindow ( wxWindow *  window)
inline

Definition at line 127 of file TrackPanelAx.h.

127{ mWindow = window; }

References mWindow.

◆ UpdateAccessibility()

void TrackPanelAx::UpdateAccessibility ( )
overrideprivatevirtual

Implements TrackFocusCallbacks.

Definition at line 130 of file TrackPanelAx.cpp.

131{
132 Updated();
133}

References Updated().

Here is the call graph for this function:

◆ Updated()

void TrackPanelAx::Updated ( )

Definition at line 135 of file TrackPanelAx.cpp.

136{
137#if wxUSE_ACCESSIBILITY
138 auto pFocus = mwFocus.lock();
139 if (!pFocus)
140 return;
141
142 auto t = pFocus->GetFocus();
143 mTrackName = true;
144
145 // The object_focus event is only needed by Window-Eyes
146 // and can be removed when we cease to support this screen reader.
147 NotifyEvent(wxACC_EVENT_OBJECT_FOCUS,
148 GetWindow(),
149 wxOBJID_CLIENT,
150 pFocus->TrackNum(t));
151
152 NotifyEvent(wxACC_EVENT_OBJECT_NAMECHANGE,
153 GetWindow(),
154 wxOBJID_CLIENT,
155 pFocus->TrackNum(t));
156#endif
157}

References GetWindow(), mTrackName, and mwFocus.

Referenced by UpdateAccessibility().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mFinder

RectangleFinder TrackPanelAx::mFinder
private

Definition at line 142 of file TrackPanelAx.h.

◆ mMessage

wxString TrackPanelAx::mMessage
private

Definition at line 144 of file TrackPanelAx.h.

Referenced by MessageForScreenReader().

◆ mMessageCount

int TrackPanelAx::mMessageCount { 0 }
private

Definition at line 145 of file TrackPanelAx.h.

Referenced by MessageForScreenReader().

◆ mTrackName

bool TrackPanelAx::mTrackName { true }
private

Definition at line 146 of file TrackPanelAx.h.

Referenced by BeginChangeFocus(), MessageForScreenReader(), and Updated().

◆ mwFocus

std::weak_ptr<TrackFocus> TrackPanelAx::mwFocus
private

Definition at line 136 of file TrackPanelAx.h.

Referenced by BeginChangeFocus(), EndChangeFocus(), MessageForScreenReader(), and Updated().

◆ mWindow

wxWindow* TrackPanelAx::mWindow {}
private

Definition at line 139 of file TrackPanelAx.h.

Referenced by GetWindow(), and SetWindow().

◆ mwViewport

std::weak_ptr<Viewport> TrackPanelAx::mwViewport
private

Definition at line 135 of file TrackPanelAx.h.


The documentation for this class was generated from the following files: