8#include <ftxui/component/captured_mouse.hpp>
9#include <ftxui/component/component.hpp>
10#include <ftxui/component/component_base.hpp>
11#include <ftxui/component/event.hpp>
12#include <ftxui/component/screen_interactive.hpp>
13#include <ftxui/dom/elements.hpp>
29 std::vector<std::string> lines;
30 std::string currentLine;
31 bool insideSquareBrackets =
false;
32 bool insideCurlBrackets =
false;
33 bool lastWasUppercase =
false;
34 bool lastWasSpecialChar =
false;
35 char previousChar =
'\0';
39 if (c ==
'[' || c ==
'(')
41 if (!currentLine.empty())
43 lines.push_back(currentLine);
47 insideSquareBrackets =
true;
49 insideCurlBrackets =
true;
54 if (insideSquareBrackets || insideCurlBrackets)
57 if (c ==
']' && insideSquareBrackets)
59 lines.push_back(currentLine);
61 insideSquareBrackets =
false;
64 else if (c ==
')' && insideCurlBrackets)
66 lines.push_back(currentLine);
68 insideCurlBrackets =
false;
73 if (c ==
'\'' || c ==
'-')
76 lastWasSpecialChar =
true;
80 if (std::isupper(c) && !lastWasUppercase && !lastWasSpecialChar && !currentLine.empty() &&
81 previousChar !=
'\n' && previousChar !=
' ')
83 lines.push_back(currentLine);
91 if (!currentLine.empty())
93 lines.push_back(currentLine);
98 lastWasUppercase = std::isupper(c);
99 lastWasSpecialChar =
false;
103 if (!currentLine.empty())
105 lines.push_back(currentLine);
109 lines.erase(std::remove_if(lines.begin(), lines.end(),
110 [](
const std::string& line) { return line.empty(); }),
129 return std::string(1,
static_cast<char>(ch));
135 int minutes = seconds / 60;
136 seconds = seconds % 60;
137 std::stringstream ss;
138 ss << std::setfill(
'0') << std::setw(2) << minutes <<
":" << std::setfill(
'0') << std::setw(2)
147auto renderAlbumName(
const std::string& album_name,
const int& year, ftxui::Color sel_color)
149 return hbox({text(
" "), text(album_name) | bold, filler(),
150 text(std::to_string(year)) | dim | align_right, text(
" ")}) |
151 inverted | color(sel_color) | dim;
154auto renderSongName(
const std::string& disc_track_info,
const std::string& song_name,
157 return hbox({text(disc_track_info) | dim, text(song_name) | bold | flex_grow,
162auto CreateMenu(
const std::vector<std::string>* vecLines,
int* currLine)
164 MenuOption menu_options;
165 menu_options.on_change = [&]() {};
166 menu_options.focused_entry = currLine;
168 return Menu(vecLines, currLine, menu_options);
173 Elements rendered_items;
174 for (
int i = 0; i < items.size(); ++i)
176 rendered_items.push_back(items[i] | frame);
179 return vbox(std::move(rendered_items));
183 const std::string& songTitle,
const std::string& artistName,
184 const std::string& albumName,
const std::string& genre,
unsigned int year,
185 unsigned int trackNumber,
unsigned int discNumber,
188 auto thumbnailFilePath = cacheDirPath +
"thumbnail.png";
192 auto thumbnail = Renderer(
195 return vbox({
image_view(thumbnailFilePath)}) |
199 auto metadataView = vbox({
200 hbox({text(albumName) | bold | underlined}) | center,
201 hbox({text(songTitle) | bold, text(
" by "), text(artistName) | bold, text(
" ["),
202 text(std::to_string(year)), text(
"]"), text(
" ("),
203 text(std::to_string(discNumber)) | bold, text(
"/"),
204 text(std::to_string(trackNumber)) | bold, text(
")")}) |
206 hbox({text(
"Seems like a "), text(genre) | bold, text(
" type of song...")}) | center,
209 auto progressBar = hbox({
210 text(
"Progress: ") | bold,
211 gauge(progress) | flex,
213 text(std::to_string(
static_cast<int>(progress * 100)) +
"%"),
216 auto thumbNailEle = vbox({thumbnail->Render()});
218 auto modernUI = vbox({
219 thumbNailEle | flex_shrink,
221 metadataView | borderRounded,
231 auto errorView = vbox({
232 text(
"Error: Thumbnail not found!") | center | dim,
234 text(
"Please ensure the file has embedded artwork.") | center,
auto getTrueBGColor(TrueColors::Color color)
Definition misc.hpp:145
auto getTrueColor(TrueColors::Color color)
Definition misc.hpp:143
std::string charToStr(char ch)
Definition misc.hpp:116
auto RenderThumbnail(const std::string &songFilePath, const std::string &cacheDirPath, const std::string &songTitle, const std::string &artistName, const std::string &albumName, const std::string &genre, unsigned int year, unsigned int trackNumber, unsigned int discNumber, float progress)
Definition misc.hpp:182
auto renderSongName(const std::string &disc_track_info, const std::string &song_name, const int &duration)
Definition misc.hpp:154
auto RenderSongMenu(const std::vector< Element > &items)
Definition misc.hpp:171
auto renderAlbumName(const std::string &album_name, const int &year, ftxui::Color sel_color)
Definition misc.hpp:147
auto CreateMenu(const std::vector< std::string > *vecLines, int *currLine)
Definition misc.hpp:162
auto FormatTime(int seconds)
Definition misc.hpp:133
auto formatLyrics(const std::string &lyrics)
Definition misc.hpp:27
ftxui::Color GetColor(Color color)
Maps a predefined color enum to its corresponding ftxui::Color::RGB value.
Definition colors.hpp:78
Color
Enumeration for predefined true colors.
Definition colors.hpp:26
Element image_view(std::string_view url)
Definition image_view.cpp:82
Component songs_queue_comp
Definition misc.hpp:21
Component lyrics_scroller
Definition misc.hpp:22
Component artists_list
Definition misc.hpp:19
Component MainRenderer
Definition misc.hpp:23
Component songs_list
Definition misc.hpp:20
Component ThumbnailRenderer
Definition misc.hpp:24
A header file for the TagLibParser class and Metadata structure, used to parse metadata from audio fi...
bool extractThumbnail(const std::string &audioFilePath, const std::string &outputImagePath)
Extracts the thumbnail (album art) from an audio file and saves it to an image file.
Definition taglib_parser.h:267