Merge pull request #54 from Olekoop/master

Add option to center window title
This commit is contained in:
outfoxxed 2023-12-31 04:50:00 -08:00 committed by GitHub
commit a92314b57a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View file

@ -201,6 +201,9 @@ plugin {
# render the window title on the bar # render the window title on the bar
render_text = <bool> # default: true render_text = <bool> # default: true
# center the window title
text_center = <bool> # default: false
# font to render the window title with # font to render the window title with
text_font = <string> # default: Sans text_font = <string> # default: Sans

View file

@ -128,6 +128,7 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) {
// clang-format off // clang-format off
static const auto* s_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue; static const auto* s_rounding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:rounding")->intValue;
static const auto* render_text = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:render_text")->intValue; static const auto* render_text = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:render_text")->intValue;
static const auto* text_center = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_center")->intValue;
static const auto* text_font = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_font")->strValue; static const auto* text_font = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_font")->strValue;
static const auto* text_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_height")->intValue; static const auto* text_height = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_height")->intValue;
static const auto* text_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_padding")->intValue; static const auto* text_padding = &HyprlandAPI::getConfigValue(PHANDLE, "plugin:hy3:tabs:text_padding")->intValue;
@ -224,6 +225,9 @@ void Hy3TabBarEntry::prepareTexture(float scale, CBox& box) {
PangoLayout* layout = pango_cairo_create_layout(cairo); PangoLayout* layout = pango_cairo_create_layout(cairo);
pango_layout_set_text(layout, this->window_title.c_str(), -1); pango_layout_set_text(layout, this->window_title.c_str(), -1);
if (*text_center)
pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
PangoFontDescription* font_desc = pango_font_description_from_string(text_font->c_str()); PangoFontDescription* font_desc = pango_font_description_from_string(text_font->c_str());
pango_font_description_set_size(font_desc, *text_height * scale * PANGO_SCALE); pango_font_description_set_size(font_desc, *text_height * scale * PANGO_SCALE);
pango_layout_set_font_description(layout, font_desc); pango_layout_set_font_description(layout, font_desc);

View file

@ -44,6 +44,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
CONF("tabs:from_top", int, 0); CONF("tabs:from_top", int, 0);
CONF("tabs:rounding", int, 3); CONF("tabs:rounding", int, 3);
CONF("tabs:render_text", int, 1); CONF("tabs:render_text", int, 1);
CONF("tabs:text_center", int, 0);
CONF("tabs:text_font", str, "Sans"); CONF("tabs:text_font", str, "Sans");
CONF("tabs:text_height", int, 8); CONF("tabs:text_height", int, 8);
CONF("tabs:text_padding", int, 3); CONF("tabs:text_padding", int, 3);