Skip to content

Commit

Permalink
[MIN] Added more fields to colors in TOML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
nots1dd committed Jan 7, 2025
1 parent 87e4a4a commit a633db5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/parser/examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ play_this_song_next = "b"
view_song_queue = "3"

[colors]
active_win_color = "blue"
active_win_color = "Blue"
album_name_bg = "LightPink"
menu_cursor_bg = "LightYellow"
6 changes: 5 additions & 1 deletion src/ui/colors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ ftxui::Color GetColor(Color color)
struct InLimboColors
{
TrueColors::Color active_win_color;
TrueColors::Color album_name_bg;
TrueColors::Color menu_cursor_bg;
};

// Function to map color strings from TOML to the enum
Expand Down Expand Up @@ -225,7 +227,9 @@ InLimboColors parseColors()

// Mapping of fields in the InLimboColors struct
const std::unordered_map<std::string, TrueColors::Color*> field_map = {
{"active_win_color", &colors.active_win_color}};
{"active_win_color", &colors.active_win_color},
{"album_name_bg", &colors.album_name_bg},
{"menu_cursor_bg", &colors.menu_cursor_bg}};

for (const auto& [field, member_color] : field_map)
{
Expand Down
10 changes: 4 additions & 6 deletions src/ui/ui_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
#include "keymaps.hpp"
#include "misc.hpp"
#include <algorithm>
#include <chrono>
#include <iomanip>
#include <sstream>
#include <thread>
#include <unordered_set>

using namespace ftxui;

#define ALBUM_DELIM "----------- "

/* MACROS FOR SONG DETAILS */
#define STATUS_PLAYING "<>"
#define STATUS_PAUSED "!!"
Expand Down Expand Up @@ -375,7 +371,7 @@ class MusicPlayer
// Get year from the first song in the album
const Song& first_song = discs.begin()->second.begin()->second;
current_song_elements.push_back(
renderAlbumName(album_name, first_song.metadata.year, TrueColors::Color::LightGray));
renderAlbumName(album_name, first_song.metadata.year, global_colors.album_name_bg));
album_name_indices.insert(current_song_elements.size() - 1);

for (const auto& [disc_number, tracks] : discs)
Expand Down Expand Up @@ -488,6 +484,8 @@ class MusicPlayer
return &song_queue[current_song_queue_index];
}

dialog_message = "Something went worng";
show_dialog = true;
return nullptr;
}

Expand Down Expand Up @@ -547,7 +545,7 @@ class MusicPlayer
[&]() mutable
{
return RenderSongMenu(current_song_elements, &selected_inode,
TrueColors::Color::LightYellow); // This should return an Element
global_colors.menu_cursor_bg); // This should return an Element
});

auto main_container = Container::Horizontal({artists_list, songs_list});
Expand Down

0 comments on commit a633db5

Please sign in to comment.