Skip to content

feat(ui): implement dynamic font scaling based on screen resolution#1233

Merged
alandtse merged 3 commits into
community-shaders:devfrom
soda3000:2025-07-03
Jul 4, 2025
Merged

feat(ui): implement dynamic font scaling based on screen resolution#1233
alandtse merged 3 commits into
community-shaders:devfrom
soda3000:2025-07-03

Conversation

@soda3000
Copy link
Copy Markdown
Contributor

@soda3000 soda3000 commented Jul 3, 2025

Add dynamic font size calculation for the menu that scales with screen height. The font size is now calculated as 2% of the screen height, clamped between 24px and 48px for readability. This ensures consistent text appearance across different display resolutions.

Summary by CodeRabbit

  • Refactor
    • Font size in menu now automatically adjusts based on screen height for improved visual consistency across different display sizes.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 3, 2025

Walkthrough

The font loading in Menu::Init() was updated to calculate the font size dynamically as 2% of the screen height, clamped between 24 and 48 points. It retrieves the swap chain description to get the screen height, defaults to 1080p if unavailable, and falls back to a default font if loading the custom font fails.

Changes

File Change Summary
src/Menu.cpp Modified Menu::Init() to dynamically compute font size from screen height, handle swap chain retrieval errors, initialize swap chain description memory, and add fallback font loading with warnings.

Poem

A font once fixed, now grows and shrinks,
With screen so tall, or short, it thinks.
No more the number thirty-six,
The menu’s font is now a mix,
Of height and math—how clever, neat!
Dynamic text for all to greet.
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a15e71 and 6c684e4.

📒 Files selected for processing (1)
  • src/Menu.cpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Menu.cpp
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build plugin and addons
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 3, 2025

Using provided base ref: 0bf2c5f
Using base ref: 0bf2c5f
Base commit date: 2025-07-03T20:58:51-07:00 (Thursday, July 03, 2025 08:58 PM)
No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/Menu.cpp (1)

275-279: Missing <algorithm> include for std::clamp.

std::clamp lives in <algorithm>; rely on an incidental transitive include is brittle.
Add the header near the other STL includes.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b225568 and 0a15e71.

📒 Files selected for processing (1)
  • src/Menu.cpp (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.
src/Menu.cpp (1)
Learnt from: davo0411
PR: doodlum/skyrim-community-shaders#1107
File: src/Menu.cpp:310-315
Timestamp: 2025-05-31T02:51:24.195Z
Learning: In the Community Shaders codebase, when validating UI icons, checking for texture presence (non-null pointer) is sufficient. Avoid adding dimension validation checks as icon sizes should vary based on user needs (4K+ resolution users may want higher resolution icons). Don't artificially limit icon dimensions.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build plugin and addons

Comment thread src/Menu.cpp
Comment thread src/Menu.cpp Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 4, 2025

✅ A pre-release build is available for this PR:
Download

Comment thread src/Menu.cpp Outdated
Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
@alandtse
Copy link
Copy Markdown
Collaborator

alandtse commented Jul 4, 2025

@coderabbitai is this a feat?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 4, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Let's examine the actual changes in src/Menu.cpp to understand the implementation
cat src/Menu.cpp

Length of output: 104885


@alandtse Yes, this is appropriately classified as a feat.

Looking at the code changes in src/Menu.cpp, this PR introduces new user-facing functionality that dynamically calculates font size based on screen resolution:

// Calculate base font size based on screen height (e.g., 2% of screen height)
const float baseFontSize = height * 0.02f;
// Clamp between reasonable min/max values
const float fontSize = std::clamp(baseFontSize, 24.0f, 48.0f);

This change:

  • Adds new functionality for end users (dynamic font scaling)
  • Enhances user experience by making text size adaptive to screen resolution
  • Improves accessibility across various display configurations
  • Provides value for users with different screen sizes

According to conventional commits, a "feat" introduces new functionality for the end user, which this clearly does. As noted in my learnings, both the committer's intent and conventional commit standards should be considered - in this case, both align perfectly for a "feat" classification.

🐰✨


🧠 Learnings used
Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.

Learnt from: alandtse
PR: doodlum/skyrim-community-shaders#0
File: :0-0
Timestamp: 2025-06-29T00:27:42.680Z
Learning: When reviewing PRs, the committer's description should inform analysis of changes and may take precedence to conclusions when reasonable, but the choice of commit type should still be independently evaluated for compliance with conventional commits. Both committer intent and conventional commit standards should be considered to determine if the classification is defensible.

@alandtse alandtse merged commit be967a1 into community-shaders:dev Jul 4, 2025
15 checks passed
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
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.

2 participants