Skip to content

Commit

Permalink
option to permanently show the current play time
Browse files Browse the repository at this point in the history
  • Loading branch information
kajott committed Aug 16, 2024
1 parent 3c78bb3 commit fc02334
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,14 @@ void Application::draw(float dt) {
y += float(m_infoLineSpacing);
}
if (!m_details.empty()) {
m_renderer.text(float(m_infoKeyX), float(m_infoDetailsY), float(m_infoDetailsSize), m_details.c_str(), 0, m_config.infoDetailsColor);
if (m_config.showTime) {
char suffix[20];
int sec = int(m_position);
sprintf(suffix, " (%d:%02d)", sec / 60, sec % 60);
m_renderer.text(float(m_infoKeyX), float(m_infoDetailsY), float(m_infoDetailsSize), (m_details + suffix).c_str(), 0, m_config.infoDetailsColor);
} else {
m_renderer.text(float(m_infoKeyX), float(m_infoDetailsY), float(m_infoDetailsSize), m_details.c_str(), 0, m_config.infoDetailsColor);
}
}
if (m_progSize > 0) {
if (m_progOuterDXY > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/app_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void Application::updateLayout(bool resetBoxVisibility) {
}
}
// stop if it fits
if (textWidth(m_infoDetailsSize, m_details.c_str()) <= maxWidth) { break; }
if (textWidth(m_infoDetailsSize, (m_details + (m_config.showTime ? " (0:00)" : "")).c_str()) <= maxWidth) { break; }
}
}

Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ struct Config {

bool infoEnabled = true; //!< whether to enable the top information bar by default after loading a module
bool trackNumberEnabled = true; //!< whether to extract and display the track number from the filename; used if the filename starts with two digits followed by a dash (-), underscore (_) or space
bool showTime = false; //!< show current time in track at the end of the details line
bool hideFileExt = false; //!< whether to remove the file extension from the filename in the info bar
bool autoHideFileName = false; //!< whether to hide the filename completely if title and/or artist information is available
std::string artist; //!< override artist info from the module with a custom string
Expand Down
5 changes: 5 additions & 0 deletions src/config_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ const ConfigItem g_ConfigItems[] = { {
"whether to extract and display the track number from the filename; used if the filename starts with two digits followed by a dash (-), underscore (_) or space",
[] (const Config& cfg) -> std::string { return ConfigItem::formatBool(cfg.trackNumberEnabled); },
[] (ConfigParserContext& ctx, Config& cfg, const char* s) { ctx.checkParseResult(ConfigItem::parseBool(cfg.trackNumberEnabled, s), s); }
}, {
false, "show time ",
"show current time in track at the end of the details line",
[] (const Config& cfg) -> std::string { return ConfigItem::formatBool(cfg.showTime); },
[] (ConfigParserContext& ctx, Config& cfg, const char* s) { ctx.checkParseResult(ConfigItem::parseBool(cfg.showTime, s), s); }
}, {
false, "hide file ext ",
"whether to remove the file extension from the filename in the info bar",
Expand Down

0 comments on commit fc02334

Please sign in to comment.