hyprbars: fix left align (#153)

Co-authored-by: Liassica <git-commit.jingle869@aleeas.com>
This commit is contained in:
Liassica 2024-04-23 16:05:52 -05:00 committed by GitHub
parent be8f8d81ef
commit d8f695a7c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -233,7 +233,7 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) {
pango_layout_set_font_description(layout, fontDesc); pango_layout_set_font_description(layout, fontDesc);
pango_font_description_free(fontDesc); pango_font_description_free(fontDesc);
const int paddingTotal = scaledBarPadding * 2 + scaledButtonsSize + (*PALIGN != "left" ? scaledButtonsSize : 0); const int paddingTotal = scaledBarPadding * 2 + scaledButtonsSize + (std::string{*PALIGN} != "left" ? scaledButtonsSize : 0);
const int maxWidth = std::clamp(static_cast<int>(bufferSize.x - paddingTotal), 0, INT_MAX); const int maxWidth = std::clamp(static_cast<int>(bufferSize.x - paddingTotal), 0, INT_MAX);
pango_layout_set_width(layout, maxWidth * PANGO_SCALE); pango_layout_set_width(layout, maxWidth * PANGO_SCALE);
@ -243,7 +243,7 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) {
int layoutWidth, layoutHeight; int layoutWidth, layoutHeight;
pango_layout_get_size(layout, &layoutWidth, &layoutHeight); pango_layout_get_size(layout, &layoutWidth, &layoutHeight);
const int xOffset = *PALIGN == "left" ? std::round(scaledBarPadding + (BUTTONSRIGHT ? 0 : scaledButtonsSize)) : const int xOffset = std::string{*PALIGN} == "left" ? std::round(scaledBarPadding + (BUTTONSRIGHT ? 0 : scaledButtonsSize)) :
std::round(((bufferSize.x - scaledBorderSize) / 2.0 - layoutWidth / PANGO_SCALE / 2.0)); std::round(((bufferSize.x - scaledBorderSize) / 2.0 - layoutWidth / PANGO_SCALE / 2.0));
const int yOffset = std::round((bufferSize.y / 2.0 - layoutHeight / PANGO_SCALE / 2.0)); const int yOffset = std::round((bufferSize.y / 2.0 - layoutHeight / PANGO_SCALE / 2.0));