Skip to content

refactor(ui): improve menu layout and organization#1178

Merged
doodlum merged 7 commits into
community-shaders:devfrom
soda3000:dev
Jun 23, 2025
Merged

refactor(ui): improve menu layout and organization#1178
doodlum merged 7 commits into
community-shaders:devfrom
soda3000:dev

Conversation

@soda3000
Copy link
Copy Markdown
Contributor

@soda3000 soda3000 commented Jun 22, 2025

This PR includes my updates to the feature menu layout and organization, as well as the label number counts of features under each menu category.

Summary by CodeRabbit

  • New Features

    • Category headers now display the number of features in each category.
    • The feature detail panel uses a new tabbed interface with separate "Settings" and "About" tabs for improved organization.
  • UI Improvements

    • Feature management controls and information are now more clearly separated in the detail view.
    • Status information is color-coded for easier identification.
    • Color editing for feature headings has been simplified with updated controls.
  • Removals

    • Inline tooltips showing feature summaries on hover in the feature list have been removed.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 22, 2025

Walkthrough

This update introduces a static map to track the number of features per category in the menu system. Category headers in the UI now display feature counts. The feature detail panel is reorganized into "Settings" and "About" tabs, and inline tooltips in the feature list are removed for a cleaner interface.

Changes

File(s) Change Summary
src/Menu.cpp, src/Menu.h Added static categoryCounts map and BuildCategoryCounts() method to track and build category counts. Menu UI updated to use these counts in headers. Refactored feature detail panel to use tabbed interface ("Settings" and "About"). Removed inline tooltips from feature list.
src/Utils/UI.cpp, src/Utils/UI.h Updated DrawCategoryHeader to accept and display a feature count per category in the header.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Menu
    participant Util

    User->>Menu: Open Features Menu
    Menu->>Menu: BuildCategoryCounts()
    loop For each category
        Menu->>Util: DrawCategoryHeader(categoryName, isExpanded, categoryCount)
    end
    User->>Menu: Select Feature
    Menu->>Menu: Show Detail Panel (Tabbed: Settings/About)
Loading

Possibly related PRs

Suggested reviewers

  • alandtse

Poem

A menu refreshed, with tabs so neat,
Category counts make browsing sweet.
No more tooltips in the list—
Just tabs for settings and feature gist.
With headers bold and numbers bright,
This bunny hops with pure delight! 🐇✨


📜 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 92279ca and f3e0e61.

