Skip to content

Commit

Permalink
App: Various UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tallbl0nde committed Jul 25, 2021
1 parent 3acaa9e commit 160e5ed
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 17 deletions.
3 changes: 2 additions & 1 deletion Application/include/ui/element/listitem/Playlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ namespace CustomElm::ListItem {
class Playlist : public More {
private:
// Elements
bool showMore;
Aether::Image * image;
Aether::Text * name;
Aether::Text * songs;
void positionElements();

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);
Expand Down
4 changes: 2 additions & 2 deletions Application/include/ui/frame/Queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Frame {
Aether::Element * queue;
std::list<CustomElm::ListItem::Song *> queueEls;
Aether::Element * upnext;
Aether::Text * upnextStr;
Aether::TextBlock * upnextStr;
std::list<CustomElm::ListItem::Song *> upnextEls;

// Temporary vector of song metadata
Expand Down Expand Up @@ -77,4 +77,4 @@ namespace Frame {
};
};

#endif
#endif
2 changes: 1 addition & 1 deletion Application/libs/Aether
1 change: 1 addition & 0 deletions Application/romfs/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"No": "No",
"NotPlaying1": "Nothing playing!",
"NotPlaying2": "Play a song",
"NotPlaying3": "Not Playing",
"Play": "Play",
"Quit": "Quit",
"Remove": "Remove",
Expand Down
2 changes: 1 addition & 1 deletion Application/source/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions Application/source/ui/element/listitem/Playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -33,17 +34,18 @@ namespace CustomElm::ListItem {
} else if (!this->highlighted() && this->name->canScroll()) {
this->name->setCanScroll(false);
}

if (!this->showMore) {
this->more->setHidden(true);
}
}

void Playlist::positionElements() {
this->image->setWH(HEIGHT - 2*PADDING, HEIGHT - 2*PADDING);

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 {
Expand Down
2 changes: 1 addition & 1 deletion Application/source/ui/frame/Playlists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Application/source/ui/frame/Queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Application/source/ui/overlay/AddToPlaylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]() {
Expand Down
13 changes: 11 additions & 2 deletions Application/source/ui/screen/Fullscreen.cpp
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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 += "...";
Expand All @@ -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 ===
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion Application/source/ui/screen/Home.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace Screen {
// Insert items for playlists
std::vector<Metadata::Playlist> 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);
Expand Down

0 comments on commit 160e5ed

Please sign in to comment.