Skip to content

Add custom folder coloring#1304

Open
JoltedJon wants to merge 1 commit into
Redot-Engine:masterfrom
JoltedJon:custom_colors
Open

Add custom folder coloring#1304
JoltedJon wants to merge 1 commit into
Redot-Engine:masterfrom
JoltedJon:custom_colors

Conversation

@JoltedJon

@JoltedJon JoltedJon commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

This adds in an option to set custom folder colors in the filesystem as suggested by @TheAenema

SVG courtesy of @memmoxt

Summary by CodeRabbit

  • New Features
    • Added enhanced folder color assignment in the file browser, including a new Custom option.
    • Folder colors can now be applied via both preset names and a Color Picker.
    • Supports applying the same color to multiple selected folders at once.
  • Bug Fixes
    • Improved folder icon/background coloring when switching between saved preset colors and custom selections.
    • Folder color settings are now correctly cleared when no custom folder colors are set.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

FileSystemDock now supports preset and custom folder colors, persists direct Color variants, and resolves folder colors from either stored names or direct values across the tree, file list, and directory icons.

Changes

Folder Color Support

Layer / File(s) Summary
Folder color state and contracts
editor/docks/filesystem_dock.h, editor/docks/filesystem_dock.cpp
Adds color-picker state, selected-folder tracking, helper method declarations, and required UI and Variant includes.
Folder color selection workflow
editor/docks/filesystem_dock.cpp
Adds the Custom context-menu option, collects selected folders, opens the color picker, applies confirmed colors, and updates project settings.
Variant-aware folder color rendering
editor/docks/filesystem_dock.cpp
Resolves folder colors from named strings or direct Color variants in the tree, file list, and directory icons.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant FileSystemDock
  participant ColorPicker
  participant ProjectSettings

  User->>FileSystemDock: Choose Custom folder color
  FileSystemDock->>ColorPicker: Open picker for selected folders
  User->>ColorPicker: Select and confirm color
  ColorPicker->>FileSystemDock: Return Color value
  FileSystemDock->>ProjectSettings: Persist folder color assignments
  FileSystemDock->>FileSystemDock: Refresh folder color rendering
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding custom folder coloring support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
editor/docks/filesystem_dock.cpp (2)

3298-3313: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Check for NIL instead of p_color truthiness
Variant::booleanize() treats Color(0, 0, 0, 1) as false, so a user-picked pure black folder color gets erased instead of stored. Use a type check here rather than if (p_color).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@editor/docks/filesystem_dock.cpp` around lines 3298 - 3313, The folder-color
assignment in FileSystemDock::_set_folder_color must distinguish an absent color
from a valid black Color value. Replace the truthiness check on p_color with a
Variant type check for a Color, storing valid colors and erasing the folder
entry only when p_color is NIL.

1074-1118: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Handle direct Color folder assignments here. assigned_folder_colors can hold preset names or Color values, but this lookup still treats every value as a preset key. Direct colors will miss the preset map, render inherited colors incorrectly, and can insert a stray entry into folder_colors. editor/docks/filesystem_dock.cpp:1084

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@editor/docks/filesystem_dock.cpp` around lines 1074 - 1118, The folder color
inheritance lookup in the directory scan must support both preset-name and
direct Color values in assigned_folder_colors. Update the inheritance logic near
the color_scan_dir loop to inspect the stored Variant, resolving string values
through folder_colors while using Color values directly, without indexing
folder_colors for non-string assignments or creating stray entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@editor/docks/filesystem_dock.cpp`:
- Around line 3298-3313: The folder-color assignment in
FileSystemDock::_set_folder_color must distinguish an absent color from a valid
black Color value. Replace the truthiness check on p_color with a Variant type
check for a Color, storing valid colors and erasing the folder entry only when
p_color is NIL.
- Around line 1074-1118: The folder color inheritance lookup in the directory
scan must support both preset-name and direct Color values in
assigned_folder_colors. Update the inheritance logic near the color_scan_dir
loop to inspect the stored Variant, resolving string values through
folder_colors while using Color values directly, without indexing folder_colors
for non-string assignments or creating stray entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63fbc569-a3ba-429e-b954-fdd3cd09b763

📥 Commits

Reviewing files that changed from the base of the PR and between aab4134 and 28aa78f.

⛔ Files ignored due to path filters (1)
  • editor/icons/FolderQuestion.svg is excluded by !**/*.svg
📒 Files selected for processing (2)
  • editor/docks/filesystem_dock.cpp
  • editor/docks/filesystem_dock.h

@Shakai-Dev Shakai-Dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR LGTM but I was wondering, would #1297 & #1305 affect this? If so, maybe we shouldn't merge this atm & merge it after those are merged

@JoltedJon

Copy link
Copy Markdown
Contributor Author

@Shakai-Dev There shouldn't be any reason why those two PRs would change it. The only thing that would probably cause issues is #1306 which I would need to rebase this PR

@Shakai-Dev

Copy link
Copy Markdown
Member

@Shakai-Dev There shouldn't be any reason why those two PRs would change it. The only thing that would probably cause issues is #1306 which I would need to rebase this PR

Ok, then that's good

@Shakai-Dev
Shakai-Dev self-requested a review July 15, 2026 11:57

@Shakai-Dev Shakai-Dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR_test.mp4

It only works partially, you can only apply a color to the folder via custom color. You can't use any of the presets. I'm using the build from GH actions (linux-editor-mono)

Co-authored-by: memmoxt <109536933+memmoxt@users.noreply.github.com>
@JoltedJon
JoltedJon requested review from a team July 16, 2026 14:17
@JoltedJon

Copy link
Copy Markdown
Contributor Author

Ok @Shakai-Dev It should be fixed, please give it another test

@JoltedJon

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@editor/docks/filesystem_dock.cpp`:
- Around line 1084-1085: Update the folder-color inheritance logic around
assigned_folder_colors and inherited_folder_color to track whether an ancestor
assignment was found separately from whether its color equals
default_folder_color. Stop scanning once an explicit assignment is discovered,
including custom colors matching the default, so ancestor colors cannot override
it.
🪄 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: 54e84d8b-81ef-4c68-8e8b-a6555daf4b83

📥 Commits

Reviewing files that changed from the base of the PR and between d3f956d and 408d3a5.

⛔ Files ignored due to path filters (1)
  • editor/icons/FolderQuestion.svg is excluded by !**/*.svg
📒 Files selected for processing (2)
  • editor/docks/filesystem_dock.cpp
  • editor/docks/filesystem_dock.h

Comment on lines +1084 to +1085
Variant assigned_color = assigned_folder_colors[color_scan_dir];
inherited_folder_color = assigned_color.is_string() ? folder_colors[assigned_folder_colors[color_scan_dir]] : Color(assigned_color);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Stop inheritance when an explicit default-matching color is found.

A custom color equal to default_folder_color leaves the loop condition true, allowing an ancestor color to override it. Track assignment discovery separately from color equality.

Proposed fix
 Color inherited_folder_color = default_folder_color;
+bool inherited_color_found = false;
 String color_scan_dir = directory;
-while (color_scan_dir != "res://" && inherited_folder_color == default_folder_color) {
+while (color_scan_dir != "res://" && !inherited_color_found) {
 	...
 	if (assigned_folder_colors.has(color_scan_dir)) {
 		Variant assigned_color = assigned_folder_colors[color_scan_dir];
-		inherited_folder_color = assigned_color.is_string() ? folder_colors[assigned_folder_colors[color_scan_dir]] : Color(assigned_color);
+		inherited_folder_color = assigned_color.is_string() ? folder_colors[assigned_color] : Color(assigned_color);
+		inherited_color_found = true;
 	}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Variant assigned_color = assigned_folder_colors[color_scan_dir];
inherited_folder_color = assigned_color.is_string() ? folder_colors[assigned_folder_colors[color_scan_dir]] : Color(assigned_color);
Variant assigned_color = assigned_folder_colors[color_scan_dir];
inherited_folder_color = assigned_color.is_string() ? folder_colors[assigned_color] : Color(assigned_color);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@editor/docks/filesystem_dock.cpp` around lines 1084 - 1085, Update the
folder-color inheritance logic around assigned_folder_colors and
inherited_folder_color to track whether an ancestor assignment was found
separately from whether its color equals default_folder_color. Stop scanning
once an explicit assignment is discovered, including custom colors matching the
default, so ancestor colors cannot override it.

@Shakai-Dev

Copy link
Copy Markdown
Member

Ok @Shakai-Dev It should be fixed, please give it another test

Works now

@Shakai-Dev Shakai-Dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM & works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants