From c90251a52b7240cabeaf4ef1e11e78b2489a41e1 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Sun, 13 Jun 2021 13:47:00 -0400 Subject: [PATCH] GameCardTab: fix drawing issues while switching views through the LayerView class. --- include/gamecard_tab.hpp | 2 ++ source/gamecard_tab.cpp | 25 +++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/gamecard_tab.hpp b/include/gamecard_tab.hpp index 1a10814..5518288 100644 --- a/include/gamecard_tab.hpp +++ b/include/gamecard_tab.hpp @@ -37,7 +37,9 @@ namespace nxdt::views GameCardStatus gc_status = GameCardStatus_NotInserted; ErrorFrame *error_frame = nullptr; + brls::List *list = nullptr; + brls::ListItem *placeholder = nullptr; std::vector views; int view_index = -1; diff --git a/source/gamecard_tab.cpp b/source/gamecard_tab.cpp index 7cb0b42..1b29e3e 100644 --- a/source/gamecard_tab.cpp +++ b/source/gamecard_tab.cpp @@ -30,15 +30,18 @@ namespace nxdt::views { /* Add error frame. */ this->error_frame = new ErrorFrame("No gamecard inserted."); - this->addLayer(this->error_frame); + this->addLayerWrapper(this->error_frame); /* Add list. */ this->list = new brls::List(); - this->list->addView(new brls::ListItem("Placeholder")); - this->addLayer(this->list); + this->placeholder = new brls::ListItem("Placeholder"); + this->list->addView(this->placeholder); + this->addLayerWrapper(this->list); /* Setup gamecard status task. */ this->gc_status_task_sub = this->gc_status_task->RegisterListener([this](GameCardStatus gc_status) { + if (gc_status < GameCardStatus_InsertedAndInfoLoaded) this->changeLayerWrapper(this->error_frame); + switch(gc_status) { case GameCardStatus_NotInserted: @@ -62,15 +65,12 @@ namespace nxdt::views "Please check the logfile and report this issue to " APP_AUTHOR "."); break; case GameCardStatus_InsertedAndInfoLoaded: - this->changeLayer(1); - this->list->invalidate(true); + this->changeLayerWrapper(this->list); break; default: break; } - if (gc_status < GameCardStatus_InsertedAndInfoLoaded) this->changeLayer(0); - this->gc_status = gc_status; }); } @@ -79,6 +79,9 @@ namespace nxdt::views { /* Unregister gamecard task listener. */ this->gc_status_task->UnregisterListener(this->gc_status_task_sub); + + /* Clear views vector. */ + if (this->views.size()) this->views.clear(); } void GameCardTab::addLayerWrapper(brls::View* view) @@ -101,11 +104,13 @@ namespace nxdt::views } } - if (index == -1 || index == this->view_index) return; + if (index == -1) return; + + /* TODO: check all ListItem elements using a loop. */ + if (brls::Application::getCurrentFocus() == this->placeholder) brls::Application::onGamepadButtonPressed(GLFW_GAMEPAD_BUTTON_DPAD_LEFT, false); - //reinterpret_cast(this->getParent())->onCancel(); this->changeLayer(index); + this->invalidate(true); this->view_index = index; - view->invalidate(true); } }