1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-26 20:22:17 +00:00

RootView: display USB host speed.

This commit is contained in:
Pablo Curiel 2021-06-25 19:28:38 -04:00
parent 41ce1f23b2
commit a9d8edebcb
3 changed files with 60 additions and 40 deletions

View file

@ -37,6 +37,7 @@ namespace nxdt::views
brls::Label *time_lbl = nullptr; brls::Label *time_lbl = nullptr;
brls::Label *battery_icon = nullptr, *battery_percentage = nullptr; brls::Label *battery_icon = nullptr, *battery_percentage = nullptr;
brls::Label *connection_icon = nullptr, *connection_status_lbl = nullptr; brls::Label *connection_icon = nullptr, *connection_status_lbl = nullptr;
brls::Label *usb_icon = nullptr, *usb_host_speed_lbl = nullptr;
nxdt::tasks::StatusInfoTask *status_info_task = nullptr; nxdt::tasks::StatusInfoTask *status_info_task = nullptr;
nxdt::tasks::GameCardTask *gc_status_task = nullptr; nxdt::tasks::GameCardTask *gc_status_task = nullptr;
@ -45,6 +46,7 @@ namespace nxdt::views
nxdt::tasks::UsbHostTask *usb_host_task = nullptr; nxdt::tasks::UsbHostTask *usb_host_task = nullptr;
nxdt::tasks::StatusInfoEvent::Subscription status_info_task_sub; nxdt::tasks::StatusInfoEvent::Subscription status_info_task_sub;
nxdt::tasks::UsbHostEvent::Subscription usb_host_task_sub;
protected: protected:
void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override; void draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) override;

View file

