Skip to content

fix: prevent overflow for home page quick links#2059

Merged
alandtse merged 2 commits into
community-shaders:devfrom
brucenguyen:home-page-info-update-2
Apr 4, 2026
Merged

fix: prevent overflow for home page quick links#2059
alandtse merged 2 commits into
community-shaders:devfrom
brucenguyen:home-page-info-update-2

Conversation

@brucenguyen
Copy link
Copy Markdown
Contributor

@brucenguyen brucenguyen commented Apr 4, 2026

Follow up to #2055.

Sort of haphazard on my end, the button widths were hard-coded to only fit 3 in a row, which means the 4th one I added was causing overflow.

This PR refactors so it uses the column system instead of the computed button widths.

This changes the design behaviour though. Previously the buttons were set to a fixed width and then centered. The new behaviour is akin to flex rows in CSS, where it's column-based and the buttons dynamically grow to fit. This means the buttons can stretch really wide (more than the previous 180px) to fit. While it's pretty easy to re-constrain the button widths (apply a container which constrains the columns), the code simplicity might be preferred here. Though if someone feels strongly about constraining the button widths then I can look into that.

image

Summary by CodeRabbit

  • Enhancements
    • Reorganized the "Quick Links" section from a 3-button centered layout to a 4-column grid layout for improved space utilization.
    • Updated Discord "Join Server" button width calculation for better visual consistency.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 4, 2026

📝 Walkthrough

Walkthrough

The HomePageRenderer UI layout was refactored to restructure the Quick Links section from a 3-button manually-positioned layout to a 4-column ImGui columns layout with auto-width buttons. The Discord fallback button width calculation was updated to use DISCORD_BANNER_MIN_WIDTH instead of the removed QUICK_LINKS_BUTTON_WIDTH constant.

Changes

Cohort / File(s) Summary
Quick Links Layout Refactoring
src/Menu/HomePageRenderer.cpp, src/Menu/HomePageRenderer.h
Restructured Quick Links from manual 3-button centered layout to 4-column ImGui columns layout with auto-width buttons (ImVec2(-1, 0)). Updated Discord button width to use DISCORD_BANNER_MIN_WIDTH * scale. Removed QUICK_LINKS_BUTTON_WIDTH constant.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #1463: Introduces DISCORD_BANNER_MIN_WIDTH constant and changes Quick Links layout, which directly relates to the width calculation update in this PR.
  • PR #2055: Modifies RenderQuickLinksSection with button label and URL changes, affecting the same Quick Links layout being refactored here.

Suggested reviewers

  • alandtse
  • davo0411

Poem

🐰 Four columns now, instead of three,
Quick Links dance in harmony,
With auto-widths, so neat and bright,
The Discord button sized just right! ✨
Layout hops to a better sight!

🚥 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
Title check ✅ Passed The PR title 'fix: prevent overflow for home page quick links' directly and clearly summarizes the main change: addressing an overflow issue with the quick links layout by refactoring from fixed button widths to a column-based system.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 4, 2026

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: 1

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

158-180: Consider responsive quick-link column count

Using exactly 4 columns fixes overflow, but at small widths it compresses labels heavily. A width-based column count (1..4) keeps the layout usable across window sizes.

Proposed refactor
-	ImGui::Columns(4, nullptr, false);
+	float scale = Util::GetUIScale();
+	float minColumnWidth = 150.0f * scale;
+	float availableWidth = ImGui::GetContentRegionAvail().x;
+	int columnCount = std::clamp(static_cast<int>(availableWidth / minColumnWidth), 1, 4);
+	ImGui::Columns(columnCount, "QuickLinksColumns", false);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Menu/HomePageRenderer.cpp` around lines 158 - 180, The fixed 4-column
layout (ImGui::Columns) causes cramped buttons at narrow widths; compute a
responsive column count based on available width (use
ImGui::GetContentRegionAvailWidth or GetWindowWidth) and a minimum button width,
clamp it between 1 and 4, then call ImGui::Columns(calculatedCols, nullptr,
false). Iterate your links and call ImGui::Button(...) / ImGui::NextColumn() in
a loop (replace the four repeated Button/NextColumn blocks) so the UI adapts
automatically as the window resizes while preserving ImGui::Columns,
ImGui::NextColumn, and ImGui::Button usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Menu/HomePageRenderer.cpp`:
- Around line 137-140: Clamp the computed buttonWidth (currently calculated as
DISCORD_BANNER_MIN_WIDTH * scale) to the available window width before centering
so it never exceeds windowSize.x (accounting for any desired horizontal padding)
and ensure the SetCursorPosX call receives a non-negative value; update the
logic around the variables buttonWidth, scale and windowSize used before
ImGui::SetCursorPosX and ImGui::Button("Join Discord Server",
ImVec2(buttonWidth, 0)) so the button fits on narrow windows or high UI scales
while still invoking ShellExecuteA with DISCORD_URL when pressed.

---

Nitpick comments:
In `@src/Menu/HomePageRenderer.cpp`:
- Around line 158-180: The fixed 4-column layout (ImGui::Columns) causes cramped
buttons at narrow widths; compute a responsive column count based on available
width (use ImGui::GetContentRegionAvailWidth or GetWindowWidth) and a minimum
button width, clamp it between 1 and 4, then call ImGui::Columns(calculatedCols,
nullptr, false). Iterate your links and call ImGui::Button(...) /
ImGui::NextColumn() in a loop (replace the four repeated Button/NextColumn
blocks) so the UI adapts automatically as the window resizes while preserving
ImGui::Columns, ImGui::NextColumn, and ImGui::Button usage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: be78203a-78bb-49df-9239-b54458c7ee1a

📥 Commits

Reviewing files that changed from the base of the PR and between 6d72613 and 862ab49.

📒 Files selected for processing (2)
  • src/Menu/HomePageRenderer.cpp
  • src/Menu/HomePageRenderer.h
💤 Files with no reviewable changes (1)
  • src/Menu/HomePageRenderer.h

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

github-actions Bot commented Apr 4, 2026

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

@alandtse
Copy link
Copy Markdown
Contributor

alandtse commented Apr 4, 2026

Please make sure you test changes before marking a draft ready to avoid follow-ups like this.

@brucenguyen
Copy link
Copy Markdown
Contributor Author

Yeah sort of broke my own rule. I enforce that most frontend changes have screenshots at the bare minimum at my workplace.

No excuses really here.

@alandtse alandtse merged commit abeb11b into community-shaders:dev Apr 4, 2026
21 checks passed
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Apr 5, 2026
@brucenguyen brucenguyen deleted the home-page-info-update-2 branch May 2, 2026 21:26
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