Audacity 3.2.0
Public Member Functions | Private Member Functions | List of all members
anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase > Class Template Reference

Changes default arrow navigation to behave more list- or table-like. Instead of searching focusable items among children first, list navigation searches for siblings when arrow key is pressed. Tab behaviour stays same. Requires wxWANT_CHARS style flag to be set. More...

Inheritance diagram for anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >:
[legend]
Collaboration diagram for anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >:
[legend]

Public Member Functions

 ListNavigationEnabled ()
 

Private Member Functions

void SetFocus () override
 
void OnCharHook (wxKeyEvent &evt)
 
void OnKeyDown (wxKeyEvent &evt)
 
void OnNavigationKeyEvent (wxNavigationKeyEvent &evt)
 
bool Destroy () override
 

Detailed Description

template<class WindowBase>
class anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >

Changes default arrow navigation to behave more list- or table-like. Instead of searching focusable items among children first, list navigation searches for siblings when arrow key is pressed. Tab behaviour stays same. Requires wxWANT_CHARS style flag to be set.

Definition at line 147 of file RealtimeEffectPanel.cpp.

Constructor & Destructor Documentation

◆ ListNavigationEnabled()

template<class WindowBase >
anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >::ListNavigationEnabled ( )
inline

Definition at line 150 of file RealtimeEffectPanel.cpp.

151 {
152 WindowBase::Bind(wxEVT_NAVIGATION_KEY, &ListNavigationEnabled::OnNavigationKeyEvent, this);
153 WindowBase::Bind(wxEVT_KEY_DOWN, &ListNavigationEnabled::OnKeyDown, this);
154 WindowBase::Bind(wxEVT_CHAR_HOOK, &ListNavigationEnabled::OnCharHook, this);
155 }

Member Function Documentation

◆ Destroy()

template<class WindowBase >
bool anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >::Destroy ( )
inlineoverrideprivate

Definition at line 223 of file RealtimeEffectPanel.cpp.

224 {
225 if(WindowBase::IsDescendant(wxWindow::FindFocus()))
226 {
227 auto next = WindowBase::GetNextSibling();
228 if(next != nullptr && next->AcceptsFocus())
229 next->SetFocus();
230 else
231 {
232 auto prev = WindowBase::GetPrevSibling();
233 if(prev != nullptr && prev->AcceptsFocus())
234 prev->SetFocus();
235 }
236 }
237 return wxNavigationEnabled<WindowBase>::Destroy();
238 }
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:343

References BasicUI::FindFocus().

Here is the call graph for this function:

◆ OnCharHook()

template<class WindowBase >
void anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >::OnCharHook ( wxKeyEvent &  evt)
inlineprivate

Definition at line 164 of file RealtimeEffectPanel.cpp.

165 {
166 //We want to restore focus to list item once arrow navigation is used
167 //on the child item, for this we need a char hook since key/navigation
168 //events are sent directly to the focused item
169 const auto keyCode = evt.GetKeyCode();
170 if((keyCode == WXK_DOWN || keyCode == WXK_UP) &&
171 !WindowBase::HasFocus() &&
172 WindowBase::IsDescendant(WindowBase::FindFocus()))
173 {
174 wxWindow::SetFocusFromKbd();
175 }
176 else
177 evt.Skip();
178 }

References BasicUI::FindFocus().

Here is the call graph for this function:

◆ OnKeyDown()

template<class WindowBase >
void anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >::OnKeyDown ( wxKeyEvent &  evt)
inlineprivate

Definition at line 180 of file RealtimeEffectPanel.cpp.

181 {
182 const auto keyCode = evt.GetKeyCode();
183 if(keyCode == WXK_TAB)
184 WindowBase::NavigateIn(wxNavigationKeyEvent::FromTab | (evt.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward));
185 else if(keyCode == WXK_DOWN)
186 WindowBase::Navigate(wxNavigationKeyEvent::IsForward);
187 else if(keyCode == WXK_UP)
188 WindowBase::Navigate(wxNavigationKeyEvent::IsBackward);
189 else
190 evt.Skip();
191 }

◆ OnNavigationKeyEvent()

template<class WindowBase >
void anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >::OnNavigationKeyEvent ( wxNavigationKeyEvent &  evt)
inlineprivate

Definition at line 193 of file RealtimeEffectPanel.cpp.

194 {
195 if(evt.GetEventObject() == WindowBase::GetParent() && !evt.IsFromTab())
196 WindowBase::SetFocusFromKbd();
197 else if(evt.GetEventObject() == this && evt.GetCurrentFocus() == this && evt.IsFromTab())
198 {
199 //NavigateIn
200 wxPropagationDisabler disableProp(evt);
201 const auto isForward = evt.GetDirection();
202 const auto& children = WindowBase::GetChildren();
203 auto node = isForward ? children.GetFirst() : children.GetLast();
204 while(node)
205 {
206 auto child = node->GetData();
207 if(child->CanAcceptFocusFromKeyboard())
208 {
209 if(!child->GetEventHandler()->ProcessEvent(evt))
210 {
211 child->SetFocusFromKbd();
212 }
213 evt.Skip(false);
214 return;
215 }
216 node = isForward ? node->GetNext() : node->GetPrevious();
217 }
218 }
219 else
220 evt.Skip();
221 }

◆ SetFocus()

template<class WindowBase >
void anonymous_namespace{RealtimeEffectPanel.cpp}::ListNavigationEnabled< WindowBase >::SetFocus ( )
inlineoverrideprivate

Definition at line 158 of file RealtimeEffectPanel.cpp.

159 {
160 //Prevent attempt to search for a focusable child
162 }
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:352

References BasicUI::SetFocus().

Here is the call graph for this function:

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