@ -66,6 +66,13 @@ namespace nxdt::views
this->connection_status_lbl = new brls::Label(brls::LabelStyle::SMALL, ""); this->connection_status_lbl = new brls::Label(brls::LabelStyle::SMALL, "");
this->connection_status_lbl->setParent(this); this->connection_status_lbl->setParent(this);
this->usb_icon = new brls::Label(brls::LabelStyle::SMALL, "\uE1E0");
this->usb_icon->setFont(material);
this->usb_icon->setParent(this);
this->usb_host_speed_lbl = new brls::Label(brls::LabelStyle::SMALL, "root_view/not_connected"_i18n);
this->usb_host_speed_lbl->setParent(this);
/* Start background tasks. */ /* Start background tasks. */
this->status_info_task = new nxdt::tasks::StatusInfoTask(); this->status_info_task = new nxdt::tasks::StatusInfoTask();
this->gc_status_task = new nxdt::tasks::GameCardTask(); this->gc_status_task = new nxdt::tasks::GameCardTask();
@ -141,10 +148,22 @@ namespace nxdt::views
/* Update layout. */ /* Update layout. */
this->invalidate(true); this->invalidate(true);
}); });
/* Subscribe to USB host event. */
this->usb_host_task_sub = this->usb_host_task->RegisterListener([this](UsbHostSpeed usb_host_speed) {
/* Update USB host speed label. */
this->usb_host_speed_lbl->setText(usb_host_speed ? fmt::format("USB {}.0", usb_host_speed) : "root_view/not_connected"_i18n);
/* Update layout. */
this->invalidate(true);
});
} }
RootView::~RootView(void) RootView::~RootView(void)
{ {
/* Unregister USB host task listener. */
this->usb_host_task->UnregisterListener(this->usb_host_task_sub);
/* Unregister status info task listener. */ /* Unregister status info task listener. */
this->status_info_task->UnregisterListener(this->status_info_task_sub); this->status_info_task->UnregisterListener(this->status_info_task_sub);
@ -161,6 +180,8 @@ namespace nxdt::views
delete this->battery_percentage; delete this->battery_percentage;
delete this->connection_icon; delete this->connection_icon;
delete this->connection_status_lbl; delete this->connection_status_lbl;
delete this->usb_icon;
delete this->usb_host_speed_lbl;
} }
void RootView::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx) void RootView::draw(NVGcontext* vg, int x, int y, unsigned width, unsigned height, brls::Style* style, brls::FrameContext* ctx)
@ -176,11 +197,14 @@ namespace nxdt::views
this->connection_icon->frame(ctx); this->connection_icon->frame(ctx);
this->connection_status_lbl->frame(ctx); this->connection_status_lbl->frame(ctx);
this->usb_icon->frame(ctx);
this->usb_host_speed_lbl->frame(ctx);
} }
void RootView::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash) void RootView::layout(NVGcontext* vg, brls::Style* style, brls::FontStash* stash)
{ {
int y_pos = 0; int x_pos = 0, y_pos = 0;
brls::AppletFrame::layout(vg, style, stash); brls::AppletFrame::layout(vg, style, stash);
@ -188,55 +212,53 @@ namespace nxdt::views
{ {
/* Applet mode label. */ /* Applet mode label. */
this->applet_mode_lbl->invalidate(true); this->applet_mode_lbl->invalidate(true);
this->applet_mode_lbl->setBoundaries(
this->x + (this->width - this->applet_mode_lbl->getWidth()) / 2, x_pos = (this->x + (this->width - this->applet_mode_lbl->getWidth()) / 2);
this->y + (style->AppletFrame.headerHeightRegular / 2) + style->AppletFrame.titleOffset, y_pos = (this->y + (style->AppletFrame.headerHeightRegular / 2) + style->AppletFrame.titleOffset);
this->applet_mode_lbl->getWidth(),
this->applet_mode_lbl->getHeight()); this->applet_mode_lbl->setBoundaries(x_pos, y_pos, this->applet_mode_lbl->getWidth(), this->applet_mode_lbl->getHeight());
y_pos = 0;
} }
/* Time label. */ /* Time label. */
this->time_lbl->invalidate(true); this->time_lbl->invalidate(true);
x_pos = (this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->time_lbl->getWidth());
y_pos += this->y + 25 + this->time_lbl->getHeight(); y_pos += this->y + 25 + this->time_lbl->getHeight();
this->time_lbl->setBoundaries( this->time_lbl->setBoundaries(x_pos, y_pos, this->time_lbl->getWidth(), this->time_lbl->getHeight());
this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->time_lbl->getWidth(),
y_pos,
this->time_lbl->getWidth(),
this->time_lbl->getHeight());
/* Battery stats labels. */ /* Battery stats and network connection labels. */
this->battery_icon->invalidate(true); this->battery_icon->invalidate(true);
this->battery_percentage->invalidate(true); this->battery_percentage->invalidate(true);
y_pos += (20 + this->battery_icon->getHeight());
this->battery_icon->setBoundaries(
this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->battery_percentage->getWidth() - 5 - this->battery_icon->getWidth(),
y_pos,
this->battery_icon->getWidth(),
this->battery_icon->getHeight());
this->battery_percentage->setBoundaries(
this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->battery_percentage->getWidth(),
y_pos,
this->battery_percentage->getWidth(),
this->battery_percentage->getHeight());
/* Network connection labels. */
this->connection_icon->invalidate(true); this->connection_icon->invalidate(true);
this->connection_status_lbl->invalidate(true); this->connection_status_lbl->invalidate(true);
x_pos = (this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->connection_status_lbl->getWidth());
y_pos += (20 + this->connection_icon->getHeight()); y_pos += (20 + this->connection_icon->getHeight());
this->connection_icon->setBoundaries( this->connection_status_lbl->setBoundaries(x_pos, y_pos, this->connection_status_lbl->getWidth(), this->connection_status_lbl->getHeight());
this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->connection_status_lbl->getWidth() - 5 - this->connection_icon->getWidth(), x_pos -= (5 + this->connection_icon->getWidth());
y_pos,
this->connection_icon->getWidth(),
this->connection_icon->getHeight());
this->connection_status_lbl->setBoundaries( this->connection_icon->setBoundaries(x_pos, y_pos, this->connection_icon->getWidth(), this->connection_icon->getHeight());
this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->connection_status_lbl->getWidth(), x_pos -= (10 + this->battery_percentage->getWidth());
y_pos,
this->connection_status_lbl->getWidth(), this->battery_percentage->setBoundaries(x_pos, y_pos, this->battery_percentage->getWidth(), this->battery_percentage->getHeight());
this->connection_status_lbl->getHeight()); x_pos -= (5 + this->battery_icon->getWidth());
this->battery_icon->setBoundaries(x_pos, y_pos, this->battery_icon->getWidth(), this->battery_icon->getHeight());
/* USB host speed labels. */
this->usb_icon->invalidate(true);
this->usb_host_speed_lbl->invalidate(true);
x_pos = (this->x + this->width - (style->AppletFrame.separatorSpacing * 2) - this->usb_host_speed_lbl->getWidth());
y_pos += (20 + this->usb_icon->getHeight());
this->usb_host_speed_lbl->setBoundaries(x_pos, y_pos, this->usb_host_speed_lbl->getWidth(), this->usb_host_speed_lbl->getHeight());
x_pos -= (5 + this->usb_icon->getWidth());
this->usb_icon->setBoundaries(x_pos, y_pos, this->battery_icon->getWidth(), this->battery_icon->getHeight());
} }
} }

View file

@ -104,10 +104,6 @@ namespace nxdt::views
{ {
if (!app_metadata) return; if (!app_metadata) return;
/* Block inputs while we're doing our thing. */
brls::Application::blockInputs();
ON_SCOPE_EXIT { brls::Application::unblockInputs(); };
/* Populate variables. */ /* Populate variables. */
size_t app_metadata_count = app_metadata->size(); size_t app_metadata_count = app_metadata->size();
bool update_focused_view = this->IsListItemFocused(); bool update_focused_view = this->IsListItemFocused();