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

[macOS] Ugly drawing of slider's ticks #24532

Closed
hwiesmann opened this issue May 14, 2024 · 4 comments
Closed

[macOS] Ugly drawing of slider's ticks #24532

hwiesmann opened this issue May 14, 2024 · 4 comments
Labels
macOS Specific to Cocoa macOS port

Comments

@hwiesmann
Copy link
Contributor

hwiesmann commented May 14, 2024

Description

Compile widgets sample with default compiler options and select the native slider in the tree book. When the ticks are shown it can be seen that the first half of the ticks is slightly centered above the slider's line, the other half is slight centered below the slider's line (see attached screenshot).

Bildschirmfoto 2024-05-14 um 22 33 54

The reason for this behavior is the result line 22 in slider_osx.cpp:

 // The dimensions of the different styles of sliders (from Aqua document)

#if wxOSX_USE_COCOA
    #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 28 /* this is the critical line! */
    #define wxSLIDER_DIMENSIONACROSS_ARROW 21
#else
    #define wxSLIDER_DIMENSIONACROSS_WITHTICKMARKS 24
    #define wxSLIDER_DIMENSIONACROSS_ARROW 18
#endif

Whenever the defined preprocessor variable has an even value, the slider's ticks are badly centered, choosing an odd value solves the issue. So, 29 is a good value.

BTW: Aqua is pretty much outdated.

  • wxWidgets version you use: latest master built from GitHub
  • wxWidgets port you use: macOS 14.4.1
@vadz
Copy link
Contributor

vadz commented May 15, 2024

Thanks, let's indeed fix this but I don't know what are the currently recommended values, @csomor would you know this by chance? If we change this to 29 we should probably use the other branch to use 25?

P.S. I've edited the description to use proper code block (triple single quotes).

@vadz vadz added the macOS Specific to Cocoa macOS port label May 15, 2024
@csomor
Copy link
Contributor

csomor commented May 15, 2024

Actually the 28 is correct for the slider, but the labels calculation lead to a height of 49 when shown, this number leads to the ugly rendering. When neither min max nor value are shown, then IMHO things look fine with 28, so the real fix would be there I think. But unfortunately at the moment I don't have time for it ...

@hwiesmann
Copy link
Contributor Author

hwiesmann commented May 15, 2024 via email

@csomor
Copy link
Contributor

csomor commented May 15, 2024

When the min and max value are not shown but only the value the drawing of the slider’s ticks is as ugly as with the min and max values (I use the widgets sample, see screenshot attached). 

yes, that's correct, as I wrote when no values and no min max labels are shown, then 28 is correct

Nevertheless, we should change the slider's implementation. Instead of changing one of the constants we can also make sure that the overall height is always an even number.

this would be best IMHO

hwiesmann pushed a commit to hwiesmann/wxWidgets that referenced this issue May 16, 2024
… slider's line

To have a proper centering with respect to the slider's line, the size of the slider in the dimension perpendicular to the slider's line has to be an even number. Therefore,when determining the best size, the size is adjusted to an even number when ticks are shown.
hwiesmann pushed a commit to hwiesmann/wxWidgets that referenced this issue May 17, 2024
@vadz vadz closed this as completed in a4a334e May 19, 2024
vadz pushed a commit to vadz/wxWidgets that referenced this issue May 19, 2024
To have a proper centering with respect to the slider's line, the size
of the slider in the dimension perpendicular to the slider's line has to
be an even number. Therefore,when determining the best size, the size is
adjusted to an even number when ticks are shown.

See wxWidgets#24532, wxWidgets#24537.

(cherry picked from commit a4a334e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS Specific to Cocoa macOS port
Projects
None yet
Development

No branches or pull requests

3 participants