Skip to content

chore(ui): fix icon inconsistencies when ui is docked, added watermark#1181

Merged
doodlum merged 2 commits into
community-shaders:devfrom
davo0411:icon-fixes
Jun 23, 2025
Merged

chore(ui): fix icon inconsistencies when ui is docked, added watermark#1181
doodlum merged 2 commits into
community-shaders:devfrom
davo0411:icon-fixes

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented Jun 23, 2025

2083B2~1

  • Fixes icons when in docked UI mode. Added watermark to background when docked since the icon can't be added next to the title. Remains crisp thanks to GPU mipmapping.
  • Moved the icons to top title bar when docked too.
  • Streamlined the icon sizing system so everything matches better when undocked.
  • Made the icons respect the global UI scale setting

Summary by CodeRabbit

  • Refactor
    • Improved the visual layout and consistency of the settings window header and action buttons.
    • Centralized and unified the rendering of action icons, with different behaviors for docked and undocked window states.
    • Enhanced docking-aware UI behavior, including dynamic placement of icons and logo display based on window state.
    • Adjusted scaling and layout for better visual clarity and usability.

@davo0411 davo0411 changed the title chore(ui): Fix icon issues with docked ui mode chore(ui): fix icon issues with docked ui mode Jun 23, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 23, 2025

Walkthrough

The Menu::DrawSettings() function was refactored to centralize and streamline the rendering of action icons and the logo, with new logic to handle docked versus undocked window states. Icon rendering, tooltips, and layout adjustments are now managed through structured data and unified rendering functions, improving consistency and docking awareness.

Changes

File(s) Summary of Changes
src/Menu.cpp Refactored Menu::DrawSettings() to centralize action icon rendering, add docking-aware UI logic, and update logo and layout handling. No public API changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Menu
    participant Window
    participant IconRenderer

    User->>Menu: Open Settings
    Menu->>Window: Check docking state
    alt Window is docked
        Menu->>IconRenderer: Render icons in title bar
        Menu->>Window: Draw logo as watermark
    else Window is undocked
        Menu->>IconRenderer: Render icons as ImageButtons in header
        Menu->>Window: Draw logo and title in header
    end
    Menu->>Window: Show/hide separators and layout elements based on docking
Loading

Possibly related PRs

Suggested reviewers

  • alandtse
  • FlayaN

Poem

In the menu’s gentle light,
Icons gather, crisp and bright.
Docked or free, they find their place,
With logos drawn in subtle grace.
Rabbits cheer the tidy view—
Refactored code, refreshed anew!
🐇✨

✨ 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.
@davo0411 davo0411 changed the title chore(ui): fix icon issues with docked ui mode chore(ui): fix icon inconsistencies when ui is docked, added watermark Jun 23, 2025
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)

382-474: Consider extracting constants and simplifying the unified rendering function.

While this lambda effectively consolidates icon rendering for both modes, it has grown quite complex. Consider these improvements:

  1. Extract magic numbers to named constants:

    static constexpr float ICON_SIZE_DOCKED = 40.0f;
    static constexpr float ICON_SPACING = 8.0f;
    static constexpr float RIGHT_MARGIN = 45.0f;
    static constexpr float PADDING_REDUCTION = 2.0f;
  2. Consider splitting into separate functions: The docked and undocked rendering logic are quite different and might benefit from separation for maintainability.

The manual mouse interaction handling for docked mode is well-implemented, but the function's complexity suggests it might be doing too much.


476-508: Consider reducing the watermark size for better subtlety.

The watermark implementation is technically sound with correct positioning and aspect ratio calculations. However, using 50% of the content height (watermarkHeightPercent = 0.50f) might make the watermark too prominent, even with the low alpha value.

Consider reducing this to 25-30% for a more subtle background effect:

-const float watermarkHeightPercent = 0.50f;  // 25% of content height
+const float watermarkHeightPercent = 0.25f;  // 25% of content height
📜 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 8b6cd51.

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

306-317: Good approach to handling ImGui docking state detection.

Using the previous frame's docking state as an approximation is a smart solution to the chicken-and-egg problem of needing to know docking state before creating the window. The conditional window flags correctly implement the requirement to show title bars only when docked.


324-335: Well-structured icon availability and scaling logic.

The separation between action icons and logo display is appropriate, and the texture availability checking ensures graceful fallback behavior. The logarithmic UI scaling using exp2() is a good choice for smooth UI scaling transitions.


336-381: Excellent data-driven approach to action icon management.

The ActionIcon struct with texture, tooltip, and callback encapsulates icon behavior nicely. The conditional population based on texture availability and the comprehensive tooltips provide both robustness and good user experience. This design makes adding new icons straightforward and maintains separation of concerns.


509-562: Well-structured undocked header layout with robust fallback handling.

The table-based layout effectively manages the alignment between title/logo and action icons. The consistent use of UI scaling throughout and the comprehensive fallback handling for missing assets demonstrate good defensive programming. The intentional 25% reduction in icon size for visual balance shows attention to UI design details.


563-653: Excellent preservation of functionality with docking-aware adaptations.

The conditional separator and fallback text button logic properly maintains existing functionality while adapting to the new docking-aware system. The error toggle button handling is appropriately gated to only show when not docked, and the fallback text buttons ensure users can still access all functionality even when icons are disabled or unavailable.

@github-actions
Copy link
Copy Markdown

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

@doodlum doodlum merged commit 1d95bbc into community-shaders:dev Jun 23, 2025
12 checks passed
@davo0411 davo0411 deleted the icon-fixes branch June 23, 2025 12:58
alandtse pushed a commit to alandtse/open-shaders that referenced this pull request Jul 20, 2025
community-shaders#1181)

* Update Menu.cpp

* style: 🎨 apply pre-commit.ci formatting

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

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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