godot icon indicating copy to clipboard operation
godot copied to clipboard

Implement coloring for disabled branches in the shader editor

Open Chaosus opened this issue 3 years ago • 5 comments

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:

image

This is a part of https://github.com/godotengine/godot-proposals/issues/5062

Chaosus avatar Aug 03 '22 12:08 Chaosus

Looks nice!

How come #else has a different color than #ifdef and #endif?

akien-mga avatar Aug 03 '22 12:08 akien-mga

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.

Chaosus avatar Aug 03 '22 12:08 Chaosus

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

image

Chaosus avatar Aug 03 '22 14:08 Chaosus

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.

bitsawer avatar Aug 03 '22 15:08 bitsawer

@Paulb23 Done, I think - pushed new methods to a new class GDShaderSyntaxHighlighter.

Chaosus avatar Aug 06 '22 12:08 Chaosus

@Paulb23 Fixed as you said.

Chaosus avatar Aug 10 '22 04:08 Chaosus

@Paulb23 OK, I've cut all unused methods and made this class unexposed to the editor.

Chaosus avatar Aug 14 '22 10:08 Chaosus

@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 avatar Aug 14 '22 10:08 Paulb23

@Paulb23 Done

Chaosus avatar Aug 14 '22 11:08 Chaosus

Thanks!

akien-mga avatar Aug 15 '22 10:08 akien-mga