📒 Files selected for processing (1)
  • src/Menu.cpp (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Menu.cpp
✨ 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.

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
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.cpp (1)

587-588: Category count integration works correctly.

The logic properly retrieves and passes category counts to the header drawing function. Minor optimization opportunity: consider using a string_view-compatible map or caching the string conversion if this becomes a performance concern.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e10f16a and a765c00.

📒 Files selected for processing (4)
  • src/Menu.cpp (5 hunks)
  • src/Menu.h (3 hunks)
  • src/Utils/UI.cpp (2 hunks)
  • src/Utils/UI.h (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (9)
src/Menu.h (3)

6-6: LGTM! Include statement is appropriate.

The inclusion of "Feature.h" is necessary for the categoryCounts functionality and follows proper dependency management.


293-293: LGTM! Well-encapsulated design.

The private BuildCategoryCounts() method follows good encapsulation practices by keeping the implementation details internal to the Menu class.


220-220: Consider thread safety for the static member.

The static categoryCounts map looks well-designed for tracking feature counts per category. However, consider potential thread safety implications if this map could be accessed concurrently.

#!/bin/bash
# Description: Check if the categoryCounts map is accessed from multiple threads
# Expected: Find usage patterns to assess thread safety requirements

# Search for usage of categoryCounts
rg -A 3 -B 3 "categoryCounts"

# Look for threading-related code in the codebase
rg -A 2 "std::thread|std::mutex|std::lock"
src/Utils/UI.h (1)

137-140: LGTM! Function signature update is well-documented.

The addition of the categoryCount parameter is properly documented and the signature change is consistent with the implementation in UI.cpp.

src/Utils/UI.cpp (2)

354-390: LGTM! Consistent implementation of display name usage.

The implementation correctly uses the formatted displayName consistently across all UI operations (text size calculation, ID generation, and text rendering). This ensures the category count is properly displayed in the interface.


345-348: Verify C++20 support for std::format usage.

The implementation correctly integrates the category count into the display name. However, std::format requires C++20 support.

#!/bin/bash
# Description: Check if the project is configured for C++20 support
# Expected: Find C++20 configuration in build files

# Search for C++ standard configuration
rg -i "c\+\+20|cxx.*20|std.*20" --type cmake --type makefile
fd -e cmake -e vcxproj -e props | xargs rg -l "c\+\+20|cxx.*20|std.*20"

# Check for other std::format usage in codebase
rg "std::format"
src/Menu.cpp (3)

222-222: LGTM - Clean addition of category counting infrastructure.

The static categoryCounts map is appropriately placed and typed for tracking feature counts per category.


295-295: LGTM - Proper initialization placement.

Calling BuildCategoryCounts() during Init() ensures category counts are populated before UI rendering begins.


659-798: Excellent UI refactor - significant improvement in organization.

The tabbed interface is a major improvement over the previous single-panel layout:

Proper separation of concerns: Settings vs. About information
Correct ImGui implementation: Proper tab bar structure and child windows
Enhanced UX: Better organization of feature management controls and information
Consistent styling: Proper use of theme colors and status indicators

This refactor aligns perfectly with the PR objectives to improve menu layout and organization.

Comment thread src/Menu.cpp Outdated
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: 0

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

587-588: Optimize map lookup and verify count accuracy.

Two potential improvements:

  1. Performance: Line 587 creates an unnecessary temporary string. Consider using find() or storing header.name as std::string to avoid conversion.

  2. Accuracy: BuildCategoryCounts() counts all features, but the UI only displays loaded features that are in the menu (see lines 819-823). This could lead to misleading counts.

Apply this diff to improve performance:

-int count = categoryCounts[std::string(header.name)];
+auto it = categoryCounts.find(header.name);
+int count = (it != categoryCounts.end()) ? it->second : 0;

659-798: Excellent UI reorganization with opportunity for refactoring.

The tab-based separation of "Settings" (management) and "About" (information) significantly improves the user experience and logical organization. The state handling for disabled/loaded/failed features is comprehensive and well-implemented.

Consider breaking this large block into separate methods for better maintainability:

void DrawFeatureSettingsTab(Feature* feat, bool isDisabled, bool isLoaded, bool hasFailedMessage);
void DrawFeatureAboutTab(Feature* feat, bool isDisabled, bool isLoaded, bool hasFailedMessage);

This would make the DrawMenuVisitor cleaner and each tab's logic more focused and testable.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e10f16a and d99f39f.

📒 Files selected for processing (4)
  • src/Menu.cpp (5 hunks)
  • src/Menu.h (3 hunks)
  • src/Utils/UI.cpp (2 hunks)
  • src/Utils/UI.h (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build plugin and addons
🔇 Additional comments (9)
src/Utils/UI.h (1)

137-140: Function signature update looks good.

The addition of the categoryCount parameter to DrawCategoryHeader is well-named and appropriately typed for displaying feature counts in category headers.

src/Menu.h (3)

3-3: Include addition supports feature counting functionality.

The addition of "Feature.h" include is consistent with the need to work with Feature objects for counting features per category.


220-220: Static member for category counts is well-designed.

Using std::unordered_map<std::string, int> for tracking feature counts per category is efficient and appropriate. The static nature ensures consistent counts across the application.


293-293: Private method declaration follows good encapsulation.

The BuildCategoryCounts() method declaration properly encapsulates the category counting logic within the Menu class.

src/Utils/UI.cpp (2)

345-348: Function implementation correctly matches header and formats display string.

The updated function signature matches the header declaration, and the use of std::format to create the display string with category count is clean and safe.


354-354: Consistent usage of formatted display name throughout the function.

The implementation correctly uses the formatted displayName consistently for text size calculation, ID pushing, and text rendering, ensuring the category count is properly displayed in all contexts.

Also applies to: 361-361, 390-390

src/Menu.cpp (3)

222-222: LGTM: Clean static member for category tracking.

The static unordered_map is an appropriate choice for storing category counts that are computed once and used throughout the UI rendering lifecycle.


295-295: LGTM: Proper initialization placement.

Calling BuildCategoryCounts() during initialization ensures category counts are available when the UI is first rendered.


2589-2600: Clean implementation with potential count mismatch.

The method correctly iterates through features and builds category counts. However, this counts all features while the UI display logic (lines 819-823) only shows features that are both loaded and IsInMenu().

Please verify if the count should match visible features or include all features. If it should match visible features, consider filtering:

 void Menu::BuildCategoryCounts()
 {
 	const std::vector<Feature*>& features = Feature::GetFeatureList();
-	// Get the category of each feature, and if it is not in the featureGroups
-	// vector, add it and increment the count
 	for (auto& feature : features) {
+		if (feature->IsInMenu() && feature->loaded) {
 			std::string_view category = feature->GetCategory();
 			categoryCounts[std::string(category)]++;
+		}
 	}
 }

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 22, 2025

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

@alandtse
Copy link
Copy Markdown
Collaborator

Screenshots?

@doodlum doodlum merged commit d19fd3b into community-shaders:dev Jun 23, 2025
10 checks passed
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
…#1178)

* refactor(ui): improve menu layout and organization

* style: 🎨 apply pre-commit.ci formatting

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.

* refactor(ui): simplify and improve theme color handling

* style: 🎨 apply pre-commit.ci formatting

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.

* fix(ui): improve category counting and code cleanup

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@coderabbitai coderabbitai Bot mentioned this pull request Sep 7, 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.

3 participants