mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-22 18:26:39 +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:
parent
ba0c5d9e35
commit
405df0c81a
7 changed files with 41 additions and 34 deletions
|
@ -33,7 +33,7 @@ namespace nxdt::views
|
||||||
class AboutTabLabel: public FocusableLabel
|
class AboutTabLabel: public FocusableLabel
|
||||||
{
|
{
|
||||||
public:
|
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);
|
if (center) this->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,8 @@
|
||||||
|
|
||||||
#define HTTP_USER_AGENT APP_TITLE "/" APP_VERSION " (Nintendo Switch)"
|
#define HTTP_USER_AGENT APP_TITLE "/" APP_VERSION " (Nintendo Switch)"
|
||||||
#define HTTP_CONNECT_TIMEOUT 10L /* 10 seconds. */
|
#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 HTTP_BUFFER_SIZE 131072L /* 128 KiB. */
|
||||||
|
|
||||||
#define GITHUB_URL "https://github.com"
|
#define GITHUB_URL "https://github.com"
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace nxdt::views
|
||||||
class FocusableItem: public ViewType
|
class FocusableItem: public ViewType
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
bool highlight_view;
|
bool highlight, highlight_bg;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
brls::View* getDefaultFocus(void) override
|
brls::View* getDefaultFocus(void) override
|
||||||
|
@ -40,28 +40,14 @@ namespace nxdt::views
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void playClickAnimation(void) override;
|
bool isHighlightBackgroundEnabled(void) override
|
||||||
void onFocusGained(void) override;
|
|
||||||
|
|
||||||
public:
|
|
||||||
template<typename... Types>
|
|
||||||
FocusableItem(bool highlight_view, Types... args) : ViewType(args...)
|
|
||||||
{
|
{
|
||||||
this->highlight_view = highlight_view;
|
return this->highlight_bg;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename ViewType>
|
|
||||||
void FocusableItem<ViewType>::playClickAnimation(void)
|
|
||||||
{
|
|
||||||
/* Play click animation. */
|
|
||||||
if (this->highlight_view) brls::View::playClickAnimation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ViewType>
|
void onFocusGained(void) override
|
||||||
void FocusableItem<ViewType>::onFocusGained(void)
|
|
||||||
{
|
{
|
||||||
if (this->highlight_view)
|
if (this->highlight)
|
||||||
{
|
{
|
||||||
/* Focus and highlight view. */
|
/* Focus and highlight view. */
|
||||||
brls::View::onFocusGained();
|
brls::View::onFocusGained();
|
||||||
|
@ -73,9 +59,26 @@ namespace nxdt::views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Instantiate templates for the focusable item classes we're gonna use. */
|
public:
|
||||||
typedef FocusableItem<brls::Label> FocusableLabel;
|
template<typename... Types>
|
||||||
typedef FocusableItem<brls::Table> FocusableTable;
|
FocusableItem(bool highlight, bool highlight_bg, Types... args) : ViewType(args...), highlight(highlight), highlight_bg(highlight_bg) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Define templated classes for the focusable items we're gonna use. */
|
||||||
|
|
||||||
|
class FocusableLabel: public FocusableItem<brls::Label>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename... Types>
|
||||||
|
FocusableLabel(Types... args) : FocusableItem<brls::Label>(false, false, args...) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
class FocusableTable: public FocusableItem<brls::Table>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename... Types>
|
||||||
|
FocusableTable(Types... args) : FocusableItem<brls::Table>(true, false, args...) { }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __FOCUSABLE_ITEM_HPP__ */
|
#endif /* __FOCUSABLE_ITEM_HPP__ */
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit fb8891e4d75474d1a1ecbde1c930b0a308b1c3e0
|
Subproject commit 4642d9f87b1fb5509ea771f03d6a194d2accaa2d
|
|
@ -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_MAXREDIRS, 50L);
|
||||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
|
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L);
|
||||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, HTTP_CONNECT_TIMEOUT);
|
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_BUFFERSIZE, HTTP_BUFFER_SIZE);
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)(force_https ? CURL_HTTP_VERSION_2TLS : CURL_HTTP_VERSION_1_1));
|
curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, (long)(force_https ? CURL_HTTP_VERSION_2TLS : CURL_HTTP_VERSION_1_1));
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace nxdt::views
|
||||||
/* Gamecard properties table. */
|
/* Gamecard properties table. */
|
||||||
this->list->addView(new brls::Header("gamecard_tab/list/properties_table/header"_i18n));
|
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->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->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);
|
this->trimmed_size = this->properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/trimmed_size"_i18n);
|
||||||
|
|
|
@ -306,7 +306,7 @@ namespace nxdt::views
|
||||||
std::stringstream ss(std::string(this->json_data.changelog));
|
std::stringstream ss(std::string(this->json_data.changelog));
|
||||||
|
|
||||||
/* Display version string at the top. */
|
/* 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);
|
version_lbl->setHorizontalAlign(NVG_ALIGN_CENTER);
|
||||||
this->changelog_list->addView(version_lbl);
|
this->changelog_list->addView(version_lbl);
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ namespace nxdt::views
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add line to the changelog view. */
|
/* 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. */
|
/* Register update action. */
|
||||||
|
|
Loading…
Reference in a new issue