1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-12-23 00:52:10 +00:00

FocusableItem: reestructure class.

Other changes include:

* Codebase: update all references to FocusableLabel and FocusableTable constructors to match the changes in FocusableItem.
* FocusableTable: objects can now be highlighted, but the highlight background won't be drawn.
* http: set low speed limit and time values.
This commit is contained in:
Pablo Curiel 2021-08-08 03:39:21 -04:00
parent ba0c5d9e35
commit 405df0c81a
7 changed files with 41 additions and 34 deletions

View file

@ -33,7 +33,7 @@ namespace nxdt::views
class AboutTabLabel: public FocusableLabel
{
public:
AboutTabLabel(brls::LabelStyle labelStyle, std::string text, bool center = false) : FocusableLabel(false, labelStyle, text, true)
AboutTabLabel(brls::LabelStyle labelStyle, std::string text, bool center = false) : FocusableLabel(labelStyle, text, true)
{
if (center) this->setHorizontalAlign(NVG_ALIGN_CENTER);
}

View file

@ -104,6 +104,8 @@
#define HTTP_USER_AGENT APP_TITLE "/" APP_VERSION " (Nintendo Switch)"
#define HTTP_CONNECT_TIMEOUT 10L /* 10 seconds. */
#define HTTP_LOW_SPEED_LIMIT 30L /* 30 bytes per second. */
#define HTTP_LOW_SPEED_TIME HTTP_CONNECT_TIMEOUT
#define HTTP_BUFFER_SIZE 131072L /* 128 KiB. */
#define GITHUB_URL "https://github.com"

View file

@ -32,7 +32,7 @@ namespace nxdt::views
class FocusableItem: public ViewType
{
private:
bool highlight_view;
bool highlight, highlight_bg;
protected:
brls::View* getDefaultFocus(void) override
@ -40,42 +40,45 @@ namespace nxdt::views
return this;
}
void playClickAnimation(void) override;
void onFocusGained(void) override;
bool isHighlightBackgroundEnabled(void) override
{
return this->highlight_bg;
}
void onFocusGained(void) override
{
if (this->highlight)
{
/* Focus and highlight view. */
brls::View::onFocusGained();
} else {
/* Focus view without highlighting it. */
this->focused = true;
this->focusEvent.fire(this);
if (this->hasParent()) this->getParent()->onChildFocusGained(this);
}
}
public:
template<typename... Types>
FocusableItem(bool highlight_view, Types... args) : ViewType(args...)
{
this->highlight_view = highlight_view;
}
FocusableItem(bool highlight, bool highlight_bg, Types... args) : ViewType(args...), highlight(highlight), highlight_bg(highlight_bg) { }
};
template<typename ViewType>
void FocusableItem<ViewType>::playClickAnimation(void)
{
/* Play click animation. */
if (this->highlight_view) brls::View::playClickAnimation();
}
/* Define templated classes for the focusable items we're gonna use. */
template<typename ViewType>
void FocusableItem<ViewType>::onFocusGained(void)
class FocusableLabel: public FocusableItem<brls::Label>
{
if (this->highlight_view)
{
/* Focus and highlight view. */
brls::View::onFocusGained();
} else {
/* Focus view without highlighting it. */
this->focused = true;
this->focusEvent.fire(this);
if (this->hasParent()) this->getParent()->onChildFocusGained(this);
}
}
public:
template<typename... Types>
FocusableLabel(Types... args) : FocusableItem<brls::Label>(false, false, args...) { }
};
/* Instantiate templates for the focusable item classes we're gonna use. */
typedef FocusableItem<brls::Label> FocusableLabel;
typedef FocusableItem<brls::Table> FocusableTable;
class FocusableTable: public FocusableItem<brls::Table>
{
public:
template<typename... Types>
FocusableTable(Types... args) : FocusableItem<brls::Table>(true, false, args...) { }
};
}
#endif /* __FOCUSABLE_ITEM_HPP__ */

@ -1 +1 @@
Subproject commit fb8891e4d75474d1a1ecbde1c930b0a308b1c3e0
Subproject commit 4642d9f87b1fb5509ea771f03d6a194d2accaa2d

View file

@ -125,6 +125,8 @@ bool httpPerformGetRequest(const char *url, bool force_https, size_t *outsize, H
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, HTTP_CONNECT_TIMEOUT);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, HTTP_LOW_SPEED_LIMIT);
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, HTTP_LOW_SPEED_TIME);
curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, HTTP_BUFFER_SIZE);
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)(force_https ? CURL_HTTP_VERSION_2TLS : CURL_HTTP_VERSION_1_1));

View file

@ -50,7 +50,7 @@ namespace nxdt::views
/* Gamecard properties table. */
this->list->addView(new brls::Header("gamecard_tab/list/properties_table/header"_i18n));
this->properties_table = new FocusableTable(false);
this->properties_table = new FocusableTable();
this->capacity = this->properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/capacity"_i18n);
this->total_size = this->properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/total_size"_i18n);
this->trimmed_size = this->properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/trimmed_size"_i18n);

View file

@ -306,7 +306,7 @@ namespace nxdt::views
std::stringstream ss(std::string(this->json_data.changelog));
/* Display version string at the top. */
FocusableLabel *version_lbl = new FocusableLabel(false, brls::LabelStyle::CRASH, std::string(this->json_data.version), true);
FocusableLabel *version_lbl = new FocusableLabel(brls::LabelStyle::CRASH, std::string(this->json_data.version), true);
version_lbl->setHorizontalAlign(NVG_ALIGN_CENTER);
this->changelog_list->addView(version_lbl);
@ -338,7 +338,7 @@ namespace nxdt::views
}
/* Add line to the changelog view. */
this->changelog_list->addView(new FocusableLabel(false, brls::LabelStyle::SMALL, item, true));
this->changelog_list->addView(new FocusableLabel(brls::LabelStyle::SMALL, item, true));
}
/* Register update action. */