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

Scale lines according to screen font size #4071

Merged
merged 2 commits into from
Jan 12, 2025

Conversation

10110111
Copy link
Contributor

Description

Currently lines (constellations, DSO markers etc.) are scaled in thickness according to device pixel ratio. I'm continuing the work on basing this on font scale instead.

This PR uses a product of device pixel ratio and font size ratio to yield the final scaling coefficient of the lines (and dotted DSO markers). For this, a function called screenScale is introduced in both ConstellationMgr.cpp and Nebula.cpp. It's rather simple, but I'd rather not repeat its implementation everywhere, so I have a question: where is the best place for it? StelApp, or maybe StelSkyDrawer, or StelPainter or StelProjector? It seems StelApp is too general a place for an OpenGL-rendering-specific coefficient, but OTOH, after we get rid of the Qt scaling kludge, this function will be simplified to just StelApp::screenFontSizeRatio(). And StelSkyDrawer doesn't appear to have getters for such low-level factors. Not sure about StelPainter or StelProjector either.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • Housekeeping

How Has This Been Tested?

Test Configuration:

  • Operating system: Ubuntu 20.04
  • Graphics Card: Intel UHD Graphics 620

Checklist:

  • My code follows the code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (header file)
  • I have updated the respective chapter in the Stellarium User Guide
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link

Great PR! Please pay attention to the following items before merging:

Files matching src/**/*.cpp:

  • Are possibly unused includes removed?

This is an automatically generated QA checklist based on modified files.

@alex-w
Copy link
Member

alex-w commented Jan 11, 2025

StelProjector of course - it has getDevicePixelsPerPixel() and getPixelPerRadAtCenter() already

@alex-w alex-w added the subsystem: gui The issue is related to GUI subsystem of planetarium... label Jan 11, 2025
@alex-w alex-w added this to the 25.1 milestone Jan 11, 2025
@10110111
Copy link
Contributor Author

OK, this makes sense, since I already was passing an instance of StelProjector into the function. I just thought that it might be better for the function to not require construction of an instance of StelProjector and instead use a singleton like StelApp.

Anyway, I've updated the PR.

@10110111
Copy link
Contributor Author

10110111 commented Jan 12, 2025

With these changes, and a fix to make line strips & loops joined (in a miter joint style) I'm gonna push soon, I've been able to make the following version of the book cover. I'm sure Alex can make a better composition, and I forgot to enable constellation names, but notice how much crisper it looks compared to the current state at 100% scale. And when encoded in JPEG with 95% quality (via ImageMagick) it is even smaller in file size (compared to the current PNG)!

stellarium-011

@gzotti
Copy link
Member

gzotti commented Jan 12, 2025

The current link of screen font size and button size is a bit unbalanced IMO, buttons too large or bottom bar text too small. Is there a way to either fully decouple or add some relative scaling factor?

@10110111
Copy link
Contributor Author

10110111 commented Jan 12, 2025

The current link of screen font size and button size is a bit unbalanced IMO, buttons too large or bottom bar text too small.

Do you mean you dislike the relation between the default sizes of 13px font and 32px buttons and want to use a different ratio? I suppose this is possible to implement by adding a factor into screenFontSizeRatio() (and rename the function to something like screenMarkingsScale() to better reflect its function).

@gzotti
Copy link
Member

gzotti commented Jan 12, 2025

Yes, please.

@10110111
Copy link
Contributor Author

OK, but this is unrelated to this PR.

Copy link
Member

@alex-w alex-w left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@gzotti
Copy link
Member

gzotti commented Jan 12, 2025

OK then, will be a new issue soon. Else no current objections.

@10110111 10110111 merged commit dd82832 into Stellarium:master Jan 12, 2025
15 checks passed
@10110111 10110111 deleted the scalable-lines branch January 12, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subsystem: gui The issue is related to GUI subsystem of planetarium...
Development

Successfully merging this pull request may close these issues.

3 participants