godot
godot copied to clipboard
Implement coloring for disabled branches in the shader editor
This PR implement dimming of the disabled branches of the shader preprocessor. To do it, besides adding a handling of the branch to the shader preprocessor, I've implemented some new methods to the CodeHighlighter:

This is a part of https://github.com/godotengine/godot-proposals/issues/5062
Looks nice!
How come #else has a different color than #ifdef and #endif?
How come #else has a different color than #ifdef and #endif?
That's strange, I will look what caused this a bit later this day.
@akien-mga It's not related or introduced by this PR, it's due preprocessor directive and keywords have similar names (#if, #else and if, else) and the control flow keywords have a separate control_flow_keyword_color. Not sure how it should be fixed, and I think it's a subject for other PR:

That was fast :) I guess you were already working on that before I made that improvement proposal! Looks good!
Interestingly, I think the structure ShaderPreprocessor::SkippedCondition and all logic related to that is actually dead code and mostly unused. I think TheOrangeDay was working on that to implement this very syntax highlighting feature but never finished it and now it doesn't really do anything useful. Removing it might be a good idea, unless I remember wrong. It has been a while since I touched that code, so no guarantees. Not really related to this PR either.
@Paulb23 Done, I think - pushed new methods to a new class GDShaderSyntaxHighlighter.
@Paulb23 Fixed as you said.
@Paulb23 OK, I've cut all unused methods and made this class unexposed to the editor.
@Chaosus would move the highlighter code to the top of shader_editor_plugin.[cpp|h] as it's not relevant for scene now. Same way EditorSyntaxHighlighter is at the top of script_editor_plugin.
@Paulb23 Done
Thanks!