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

Setting width of display area of slider value #285

Closed
Albrecht-S opened this issue Oct 21, 2021 · 3 comments
Closed

Setting width of display area of slider value #285

Albrecht-S opened this issue Oct 21, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request fixed The issue or PR was fixed.

Comments

@Albrecht-S
Copy link
Member

Referring to stackoverflow question "FLTK Setting width of display area of slider value":

We should consider making the value display size of sliders changeable by the user so they can use larger numbers or larger fonts.

Citation from the question: "I was wondering how to change the width of the area responsible for showing the current value of a Fl_Hor_Value_Slider. The thing is, I want to be able to select a year (that's 4 digits) and the space on the side of the slider is not enough to display the year number correctly."

@Albrecht-S Albrecht-S added the enhancement New feature or request label Oct 21, 2021
@Albrecht-S
Copy link
Member Author

Some parts of the given answer with code suggestions:

The problem is that the size is hardcoded to 35 for horizontal or 25 for vertical. You need to modify Fl_Value_Slider.cxx. In the routine draw, it has

if (horizontal()) {
  bww = 35; sxx += 35; sww -= 35;
} else {
  syy += 25; bhh = 25; shh -= 25;
}

This is based on a textsize of 10. If you change the text size, then it needs to go up based on the text size. Something like

if (horizontal()) {
   int width = textsize() * 3 + 5;
   bww = width; sxx += width; sww -= width;
} else {
   int height = textsize() * 2 + 5;
   syy += height; bhh = height; shh -= height;
}

Then rebuild the fltk library. Either keep this patch or send it to FLTK ...

Thanks to cup for this answer and patch suggestion. I can't tell if this is the correct or best patch but it's something that should be considered.

In the final version this should likely get a new method to set the different drawing sizes. This is not only true for Fl_Hor_Value_Slider but also for several other slider types and even some more widgets.

@MatthiasWM MatthiasWM self-assigned this Jan 21, 2023
@MatthiasWM
Copy link
Contributor

MatthiasWM commented Jan 26, 2023

All value sliders in 1.4 have the method value_width(int) that does exactly that. Are there other widgets that need to be fixed, because:
@Albrecht-S This is not only true for Fl_Hor_Value_Slider but also for several other slider types and even some more widgets.

https://www.fltk.org/doc-1.4/classFl__Value__Slider.html#af2e23cdfcd2417445d08e6f8a3783dfd

@MatthiasWM MatthiasWM added active Somebody is working on it waiting for confirmation waiting for someone's confirmation labels Jan 26, 2023
@Albrecht-S
Copy link
Member Author

The method value_width() has been added in FLTK 1.4.0 in commit 191aeef based on STR 3222 in Nov. 2022 (later than this issue was created). Hence (the main part of) this issue is resolved and it can probably be closed.

@MatthiasWM My point "... and some more widgets" was off the top of my head and should be interpreted that there are some other widgets with hardcoded values, sizes, or colors for some aspects. Since I don't know which ones there are two options: you can either search for such hardcoded properties that users can't change, or ... we close this issue and wait for other reports. I wouldn't mind if you closed it as "fixed".

@Albrecht-S Albrecht-S added fixed The issue or PR was fixed. and removed active Somebody is working on it waiting for confirmation waiting for someone's confirmation labels Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fixed The issue or PR was fixed.
Projects
None yet
Development

No branches or pull requests

2 participants