hyprbars: add an option to remove title

fixes #59
This commit is contained in:
Vaxry 2023-12-15 15:46:37 +00:00
parent af229e6aee
commit a1277add4b
3 changed files with 7 additions and 2 deletions

View file

@ -28,6 +28,8 @@ plugin {
`col.text` -> (col) bar's title text color
`bar_title_enabled` -> (bool) whether to render the title (default `true`)
`bar_text_size` -> (int) bar's title text font size (default `10`)
`bar_text_font` -> (str) bar's title text font (default `Sans`)

View file

@ -380,6 +380,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
static auto* const PHEIGHT = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_height")->intValue;
static auto* const PPRECEDENCE = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_precedence_over_border")->intValue;
static auto* const PALIGNBUTTONS = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_buttons_alignment")->strValue;
static auto* const PENABLETITLE = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hyprbars:bar_title_enabled")->intValue;
const bool BUTTONSRIGHT = *PALIGNBUTTONS != "left";
@ -438,7 +439,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
g_pHyprOpenGL->renderRect(&titleBarBox, color, scaledRounding);
// render title
if (m_szLastTitle != m_pWindow->m_szTitle || m_bWindowSizeChanged || m_tTextTex.m_iTexID == 0) {
if (*PENABLETITLE && (m_szLastTitle != m_pWindow->m_szTitle || m_bWindowSizeChanged || m_tTextTex.m_iTexID == 0)) {
m_szLastTitle = m_pWindow->m_szTitle;
renderBarTitle(BARBUF, pMonitor->scale);
}
@ -453,6 +454,7 @@ void CHyprBar::draw(CMonitor* pMonitor, float a, const Vector2D& offset) {
}
CBox textBox = {titleBarBox.x, titleBarBox.y, (int)BARBUF.x, (int)BARBUF.y};
if (*PENABLETITLE)
g_pHyprOpenGL->renderTexture(m_tTextTex, &textBox, a);
if (m_bButtonsDirty || m_bWindowSizeChanged) {

View file

@ -69,6 +69,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_height", SConfigValue{.intValue = 15});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:col.text", SConfigValue{.intValue = configStringToInt("rgba(ffffffff)")});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_size", SConfigValue{.intValue = 10});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_title_enabled", SConfigValue{.intValue = 1});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_font", SConfigValue{.strValue = "Sans"});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_text_align", SConfigValue{.strValue = "center"});
HyprlandAPI::addConfigValue(PHANDLE, "plugin:hyprbars:bar_part_of_window", SConfigValue{.intValue = 1});