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

label: add relative values for font_size #674

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

Conversation

NotLebedev
Copy link

This adds ability to use relative sizing for font_size of label widget. It's really useful to use % to position and size widgets across displays with different resolutions, however such functionality is lacking in font_size. Added vh and vw suffixes to size text proportionally to viewport height and width respectively. This functions the same as in css. Also I picked vw and vh instead of % because in css it is defined as "relative to parent objects" font size and in hyprlock there is no parent object font size, so this would be just confusing whichever way it is implemented.

Examples in action (sorry for photos of screen, didn't figure out how to screenshot):
4K screen before (config was created for it):
image

4K screen after (changed all values in config to vh):
image

1080p screen before:
image

1080p screen after:
image

P.S. thanks for this awesome piece of software. Works like a charm!

@PaideiaDilemma
Copy link
Collaborator

Looks exactly like what I initially intended for label size to be output relative.

However, there is also #591,
which essentially solves the same problem, but not via the font_size option.
Have to looked at that?

That pr makes you configure sizex instead of font_size and also addresses the image widget.
Let me know what you think, I think both solutions are OK.

I will test this later.

@PaideiaDilemma
Copy link
Collaborator

@Memoraike, since you commented on the other PR, which solution would you prefer?

@Memoraike
Copy link

@Memoraike, since you commented on the other PR, which solution would you prefer?

I prefer #591, it's more flexible and perfectly solves the problem I faced when developing complex CLabel based widgets.

@NotLebedev
Copy link
Author

NotLebedev commented Feb 6, 2025

However, there is also #591,
which essentially solves the same problem, but not via the font_size option.
Have to looked at that?

Didn't realize that MR implemented ~ the same thing. Name is kinda not obvious.
Biased, but I kinda like my approach better because

  1. vh, vw is a well known unit used everywhere css or some resembling stuff is used.
  2. vh vw allows to size both relative to width and height, sizex is only relative to width, if I understand correctly.
  3. It is kinda unrelated to sizex. One can do sizex: 10, sizex: 10vw and sizex: 10vh which all mean different things and this way it is more flexible
    Adding vh vw to image:sizex seems trivial

@NotLebedev
Copy link
Author

Illustration for point 3.

Untitled

@NotLebedev
Copy link
Author

NotLebedev commented Feb 6, 2025

Also sizex does not work the same as font_size because if there is more text in label with fixed sizex font size shrinks? E.g. in my screenshots on "Monday, May 05" date text will be bigger then on "Monday, September 01"?

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.

3 participants