Skip to content

Add option to display labels#109

Open
columbarius wants to merge 3 commits intoemersion:masterfrom
columbarius:display-labels
Open

Add option to display labels#109
columbarius wants to merge 3 commits intoemersion:masterfrom
columbarius:display-labels

Conversation

@columbarius
Copy link
Contributor

This introduces the option flags P, l, L which can be used to display a box with the of the selectable rectangle inside.

l, L are used for the text and background colours.
P is used for the position to anchor the labelbox. The same syntax is used as in wlr_layer_surface with an additional 'center' keyword.

return res;
}

enum slurp_label_anchor parse_label_anchor(const char *anchor) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"center-top" is equivalent to "top-center" is equivalent to "center" is equivalent to "top-bottom-left-right-center".

It will also happily accept something like "top-nonsenes" and treat it the same as "top" or "not-top" is also the same as "top", or "neotop".

Should this be more strict in what it accepts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also "top-bottom" is the same as "center" (and similarly "left-right")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this lack of strictness simplifies parsing without any harm/conflict.
The structure of the anchor is the same as used for wlr_layer_surface and I just added center as convenience. As such the same duplications happen, but I don't se an issue there.

render.c Outdated
if (anchor & ANCHOR_LEFT && anchor & ANCHOR_RIGHT) {
// Nothing to do
} else if (anchor & ANCHOR_LEFT) {
labelbox.x = box->x + 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the horizonal margin different than the vertical margin?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used the same offset as used for the dimensions.

@tmccombs tmccombs added the enhancement New feature or request label Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants