Minor cleanup in MoveFocus, set tags on screen roots for debugging

This commit is contained in:
Henrik Rydgård 2023-07-06 16:34:54 +02:00
parent 26e097923d
commit f27850ec1d
4 changed files with 14 additions and 21 deletions

View File

@ -133,7 +133,7 @@ void LayoutViewHierarchy(const UIContext &dc, ViewGroup *root, bool ignoreInsets
root->Layout(); root->Layout();
} }
void MoveFocus(ViewGroup *root, FocusDirection direction) { static void MoveFocus(ViewGroup *root, FocusDirection direction) {
View *focusedView = GetFocusedView(); View *focusedView = GetFocusedView();
if (!focusedView) { if (!focusedView) {
// Nothing was focused when we got in here. Focus the first non-group in the hierarchy. // Nothing was focused when we got in here. Focus the first non-group in the hierarchy.

View File

@ -418,25 +418,6 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei
} }
} }
if (direction == FOCUS_PREV || direction == FOCUS_NEXT) {
switch (direction) {
case FOCUS_PREV:
// If view not found, no neighbor to find.
if (num == -1)
return NeighborResult(nullptr, 0.0f);
return NeighborResult(views_[(num + views_.size() - 1) % views_.size()], 0.0f);
case FOCUS_NEXT:
// If view not found, no neighbor to find.
if (num == -1)
return NeighborResult(0, 0.0f);
return NeighborResult(views_[(num + 1) % views_.size()], 0.0f);
default:
// Can't happen
return NeighborResult(nullptr, 0.0f);
}
}
switch (direction) { switch (direction) {
case FOCUS_UP: case FOCUS_UP:
case FOCUS_LEFT: case FOCUS_LEFT:
@ -472,10 +453,19 @@ NeighborResult ViewGroup::FindNeighbor(View *view, FocusDirection direction, Nei
} }
return result; return result;
} }
case FOCUS_PREV_PAGE: case FOCUS_PREV_PAGE:
case FOCUS_NEXT_PAGE: case FOCUS_NEXT_PAGE:
return FindScrollNeighbor(view, Point(INFINITY, INFINITY), direction, result); return FindScrollNeighbor(view, Point(INFINITY, INFINITY), direction, result);
case FOCUS_PREV:
// If view not found, no neighbor to find.
if (num == -1)
return NeighborResult(nullptr, 0.0f);
return NeighborResult(views_[(num + views_.size() - 1) % views_.size()], 0.0f);
case FOCUS_NEXT:
// If view not found, no neighbor to find.
if (num == -1)
return NeighborResult(0, 0.0f);
return NeighborResult(views_[(num + 1) % views_.size()], 0.0f);
default: default:
ERROR_LOG(SYSTEM, "Bad focus direction %d", (int)direction); ERROR_LOG(SYSTEM, "Bad focus direction %d", (int)direction);

View File

@ -1260,6 +1260,8 @@ void MainScreen::CreateViews() {
root_->SetDefaultFocusView(tabHolder_); root_->SetDefaultFocusView(tabHolder_);
} }
root_->SetTag("mainroot");
auto u = GetI18NCategory(I18NCat::UPGRADE); auto u = GetI18NCategory(I18NCat::UPGRADE);
upgradeBar_ = 0; upgradeBar_ = 0;

View File

@ -286,5 +286,6 @@ std::string OnScreenMessagesView::DescribeText() const {
void OSDOverlayScreen::CreateViews() { void OSDOverlayScreen::CreateViews() {
root_ = new UI::AnchorLayout(); root_ = new UI::AnchorLayout();
root_->SetTag("OSDOverlayScreen");
root_->Add(new OnScreenMessagesView(new UI::AnchorLayoutParams(0.0f, 0.0f, 0.0f, 0.0f))); root_->Add(new OnScreenMessagesView(new UI::AnchorLayoutParams(0.0f, 0.0f, 0.0f, 0.0f)));
} }