-
-
Notifications
You must be signed in to change notification settings - Fork 145
center bar content #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aphelei
wants to merge
1
commit into
hyprwm:main
Choose a base branch
from
aphelei:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
center bar content #391
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,7 +380,7 @@ void CHyprBar::renderBarTitle(const Vector2D& bufferSize, const float scale) { | |
| pango_layout_get_size(layout, &layoutWidth, &layoutHeight); | ||
| 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)); | ||
| 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 - scaledBorderSize / 2.0)); | ||
|
|
||
| cairo_move_to(CAIRO, xOffset, yOffset); | ||
| pango_cairo_show_layout(CAIRO, layout); | ||
|
|
@@ -435,6 +435,10 @@ void CHyprBar::renderBarButtons(const Vector2D& bufferSize, const float scale) { | |
| const auto CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, bufferSize.x, bufferSize.y); | ||
| const auto CAIRO = cairo_create(CAIROSURFACE); | ||
|
|
||
| const auto PWINDOW = m_pWindow.lock(); | ||
| const auto BORDERSIZE = PWINDOW->getRealBorderSize(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only used once, redundant local |
||
| const auto scaledBorderSize = BORDERSIZE * scale; | ||
|
|
||
| // clear the pixmap | ||
| cairo_save(CAIRO); | ||
| cairo_set_operator(CAIRO, CAIRO_OPERATOR_CLEAR); | ||
|
|
@@ -448,7 +452,7 @@ void CHyprBar::renderBarButtons(const Vector2D& bufferSize, const float scale) { | |
| const auto scaledButtonSize = button.size * scale; | ||
| const auto scaledButtonsPad = **PBARBUTTONPADDING * scale; | ||
|
|
||
| const auto pos = Vector2D{BUTTONSRIGHT ? bufferSize.x - offset - scaledButtonSize / 2.0 : offset + scaledButtonSize / 2.0, bufferSize.y / 2.0}.floor(); | ||
| const auto pos = Vector2D{BUTTONSRIGHT ? bufferSize.x - offset - scaledButtonSize / 2.0 : offset + scaledButtonSize / 2.0, bufferSize.y / 2.0 - scaledBorderSize / 2.0}.floor(); | ||
|
|
||
| cairo_set_source_rgba(CAIRO, button.bgcol.r, button.bgcol.g, button.bgcol.b, button.bgcol.a); | ||
| cairo_arc(CAIRO, pos.x, pos.y, scaledButtonSize / 2, 0, 2 * M_PI); | ||
|
|
@@ -489,7 +493,11 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float | |
|
|
||
| int offset = **PBARPADDING * scale; | ||
| float noScaleOffset = **PBARPADDING; | ||
|
|
||
|
|
||
| const auto PWINDOW = m_pWindow.lock(); | ||
| const auto BORDERSIZE = PWINDOW->getRealBorderSize(); | ||
| const auto scaledBorderSize = BORDERSIZE * scale; | ||
|
|
||
| for (size_t i = 0; i < visibleCount; ++i) { | ||
| auto& button = g_pGlobalState->buttons[i]; | ||
| const auto scaledButtonSize = button.size * scale; | ||
|
|
@@ -498,7 +506,7 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float | |
| // check if hovering here | ||
| const auto BARBUF = Vector2D{(int)assignedBoxGlobal().w, **PHEIGHT}; | ||
| Vector2D currentPos = Vector2D{(BUTTONSRIGHT ? BARBUF.x - **PBARBUTTONPADDING - button.size - noScaleOffset : noScaleOffset), (BARBUF.y - button.size) / 2.0}.floor(); | ||
| bool hovering = VECINRECT(COORDS, currentPos.x, currentPos.y, currentPos.x + button.size + **PBARBUTTONPADDING, currentPos.y + button.size); | ||
| bool hovering = VECINRECT(COORDS, currentPos.x, currentPos.y, currentPos.x + button.size + **PBARBUTTONPADDING, currentPos.y + button.size - scaledBorderSize / 2.0); | ||
| noScaleOffset += **PBARBUTTONPADDING + button.size; | ||
|
|
||
| if (button.iconTex->m_texID == 0 /* icon is not rendered */ && !button.icon.empty()) { | ||
|
|
@@ -512,7 +520,7 @@ void CHyprBar::renderBarButtonsText(CBox* barBox, const float scale, const float | |
| if (button.iconTex->m_texID == 0) | ||
| continue; | ||
|
|
||
| CBox pos = {barBox->x + (BUTTONSRIGHT ? barBox->width - offset - scaledButtonSize : offset), barBox->y + (barBox->height - scaledButtonSize) / 2.0, scaledButtonSize, | ||
| CBox pos = {barBox->x + (BUTTONSRIGHT ? barBox->width - offset - scaledButtonSize : offset), barBox->y + (barBox->height - scaledButtonSize) / 2.0 - scaledBorderSize / 2.0, scaledButtonSize, | ||
| scaledButtonSize}; | ||
|
|
||
| if (!**PICONONHOVER || (**PICONONHOVER && m_iButtonHoverState > 0)) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? you can just deref m_pWindow