-
Notifications
You must be signed in to change notification settings - Fork 57
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
base: master
Are you sure you want to change the base?
Conversation
@@ -717,6 +722,26 @@ uint32_t parse_color(const char *color) { | |||
return res; | |||
} | |||
|
|||
enum slurp_label_anchor parse_label_anchor(const char *anchor) { |
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.
"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?
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.
Also "top-bottom" is the same as "center" (and similarly "left-right")
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.
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; |
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 is the horizonal margin different than the vertical margin?
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.
I've used the same offset as used for the dimensions.
c149e85
to
4c5e24f
Compare
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.