Strategy for finding the next focusable view: - keep going down the first child, stop when you find a focusable view or a focus traversable view (in that case return it) or when you reach a view with no children. - go to the right sibling and start the search from there (by invoking FindNextFocusableViewImpl on that view). - if the view has no right sibling, go up the parents until you find a pare
| 62 | // - if the view has no right sibling, go up the parents until you find a parent |
| 63 | // with a right sibling and start the search from there. |
| 64 | SWindow* FocusSearch::FindNextFocusableViewImpl( SWindow* starting_view, bool check_starting_view, bool can_go_up, bool can_go_down , SWindow * pSkipGroupOwner) |
| 65 | { |
| 66 | if(check_starting_view) |
| 67 | { |
| 68 | if(IsViewFocusableCandidate(starting_view, pSkipGroupOwner)) |
| 69 | { |
| 70 | SWindow* v = starting_view->GetSelectedSiblingInGroup(); |
| 71 | if(!v) v= starting_view; |
| 72 | // The selected view might not be focusable (if it is disabled for |
| 73 | // example). |
| 74 | if(IsFocusable(v)) |
| 75 | { |
| 76 | return v; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | } |
| 81 | |
| 82 | // First let's try the left child. |
| 83 | if(can_go_down) |
| 84 | { |
| 85 | SWindow *pChild=starting_view->GetWindow(GSW_FIRSTCHILD); |
| 86 | if(pChild) |
| 87 | { |
| 88 | SWindow* v = FindNextFocusableViewImpl( |
| 89 | pChild, |
| 90 | true, false, true, pSkipGroupOwner); |
| 91 | if(v ) |
| 92 | { |
| 93 | return v; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Then try the right sibling. |
| 99 | SWindow* sibling = starting_view->GetWindow(GSW_NEXTSIBLING); |
| 100 | if(sibling) |
| 101 | { |
| 102 | SWindow* v = FindNextFocusableViewImpl(sibling, |
| 103 | true, false, true, pSkipGroupOwner); |
| 104 | if(v ) |
| 105 | { |
| 106 | return v; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // Then go up to the parent sibling. |
| 111 | if(can_go_up) |
| 112 | { |
| 113 | SWindow* parent = starting_view->GetParent(); |
| 114 | while(parent) |
| 115 | { |
| 116 | sibling = parent->GetWindow(GSW_NEXTSIBLING); |
| 117 | if(sibling) |
| 118 | { |
| 119 | return FindNextFocusableViewImpl(sibling, |
| 120 | true, true, true, |
| 121 | pSkipGroupOwner); |
nothing calls this directly
no test coverage detected