Skip to content
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

Add option to display labels #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

@@ -717,6 +722,26 @@ uint32_t parse_color(const char *color) {
return res;
}

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

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
Collaborator

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 Show resolved Hide resolved
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
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants