Skip to content

fix: make FanCurveControl DPI-aware - #31

Merged
beenycool merged 2 commits into
masterfrom
pr5-dpi-fix
Apr 17, 2026
Merged

fix: make FanCurveControl DPI-aware#31
beenycool merged 2 commits into
masterfrom
pr5-dpi-fix

Conversation

@beenycool

@beenycool beenycool commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Convert hardcoded constants (PointRadius, Margins) to scale with DeviceDpi
  • Ensures proper rendering on high-DPI displays

Summary by CodeRabbit

  • Bug Fixes
    • Improved fan curve control interface scaling on high-DPI and scaled displays for better visibility and interaction accuracy.

Convert hardcoded constants (PointRadius, margins) to scale with DeviceDpi for proper high-DPI display support.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

Replaced five fixed pixel constants in FanCurveControl.cs with dynamic properties that scale values using LogicalToDeviceUnits(). All rendering calculations and hit-testing now adapt to device units instead of relying on compile-time pixel values.

Changes

Cohort / File(s) Summary
DPI-Aware Scaling
AsusFanControlGUI/FanCurveControl.cs
Converted PointRadius, MarginLeft, MarginBottom, MarginRight, and MarginTop from static pixel constants to dynamic properties that scale values based on device units for improved high-DPI display support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

Poem

🐰 With whiskers twitched, this rabbit sees,
Constants dancing, pixels freed—
From fixed to flow, the curves now scale,
High-DPI screens? We shall not fail!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: converting hardcoded UI constants to be DPI-aware using LogicalToDeviceUnits scaling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr5-dpi-fix

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@kilo-code-bot

kilo-code-bot Bot commented Apr 12, 2026

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 file)
  • AsusFanControlGUI/FanCurveControl.cs

Reviewed by trinity-large-thinking · 139,950 tokens

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces DPI scaling for the fan curve control's margins and point radius by replacing static constants with dynamic properties. The review feedback suggests using the built-in LogicalToDeviceUnits method for more efficient and accurate scaling, and recommends extending this scaling to other hardcoded pixel values throughout the file.

Comment thread AsusFanControlGUI/FanCurveControl.cs Outdated
Comment on lines +15 to +19
private int PointRadius => (int)(6 * (DeviceDpi / 96f));
private int MarginLeft => (int)(40 * (DeviceDpi / 96f));
private int MarginBottom => (int)(30 * (DeviceDpi / 96f));
private int MarginRight => (int)(20 * (DeviceDpi / 96f));
private int MarginTop => (int)(20 * (DeviceDpi / 96f));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current implementation recalculates the scaled values every time these properties are accessed. Since they are used frequently within OnPaint (including inside loops) and event handlers, this introduces redundant floating-point calculations. Additionally, casting to int truncates the result, which can lead to slight rendering inaccuracies compared to rounding.

A more efficient and idiomatic approach in Windows Forms (available since .NET Framework 4.7) is to use the built-in LogicalToDeviceUnits method. This method handles the scaling logic and rounding correctly.

Also, note that to achieve full DPI awareness, you should consider applying similar scaling to other hardcoded pixel values in the file, such as pen widths (e.g., line 101) and text offsets (e.g., lines 88, 93, 131).

        private int PointRadius => LogicalToDeviceUnits(6);
        private int MarginLeft => LogicalToDeviceUnits(40);
        private int MarginBottom => LogicalToDeviceUnits(30);
        private int MarginRight => LogicalToDeviceUnits(20);
        private int MarginTop => LogicalToDeviceUnits(20);

@beenycool
beenycool merged commit 7eabd99 into master Apr 17, 2026
2 of 3 checks passed
@beenycool
beenycool deleted the pr5-dpi-fix branch April 17, 2026 07:14
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.

1 participant