From 160e5edcd40d4f4c06329c9c59c79aadd8a0e4f0 Mon Sep 17 00:00:00 2001 From: tallbl0nde <40382856+tallbl0nde@users.noreply.github.com> Date: Sun, 25 Jul 2021 19:58:05 +0930 Subject: [PATCH] App: Various UI fixes --- .../include/ui/element/listitem/Playlist.hpp | 3 ++- Application/include/ui/frame/Queue.hpp | 4 ++-- Application/libs/Aether | 2 +- Application/romfs/lang/en.json | 1 + Application/source/Application.cpp | 2 +- .../source/ui/element/listitem/Playlist.cpp | 14 ++++++++------ Application/source/ui/frame/Playlists.cpp | 2 +- Application/source/ui/frame/Queue.cpp | 2 +- Application/source/ui/overlay/AddToPlaylist.cpp | 2 +- Application/source/ui/screen/Fullscreen.cpp | 13 +++++++++++-- Application/source/ui/screen/Home.cpp | 2 +- 11 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Application/include/ui/element/listitem/Playlist.hpp b/Application/include/ui/element/listitem/Playlist.hpp index ac61abd..89db8df 100644 --- a/Application/include/ui/element/listitem/Playlist.hpp +++ b/Application/include/ui/element/listitem/Playlist.hpp @@ -7,6 +7,7 @@ namespace CustomElm::ListItem { class Playlist : public More { private: // Elements + bool showMore; Aether::Image * image; Aether::Text * name; Aether::Text * songs; @@ -14,7 +15,7 @@ namespace CustomElm::ListItem { public: // Constructor sets up elements (takes path to image) - Playlist(const std::string &); + Playlist(const std::string &, const bool); // Scroll if needed void update(uint32_t); diff --git a/Application/include/ui/frame/Queue.hpp b/Application/include/ui/frame/Queue.hpp index c159523..9b0a6f9 100644 --- a/Application/include/ui/frame/Queue.hpp +++ b/Application/include/ui/frame/Queue.hpp @@ -28,7 +28,7 @@ namespace Frame { Aether::Element * queue; std::list queueEls; Aether::Element * upnext; - Aether::Text * upnextStr; + Aether::TextBlock * upnextStr; std::list upnextEls; // Temporary vector of song metadata @@ -77,4 +77,4 @@ namespace Frame { }; }; -#endif \ No newline at end of file +#endif diff --git a/Application/libs/Aether b/Application/libs/Aether index 188b471..bc547ec 160000 --- a/Application/libs/Aether +++ b/Application/libs/Aether @@ -1 +1 @@ -Subproject commit 188b4719fa03149c28bf0d645b38350743905890 +Subproject commit bc547ec192d8a973a63a97eda2994b3c2bdfeef7 diff --git a/Application/romfs/lang/en.json b/Application/romfs/lang/en.json index b483c97..aa0aa52 100644 --- a/Application/romfs/lang/en.json +++ b/Application/romfs/lang/en.json @@ -97,6 +97,7 @@ "No": "No", "NotPlaying1": "Nothing playing!", "NotPlaying2": "Play a song", + "NotPlaying3": "Not Playing", "Play": "Play", "Quit": "Quit", "Remove": "Remove", diff --git a/Application/source/Application.cpp b/Application/source/Application.cpp index 3d74a1d..3571b0a 100644 --- a/Application/source/Application.cpp +++ b/Application/source/Application.cpp @@ -54,7 +54,7 @@ namespace Main { this->window->setHighlightOverlay(this->theme_->selected()); this->window->setFadeIn(true); this->window->setFadeOut(true); - this->window->showDebugInfo(true); + // this->window->showDebugInfo(true); this->exitPrompt = nullptr; // Setup screens diff --git a/Application/source/ui/element/listitem/Playlist.cpp b/Application/source/ui/element/listitem/Playlist.cpp index 66bc812..7effc87 100644 --- a/Application/source/ui/element/listitem/Playlist.cpp +++ b/Application/source/ui/element/listitem/Playlist.cpp @@ -9,19 +9,20 @@ #define PADDING 12 namespace CustomElm::ListItem { - Playlist::Playlist(const std::string & img) : More(HEIGHT) { + Playlist::Playlist(const std::string & img, const bool showMore) : More(HEIGHT) { this->image = new Aether::Image(this->x() + PADDING, this->y() + PADDING, img, Aether::Render::Wait); this->addElement(this->image); this->addTexture(this->image); this->name = new Aether::Text(this->x(), this->y(), "", NAME_FONT_SIZE, Aether::Render::Wait); this->name->setCanScroll(false); this->name->setScrollPause(1000); - this->name->setScrollSpeed(60); + this->name->setScrollSpeed(50); this->addElement(this->name); this->addTexture(this->name); this->songs = new Aether::Text(this->x(), this->y(), "", SONGS_FONT_SIZE, Aether::Render::Wait); this->addElement(this->songs); this->addTexture(this->songs); + this->showMore = showMore; } void Playlist::update(uint32_t dt) { @@ -33,6 +34,10 @@ namespace CustomElm::ListItem { } else if (!this->highlighted() && this->name->canScroll()) { this->name->setCanScroll(false); } + + if (!this->showMore) { + this->more->setHidden(true); + } } void Playlist::positionElements() { @@ -40,10 +45,7 @@ namespace CustomElm::ListItem { this->name->setX(this->image->x() + this->image->w() + 2*PADDING); this->name->setY(this->y() + 0.38*HEIGHT - this->name->h()/2); - int maxW = (this->x() + this->w()) - this->name->x() - PADDING; - if (this->more->colour().a() != 0) { - maxW -= (this->x() + this->w()) - this->more->x(); - } + int maxW = (this->x() + this->w()) - this->name->x() - (3*PADDING) - this->more->w(); if (this->name->textureWidth() > maxW) { this->name->setW(maxW); } else { diff --git a/Application/source/ui/frame/Playlists.cpp b/Application/source/ui/frame/Playlists.cpp index 785ad5f..f1516ba 100644 --- a/Application/source/ui/frame/Playlists.cpp +++ b/Application/source/ui/frame/Playlists.cpp @@ -86,7 +86,7 @@ namespace Frame { } CustomElm::ListItem::Playlist * Playlists::getListItem(const Metadata::Playlist & m) { - CustomElm::ListItem::Playlist * l = new CustomElm::ListItem::Playlist(m.imagePath.empty() ? Path::App::DefaultPlaylistFile : m.imagePath); + CustomElm::ListItem::Playlist * l = new CustomElm::ListItem::Playlist(m.imagePath.empty() ? Path::App::DefaultPlaylistFile : m.imagePath, true); // Set styling parameters l->setNameString(m.name); diff --git a/Application/source/ui/frame/Queue.cpp b/Application/source/ui/frame/Queue.cpp index 433bae2..2e38be6 100644 --- a/Application/source/ui/frame/Queue.cpp +++ b/Application/source/ui/frame/Queue.cpp @@ -78,7 +78,7 @@ namespace Frame { // Up Next this->upnext = new Aether::Element(0, 0, 100, 80); - this->upnextStr = new Aether::Text(this->upnext->x(), this->upnext->y(), "Queue.UpNextBlank"_lang, 28); + this->upnextStr = new Aether::TextBlock(this->upnext->x(), this->upnext->y(), "Queue.UpNextBlank"_lang, 28, this->list->w() * 0.9); this->upnextStr->setY(this->upnextStr->y() + (this->upnext->h() - this->upnextStr->h())/2 + 10); this->upnextStr->setColour(this->app->theme()->FG()); this->upnext->addElement(this->upnextStr); diff --git a/Application/source/ui/overlay/AddToPlaylist.cpp b/Application/source/ui/overlay/AddToPlaylist.cpp index 4c95765..f85aec0 100644 --- a/Application/source/ui/overlay/AddToPlaylist.cpp +++ b/Application/source/ui/overlay/AddToPlaylist.cpp @@ -51,7 +51,7 @@ namespace CustomOvl { void AddToPlaylist::addPlaylist(CustomElm::ListItem::Playlist * l, PlaylistID id) { l->setMoreCallback([l]() { - l->onPressFunc(); + l->onPressFunc()(); }); l->setMoreColour(Aether::Colour{0, 0, 0, 0}); l->onPress([this, id]() { diff --git a/Application/source/ui/screen/Fullscreen.cpp b/Application/source/ui/screen/Fullscreen.cpp index af432c2..a0f0e5d 100644 --- a/Application/source/ui/screen/Fullscreen.cpp +++ b/Application/source/ui/screen/Fullscreen.cpp @@ -1,6 +1,7 @@ #include "Application.hpp" #include "Paths.hpp" #include "ui/screen/Fullscreen.hpp" +#include "lang/Lang.hpp" #include "utils/Splash.hpp" #include "utils/Utils.hpp" @@ -311,6 +312,9 @@ namespace Screen { this->noteElement->addElement(this->note); this->addElement(this->noteElement); std::string str = this->app->sysmodule()->playingFrom(); + if (str.empty()) { + str = "Common.NotPlaying3"_lang; + } if (str.length() > 16) { str = str.substr(0, 16); str += "..."; @@ -326,12 +330,12 @@ namespace Screen { this->addElement(this->clock); // === METADATA === - this->title = new Aether::Text(0, 450, "", 36); + this->title = new Aether::Text(0, 450, "Common.NotPlaying1"_lang, 36); this->title->setCanScroll(true); this->title->setScrollPause(1200); this->title->setScrollSpeed(35); this->addElement(this->title); - this->artist = new Aether::Text(0, this->title->y() + 50, "", 24); + this->artist = new Aether::Text(0, this->title->y() + 50, "Common.NotPlaying2"_lang, 24); this->addElement(this->artist); // === CONTROLS === @@ -434,6 +438,11 @@ namespace Screen { this->targetBackground = this->currentBackground; this->buttonMs = 0; this->playingID = -1; + + // Start with no song + this->title->setX(640 - this->title->w()/2); + this->artist->setX(640 - this->artist->w()/2); + this->updateImage(Path::App::DefaultArtFile); } void Fullscreen::onUnload() { diff --git a/Application/source/ui/screen/Home.cpp b/Application/source/ui/screen/Home.cpp index 1f9632b..c7b8fbc 100644 --- a/Application/source/ui/screen/Home.cpp +++ b/Application/source/ui/screen/Home.cpp @@ -97,7 +97,7 @@ namespace Screen { // Insert items for playlists std::vector pls = this->app->database()->getAllPlaylistMetadata(Database::SortBy::TitleAsc); for (size_t i = 0; i < pls.size(); i++) { - CustomElm::ListItem::Playlist * l = new CustomElm::ListItem::Playlist(pls[i].imagePath.empty() ? "romfs:/misc/noplaylist.png" : pls[i].imagePath); + CustomElm::ListItem::Playlist * l = new CustomElm::ListItem::Playlist(pls[i].imagePath.empty() ? "romfs:/misc/noplaylist.png" : pls[i].imagePath, false); l->setNameString(pls[i].name); std::string str = (pls[i].songCount == 1 ? "Common.Song"_lang : Utils::substituteTokens("Common.Songs"_lang, std::to_string(pls[i].songCount))); l->setSongsString(str);